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: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_domain.c | 16 ++++++++++------
src/qemu/qemu_domain.h | 2 ++
src/qemu/qemu_driver.c | 9 +++++----
src/qemu/qemu_migration.c | 4 ++--
4 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 0555caa6ab..dba5db68ec 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -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,
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index b76d3cace9..94ff6e7bd3 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -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);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ff83d1c024..4d6a933243 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -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,
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 7c6be201b9..ec1cae8bec 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -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;
--
2.22.0