
On Wed, Nov 25, 2009 at 04:40:09PM +0100, Paolo Bonzini wrote:
This patch would fix the case where paused/running state is changed during live migration. In order to do so, libvirt attaches an event handler that tracks the paused/running state on the source side. Then, based on the state _just before_ the end of the migration, it can stick a VIR_MIGRATE_PAUSED flag into the flags passed to MigrateFinish or MigrateFinish2. It is not a problem for the QEMU driver if the flag is not passed in the Perform callback.
This would have the advantage of working even with asynchronous changes to the state that can happen during the migration itself. However, since the driver lock is held during migration, this is basically impossible to test until asynchronous notifications are in place. Also, it is somewhat inherently racy: maybe when notifications are added to QEMU, it should also have a "sync" monitor command to flush all notifications.
Hence, this is just an RFC.
* src/libvirt.c (struct _migrateEventState, migrateEventState, virMigrateEventCallback): New. (virDomainMigrateVersion1, virDomainMigrateVersion2): Use them. --- src/libvirt.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 60 insertions(+), 8 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c index 9d03e13..12e90cd 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -2951,6 +2951,42 @@ error: return NULL; }
- virDomainGetInfo (domain, &info); - if (info.state == VIR_DOMAIN_PAUSED) { - flags |= VIR_MIGRATE_PAUSED; + data.domain = domain; + if (virConnectDomainEventRegister (domain->conn, virMigrateEventCallback, + &data, NULL) == -1) { + return NULL; }
Calling virConnectDomainEventRegister() is not valid unless the application has registered an event loop impl with libvit (virEventRegister), but we cannot assume it has done so. Daniel. -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|