提交 cdd5ef7b 编写于 作者: J Jiri Denemark

qemu: Fix migration with dname

Destination libvirtd remembers the original name in the prepare phase
and clears it in the finish phase. The original name is used when
comparing domain name in migration cookie.
上级 652f8871
...@@ -231,6 +231,7 @@ static void qemuDomainObjPrivateFree(void *data) ...@@ -231,6 +231,7 @@ static void qemuDomainObjPrivateFree(void *data)
qemuDomainObjFreeJob(priv); qemuDomainObjFreeJob(priv);
VIR_FREE(priv->vcpupids); VIR_FREE(priv->vcpupids);
VIR_FREE(priv->lockState); VIR_FREE(priv->lockState);
VIR_FREE(priv->origname);
/* This should never be non-NULL if we get here, but just in case... */ /* This should never be non-NULL if we get here, but just in case... */
if (priv->mon) { if (priv->mon) {
......
...@@ -126,6 +126,7 @@ struct _qemuDomainObjPrivate { ...@@ -126,6 +126,7 @@ struct _qemuDomainObjPrivate {
int jobs_queued; int jobs_queued;
unsigned long migMaxBandwidth; unsigned long migMaxBandwidth;
char *origname;
}; };
struct qemuDomainWatchdogEvent struct qemuDomainWatchdogEvent
......
...@@ -254,12 +254,18 @@ error: ...@@ -254,12 +254,18 @@ error:
static qemuMigrationCookiePtr static qemuMigrationCookiePtr
qemuMigrationCookieNew(virDomainObjPtr dom) qemuMigrationCookieNew(virDomainObjPtr dom)
{ {
qemuDomainObjPrivatePtr priv = dom->privateData;
qemuMigrationCookiePtr mig = NULL; qemuMigrationCookiePtr mig = NULL;
const char *name;
if (VIR_ALLOC(mig) < 0) if (VIR_ALLOC(mig) < 0)
goto no_memory; goto no_memory;
if (!(mig->name = strdup(dom->def->name))) if (priv->origname)
name = priv->origname;
else
name = dom->def->name;
if (!(mig->name = strdup(name)))
goto no_memory; goto no_memory;
memcpy(mig->uuid, dom->def->uuid, VIR_UUID_BUFLEN); memcpy(mig->uuid, dom->def->uuid, VIR_UUID_BUFLEN);
...@@ -1064,6 +1070,7 @@ qemuMigrationPrepareAny(struct qemud_driver *driver, ...@@ -1064,6 +1070,7 @@ qemuMigrationPrepareAny(struct qemud_driver *driver,
unsigned long long now; unsigned long long now;
qemuMigrationCookiePtr mig = NULL; qemuMigrationCookiePtr mig = NULL;
bool tunnel = !!st; bool tunnel = !!st;
char *origname = NULL;
if (virTimeMs(&now) < 0) if (virTimeMs(&now) < 0)
return -1; return -1;
...@@ -1078,7 +1085,7 @@ qemuMigrationPrepareAny(struct qemud_driver *driver, ...@@ -1078,7 +1085,7 @@ qemuMigrationPrepareAny(struct qemud_driver *driver,
/* Target domain name, maybe renamed. */ /* Target domain name, maybe renamed. */
if (dname) { if (dname) {
VIR_FREE(def->name); origname = def->name;
def->name = strdup(dname); def->name = strdup(dname);
if (def->name == NULL) if (def->name == NULL)
goto cleanup; goto cleanup;
...@@ -1095,6 +1102,8 @@ qemuMigrationPrepareAny(struct qemud_driver *driver, ...@@ -1095,6 +1102,8 @@ qemuMigrationPrepareAny(struct qemud_driver *driver,
} }
def = NULL; def = NULL;
priv = vm->privateData; priv = vm->privateData;
priv->origname = origname;
origname = NULL;
if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen, if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen,
QEMU_MIGRATION_COOKIE_LOCKSTATE))) QEMU_MIGRATION_COOKIE_LOCKSTATE)))
...@@ -1175,6 +1184,7 @@ qemuMigrationPrepareAny(struct qemud_driver *driver, ...@@ -1175,6 +1184,7 @@ qemuMigrationPrepareAny(struct qemud_driver *driver,
ret = 0; ret = 0;
cleanup: cleanup:
VIR_FREE(origname);
virDomainDefFree(def); virDomainDefFree(def);
VIR_FORCE_CLOSE(dataFD[0]); VIR_FORCE_CLOSE(dataFD[0]);
VIR_FORCE_CLOSE(dataFD[1]); VIR_FORCE_CLOSE(dataFD[1]);
...@@ -2542,6 +2552,7 @@ qemuMigrationFinish(struct qemud_driver *driver, ...@@ -2542,6 +2552,7 @@ qemuMigrationFinish(struct qemud_driver *driver,
qemuMigrationCookiePtr mig = NULL; qemuMigrationCookiePtr mig = NULL;
virErrorPtr orig_err = NULL; virErrorPtr orig_err = NULL;
int cookie_flags = 0; int cookie_flags = 0;
qemuDomainObjPrivatePtr priv = vm->privateData;
VIR_DEBUG("driver=%p, dconn=%p, vm=%p, cookiein=%s, cookieinlen=%d, " VIR_DEBUG("driver=%p, dconn=%p, vm=%p, cookiein=%s, cookieinlen=%d, "
"cookieout=%p, cookieoutlen=%p, flags=%lx, retcode=%d", "cookieout=%p, cookieoutlen=%p, flags=%lx, retcode=%d",
...@@ -2695,8 +2706,10 @@ endjob: ...@@ -2695,8 +2706,10 @@ endjob:
} }
cleanup: cleanup:
if (vm) if (vm) {
VIR_FREE(priv->origname);
virDomainObjUnlock(vm); virDomainObjUnlock(vm);
}
if (event) if (event)
qemuDomainEventQueue(driver, event); qemuDomainEventQueue(driver, event);
qemuMigrationCookieFree(mig); qemuMigrationCookieFree(mig);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册