提交 48bc3053 编写于 作者: J Jiri Denemark

qemu: Send updated CPU in migration cookie

Since the domain XML send during migration uses the original guest CPU
definition but we still want the destination to enforce ABI if it is new
enough, we send the live updated CPU definition in a migration cookie.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NPavel Hrdina <phrdina@redhat.com>
上级 b0a16641
...@@ -2020,6 +2020,9 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver, ...@@ -2020,6 +2020,9 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
vm->newDef && !qemuDomainVcpuHotplugIsInOrder(vm->newDef))) vm->newDef && !qemuDomainVcpuHotplugIsInOrder(vm->newDef)))
cookieFlags |= QEMU_MIGRATION_COOKIE_CPU_HOTPLUG; cookieFlags |= QEMU_MIGRATION_COOKIE_CPU_HOTPLUG;
if (priv->origCPU)
cookieFlags |= QEMU_MIGRATION_COOKIE_CPU;
if (!(mig = qemuMigrationEatCookie(driver, vm, NULL, 0, 0))) if (!(mig = qemuMigrationEatCookie(driver, vm, NULL, 0, 0)))
goto cleanup; goto cleanup;
...@@ -2644,7 +2647,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, ...@@ -2644,7 +2647,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
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 |
QEMU_MIGRATION_COOKIE_CPU_HOTPLUG))) QEMU_MIGRATION_COOKIE_CPU_HOTPLUG |
QEMU_MIGRATION_COOKIE_CPU)))
goto cleanup; goto cleanup;
if (STREQ_NULLABLE(protocol, "rdma") && if (STREQ_NULLABLE(protocol, "rdma") &&
......
...@@ -48,7 +48,8 @@ VIR_ENUM_IMPL(qemuMigrationCookieFlag, ...@@ -48,7 +48,8 @@ VIR_ENUM_IMPL(qemuMigrationCookieFlag,
"nbd", "nbd",
"statistics", "statistics",
"memory-hotplug", "memory-hotplug",
"cpu-hotplug"); "cpu-hotplug",
"cpu");
static void static void
...@@ -109,6 +110,7 @@ qemuMigrationCookieFree(qemuMigrationCookiePtr mig) ...@@ -109,6 +110,7 @@ qemuMigrationCookieFree(qemuMigrationCookiePtr mig)
VIR_FREE(mig->lockState); VIR_FREE(mig->lockState);
VIR_FREE(mig->lockDriver); VIR_FREE(mig->lockDriver);
VIR_FREE(mig->jobInfo); VIR_FREE(mig->jobInfo);
virCPUDefFree(mig->cpu);
VIR_FREE(mig); VIR_FREE(mig);
} }
...@@ -519,6 +521,22 @@ qemuMigrationCookieAddStatistics(qemuMigrationCookiePtr mig, ...@@ -519,6 +521,22 @@ qemuMigrationCookieAddStatistics(qemuMigrationCookiePtr mig,
} }
static int
qemuMigrationCookieAddCPU(qemuMigrationCookiePtr mig,
virDomainObjPtr vm)
{
if (mig->cpu)
return 0;
if (!(mig->cpu = virCPUDefCopy(vm->def->cpu)))
return -1;
mig->flags |= QEMU_MIGRATION_COOKIE_CPU;
return 0;
}
static void static void
qemuMigrationCookieGraphicsXMLFormat(virBufferPtr buf, qemuMigrationCookieGraphicsXMLFormat(virBufferPtr buf,
qemuMigrationCookieGraphicsPtr grap) qemuMigrationCookieGraphicsPtr grap)
...@@ -755,6 +773,9 @@ qemuMigrationCookieXMLFormat(virQEMUDriverPtr driver, ...@@ -755,6 +773,9 @@ qemuMigrationCookieXMLFormat(virQEMUDriverPtr driver,
if (mig->flags & QEMU_MIGRATION_COOKIE_STATS && mig->jobInfo) if (mig->flags & QEMU_MIGRATION_COOKIE_STATS && mig->jobInfo)
qemuMigrationCookieStatisticsXMLFormat(buf, mig->jobInfo); qemuMigrationCookieStatisticsXMLFormat(buf, mig->jobInfo);
if (mig->flags & QEMU_MIGRATION_COOKIE_CPU && mig->cpu)
virCPUDefFormatBufFull(buf, mig->cpu, NULL, false);
virBufferAdjustIndent(buf, -2); virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</qemu-migration>\n"); virBufferAddLit(buf, "</qemu-migration>\n");
return 0; return 0;
...@@ -1198,6 +1219,10 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig, ...@@ -1198,6 +1219,10 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
(!(mig->jobInfo = qemuMigrationCookieStatisticsXMLParse(ctxt)))) (!(mig->jobInfo = qemuMigrationCookieStatisticsXMLParse(ctxt))))
goto error; goto error;
if (flags & QEMU_MIGRATION_COOKIE_CPU &&
virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST, &mig->cpu) < 0)
goto error;
virObjectUnref(caps); virObjectUnref(caps);
return 0; return 0;
...@@ -1274,6 +1299,10 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig, ...@@ -1274,6 +1299,10 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
if (flags & QEMU_MIGRATION_COOKIE_CPU_HOTPLUG) if (flags & QEMU_MIGRATION_COOKIE_CPU_HOTPLUG)
mig->flagsMandatory |= QEMU_MIGRATION_COOKIE_CPU_HOTPLUG; mig->flagsMandatory |= QEMU_MIGRATION_COOKIE_CPU_HOTPLUG;
if (flags & QEMU_MIGRATION_COOKIE_CPU &&
qemuMigrationCookieAddCPU(mig, dom) < 0)
return -1;
if (!(*cookieout = qemuMigrationCookieXMLFormatStr(driver, mig))) if (!(*cookieout = qemuMigrationCookieXMLFormatStr(driver, mig)))
return -1; return -1;
......
...@@ -28,6 +28,7 @@ typedef enum { ...@@ -28,6 +28,7 @@ typedef enum {
QEMU_MIGRATION_COOKIE_FLAG_STATS, QEMU_MIGRATION_COOKIE_FLAG_STATS,
QEMU_MIGRATION_COOKIE_FLAG_MEMORY_HOTPLUG, QEMU_MIGRATION_COOKIE_FLAG_MEMORY_HOTPLUG,
QEMU_MIGRATION_COOKIE_FLAG_CPU_HOTPLUG, QEMU_MIGRATION_COOKIE_FLAG_CPU_HOTPLUG,
QEMU_MIGRATION_COOKIE_FLAG_CPU,
QEMU_MIGRATION_COOKIE_FLAG_LAST QEMU_MIGRATION_COOKIE_FLAG_LAST
} qemuMigrationCookieFlags; } qemuMigrationCookieFlags;
...@@ -43,6 +44,7 @@ typedef enum { ...@@ -43,6 +44,7 @@ typedef enum {
QEMU_MIGRATION_COOKIE_STATS = (1 << QEMU_MIGRATION_COOKIE_FLAG_STATS), QEMU_MIGRATION_COOKIE_STATS = (1 << QEMU_MIGRATION_COOKIE_FLAG_STATS),
QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG = (1 << QEMU_MIGRATION_COOKIE_FLAG_MEMORY_HOTPLUG), QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG = (1 << QEMU_MIGRATION_COOKIE_FLAG_MEMORY_HOTPLUG),
QEMU_MIGRATION_COOKIE_CPU_HOTPLUG = (1 << QEMU_MIGRATION_COOKIE_FLAG_CPU_HOTPLUG), QEMU_MIGRATION_COOKIE_CPU_HOTPLUG = (1 << QEMU_MIGRATION_COOKIE_FLAG_CPU_HOTPLUG),
QEMU_MIGRATION_COOKIE_CPU = (1 << QEMU_MIGRATION_COOKIE_FLAG_CPU),
} qemuMigrationCookieFeatures; } qemuMigrationCookieFeatures;
typedef struct _qemuMigrationCookieGraphics qemuMigrationCookieGraphics; typedef struct _qemuMigrationCookieGraphics qemuMigrationCookieGraphics;
...@@ -122,6 +124,9 @@ struct _qemuMigrationCookie { ...@@ -122,6 +124,9 @@ struct _qemuMigrationCookie {
/* If (flags & QEMU_MIGRATION_COOKIE_STATS) */ /* If (flags & QEMU_MIGRATION_COOKIE_STATS) */
qemuDomainJobInfoPtr jobInfo; qemuDomainJobInfoPtr jobInfo;
/* If flags & QEMU_MIGRATION_COOKIE_CPU */
virCPUDefPtr cpu;
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册