[libvirt] [libvirt-php PATCH 0/2] *** Add libvirt_domain_migrate_to_uri2() for virDomainMigrateToURI2() ***

*** Please add new function libvirt_domain_migrate_to_uri2 for libirts virDomainMigrateToURI2(). *** Stefan Kuhn (2): Implement libvirt_domain_migrate_to_uri2 for virDomainMigrateToURI2 Document new funct. libvirt_domain_migrate_to_uri2 .../functions/libvirt-domain-get-job-info.xml | 1 + .../functions/libvirt-domain-migrate-to-uri.xml | 5 +- .../functions/libvirt-domain-migrate-to-uri2.xml | 134 +++++++++++++++++++++ .../libvirt/functions/libvirt-domain-migrate.xml | 3 +- doc/source/libvirt/versions.xml | 1 + src/libvirt-php.c | 53 ++++++++ src/libvirt-php.h | 1 + 7 files changed, 195 insertions(+), 3 deletions(-) create mode 100644 doc/source/libvirt/functions/libvirt-domain-migrate-to-uri2.xml -- 1.7.12.4

--- src/libvirt-php.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/libvirt-php.h | 1 + 2 files changed, 54 insertions(+) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 19c97e8..b795667 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -111,6 +111,7 @@ static zend_function_entry libvirt_functions[] = { PHP_FE(libvirt_domain_get_connect, NULL) PHP_FE(libvirt_domain_migrate, NULL) PHP_FE(libvirt_domain_migrate_to_uri, NULL) + PHP_FE(libvirt_domain_migrate_to_uri2, NULL) PHP_FE(libvirt_domain_get_job_info, NULL) PHP_FE(libvirt_domain_xml_xpath, NULL) PHP_FE(libvirt_domain_get_block_info, NULL) @@ -5367,6 +5368,58 @@ PHP_FUNCTION(libvirt_domain_migrate_to_uri) RETURN_FALSE; } +/* + Function name: libvirt_domain_migrate_to_uri2 + Since version: 0.4.6(-1) + Description: Function is used migrate domain to another libvirt daemon specified by it's URI + Arguments: @res [resource]: libvirt domain resource, e.g. from libvirt_domain_lookup_by_*() + @dconnuri [string]: URI for target libvirtd + @miguri [string]: URI for invoking the migration + @dxml [string]: XML config for launching guest on target + @flags [int]: migration flags + @dname [string]: domain name to rename domain to on destination side + @bandwidth [int]: migration bandwidth in Mbps + Returns: TRUE for success, FALSE on error +*/ +PHP_FUNCTION(libvirt_domain_migrate_to_uri2) +{ + php_libvirt_domain *domain=NULL; + zval *zdomain; + int retval; + char *dconnuri; + int dconnuri_len; + char *miguri; + int miguri_len; + char *dxml; + int dxml_len; + long flags=0; + char *dname; + int dname_len; + long bandwidth; + + dconnuri=NULL; + dconnuri_len=0; + miguri=NULL; + miguri_len=0; + dxml=NULL; + dxml_len=0; + dname=NULL; + dname_len=0; + bandwidth=0; + GET_DOMAIN_FROM_ARGS("r|ssslsl",&zdomain,&dconnuri,&dconnuri_len,&miguri,&miguri_len,&dxml,&dxml_len,&flags,&dname,&dname_len,&bandwidth); + + // set to NULL if empty string + if (dconnuri_len == 0) dconnuri=NULL; + if (miguri_len == 0) miguri=NULL; + if (dxml_len == 0) dxml=NULL; + if (dname_len == 0) dname=NULL; + + retval=virDomainMigrateToURI2(domain->domain,dconnuri,miguri,dxml,flags,dname,bandwidth); + DPRINTF("%s: virDomainMigrateToURI2() returned %d\n", PHPFUNC, retval); + + if (retval == 0) RETURN_TRUE; + RETURN_FALSE; +} /* Function name: libvirt_domain_migrate diff --git a/src/libvirt-php.h b/src/libvirt-php.h index c0a4b50..bbcb3f2 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -336,6 +336,7 @@ PHP_FUNCTION(libvirt_domain_xml_xpath); PHP_FUNCTION(libvirt_domain_get_block_info); PHP_FUNCTION(libvirt_domain_get_network_info); PHP_FUNCTION(libvirt_domain_migrate_to_uri); +PHP_FUNCTION(libvirt_domain_migrate_to_uri2); PHP_FUNCTION(libvirt_domain_get_autostart); PHP_FUNCTION(libvirt_domain_set_autostart); PHP_FUNCTION(libvirt_domain_is_active); -- 1.7.12.4

--- .../functions/libvirt-domain-get-job-info.xml | 1 + .../functions/libvirt-domain-migrate-to-uri.xml | 5 +- .../functions/libvirt-domain-migrate-to-uri2.xml | 134 +++++++++++++++++++++ .../libvirt/functions/libvirt-domain-migrate.xml | 3 +- doc/source/libvirt/versions.xml | 1 + 5 files changed, 141 insertions(+), 3 deletions(-) create mode 100644 doc/source/libvirt/functions/libvirt-domain-migrate-to-uri2.xml diff --git a/doc/source/libvirt/functions/libvirt-domain-get-job-info.xml b/doc/source/libvirt/functions/libvirt-domain-get-job-info.xml index e39694c..d5ff320 100644 --- a/doc/source/libvirt/functions/libvirt-domain-get-job-info.xml +++ b/doc/source/libvirt/functions/libvirt-domain-get-job-info.xml @@ -117,6 +117,7 @@ Array <para> <simplelist> <member><function>libvirt_domain_migrate</function></member> + <member><function>libvirt_domain_migrate_to_uri2</function></member> <member><function>libvirt_domain_migrate_to_uri</function></member> </simplelist> </para> diff --git a/doc/source/libvirt/functions/libvirt-domain-migrate-to-uri.xml b/doc/source/libvirt/functions/libvirt-domain-migrate-to-uri.xml index 752f965..2e6bf27 100644 --- a/doc/source/libvirt/functions/libvirt-domain-migrate-to-uri.xml +++ b/doc/source/libvirt/functions/libvirt-domain-migrate-to-uri.xml @@ -13,13 +13,13 @@ <type>bool</type><methodname>libvirt_domain_migrate_to_uri</methodname> <methodparam ><type>resource</type><parameter>domain</parameter></methodparam> <methodparam ><type>string</type><parameter>duri</parameter></methodparam> - <methodparam ><type>int</type><parameter>flags</parameter></methodparam> + <methodparam ><type>integer</type><parameter>flags</parameter></methodparam> <methodparam ><type>string</type><parameter>dname</parameter></methodparam> <methodparam ><type>string</type><parameter>uri</parameter></methodparam> <methodparam ><type>integer</type><parameter>bandwith</parameter></methodparam> </methodsynopsis> <para> - Performs migration of the domain from one host to another. For description of parameters and flags see <link xlink:href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMigrateToUri">original documentation</link>. + Performs migration of the domain from one host to another. For description of parameters and flags see <link xlink:href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMigrateToURI">original documentation</link>. </para> <para> Please note that the function returns after the migration is complete. It may take a lot of time to migrate a host. Be sure to configure PHP maximum execution time. @@ -81,6 +81,7 @@ &reftitle.seealso; <para> <simplelist> + <member><function>libvirt_domain_migrate_to_uri2</function></member> <member><function>libvirt_domain_migrate</function></member> <member><function>libvirt_domain_get_job_info</function></member> </simplelist> diff --git a/doc/source/libvirt/functions/libvirt-domain-migrate-to-uri2.xml b/doc/source/libvirt/functions/libvirt-domain-migrate-to-uri2.xml new file mode 100644 index 0000000..0cbb414 --- /dev/null +++ b/doc/source/libvirt/functions/libvirt-domain-migrate-to-uri2.xml @@ -0,0 +1,134 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.28 $ --> + +<refentry xml:id="function.libvirt-domain-migrate-to-uri" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> + <refnamediv> + <refname>libvirt_domain_migrate_to_uri</refname> + <refpurpose>Migrate the domain object from its current host to the destination host defined by URI</refpurpose> + </refnamediv> + + <refsect1 role="description"> + &reftitle.description; + <methodsynopsis> + <type>bool</type><methodname>libvirt_domain_migrate_to_uri</methodname> + <methodparam ><type>resource</type><parameter>domain</parameter></methodparam> + <methodparam ><type>string</type><parameter>dconnuri</parameter></methodparam> + <methodparam ><type>string</type><parameter>miguri</parameter></methodparam> + <methodparam ><type>string</type><parameter>dxml</parameter></methodparam> + <methodparam ><type>integer</type><parameter>flags</parameter></methodparam> + <methodparam ><type>string</type><parameter>dname</parameter></methodparam> + <methodparam ><type>string</type><parameter>uri</parameter></methodparam> + <methodparam ><type>integer</type><parameter>bandwith</parameter></methodparam> + </methodsynopsis> + <para> + Performs migration of the domain from one host to another. For description of parameters and flags see <link xlink:href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMigrateToURI2">original documentation</link>. + </para> + <para> + Please note that the function returns after the migration is complete. It may take a lot of time to migrate a host. Be sure to configure PHP maximum execution time. + </para> + + </refsect1> + + <refsect1 role="returnvalues"> + &reftitle.returnvalues; + <!-- See also &return.success; --> + <para> + &true; on success and &false; on failure. + </para> + </refsect1> + +<refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>libvirt_domain_migrate_to_uri2</function> example</title> + <para> + Live migrate domain (f13_exper) to another node + </para> + <programlisting role="php"> +<![CDATA[ +<?php + echo ("Looking up f13_exper domain\n"); + $domain=@libvirt_domain_lookup_by_name($conn,"f13_exper"); + if ($domain==false) + { + echo ("Domain not found\n"); + echo ("Libvirt last error: ".libvirt_get_last_error()."\n"); + exit; + } + echo ("Domain found\n"); + + $xmllibvirt=libvirt_domain_get_xml_desc($domain, NULL); + $spicePort=5900; + $xml=''; + $pos1=strpos($xmllibvirt,'<graphics'); + if (false!==$pos1) + { + $pos2=strpos($xmllibvirt,"</graphics>",$pos1+1); + if (false!==$pos2) + { + $pos3=($xmllibvirt,"port='",$pos1+1); + if (false!==$pos3 && $pos3<$pos2) { + $start=$pos3+6; + $end=($xmllibvirt,"'",$start); + if (false!==$end) { + $xml=substr_replace($xmllibvirt,$spicePort,$start,$end-$start); + } + } + } + } + $flags=$VIR_MIGRATE_LIVE | $VIR_MIGRATE_UNDEFINE_SOURCE | $VIR_MIGRATE_PEER2PEER | $VIR_MIGRATE_TUNNELLED | $VIR_MIGRATE_PERSIST_DEST | $VIR_MIGRATE_UNSAFE; + + echo ("Migrating domain to $miguri\n"); + $rv=libvirt_domain_migrate_to_uri2($domain,$miguri,null,$xml,$flags); + if ($rv==false) + { + echo ("Failure!"); + echo ("Libvirt last error: ".libvirt_get_last_error()."\n"); + } + else + { + echo ("Success\n"); + } +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + + + + <refsect1 role="seealso"> + &reftitle.seealso; + <para> + <simplelist> + <member><function>libvirt_domain_migrate_to_uri</function></member> + <member><function>libvirt_domain_migrate</function></member> + <member><function>libvirt_domain_get_job_info</function></member> + </simplelist> + </para> + </refsect1> + +</refentry> + +<!-- Keep this comment at the end of the file +Local variables: +mode: sgml +sgml-omittag:t +sgml-shorttag:t +sgml-minimize-attributes:nil +sgml-always-quote-attributes:t +sgml-indent-step:1 +sgml-indent-data:t +indent-tabs-mode:nil +sgml-parent-document:nil +sgml-default-dtd-file:"../../../../manual.ced" +sgml-exposed-tags:nil +sgml-local-catalogs:nil +sgml-local-ecat-files:nil +End: +vim600: syn=xml fen fdm=syntax fdl=2 si +vim: et tw=78 syn=sgml +vi: ts=1 sw=1 +--> diff --git a/doc/source/libvirt/functions/libvirt-domain-migrate.xml b/doc/source/libvirt/functions/libvirt-domain-migrate.xml index 862a6e9..11170cb 100644 --- a/doc/source/libvirt/functions/libvirt-domain-migrate.xml +++ b/doc/source/libvirt/functions/libvirt-domain-migrate.xml @@ -13,7 +13,7 @@ <type>resource</type><methodname>libvirt_domain_migrate</methodname> <methodparam ><type>resource</type><parameter>domain</parameter></methodparam> <methodparam ><type>resource</type><parameter>dconn</parameter></methodparam> - <methodparam ><type>int</type><parameter>flags</parameter></methodparam> + <methodparam ><type>integer</type><parameter>flags</parameter></methodparam> <methodparam ><type>string</type><parameter>dname</parameter></methodparam> <methodparam ><type>string</type><parameter>uri</parameter></methodparam> <methodparam ><type>integer</type><parameter>bandwith</parameter></methodparam> @@ -91,6 +91,7 @@ &reftitle.seealso; <para> <simplelist> + <member><function>libvirt_domain_migrate_to_uri2</function></member> <member><function>libvirt_domain_migrate_to_uri</function></member> <member><function>libvirt_domain_get_job_info</function></member> </simplelist> diff --git a/doc/source/libvirt/versions.xml b/doc/source/libvirt/versions.xml index adc01a4..5a00c39 100644 --- a/doc/source/libvirt/versions.xml +++ b/doc/source/libvirt/versions.xml @@ -42,6 +42,7 @@ Example entries: <function name='libvirt_domain_memory_peek' from='php-libvirt 0.1'/> <function name='libvirt_domain_memory_stats' from='php-libvirt 0.3'/> <function name='libvirt_domain_migrate' from='php-libvirt 0.4'/> + <function name='libvirt_domain_migrate_to_uri2' from='php-libvirt 0.4.8'/> <function name='libvirt_domain_migrate_to_uri' from='php-libvirt 0.4'/> <function name='libvirt_domain_get_job_info' from='php-libvirt 0.4'/> <function name='libvirt_domain_block_stats' from='php-libvirt 0.3'/> -- 1.7.12.4

Thanks for the patches! They's working fine and they're looking good so I've applied it, also, I've added your name & e-mail to the AUTHORS file. Thanks again! Michal On 01/29/2013 12:47 PM, stefan.kuhn@foss-group.ch wrote:
*** Please add new function libvirt_domain_migrate_to_uri2 for libirts virDomainMigrateToURI2(). ***
Stefan Kuhn (2): Implement libvirt_domain_migrate_to_uri2 for virDomainMigrateToURI2 Document new funct. libvirt_domain_migrate_to_uri2
.../functions/libvirt-domain-get-job-info.xml | 1 + .../functions/libvirt-domain-migrate-to-uri.xml | 5 +- .../functions/libvirt-domain-migrate-to-uri2.xml | 134 +++++++++++++++++++++ .../libvirt/functions/libvirt-domain-migrate.xml | 3 +- doc/source/libvirt/versions.xml | 1 + src/libvirt-php.c | 53 ++++++++ src/libvirt-php.h | 1 + 7 files changed, 195 insertions(+), 3 deletions(-) create mode 100644 doc/source/libvirt/functions/libvirt-domain-migrate-to-uri2.xml
-- Michal Novotny <minovotn@redhat.com>, RHCE, Red Hat Virtualization | libvirt-php bindings | php-virt-control.org

I had a problem with the file "docs/distros.html.in" in libvirt-php-0.4.7 - The file is not in the repository! The error is: ### distros.html.tmp:96: element table: validity error : No declaration for attribute align of element table <table align="center" width="75%"> ^ make[2]: *** [distros.html] Error 1 ### This patch would fix it: ### --- ./docs/distros.html.in +++ ./docs/distros.html.in @@ -4,8 +4,8 @@ <p> There are several distributions that supports the libvirt-php in it's repositories. You can see the list in here:<br /> - <table align="center" width="75%"> - <tr> + <table width="75%"> + <tr align="center"> <th>Distribution</th> <th>Installer command</th> <th>Link</th> ### Thanks - Regards Stefan Kuhn On Tue, 2013-01-29 at 15:24 +0100, Michal Novotny wrote:
Thanks for the patches! They's working fine and they're looking good so I've applied it, also, I've added your name & e-mail to the AUTHORS file.
Thanks again! Michal
On 01/29/2013 12:47 PM, stefan.kuhn@foss-group.ch wrote:
*** Please add new function libvirt_domain_migrate_to_uri2 for libirts virDomainMigrateToURI2(). ***
Stefan Kuhn (2): Implement libvirt_domain_migrate_to_uri2 for virDomainMigrateToURI2 Document new funct. libvirt_domain_migrate_to_uri2
.../functions/libvirt-domain-get-job-info.xml | 1 + .../functions/libvirt-domain-migrate-to-uri.xml | 5 +- .../functions/libvirt-domain-migrate-to-uri2.xml | 134 +++++++++++++++++++++ .../libvirt/functions/libvirt-domain-migrate.xml | 3 +- doc/source/libvirt/versions.xml | 1 + src/libvirt-php.c | 53 ++++++++ src/libvirt-php.h | 1 + 7 files changed, 195 insertions(+), 3 deletions(-) create mode 100644 doc/source/libvirt/functions/libvirt-domain-migrate-to-uri2.xml

Thanks for notification, it was missing in the repository so I've pushed my version of the file there. Thanks, Michal On 01/31/2013 02:31 PM, Stefan Kuhn wrote:
I had a problem with the file "docs/distros.html.in" in libvirt-php-0.4.7 - The file is not in the repository!
The error is: ### distros.html.tmp:96: element table: validity error : No declaration for attribute align of element table <table align="center" width="75%"> ^ make[2]: *** [distros.html] Error 1 ###
This patch would fix it: ### --- ./docs/distros.html.in +++ ./docs/distros.html.in @@ -4,8 +4,8 @@ <p> There are several distributions that supports the libvirt-php in it's repositories. You can see the list in here:<br />
- <table align="center" width="75%"> - <tr> + <table width="75%"> + <tr align="center"> <th>Distribution</th> <th>Installer command</th> <th>Link</th> ###
Thanks - Regards Stefan Kuhn
Thanks for the patches! They's working fine and they're looking good so I've applied it, also, I've added your name & e-mail to the AUTHORS file.
Thanks again! Michal
On 01/29/2013 12:47 PM, stefan.kuhn@foss-group.ch wrote:
*** Please add new function libvirt_domain_migrate_to_uri2 for libirts virDomainMigrateToURI2(). ***
Stefan Kuhn (2): Implement libvirt_domain_migrate_to_uri2 for virDomainMigrateToURI2 Document new funct. libvirt_domain_migrate_to_uri2
.../functions/libvirt-domain-get-job-info.xml | 1 + .../functions/libvirt-domain-migrate-to-uri.xml | 5 +- .../functions/libvirt-domain-migrate-to-uri2.xml | 134 +++++++++++++++++++++ .../libvirt/functions/libvirt-domain-migrate.xml | 3 +- doc/source/libvirt/versions.xml | 1 + src/libvirt-php.c | 53 ++++++++ src/libvirt-php.h | 1 + 7 files changed, 195 insertions(+), 3 deletions(-) create mode 100644 doc/source/libvirt/functions/libvirt-domain-migrate-to-uri2.xml
--
On Tue, 2013-01-29 at 15:24 +0100, Michal Novotny wrote: libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- Michal Novotny <minovotn@redhat.com>, RHCE, Red Hat Virtualization | libvirt-php bindings | php-virt-control.org
participants (3)
-
Michal Novotny
-
Stefan Kuhn
-
stefan.kuhn@foss-group.ch