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