[PATCH] qemu: Prohibit reattaching node device if it is in use

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It doesn't make sense to reattach a device to host while it's
still in use, e.g, by a domain.
---
 src/qemu/qemu_driver.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 47e2380..c920bfd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -9244,6 +9244,7 @@ qemudNodeDeviceReAttach (virNodeDevicePtr dev)
 {
     struct qemud_driver *driver = dev->conn->privateData;
     pciDevice *pci;
+    pciDevice *other;
     unsigned domain, bus, slot, function;
     int ret = -1;
 
@@ -9254,6 +9255,20 @@ qemudNodeDeviceReAttach (virNodeDevicePtr dev)
     if (!pci)
         return -1;
 
+    other = pciDeviceListFind(driver->activePciHostdevs, pci);
+    if (other) {
+        const char *other_name = pciDeviceGetUsedBy(other);
+
+        if (other_name)
+            qemuReportError(VIR_ERR_OPERATION_INVALID,
+                            _("PCI device %s is still in use by domain %s"),
+                            pciDeviceGetName(pci), other_name);
+        else
+            qemuReportError(VIR_ERR_OPERATION_INVALID,
+                            _("PCI device %s is still in use"),
+                            pciDeviceGetName(pci));
+    }
+
     pciDeviceReAttachInit(pci);
 
     qemuDriverLock(driver);
-- 
1.7.7.3

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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]