render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
43fe83
From 830af6845e0c1dd0ebe6f3de37c27ec3cd6f5e74 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <830af6845e0c1dd0ebe6f3de37c27ec3cd6f5e74.1378475168.git.jdenemar@redhat.com>
43fe83
From: Jiri Denemark <jdenemar@redhat.com>
43fe83
Date: Wed, 4 Sep 2013 09:47:02 +0200
43fe83
Subject: [PATCH] qemu: Make domain renaming work during migration
43fe83
43fe83
https://bugzilla.redhat.com/show_bug.cgi?id=999352
43fe83
43fe83
Since commit v1.0.5-56-g449e6b1 (Pull parsing of migration xml up into
43fe83
QEMU driver APIs) any attempt to rename a domain during migration fails
43fe83
with the following error message:
43fe83
43fe83
    internal error Incoming cookie data had unexpected name DOM vs DOM2
43fe83
43fe83
This is because migration cookies always use the original domain name
43fe83
and the mentioned commit failed to propagate the name back to
43fe83
qemuMigrationPrepareAny.
43fe83
43fe83
(cherry picked from commit 8d67c550e931f1dbc163e7e20784218edc1165df)
43fe83
---
43fe83
 src/qemu/qemu_driver.c    | 36 ++++++++++++++++++++++++------------
43fe83
 src/qemu/qemu_migration.c | 31 +++++++++++++++++++------------
43fe83
 src/qemu/qemu_migration.h |  5 ++++-
43fe83
 3 files changed, 47 insertions(+), 25 deletions(-)
43fe83
43fe83
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
43fe83
index 99cce90..995fe76 100644
43fe83
--- a/src/qemu/qemu_driver.c
43fe83
+++ b/src/qemu/qemu_driver.c
43fe83
@@ -10202,6 +10202,7 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn,
43fe83
 {
43fe83
     virQEMUDriverPtr driver = dconn->privateData;
43fe83
     virDomainDefPtr def = NULL;
43fe83
+    char *origname = NULL;
43fe83
     int ret = -1;
43fe83
 
43fe83
     virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
43fe83
@@ -10219,7 +10220,7 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn,
43fe83
         goto cleanup;
43fe83
     }
43fe83
 
43fe83
-    if (!(def = qemuMigrationPrepareDef(driver, dom_xml, dname)))
43fe83
+    if (!(def = qemuMigrationPrepareDef(driver, dom_xml, dname, &origname)))
43fe83
         goto cleanup;
43fe83
 
43fe83
     if (virDomainMigratePrepareTunnelEnsureACL(dconn, def) < 0)
43fe83
@@ -10227,9 +10228,10 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn,
43fe83
 
43fe83
     ret = qemuMigrationPrepareTunnel(driver, dconn,
43fe83
                                      NULL, 0, NULL, NULL, /* No cookies in v2 */
43fe83
-                                     st, &def, flags);
43fe83
+                                     st, &def, origname, flags);
43fe83
 
43fe83
 cleanup:
43fe83
+    VIR_FREE(origname);
43fe83
     virDomainDefFree(def);
43fe83
     return ret;
43fe83
 }
