libvirt_domain_migrate_to_uri Migrate the domain object from its current host to the destination host defined by URI
&reftitle.description; bool libvirt_domain_migrate_to_uri resource domain string dconnuri string miguri string dxml integer flags string dname string uri integer bandwith

Performs migration of the domain from one host to another. For description of parameters and flags see original documentation.

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.

&reftitle.returnvalues;

&true; on success and &false; on failure.

&reftitle.examples;

`libvirt_domain_migrate_to_uri2` example

Live migrate domain (f13_exper) to another node

    <?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");
       }
    ?>

&reftitle.seealso;

- `libvirt_domain_migrate_to_uri`
- `libvirt_domain_migrate`
- `libvirt_domain_get_job_info`