[libvirt] [PATCH 3/3] retrieve paused/running state at the beginning of migration

Paolo Bonzini pbonzini at redhat.com
Wed Nov 25 15:40:08 UTC 2009


This patch fixes the bug where paused/running state is not
transmitted during migration.  As a result, in the QEMU driver
for example the machine was always started on the destination
end.

In order to do so, I just read the state and if it is appropriate
I set the VIR_MIGRATE_PAUSED flag.

* src/libvirt.c (virDomainMigrateVersion1, virDomainMigrateVersion2):
Automatically add VIR_MIGRATE_PAUSED when appropriate.
* src/xen/xend_internal.c (xenDaemonDomainMigratePerform): Give a nicer
error message when migration of paused virtual machines is attempted.
---
 src/libvirt.c           |   12 ++++++++++++
 src/xen/xend_internal.c |    9 +++++++++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index 2ced604..9d03e13 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -2964,6 +2964,12 @@ virDomainMigrateVersion1 (virDomainPtr domain,
     char *uri_out = NULL;
     char *cookie = NULL;
     int cookielen = 0;
+    virDomainInfo info;
+
+    virDomainGetInfo (domain, &info);
+    if (info.state == VIR_DOMAIN_PAUSED) {
+        flags |= VIR_MIGRATE_PAUSED;
+    }
 
     /* Prepare the migration.
      *
@@ -3028,6 +3034,7 @@ virDomainMigrateVersion2 (virDomainPtr domain,
     char *cookie = NULL;
     char *dom_xml = NULL;
     int cookielen = 0, ret;
+    virDomainInfo info;
 
     /* Prepare the migration.
      *
@@ -3054,6 +3061,11 @@ virDomainMigrateVersion2 (virDomainPtr domain,
     if (!dom_xml)
         return NULL;
 
+    virDomainGetInfo (domain, &info);
+    if (info.state == VIR_DOMAIN_PAUSED) {
+        flags |= VIR_MIGRATE_PAUSED;
+    }
+
     ret = dconn->driver->domainMigratePrepare2
         (dconn, &cookie, &cookielen, uri, &uri_out, flags, dname,
          bandwidth, dom_xml);
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index e370eb8..36148d9 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -4434,6 +4434,15 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
     if (flags & VIR_MIGRATE_PERSIST_DEST)
         flags &= ~VIR_MIGRATE_PERSIST_DEST;
 
+    /* This could be supported in principle (disregard VIR_MIGRATE_LIVE, pause
+     * the VM in advance) but is buggy in Xend; give a nice error message.
+     */
+    if (flags & VIR_MIGRATE_PAUSED) {
+        virXendError (conn, VIR_ERR_NO_SUPPORT,
+                      "%s", _("xenDaemonDomainMigrate: xend cannot migrate paused virtual machines"));
+        return -1;
+    }
+
     /* XXX we could easily do tunnelled & peer2peer migration too
        if we want to. support these... */
     if (flags != 0) {
-- 
1.6.5.2





More information about the libvir-list mailing list