]> xenbits.xensource.com Git - libvirt.git/commitdiff
hostdev: Only rollback detach of managed devices on error
authorAndrea Bolognani <abologna@redhat.com>
Thu, 17 Dec 2015 14:11:27 +0000 (15:11 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 21 Dec 2015 10:22:45 +0000 (11:22 +0100)
Since we don't detach unmanaged devices before attaching them to a
domain, we shouldn't reattach them to rollback an error either.

src/util/virhostdev.c

index afacd4e9b9704519bfedff0f96b161a94ccd5ee7..c8da8e5afd9dffce5cb46c93e7202058230b31fe 100644 (file)
@@ -711,12 +711,14 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
     for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
         virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
 
-        /* NB: This doesn't actually re-bind to original driver, just
-         * unbinds from the stub driver
-         */
-        ignore_value(virPCIDeviceReattach(dev,
-                                          hostdev_mgr->activePCIHostdevs,
-                                          hostdev_mgr->inactivePCIHostdevs));
+        if (virPCIDeviceGetManaged(dev)) {
+            /* NB: This doesn't actually re-bind to original driver, just
+             * unbinds from the stub driver
+             */
+            ignore_value(virPCIDeviceReattach(dev,
+                                              hostdev_mgr->activePCIHostdevs,
+                                              hostdev_mgr->inactivePCIHostdevs));
+        }
     }
 
  cleanup: