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 <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Jiri Denemark 2019-08-05 17:31:10 +02:00
parent fd60aefec7
commit b900f7387f
3 changed files with 13 additions and 8 deletions

View File

@ -12651,7 +12651,7 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn,
goto cleanup; goto cleanup;
} }
if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname)))
goto cleanup; goto cleanup;
if (virDomainMigratePrepareTunnelEnsureACL(dconn, def) < 0) if (virDomainMigratePrepareTunnelEnsureACL(dconn, def) < 0)
@ -12712,7 +12712,7 @@ qemuDomainMigratePrepare2(virConnectPtr dconn,
goto cleanup; goto cleanup;
} }
if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname)))
goto cleanup; goto cleanup;
if (virDomainMigratePrepare2EnsureACL(dconn, def) < 0) if (virDomainMigratePrepare2EnsureACL(dconn, def) < 0)
@ -12951,7 +12951,7 @@ qemuDomainMigratePrepare3(virConnectPtr dconn,
QEMU_MIGRATION_DESTINATION))) QEMU_MIGRATION_DESTINATION)))
goto cleanup; goto cleanup;
if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname)))
goto cleanup; goto cleanup;
if (virDomainMigratePrepare3EnsureACL(dconn, def) < 0) if (virDomainMigratePrepare3EnsureACL(dconn, def) < 0)
@ -13038,7 +13038,7 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
goto cleanup; goto cleanup;
} }
if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname)))
goto cleanup; goto cleanup;
if (virDomainMigratePrepare3ParamsEnsureACL(dconn, def) < 0) if (virDomainMigratePrepare3ParamsEnsureACL(dconn, def) < 0)
@ -13092,7 +13092,7 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn,
QEMU_MIGRATION_DESTINATION))) QEMU_MIGRATION_DESTINATION)))
goto cleanup; goto cleanup;
if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname)))
goto cleanup; goto cleanup;
if (virDomainMigratePrepareTunnel3EnsureACL(dconn, def) < 0) if (virDomainMigratePrepareTunnel3EnsureACL(dconn, def) < 0)
@ -13151,7 +13151,7 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
QEMU_MIGRATION_DESTINATION))) QEMU_MIGRATION_DESTINATION)))
goto cleanup; goto cleanup;
if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname)))
goto cleanup; goto cleanup;
if (virDomainMigratePrepareTunnel3ParamsEnsureACL(dconn, def) < 0) if (virDomainMigratePrepareTunnel3ParamsEnsureACL(dconn, def) < 0)

View File

@ -2861,6 +2861,7 @@ qemuMigrationDstPrepareDirect(virQEMUDriverPtr driver,
virDomainDefPtr virDomainDefPtr
qemuMigrationAnyPrepareDef(virQEMUDriverPtr driver, qemuMigrationAnyPrepareDef(virQEMUDriverPtr driver,
virQEMUCapsPtr qemuCaps,
const char *dom_xml, const char *dom_xml,
const char *dname, const char *dname,
char **origname) char **origname)
@ -2878,7 +2879,8 @@ qemuMigrationAnyPrepareDef(virQEMUDriverPtr driver,
if (!(caps = virQEMUDriverGetCapabilities(driver, false))) if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
return NULL; 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_INACTIVE |
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE))) VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)))
goto cleanup; goto cleanup;
@ -3422,7 +3424,9 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
if (flags & VIR_MIGRATE_PERSIST_DEST) { if (flags & VIR_MIGRATE_PERSIST_DEST) {
if (persist_xml) { if (persist_xml) {
if (!(persistDef = qemuMigrationAnyPrepareDef(driver, persist_xml, if (!(persistDef = qemuMigrationAnyPrepareDef(driver,
priv->qemuCaps,
persist_xml,
NULL, NULL))) NULL, NULL)))
goto error; goto error;
} else { } else {

View File

@ -115,6 +115,7 @@ qemuMigrationSrcBegin(virConnectPtr conn,
virDomainDefPtr virDomainDefPtr
qemuMigrationAnyPrepareDef(virQEMUDriverPtr driver, qemuMigrationAnyPrepareDef(virQEMUDriverPtr driver,
virQEMUCapsPtr qemuCaps,
const char *dom_xml, const char *dom_xml,
const char *dname, const char *dname,
char **origname); char **origname);