Blame SOURCES/libvirt-qemu_hotplug-don-t-call-DetachThisHostDevice-for-hostdev-network-devices.patch

0a7476
From 34239068029f426da9861224d0140bb50da5f56f Mon Sep 17 00:00:00 2001
0a7476
Message-Id: <34239068029f426da9861224d0140bb50da5f56f@dist-git>
0a7476
From: Laine Stump <laine@laine.org>
0a7476
Date: Thu, 11 Apr 2019 15:14:35 -0400
0a7476
Subject: [PATCH] qemu_hotplug: don't call DetachThisHostDevice for hostdev
0a7476
 network devices
0a7476
0a7476
Back in the bad old days different device types required a different
0a7476
qemu monitor call to detach them, and so an <interface type='hostdev'>
0a7476
needed to call the function for detaching hostdevs, while other
0a7476
<interface> types could be deleted as netdevs.
0a7476
0a7476
Times have changed, and *all* device types are detached by calling the
0a7476
common function qemuDomainDeleteDevice(vm, alias), so we don't need to
0a7476
differentiate between hostdev interfaces and the others for that
0a7476
reason.
0a7476
0a7476
There are a few other netdev-specific functions called during
0a7476
qemuDomainDetachNetDevice() (clearing bandwidth limits, stopping the
0a7476
interface), but those turn into NOPs when type=hostdev, so they're
0a7476
safe to call for type=hostdev.
0a7476
0a7476
The only thing that is different + not a NOP is the call to
0a7476
virDomainAudit*() when qemuDomainDeleteDevice() fails, so if we add a
0a7476
conditional for that small bit of code, we can eliminate the callout
0a7476
from qemuDomainDetachNetDevice() to qemuDomainDetachThisDevice(),
0a7476
which makes this function fit the desired pattern for merging with the
0a7476
other detach functions, and paves the way to simplifying
0a7476
qemuDomainDetachHostDevice() too.
0a7476
0a7476
Signed-off-by: Laine Stump <laine@laine.org>
0a7476
ACKed-by: Peter Krempa <pkrempa@redhat.com>
0a7476
(cherry picked from commit 48a2668151c9ba3f4c94c0a4c0412a5140885ad4)
0a7476
0a7476
Partially-Resolves: https://bugzilla.redhat.com/1658198
0a7476
Signed-off-by: Laine Stump <laine@redhat.com>
0a7476
Signed-off-by: Laine Stump <laine@laine.org>
0a7476
Message-Id: <20190411191453.24055-24-laine@redhat.com>
0a7476
Acked-by: Michal Privoznik <mprivozn@redhat.com>
0a7476
---
0a7476
 src/qemu/qemu_hotplug.c | 16 +++++++---------
0a7476
 1 file changed, 7 insertions(+), 9 deletions(-)
0a7476
0a7476
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
0a7476
index 18c98c59ec..ac395b9177 100644
0a7476
--- a/src/qemu/qemu_hotplug.c
0a7476
+++ b/src/qemu/qemu_hotplug.c
0a7476
@@ -5246,13 +5246,6 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
0a7476
 
0a7476
     detach = vm->def->nets[detachidx];
0a7476
 
0a7476
-    if (virDomainNetGetActualType(detach) == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
0a7476
-        ret = qemuDomainDetachThisHostDevice(driver, vm,
0a7476
-                                             virDomainNetGetActualHostdev(detach),
0a7476
-                                             async);
0a7476
-        goto cleanup;
0a7476
-    }
0a7476
-
0a7476
     if (qemuIsMultiFunctionDevice(vm->def, &detach->info)) {
0a7476
         virReportError(VIR_ERR_OPERATION_FAILED,
0a7476
                        _("cannot hot unplug multifunction PCI device: %s"),
0a7476
@@ -5281,8 +5274,13 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
0a7476
         qemuDomainMarkDeviceForRemoval(vm, &detach->info);
0a7476
 
0a7476
     if (qemuDomainDeleteDevice(vm, detach->info.alias) < 0) {
0a7476
-        if (virDomainObjIsActive(vm))
0a7476
-            virDomainAuditNet(vm, detach, NULL, "detach", false);
0a7476
+        if (virDomainObjIsActive(vm)) {
0a7476
+            /* the audit message has a different format for hostdev network devices */
0a7476
+            if (virDomainNetGetActualType(detach) == VIR_DOMAIN_NET_TYPE_HOSTDEV)
0a7476
+                virDomainAuditHostdev(vm, virDomainNetGetActualHostdev(detach), "detach", false);
0a7476
+            else
0a7476
+                virDomainAuditNet(vm, detach, NULL, "detach", false);
0a7476
+        }
0a7476
         goto cleanup;
0a7476
     }
0a7476
 
0a7476
-- 
0a7476
2.21.0
0a7476