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

qemu: Pass qemuCaps to qemuDomainDefCopy

Since qemuDomainDefPostParse callback requires qemuCaps, we need to make
sure it gets the capabilities stored in the domain's private data if the
domain is running. Passing NULL may cause QEMU capabilities probing to
be triggered in case QEMU binary changed in the meantime. When this
happens while a running domain object is locked, QMP event delivered to
the domain before QEMU capabilities probing finishes will deadlock the
event loop.

This patch fixes all paths leading to qemuDomainDefCopy.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 0dc84c34
......@@ -8361,6 +8361,7 @@ qemuDomainObjExitRemote(virDomainObjPtr obj,
static virDomainDefPtr
qemuDomainDefFromXML(virQEMUDriverPtr driver,
virQEMUCapsPtr qemuCaps,
const char *xml)
{
virCapsPtr caps;
......@@ -8369,7 +8370,7 @@ qemuDomainDefFromXML(virQEMUDriverPtr driver,
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
return NULL;
def = virDomainDefParseString(xml, caps, driver->xmlopt, NULL,
def = virDomainDefParseString(xml, caps, driver->xmlopt, qemuCaps,
VIR_DOMAIN_DEF_PARSE_INACTIVE |
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE);
......@@ -8380,6 +8381,7 @@ qemuDomainDefFromXML(virQEMUDriverPtr driver,
virDomainDefPtr
qemuDomainDefCopy(virQEMUDriverPtr driver,
virQEMUCapsPtr qemuCaps,
virDomainDefPtr src,
unsigned int flags)
{
......@@ -8389,7 +8391,7 @@ qemuDomainDefCopy(virQEMUDriverPtr driver,
if (!(xml = qemuDomainDefFormatXML(driver, src, flags)))
return NULL;
ret = qemuDomainDefFromXML(driver, xml);
ret = qemuDomainDefFromXML(driver, qemuCaps, xml);
VIR_FREE(xml);
return ret;
......@@ -10616,6 +10618,7 @@ qemuDomainMigratableDefCheckABIStability(virQEMUDriverPtr driver,
bool
qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
virQEMUCapsPtr qemuCaps,
virDomainDefPtr src,
virDomainDefPtr dst)
{
......@@ -10623,8 +10626,8 @@ qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
virDomainDefPtr migratableDefDst = NULL;
bool ret = false;
if (!(migratableDefSrc = qemuDomainDefCopy(driver, src, COPY_FLAGS)) ||
!(migratableDefDst = qemuDomainDefCopy(driver, dst, COPY_FLAGS)))
if (!(migratableDefSrc = qemuDomainDefCopy(driver, qemuCaps, src, COPY_FLAGS)) ||
!(migratableDefDst = qemuDomainDefCopy(driver, qemuCaps, dst, COPY_FLAGS)))
goto cleanup;
ret = qemuDomainMigratableDefCheckABIStability(driver,
......@@ -10643,14 +10646,15 @@ qemuDomainCheckABIStability(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainDefPtr dst)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainDefPtr migratableSrc = NULL;
virDomainDefPtr migratableDst = NULL;
char *xml = NULL;
bool ret = false;
if (!(xml = qemuDomainFormatXML(driver, vm, COPY_FLAGS)) ||
!(migratableSrc = qemuDomainDefFromXML(driver, xml)) ||
!(migratableDst = qemuDomainDefCopy(driver, dst, COPY_FLAGS)))
!(migratableSrc = qemuDomainDefFromXML(driver, priv->qemuCaps, xml)) ||
!(migratableDst = qemuDomainDefCopy(driver, priv->qemuCaps, dst, COPY_FLAGS)))
goto cleanup;
ret = qemuDomainMigratableDefCheckABIStability(driver,
......
......@@ -649,6 +649,7 @@ int qemuDomainObjExitRemote(virDomainObjPtr obj,
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
virDomainDefPtr qemuDomainDefCopy(virQEMUDriverPtr driver,
virQEMUCapsPtr qemuCaps,
virDomainDefPtr src,
unsigned int flags);
......@@ -863,6 +864,7 @@ int qemuDomainUpdateMemoryDeviceInfo(virQEMUDriverPtr driver,
int asyncJob);
bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
virQEMUCapsPtr qemuCaps,
virDomainDefPtr src,
virDomainDefPtr dst);
......
......@@ -6764,7 +6764,7 @@ qemuDomainSaveImageUpdateDef(virQEMUDriverPtr driver,
VIR_DOMAIN_DEF_PARSE_INACTIVE)))
goto cleanup;
if (!(newdef_migr = qemuDomainDefCopy(driver,
if (!(newdef_migr = qemuDomainDefCopy(driver, NULL,
newdef,
QEMU_DOMAIN_FORMAT_LIVE_FLAGS |
VIR_DOMAIN_XML_MIGRATABLE)))
......@@ -16553,7 +16553,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
switch ((virDomainSnapshotState) snapdef->state) {
case VIR_DOMAIN_SNAPSHOT_RUNNING:
case VIR_DOMAIN_SNAPSHOT_PAUSED:
priv = vm->privateData;
start_flags |= VIR_QEMU_PROCESS_START_PAUSED;
/* Transitions 2, 3, 5, 6, 8, 9 */
......@@ -16580,7 +16580,9 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
if (!(config->cpu = virCPUDefCopy(cookie->cpu)))
goto endjob;
compatible = qemuDomainDefCheckABIStability(driver, vm->def,
compatible = qemuDomainDefCheckABIStability(driver,
priv->qemuCaps,
vm->def,
config);
} else {
compatible = qemuDomainCheckABIStability(driver, vm, config);
......@@ -16624,7 +16626,6 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
}
}
priv = vm->privateData;
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
/* Transitions 5, 6 */
if (qemuProcessStopCPUs(driver, vm,
......
......@@ -2381,7 +2381,7 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
if (!newdef)
goto cleanup;
if (!qemuDomainDefCheckABIStability(driver, *def, newdef)) {
if (!qemuDomainDefCheckABIStability(driver, NULL, *def, newdef)) {
virDomainDefFree(newdef);
goto cleanup;
}
......@@ -3427,7 +3427,7 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
goto error;
} else {
virDomainDefPtr def = vm->newDef ? vm->newDef : vm->def;
if (!(persistDef = qemuDomainDefCopy(driver, def,
if (!(persistDef = qemuDomainDefCopy(driver, priv->qemuCaps, def,
VIR_DOMAIN_XML_SECURE |
VIR_DOMAIN_XML_MIGRATABLE)))
goto error;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册