[libvirt] Migration issue php-libvirt

Hi All I am trying to migrate offline domain on other URI but its not working due to this error Failure!Libvirt last error: Requested operation is not valid: domain is not running I tried to use this option but not working VIR_MIGRATE_OFFLINE Please anybody help me? Br. Umar

On Sun, Oct 13, 2013 at 03:20:31PM +0500, Umar Draz wrote:
Hi All
I am trying to migrate offline domain on other URI but its not working
due to this error
Failure!Libvirt last error: Requested operation is not valid: domain is not running
I tried to use this option but not working
VIR_MIGRATE_OFFLINE
Please anybody help me?
You don't mention what hypervisor you're using. IIRC only the QEMU driver supports the VIR_MIGRATE_OFFLINE flag. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

HI, I am using KVM Br. Umar On Tue, Oct 15, 2013 at 4:11 PM, Daniel P. Berrange <berrange@redhat.com>wrote:
On Sun, Oct 13, 2013 at 03:20:31PM +0500, Umar Draz wrote:
Hi All
I am trying to migrate offline domain on other URI but its not working
due to this error
Failure!Libvirt last error: Requested operation is not valid: domain is not running
I tried to use this option but not working
VIR_MIGRATE_OFFLINE
Please anybody help me?
You don't mention what hypervisor you're using. IIRC only the QEMU driver supports the VIR_MIGRATE_OFFLINE flag.
Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/:| |: http://libvirt.org -o- http://virt-manager.org:| |: http://autobuild.org -o- http://search.cpan.org/~danberr/:| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc:|
-- Umar Draz Network Architect

[Please, don't top post on technical lists.] At Thu, 17 Oct 2013 08:40:52 +0500, Umar Draz wrote:
HI,
I am using KVM
Could you tell us a bit more about your setup and show your code? Which version of libvirt are you using? My guess would be that you don't have shared storage and are using the VIR_MIGRATE_NON_SHARED_DISK flag when migrating, which only works if the domain is running. In that case, you could start your domain in the 'paused' state, migrate and then destroy it.
On Tue, Oct 15, 2013 at 4:11 PM, Daniel P. Berrange <berrange@redhat.com>wrote:
On Sun, Oct 13, 2013 at 03:20:31PM +0500, Umar Draz wrote:
Hi All
I am trying to migrate offline domain on other URI but its not working
due to this error
Failure!Libvirt last error: Requested operation is not valid: domain is not running
I tried to use this option but not working
VIR_MIGRATE_OFFLINE
Please anybody help me?
You don't mention what hypervisor you're using. IIRC only the QEMU driver supports the VIR_MIGRATE_OFFLINE flag. -- AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany Phone: +49 341 265 310 19 Web:<http://www.av-test.org>
Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076) Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern

