Make sure to *not* call qemuDomainPCIAddressReleaseAddr if
QEMUD_CMD_FLAG_DEVICE is *not* set (for older qemu).  This
prevents a crash when trying to do device detachment from
a qemu guest.

Signed-off-by: Chris Lalancette <clala...@redhat.com>
---
 src/qemu/qemu_driver.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 66e9f52..93072a4 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8522,9 +8522,9 @@ static int qemudDomainDetachPciControllerDevice(struct 
qemud_driver *driver,
         vm->def->ncontrollers = 0;
     }
 
-    if (qemuDomainPCIAddressReleaseAddr(priv->pciaddrs, &detach->info) < 0) {
+    if ((qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) &&
+        qemuDomainPCIAddressReleaseAddr(priv->pciaddrs, &detach->info) < 0)
         VIR_WARN0("Unable to release PCI address on controller");
-    }
 
     virDomainControllerDefFree(detach);
 
@@ -8730,9 +8730,9 @@ static int qemudDomainDetachHostPciDevice(struct 
qemud_driver *driver,
         pciFreeDevice(pci);
     }
 
-    if (qemuDomainPCIAddressReleaseAddr(priv->pciaddrs, &detach->info) < 0) {
+    if ((qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) &&
+        qemuDomainPCIAddressReleaseAddr(priv->pciaddrs, &detach->info) < 0)
         VIR_WARN0("Unable to release PCI address on controller");
-    }
 
     if (vm->def->nhostdevs > 1) {
         memmove(vm->def->hostdevs + i,
-- 
1.6.6.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to