From b900f7387fca1cf3567935c81136579d6bee95ca Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Mon, 5 Aug 2019 17:31:10 +0200 Subject: [PATCH] qemu: Pass qemuCaps to qemuMigrationAnyPrepareDef 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 qemuMigrationAnyPrepareDef. Signed-off-by: Jiri Denemark Reviewed-by: Michal Privoznik --- src/qemu/qemu_driver.c | 12 ++++++------ src/qemu/qemu_migration.c | 8 ++++++-- src/qemu/qemu_migration.h | 1 + 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 14a20029dd..1139fde77a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12651,7 +12651,7 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn, goto cleanup; } - if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) + if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname))) goto cleanup; if (virDomainMigratePrepareTunnelEnsureACL(dconn, def) < 0) @@ -12712,7 +12712,7 @@ qemuDomainMigratePrepare2(virConnectPtr dconn, goto cleanup; } - if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) + if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname))) goto cleanup; if (virDomainMigratePrepare2EnsureACL(dconn, def) < 0) @@ -12951,7 +12951,7 @@ qemuDomainMigratePrepare3(virConnectPtr dconn, QEMU_MIGRATION_DESTINATION))) goto cleanup; - if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) + if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname))) goto cleanup; if (virDomainMigratePrepare3EnsureACL(dconn, def) < 0) @@ -13038,7 +13038,7 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn, goto cleanup; } - if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) + if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname))) goto cleanup; if (virDomainMigratePrepare3ParamsEnsureACL(dconn, def) < 0) @@ -13092,7 +13092,7 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn, QEMU_MIGRATION_DESTINATION))) goto cleanup; - if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) + if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname))) goto cleanup; if (virDomainMigratePrepareTunnel3EnsureACL(dconn, def) < 0) @@ -13151,7 +13151,7 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn, QEMU_MIGRATION_DESTINATION))) goto cleanup; - if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) + if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname))) goto cleanup; if (virDomainMigratePrepareTunnel3ParamsEnsureACL(dconn, def) < 0) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 39e574ee30..d07482d9f2 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2861,6 +2861,7 @@ qemuMigrationDstPrepareDirect(virQEMUDriverPtr driver, virDomainDefPtr qemuMigrationAnyPrepareDef(virQEMUDriverPtr driver, + virQEMUCapsPtr qemuCaps, const char *dom_xml, const char *dname, char **origname) @@ -2878,7 +2879,8 @@ qemuMigrationAnyPrepareDef(virQEMUDriverPtr driver, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) return NULL; - if (!(def = virDomainDefParseString(dom_xml, caps, driver->xmlopt, NULL, + if (!(def = virDomainDefParseString(dom_xml, caps, driver->xmlopt, + qemuCaps, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE))) goto cleanup; @@ -3422,7 +3424,9 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver, if (flags & VIR_MIGRATE_PERSIST_DEST) { if (persist_xml) { - if (!(persistDef = qemuMigrationAnyPrepareDef(driver, persist_xml, + if (!(persistDef = qemuMigrationAnyPrepareDef(driver, + priv->qemuCaps, + persist_xml, NULL, NULL))) goto error; } else { diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index bea7b1e688..188ccfa7fd 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -115,6 +115,7 @@ qemuMigrationSrcBegin(virConnectPtr conn, virDomainDefPtr qemuMigrationAnyPrepareDef(virQEMUDriverPtr driver, + virQEMUCapsPtr qemuCaps, const char *dom_xml, const char *dname, char **origname);