43fe83
@@ -10251,6 +10253,7 @@ qemuDomainMigratePrepare2(virConnectPtr dconn,
43fe83
 {
43fe83
     virQEMUDriverPtr driver = dconn->privateData;
43fe83
     virDomainDefPtr def = NULL;
43fe83
+    char *origname = NULL;
43fe83
     int ret = -1;
43fe83
 
43fe83
     virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
43fe83
@@ -10272,7 +10275,7 @@ qemuDomainMigratePrepare2(virConnectPtr dconn,
43fe83
         goto cleanup;
43fe83
     }
43fe83
 
43fe83
-    if (!(def = qemuMigrationPrepareDef(driver, dom_xml, dname)))
43fe83
+    if (!(def = qemuMigrationPrepareDef(driver, dom_xml, dname, &origname)))
43fe83
         goto cleanup;
43fe83
 
43fe83
     if (virDomainMigratePrepare2EnsureACL(dconn, def) < 0)
43fe83
@@ -10285,9 +10288,10 @@ qemuDomainMigratePrepare2(virConnectPtr dconn,
43fe83
     ret = qemuMigrationPrepareDirect(driver, dconn,
43fe83
                                      NULL, 0, NULL, NULL, /* No cookies */
43fe83
                                      uri_in, uri_out,
43fe83
-                                     &def, flags);
43fe83
+                                     &def, origname, flags);
43fe83
 
43fe83
 cleanup:
43fe83
+    VIR_FREE(origname);
43fe83
     virDomainDefFree(def);
43fe83
     return ret;
43fe83
 }
43fe83
@@ -10464,6 +10468,7 @@ qemuDomainMigratePrepare3(virConnectPtr dconn,
43fe83
 {
43fe83
     virQEMUDriverPtr driver = dconn->privateData;
43fe83
     virDomainDefPtr def = NULL;
43fe83
+    char *origname = NULL;
43fe83
     int ret = -1;
43fe83
 
43fe83
     virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
43fe83
@@ -10478,7 +10483,7 @@ qemuDomainMigratePrepare3(virConnectPtr dconn,
43fe83
         goto cleanup;
43fe83
     }
43fe83
 
43fe83
-    if (!(def = qemuMigrationPrepareDef(driver, dom_xml, dname)))
43fe83
+    if (!(def = qemuMigrationPrepareDef(driver, dom_xml, dname, &origname)))
43fe83
         goto cleanup;
43fe83
 
43fe83
     if (virDomainMigratePrepare3EnsureACL(dconn, def) < 0)
43fe83
@@ -10488,9 +10493,10 @@ qemuDomainMigratePrepare3(virConnectPtr dconn,
43fe83
                                      cookiein, cookieinlen,
43fe83
                                      cookieout, cookieoutlen,
43fe83
                                      uri_in, uri_out,
43fe83
-                                     &def, flags);
43fe83
+                                     &def, origname, flags);
43fe83
 
43fe83
 cleanup:
43fe83
+    VIR_FREE(origname);
43fe83
     virDomainDefFree(def);
43fe83
     return ret;
43fe83
 }
43fe83
@@ -10511,6 +10517,7 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
43fe83
     const char *dom_xml = NULL;
43fe83
     const char *dname = NULL;
43fe83
     const char *uri_in = NULL;
43fe83
+    char *origname = NULL;
43fe83
     int ret = -1;
43fe83
 
43fe83
     virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
43fe83
@@ -10538,7 +10545,7 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
43fe83
         goto cleanup;
43fe83
     }
43fe83
 
43fe83
-    if (!(def = qemuMigrationPrepareDef(driver, dom_xml, dname)))
43fe83
+    if (!(def = qemuMigrationPrepareDef(driver, dom_xml, dname, &origname)))
43fe83
         goto cleanup;
43fe83
 
43fe83
     if (virDomainMigratePrepare3ParamsEnsureACL(dconn, def) < 0)
43fe83
@@ -10548,9 +10555,10 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
43fe83
                                      cookiein, cookieinlen,
43fe83
                                      cookieout, cookieoutlen,
43fe83
                                      uri_in, uri_out,
43fe83
-                                     &def, flags);
43fe83
+                                     &def, origname, flags);
43fe83
 
43fe83
 cleanup:
43fe83
+    VIR_FREE(origname);
43fe83
     virDomainDefFree(def);
43fe83
     return ret;
43fe83
 }
43fe83
@@ -10570,6 +10578,7 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn,
43fe83
 {
43fe83
     virQEMUDriverPtr driver = dconn->privateData;
43fe83
     virDomainDefPtr def = NULL;
43fe83
+    char *origname = NULL;
43fe83
     int ret = -1;
43fe83
 
43fe83
     virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
43fe83
@@ -10580,7 +10589,7 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn,
43fe83
         goto cleanup;
43fe83
     }
43fe83
 
43fe83
-    if (!(def = qemuMigrationPrepareDef(driver, dom_xml, dname)))
43fe83
+    if (!(def = qemuMigrationPrepareDef(driver, dom_xml, dname, &origname)))
43fe83
         goto cleanup;
43fe83
 
43fe83
     if (virDomainMigratePrepareTunnel3EnsureACL(dconn, def) < 0)
43fe83
@@ -10589,9 +10598,10 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn,
43fe83
     ret = qemuMigrationPrepareTunnel(driver, dconn,
43fe83
                                      cookiein, cookieinlen,
43fe83
                                      cookieout, cookieoutlen,
43fe83
-                                     st, &def, flags);
43fe83
+                                     st, &def, origname, flags);
43fe83
 
43fe83
 cleanup:
43fe83
+    VIR_FREE(origname);
43fe83
     virDomainDefFree(def);
43fe83
     return ret;
43fe83
 }
43fe83
@@ -10611,6 +10621,7 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
43fe83
     virDomainDefPtr def = NULL;
43fe83
     const char *dom_xml = NULL;
43fe83
     const char *dname = NULL;
43fe83
+    char *origname = NULL;
43fe83
     int ret = -1;