Hi Claudio Here is my PHP code <?php echo ("Looking up test domain\n"); $con = new Libvirt('qemu+tcp://192.168.168.11/system'); $duri = 'qemu+tcp://192.168.168.14/system'; $dom = $con->get_domain_by_name("ldap"); if ($dom==false) { echo ("Domain not found\n"); echo ("Libvirt last error: ".libvirt_get_last_error()."\n"); exit; } echo ("Domain found\n"); echo ("Migrating domain to $duri\n"); $rv=libvirt_domain_migrate_to_uri($dom,$duri, VIR_MIGRATE_PEER2PEER | VIR_MIGRATE_UNSAFE | VIR_MIGRATE_OFFLINE | VIR_MIGRATE_PERSI ST_DEST | VIR_MIGRATE_UNDEFINE_SOURCE); if ($rv==false) { echo ("Failure!"); echo ("Libvirt last error: ".libvirt_get_last_error()."\n"); } else { echo ("Success\n"); } Here is the error message when I tried to migrate (powered off) domain ---------------------------------------------------------------------- *Looking up test domain* *Domain found* *Migrating domain to qemu+tcp://192.168.168.14/system* *Failure!Libvirt last error: Requested operation is not valid: domain is not running* And here is the error message when I tried (powered on) domain -------------------------------------------------------------- *Looking up test domain* *Domain found* *Migrating domain to qemu+tcp://192.168.168.14/system* *Failure!Libvirt last error: Unsafe migration: Migration may lead to data corruption if disks use cache != none* Here is the php_error_logs -------------------------- *[17-Oct-2013 05:17:42 America/New_York] PHP Notice: Use of undefined constant VIR_MIGRATE_UNSAFE - assumed 'VIR_MIGRATE_UNSAFE' in /home/www/virtspace/inc/mig.php on line 21* *[17-Oct-2013 05:17:42 America/New_York] PHP Notice: Use of undefined constant VIR_MIGRATE_OFFLINE - assumed 'VIR_MIGRATE_OFFLINE' in /home/www/virtspace/inc/mig.php on line 21* According to above php_notices, both VIR_OFFLINE AND VIR_UNSAFE options are not available. *My libvirt version on kvm hosts is (1000002), and php-libvirt version is (0.4.8)* Br. Umar On Thu, Oct 17, 2013 at 11:14 AM, Claudio Bley <cbley@av-test.de> wrote:
[Please, don't top post on technical lists.]
At Thu, 17 Oct 2013 08:40:52 +0500, Umar Draz wrote:
HI,
I am using KVM
Could you tell us a bit more about your setup and show your code? Which version of libvirt are you using?
My guess would be that you don't have shared storage and are using the VIR_MIGRATE_NON_SHARED_DISK flag when migrating, which only works if the domain is running.
In that case, you could start your domain in the 'paused' state, migrate and then destroy it.
On Tue, Oct 15, 2013 at 4:11 PM, Daniel P. Berrange <berrange@redhat.com wrote:
On Sun, Oct 13, 2013 at 03:20:31PM +0500, Umar Draz wrote:
Hi All
I am trying to migrate offline domain on other URI but its not working
due to this error
Failure!Libvirt last error: Requested operation is not valid: domain is not running
I tried to use this option but not working
VIR_MIGRATE_OFFLINE
Please anybody help me?
You don't mention what hypervisor you're using. IIRC only the QEMU driver supports the VIR_MIGRATE_OFFLINE flag. -- AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany Phone: +49 341 265 310 19 Web:<http://www.av-test.org>
Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076) Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern
-- Umar Draz Network Architect

