[PATCH 3/3] reattach pci devices when qemuPrepareHostdevPCIDevices() failed

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

 



Reattach all pci devices that we detached when qemuPrepareHostdevPCIDevices()
failed.

---
 src/qemu/qemu_hostdev.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index 30db0e2..7f5ad51 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -127,11 +127,11 @@ int qemuPrepareHostdevPCIDevices(struct qemud_driver *driver,
     for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
         pciDevice *dev = pciDeviceListGet(pcidevs, i);
         if (!pciDeviceIsAssignable(dev, !driver->relaxedACS))
-            goto cleanup;
+            goto reattachdevs;
 
         if (pciDeviceGetManaged(dev) &&
             pciDettachDevice(dev, driver->activePciHostdevs) < 0)
-            goto cleanup;
+            goto reattachdevs;
     }
 
     /* Now that all the PCI hostdevs have be dettached, we can safely
@@ -139,7 +139,7 @@ int qemuPrepareHostdevPCIDevices(struct qemud_driver *driver,
     for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
         pciDevice *dev = pciDeviceListGet(pcidevs, i);
         if (pciResetDevice(dev, driver->activePciHostdevs, pcidevs) < 0)
-            goto cleanup;
+            goto reattachdevs;
     }
 
     /* Now mark all the devices as active */
@@ -169,6 +169,12 @@ inactivedevs:
         pciDeviceListSteal(driver->activePciHostdevs, dev);
     }
 
+reattachdevs:
+    for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
+        pciDevice *dev = pciDeviceListGet(pcidevs, i);
+        pciReAttachDevice(dev, driver->activePciHostdevs);
+    }
+
 cleanup:
     pciDeviceListFree(pcidevs);
     return ret;
-- 
1.7.1

--
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]