43fe83
 
43fe83
     virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
43fe83
@@ -10631,7 +10642,7 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
43fe83
         goto cleanup;
43fe83
     }
43fe83
 
43fe83
-    if (!(def = qemuMigrationPrepareDef(driver, dom_xml, dname)))
43fe83
+    if (!(def = qemuMigrationPrepareDef(driver, dom_xml, dname, &origname)))
43fe83
         goto cleanup;
43fe83
 
43fe83
     if (virDomainMigratePrepareTunnel3ParamsEnsureACL(dconn, def) < 0)
43fe83
@@ -10640,9 +10651,10 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
43fe83
     ret = qemuMigrationPrepareTunnel(driver, dconn,
43fe83
                                      cookiein, cookieinlen,
43fe83
                                      cookieout, cookieoutlen,
43fe83
-                                     st, &def, flags);
43fe83
+                                     st, &def, origname, flags);
43fe83
 
43fe83
 cleanup:
43fe83
+    VIR_FREE(origname);
43fe83
     virDomainDefFree(def);
43fe83
     return ret;
43fe83
 }
43fe83
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
43fe83
index 3dedfe8..5fd52c1 100644
43fe83
--- a/src/qemu/qemu_migration.c
43fe83
+++ b/src/qemu/qemu_migration.c
43fe83
@@ -2161,6 +2161,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
43fe83
                         char **cookieout,
43fe83
                         int *cookieoutlen,
43fe83
                         virDomainDefPtr *def,
43fe83
+                        const char *origname,
43fe83
                         virStreamPtr st,
43fe83
                         unsigned int port,
43fe83
                         unsigned long flags)
43fe83
@@ -2173,7 +2174,6 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
43fe83
     unsigned long long now;
43fe83
     qemuMigrationCookiePtr mig = NULL;
43fe83
     bool tunnel = !!st;
43fe83
-    char *origname = NULL;
43fe83
     char *xmlout = NULL;
43fe83
     unsigned int cookieFlags;
43fe83
     virCapsPtr caps = NULL;
43fe83
@@ -2298,8 +2298,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
43fe83
 
43fe83
     *def = NULL;
43fe83
     priv = vm->privateData;
43fe83
-    priv->origname = origname;
43fe83
-    origname = NULL;
43fe83
+    if (VIR_STRDUP(priv->origname, origname) < 0)
43fe83
+        goto cleanup;
43fe83
 
43fe83
     if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen,
43fe83
                                        QEMU_MIGRATION_COOKIE_LOCKSTATE |
43fe83
@@ -2413,7 +2413,6 @@ done:
43fe83
 
43fe83
 cleanup:
43fe83
     VIR_FREE(migrateFrom);
43fe83
-    VIR_FREE(origname);
43fe83
     VIR_FREE(xmlout);
43fe83
     VIR_FORCE_CLOSE(dataFD[0]);
43fe83
     VIR_FORCE_CLOSE(dataFD[1]);
43fe83
@@ -2458,15 +2457,16 @@ qemuMigrationPrepareTunnel(virQEMUDriverPtr driver,
43fe83
                            int *cookieoutlen,
43fe83
                            virStreamPtr st,
43fe83
                            virDomainDefPtr *def,
43fe83
+                           const char *origname,
43fe83
                            unsigned long flags)
43fe83
 {
43fe83
     int ret;
43fe83
 
43fe83
     VIR_DEBUG("driver=%p, dconn=%p, cookiein=%s, cookieinlen=%d, "
43fe83
               "cookieout=%p, cookieoutlen=%p, st=%p, def=%p, "
43fe83
-              "flags=%lx",
43fe83
+              "origname=%s, flags=%lx",
43fe83
               driver, dconn, NULLSTR(cookiein), cookieinlen,
43fe83
-              cookieout, cookieoutlen, st, *def, flags);
43fe83
+              cookieout, cookieoutlen, st, *def, origname, flags);
43fe83
 
43fe83
     if (st == NULL) {
43fe83
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
43fe83
@@ -2475,7 +2475,7 @@ qemuMigrationPrepareTunnel(virQEMUDriverPtr driver,
43fe83
     }
43fe83
 
43fe83
     ret = qemuMigrationPrepareAny(driver, dconn, cookiein, cookieinlen,
43fe83
-                                  cookieout, cookieoutlen, def,
43fe83
+                                  cookieout, cookieoutlen, def, origname,
43fe83
                                   st, 0, flags);
43fe83
     return ret;
43fe83
 }
43fe83
@@ -2491,6 +2491,7 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
43fe83
                            const char *uri_in,
