]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
retrieve paused/running state at migration start
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 11 Dec 2009 09:06:05 +0000 (10:06 +0100)
committerDaniel Veillard <veillard@redhat.com>
Fri, 11 Dec 2009 09:06:05 +0000 (10:06 +0100)
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, just read the state and if it is appropriate and
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 domains is attempted.

src/libvirt.c
src/xen/xend_internal.c

index 2ced6048283c57d352012c0aaa479d57969ddba3..008e322887909d501b2a174f4ae65f4c9a7c6c94 100644 (file)
@@ -2963,7 +2963,13 @@ virDomainMigrateVersion1 (virDomainPtr domain,
     virDomainPtr ddomain = NULL;
     char *uri_out = NULL;
     char *cookie = NULL;
-    int cookielen = 0;
+    int cookielen = 0, ret;
+    virDomainInfo info;
+
+    ret = virDomainGetInfo (domain, &info);
+    if (ret == 0 && 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;
 
+    ret = virDomainGetInfo (domain, &info);
+    if (ret == 0 && info.state == VIR_DOMAIN_PAUSED) {
+        flags |= VIR_MIGRATE_PAUSED;
+    }
+
     ret = dconn->driver->domainMigratePrepare2
         (dconn, &cookie, &cookielen, uri, &uri_out, flags, dname,
          bandwidth, dom_xml);
index 241a102a9a0f1ea0955aae9e1c7f077829cf9875..d782a872248564198098d708899ad6978cd32bb6 100644 (file)
@@ -4444,6 +4444,15 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
     if (flags & VIR_MIGRATE_PERSIST_DEST)
         flags &= ~VIR_MIGRATE_PERSIST_DEST;
 
+    /* This is buggy in Xend, but could be supported in principle.  Give
+     * a nice error message.
+     */
+    if (flags & VIR_MIGRATE_PAUSED) {
+        virXendError (conn, VIR_ERR_NO_SUPPORT,
+                      "%s", _("xenDaemonDomainMigrate: xend cannot migrate paused domains"));
+        return -1;
+    }
+
     /* XXX we could easily do tunnelled & peer2peer migration too
        if we want to. support these... */
     if (flags != 0) {