Libvirt Functions
PHP Manual

libvirt_domain_migrate

(php-libvirt 0.4)

libvirt_domain_migrateMigrate the domain object from its current host to the destination host defined by a connection

Description

resource libvirt_domain_migrate ( resource $domain , resource $dconn , int $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.

Return Values

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

Examples

Example #1 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");
    }

?>

See Also


Libvirt Functions
PHP Manual