qemuMigrationEatCookie: Pass virDomainDef instead of virDomainObj

The function currently takes virDomainObjPtr because it's using
both: the domain definition and domain private data.
Unfortunately, this means that in prepare phase we can't parse
migration cookie before putting incoming domain def onto domain
objects list (addressed in the very next commit). Change the
arguments so that virDomainDef and private data are passed
instead of virDomainObjPtr.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Michal Privoznik 2018-11-22 11:24:03 +01:00
parent ee9175cbe2
commit 1a07aca24a
3 changed files with 25 additions and 18 deletions

View File

@ -2041,7 +2041,8 @@ qemuMigrationSrcBeginPhase(virQEMUDriverPtr driver,
if (!(flags & VIR_MIGRATE_OFFLINE)) if (!(flags & VIR_MIGRATE_OFFLINE))
cookieFlags |= QEMU_MIGRATION_COOKIE_CAPS; cookieFlags |= QEMU_MIGRATION_COOKIE_CAPS;
if (!(mig = qemuMigrationEatCookie(driver, vm, NULL, 0, 0))) if (!(mig = qemuMigrationEatCookie(driver, vm->def,
priv->origname, priv, NULL, 0, 0)))
goto cleanup; goto cleanup;
if (qemuMigrationBakeCookie(mig, driver, vm, if (qemuMigrationBakeCookie(mig, driver, vm,
@ -2411,7 +2412,8 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
priv->hookRun = true; priv->hookRun = true;
} }
if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen, if (!(mig = qemuMigrationEatCookie(driver, vm->def, origname, priv,
cookiein, cookieinlen,
QEMU_MIGRATION_COOKIE_LOCKSTATE | QEMU_MIGRATION_COOKIE_LOCKSTATE |
QEMU_MIGRATION_COOKIE_NBD | QEMU_MIGRATION_COOKIE_NBD |
QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG | QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG |
@ -2922,7 +2924,8 @@ qemuMigrationSrcConfirmPhase(virQEMUDriverPtr driver,
? QEMU_MIGRATION_PHASE_CONFIRM3 ? QEMU_MIGRATION_PHASE_CONFIRM3
: QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED); : QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED);
if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen, if (!(mig = qemuMigrationEatCookie(driver, vm->def, priv->origname, priv,
cookiein, cookieinlen,
QEMU_MIGRATION_COOKIE_STATS))) QEMU_MIGRATION_COOKIE_STATS)))
goto cleanup; goto cleanup;
@ -3427,7 +3430,8 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
} }
} }
mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen, mig = qemuMigrationEatCookie(driver, vm->def, priv->origname, priv,
cookiein, cookieinlen,
cookieFlags | cookieFlags |
QEMU_MIGRATION_COOKIE_GRAPHICS | QEMU_MIGRATION_COOKIE_GRAPHICS |
QEMU_MIGRATION_COOKIE_CAPS); QEMU_MIGRATION_COOKIE_CAPS);
@ -4948,8 +4952,8 @@ qemuMigrationDstFinish(virQEMUDriverPtr driver,
* even though VIR_MIGRATE_PERSIST_DEST was not used. */ * even though VIR_MIGRATE_PERSIST_DEST was not used. */
cookie_flags |= QEMU_MIGRATION_COOKIE_PERSISTENT; cookie_flags |= QEMU_MIGRATION_COOKIE_PERSISTENT;
if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, if (!(mig = qemuMigrationEatCookie(driver, vm->def, priv->origname, priv,
cookieinlen, cookie_flags))) cookiein, cookieinlen, cookie_flags)))
goto endjob; goto endjob;
if (flags & VIR_MIGRATE_OFFLINE) { if (flags & VIR_MIGRATE_OFFLINE) {

View File

@ -279,22 +279,22 @@ qemuMigrationCookieNetworkAlloc(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
static qemuMigrationCookiePtr static qemuMigrationCookiePtr
qemuMigrationCookieNew(virDomainObjPtr dom) qemuMigrationCookieNew(const virDomainDef *def,
const char *origname)
{ {
qemuDomainObjPrivatePtr priv = dom->privateData;
qemuMigrationCookiePtr mig = NULL; qemuMigrationCookiePtr mig = NULL;
const char *name; const char *name;
if (VIR_ALLOC(mig) < 0) if (VIR_ALLOC(mig) < 0)
goto error; goto error;
if (priv->origname) if (origname)
name = priv->origname; name = origname;
else else
name = dom->def->name; name = def->name;
if (VIR_STRDUP(mig->name, name) < 0) if (VIR_STRDUP(mig->name, name) < 0)
goto error; goto error;
memcpy(mig->uuid, dom->def->uuid, VIR_UUID_BUFLEN); memcpy(mig->uuid, def->uuid, VIR_UUID_BUFLEN);
if (!(mig->localHostname = virGetHostname())) if (!(mig->localHostname = virGetHostname()))
goto error; goto error;
@ -1472,12 +1472,13 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
qemuMigrationCookiePtr qemuMigrationCookiePtr
qemuMigrationEatCookie(virQEMUDriverPtr driver, qemuMigrationEatCookie(virQEMUDriverPtr driver,
virDomainObjPtr dom, const virDomainDef *def,
const char *origname,
qemuDomainObjPrivatePtr priv,
const char *cookiein, const char *cookiein,
int cookieinlen, int cookieinlen,
unsigned int flags) unsigned int flags)
{ {
qemuDomainObjPrivatePtr priv = dom->privateData;
qemuMigrationCookiePtr mig = NULL; qemuMigrationCookiePtr mig = NULL;
/* Parse & validate incoming cookie (if any) */ /* Parse & validate incoming cookie (if any) */
@ -1490,7 +1491,7 @@ qemuMigrationEatCookie(virQEMUDriverPtr driver,
VIR_DEBUG("cookielen=%d cookie='%s'", cookieinlen, NULLSTR(cookiein)); VIR_DEBUG("cookielen=%d cookie='%s'", cookieinlen, NULLSTR(cookiein));
if (!(mig = qemuMigrationCookieNew(dom))) if (!(mig = qemuMigrationCookieNew(def, origname)))
return NULL; return NULL;
if (cookiein && cookieinlen && if (cookiein && cookieinlen &&
@ -1502,9 +1503,9 @@ qemuMigrationEatCookie(virQEMUDriverPtr driver,
if (flags & QEMU_MIGRATION_COOKIE_PERSISTENT && if (flags & QEMU_MIGRATION_COOKIE_PERSISTENT &&
mig->persistent && mig->persistent &&
STRNEQ(dom->def->name, mig->persistent->name)) { STRNEQ(def->name, mig->persistent->name)) {
VIR_FREE(mig->persistent->name); VIR_FREE(mig->persistent->name);
if (VIR_STRDUP(mig->persistent->name, dom->def->name) < 0) if (VIR_STRDUP(mig->persistent->name, def->name) < 0)
goto error; goto error;
} }

View File

@ -160,7 +160,9 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
qemuMigrationCookiePtr qemuMigrationCookiePtr
qemuMigrationEatCookie(virQEMUDriverPtr driver, qemuMigrationEatCookie(virQEMUDriverPtr driver,
virDomainObjPtr dom, const virDomainDef *def,
const char *origname,
qemuDomainObjPrivatePtr priv,
const char *cookiein, const char *cookiein,
int cookieinlen, int cookieinlen,
unsigned int flags); unsigned int flags);