From f5bfc6725c28833ee0e4cb202e33507cd24ac089 Mon Sep 17 00:00:00 2001 Message-Id: From: Jiri Denemark Date: Fri, 16 Aug 2019 14:52:34 +0200 Subject: [PATCH] qemu: Pass correct qemuCaps to virDomainDefPostParse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 virDomainDefPostParse. Signed-off-by: Jiri Denemark Reviewed-by: Michal Privoznik (cherry picked from commit c90fb5a828a68512095d80c190c0f491e385438e) Conflicts: src/qemu/qemu_driver.c - context https://bugzilla.redhat.com/show_bug.cgi?id=1731783 https://bugzilla.redhat.com/show_bug.cgi?id=1742023 Signed-off-by: Jiri Denemark Message-Id: <816c373facf7f779dc22d8a8e6e382cadf5cc2b7.1565959866.git.jdenemar@redhat.com> Reviewed-by: Ján Tomko --- src/qemu/qemu_driver.c | 17 ++++++++++------- src/qemu/qemu_process.c | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 82371b9a66..cc7210c6f4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7881,6 +7881,7 @@ static int qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev, virCapsPtr caps, + virQEMUCapsPtr qemuCaps, unsigned int parse_flags, virDomainXMLOptionPtr xmlopt) { @@ -8070,7 +8071,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, return -1; } - if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0) + if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, qemuCaps) < 0) return -1; return 0; @@ -8081,6 +8082,7 @@ static int qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev, virCapsPtr caps, + virQEMUCapsPtr qemuCaps, unsigned int parse_flags, virDomainXMLOptionPtr xmlopt) { @@ -8262,7 +8264,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, return -1; } - if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0) + if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, qemuCaps) < 0) return -1; return 0; @@ -8272,6 +8274,7 @@ static int qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev, virCapsPtr caps, + virQEMUCapsPtr qemuCaps, unsigned int parse_flags, virDomainXMLOptionPtr xmlopt) { @@ -8367,7 +8370,7 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef, return -1; } - if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0) + if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, qemuCaps) < 0) return -1; return 0; @@ -8426,7 +8429,7 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm, VIR_DOMAIN_DEVICE_ACTION_ATTACH, false) < 0) goto cleanup; - if ((ret = qemuDomainAttachDeviceConfig(vmdef, dev, caps, + if ((ret = qemuDomainAttachDeviceConfig(vmdef, dev, caps, priv->qemuCaps, parse_flags, driver->xmlopt)) < 0) goto cleanup; @@ -8585,7 +8588,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom, /* virDomainDefCompatibleDevice call is delayed until we know the * device we're going to update. */ - if ((ret = qemuDomainUpdateDeviceConfig(vmdef, dev, caps, + if ((ret = qemuDomainUpdateDeviceConfig(vmdef, dev, caps, priv->qemuCaps, parse_flags, driver->xmlopt)) < 0) goto endjob; @@ -8680,7 +8683,7 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr driver, if (!vmdef) goto cleanup; - if (qemuDomainDetachDeviceConfig(vmdef, dev, caps, + if (qemuDomainDetachDeviceConfig(vmdef, dev, caps, priv->qemuCaps, parse_flags, driver->xmlopt) < 0) goto cleanup; @@ -8766,7 +8769,7 @@ qemuDomainDetachDeviceAliasLiveAndConfig(virQEMUDriverPtr driver, if (virDomainDefFindDevice(vmdef, alias, &dev, true) < 0) goto cleanup; - if (qemuDomainDetachDeviceConfig(vmdef, &dev, caps, + if (qemuDomainDetachDeviceConfig(vmdef, &dev, caps, priv->qemuCaps, parse_flags, driver->xmlopt) < 0) goto cleanup; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 08e1d91fcc..307098cd63 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5350,7 +5350,7 @@ qemuProcessInit(virQEMUDriverPtr driver, if (vm->def->postParseFailed) { VIR_DEBUG("re-running the post parse callback"); - if (virDomainDefPostParse(vm->def, caps, 0, driver->xmlopt, NULL) < 0) + if (virDomainDefPostParse(vm->def, caps, 0, driver->xmlopt, priv->qemuCaps) < 0) goto cleanup; } -- 2.22.1