43fe83
                            char **uri_out,
43fe83
                            virDomainDefPtr *def,
43fe83
+                           const char *origname,
43fe83
                            unsigned long flags)
43fe83
 {
43fe83
     static int port = 0;
43fe83
@@ -2503,10 +2504,10 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
43fe83
 
43fe83
     VIR_DEBUG("driver=%p, dconn=%p, cookiein=%s, cookieinlen=%d, "
43fe83
               "cookieout=%p, cookieoutlen=%p, uri_in=%s, uri_out=%p, "
43fe83
-              "def=%p, flags=%lx",
43fe83
+              "def=%p, origname=%s, flags=%lx",
43fe83
               driver, dconn, NULLSTR(cookiein), cookieinlen,
43fe83
               cookieout, cookieoutlen, NULLSTR(uri_in), uri_out,
43fe83
-              *def, flags);
43fe83
+              *def, origname, flags);
43fe83
 
43fe83
     *uri_out = NULL;
43fe83
 
43fe83
@@ -2595,7 +2596,7 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
43fe83
         VIR_DEBUG("Generated uri_out=%s", *uri_out);
43fe83
 
43fe83
     ret = qemuMigrationPrepareAny(driver, dconn, cookiein, cookieinlen,
43fe83
-                                  cookieout, cookieoutlen, def,
43fe83
+                                  cookieout, cookieoutlen, def, origname,
43fe83
                                   NULL, this_port, flags);
43fe83
 cleanup:
43fe83
     virURIFree(uri);
43fe83
@@ -2609,10 +2610,12 @@ cleanup:
43fe83
 virDomainDefPtr
43fe83
 qemuMigrationPrepareDef(virQEMUDriverPtr driver,
43fe83
                         const char *dom_xml,
43fe83
-                        const char *dname)
43fe83
+                        const char *dname,
43fe83
+                        char **origname)
43fe83
 {
43fe83
     virCapsPtr caps = NULL;
43fe83
     virDomainDefPtr def;
43fe83
+    char *name = NULL;
43fe83
 
43fe83
     if (!dom_xml) {
43fe83
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
43fe83
@@ -2629,7 +2632,7 @@ qemuMigrationPrepareDef(virQEMUDriverPtr driver,
43fe83
         goto cleanup;
43fe83
 
43fe83
     if (dname) {
43fe83
-        VIR_FREE(def->name);
43fe83
+        name = def->name;
43fe83
         if (VIR_STRDUP(def->name, dname) < 0) {
43fe83
             virDomainDefFree(def);
43fe83
             def = NULL;
43fe83
@@ -2638,6 +2641,10 @@ qemuMigrationPrepareDef(virQEMUDriverPtr driver,
43fe83
 
43fe83
 cleanup:
43fe83
     virObjectUnref(caps);
43fe83
+    if (def && origname)
43fe83
+        *origname = name;
43fe83
+    else
43fe83
+        VIR_FREE(name);
43fe83
     return def;
43fe83
 }
43fe83
 
43fe83
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
43fe83
index 0f6c5f7..4af5aed 100644
43fe83
--- a/src/qemu/qemu_migration.h
43fe83
+++ b/src/qemu/qemu_migration.h
43fe83
@@ -100,7 +100,8 @@ char *qemuMigrationBegin(virConnectPtr conn,
43fe83
 
43fe83
 virDomainDefPtr qemuMigrationPrepareDef(virQEMUDriverPtr driver,
43fe83
                                         const char *dom_xml,
43fe83
-                                        const char *dname);
43fe83
+                                        const char *dname,
43fe83
+                                        char **origname);
43fe83
 
43fe83
 int qemuMigrationPrepareTunnel(virQEMUDriverPtr driver,
43fe83
                                virConnectPtr dconn,
43fe83
@@ -110,6 +111,7 @@ int qemuMigrationPrepareTunnel(virQEMUDriverPtr driver,
43fe83
                                int *cookieoutlen,
43fe83
                                virStreamPtr st,
43fe83
                                virDomainDefPtr *def,
43fe83
+                               const char *origname,
43fe83
                                unsigned long flags);
43fe83
 
43fe83
 int qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
43fe83
@@ -121,6 +123,7 @@ int qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
43fe83
                                const char *uri_in,
43fe83
                                char **uri_out,
43fe83
                                virDomainDefPtr *def,
43fe83
+                               const char *origname,
43fe83
                                unsigned long flags);
43fe83
 
43fe83
 int qemuMigrationPerform(virQEMUDriverPtr driver,
43fe83
-- 
43fe83
1.8.3.2
43fe83