[Repeat: please, don't top post on technical lists.] At Thu, 17 Oct 2013 14:26:33 +0500, Umar Draz wrote:
Here is the php_error_logs -------------------------- *[17-Oct-2013 05:17:42 America/New_York] PHP Notice: Use of undefined constant VIR_MIGRATE_UNSAFE - assumed 'VIR_MIGRATE_UNSAFE' in /home/www/virtspace/inc/mig.php on line 21* *[17-Oct-2013 05:17:42 America/New_York] PHP Notice: Use of undefined constant VIR_MIGRATE_OFFLINE - assumed 'VIR_MIGRATE_OFFLINE' in /home/www/virtspace/inc/mig.php on line 21*
According to above php_notices, both VIR_OFFLINE AND VIR_UNSAFE options are not available.
Indeed, looking at the libvirt-php code (http://libvirt.org/git/?p=libvirt-php.git;a=blob;f=src/libvirt-php.c;h=a1496...), these constants are not defined yet. The wrapper is lacking the following constants, which you can easily define yourself in your PHP script: VIR_MIGRATE_CHANGE_PROTECTION = 256 VIR_MIGRATE_UNSAFE = 512 VIR_MIGRATE_OFFLINE = 1024 VIR_MIGRATE_COMPRESSED = 2048 Claudio -- AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany Phone: +49 341 265 310 19 Web:<http://www.av-test.org> Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076) Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern

Hi Claudio, Thanks, its working. Br. Umar On Thu, Oct 17, 2013 at 2:45 PM, Claudio Bley <cbley@av-test.de> wrote:
[Repeat: please, don't top post on technical lists.]
At Thu, 17 Oct 2013 14:26:33 +0500, Umar Draz wrote:
Here is the php_error_logs -------------------------- *[17-Oct-2013 05:17:42 America/New_York] PHP Notice: Use of undefined constant VIR_MIGRATE_UNSAFE - assumed 'VIR_MIGRATE_UNSAFE' in /home/www/virtspace/inc/mig.php on line 21* *[17-Oct-2013 05:17:42 America/New_York] PHP Notice: Use of undefined constant VIR_MIGRATE_OFFLINE - assumed 'VIR_MIGRATE_OFFLINE' in /home/www/virtspace/inc/mig.php on line 21*
According to above php_notices, both VIR_OFFLINE AND VIR_UNSAFE options
are
not available.
Indeed, looking at the libvirt-php code ( http://libvirt.org/git/?p=libvirt-php.git;a=blob;f=src/libvirt-php.c;h=a1496... ), these constants are not defined yet. The wrapper is lacking the following constants, which you can easily define yourself in your PHP script:
VIR_MIGRATE_CHANGE_PROTECTION = 256 VIR_MIGRATE_UNSAFE = 512 VIR_MIGRATE_OFFLINE = 1024 VIR_MIGRATE_COMPRESSED = 2048
Claudio -- AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany Phone: +49 341 265 310 19 Web:<http://www.av-test.org>
Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076) Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern
-- Umar Draz Network Architect

Hi, the interesting thing is that you use constructor as $conn = new Libvirt('connection-uri'); You should be using libvirt_connect() API instead. See [1] for example. Not all of the defines are defined in the libvirt-php scope, that is correct and patches are welcome :-) Thanks, Michal [1] http://libvirt.org/git/?p=libvirt-php.git;a=blob;f=tests/test-domain-create.... On 10/17/2013 11:45 AM, Claudio Bley wrote:
[Repeat: please, don't top post on technical lists.]
Here is the php_error_logs -------------------------- *[17-Oct-2013 05:17:42 America/New_York] PHP Notice: Use of undefined constant VIR_MIGRATE_UNSAFE - assumed 'VIR_MIGRATE_UNSAFE' in /home/www/virtspace/inc/mig.php on line 21* *[17-Oct-2013 05:17:42 America/New_York] PHP Notice: Use of undefined constant VIR_MIGRATE_OFFLINE - assumed 'VIR_MIGRATE_OFFLINE' in /home/www/virtspace/inc/mig.php on line 21*
According to above php_notices, both VIR_OFFLINE AND VIR_UNSAFE options are not available. Indeed, looking at the libvirt-php code (http://libvirt.org/git/?p=libvirt-php.git;a=blob;f=src/libvirt-php.c;h=a1496...),
At Thu, 17 Oct 2013 14:26:33 +0500, Umar Draz wrote: these constants are not defined yet. The wrapper is lacking the following constants, which you can easily define yourself in your PHP script:
VIR_MIGRATE_CHANGE_PROTECTION = 256 VIR_MIGRATE_UNSAFE = 512 VIR_MIGRATE_OFFLINE = 1024 VIR_MIGRATE_COMPRESSED = 2048
Claudio
-- Michal Novotny <minovotn@redhat.com>, RHCE, Red Hat Virtualization | libvirt-php bindings | php-virt-control.org

Hi Claudio, One more error, I tried this migration and its work, But its added a line in the domain xml (*<seclabel type='none' model='apparmor'/>*), now I tried to again migrate back to the host but this time I got error [17-Oct-2013 09:03:14 America/New_York] PHP Warning: libvirt_domain_migrate_to_uri(): XML error: missing security model when using multiple labels in /home/www/virtspace/migrate.php on line 35 When I used virsh for migration then virsh inserted only this line (*<seclabel type='none'/>)* * * *Br.* * * *Umar* On Thu, Oct 17, 2013 at 2:45 PM, Claudio Bley <cbley@av-test.de> wrote:
[Repeat: please, don't top post on technical lists.]
At Thu, 17 Oct 2013 14:26:33 +0500, Umar Draz wrote:
Here is the php_error_logs -------------------------- *[17-Oct-2013 05:17:42 America/New_York] PHP Notice: Use of undefined constant VIR_MIGRATE_UNSAFE - assumed 'VIR_MIGRATE_UNSAFE' in /home/www/virtspace/inc/mig.php on line 21* *[17-Oct-2013 05:17:42 America/New_York] PHP Notice: Use of undefined constant VIR_MIGRATE_OFFLINE - assumed 'VIR_MIGRATE_OFFLINE' in /home/www/virtspace/inc/mig.php on line 21*
According to above php_notices, both VIR_OFFLINE AND VIR_UNSAFE options
are
not available.
Indeed, looking at the libvirt-php code ( http://libvirt.org/git/?p=libvirt-php.git;a=blob;f=src/libvirt-php.c;h=a1496... ), these constants are not defined yet. The wrapper is lacking the following constants, which you can easily define yourself in your PHP script:
VIR_MIGRATE_CHANGE_PROTECTION = 256 VIR_MIGRATE_UNSAFE = 512 VIR_MIGRATE_OFFLINE = 1024 VIR_MIGRATE_COMPRESSED = 2048
Claudio -- AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany Phone: +49 341 265 310 19 Web:<http://www.av-test.org>
Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076) Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern
-- Umar Draz Network Architect
participants (4)
-
Claudio Bley
-
Daniel P. Berrange
-
Michal Novotny
-
Umar Draz