]> xenbits.xensource.com Git - libvirt.git/commitdiff
reattach pci devices when qemuPrepareHostdevPCIDevices() failed
authorWen Congyang <wency@cn.fujitsu.com>
Mon, 28 Mar 2011 07:01:19 +0000 (15:01 +0800)
committerWen Congyang <wency@cn.fujitsu.com>
Thu, 7 Apr 2011 05:09:46 +0000 (13:09 +0800)
Reattach all pci devices that we detached when qemuPrepareHostdevPCIDevices()
failed.

src/qemu/qemu_hostdev.c

index 30db0e2dd0ea8974b9412e3a4aea480b63c48002..7f5ad516ed1c45327f055d907afe3000a26b39f4 100644 (file)
@@ -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;