libvirt_domain_migrate Migrate the domain object from its current host to the destination host defined by a connection
&reftitle.description; resource libvirt_domain_migrate resource domain resource dconn 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;

Resource to new domain on success and &false; on failure. Please note that the resource of the domain is in the context of dconn.

&reftitle.examples;

`libvirt_domain_migrate` example

Live migrate domain (f13_exper) to another node

    <?php
        echo ("Looking up f13_exper domain\n");
        $dom=@libvirt_domain_lookup_by_name($conn,"f13_exper");
        if ($dom==false)
        {
           echo ("Domain not found\n");
           echo ("Libvirt last error: ".libvirt_get_last_error()."\n");
           exit;
        }
        echo ("Domain found\n");

        echo ("Connecting to libvirt (URI:$duri)\n");
        $dconn=libvirt_connect($duri,false,$credentials);
        if ($dconn==false)
        {
           echo ("Libvirt last error: ".libvirt_get_last_error()."\n");
           exit;
        }
        echo ("Connected\n");

        echo ("Migrating domain to $duri\n");
        $ddom=libvirt_domain_migrate($dom,$dconn,VIR_MIGRATE_LIVE | VIR_MIGRATE_PEER2PEER | VIR_MIGRATE_PERSIST_DEST | VIR_MIGRATE_UNDEFINE_SOURCE);
        if ($ddom==false)
        {
           echo ("Failure!");
           echo ("Libvirt last error: ".libvirt_get_last_error()."\n");
        }
        else
        {
    	echo ("Success\n");
    	echo ("DDom is resource ($ddom) to migrated domain in context of destination connection\n");
        }

    ?>

&reftitle.seealso;

- `libvirt_domain_migrate_to_uri2`
- `libvirt_domain_migrate_to_uri`
- `libvirt_domain_get_job_info`