render / rpms / libvirt

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