]> xenbits.xensource.com Git - libvirt.git/commitdiff
Revert "hostdev: Use actual device when reattaching"
authorAndrea Bolognani <abologna@redhat.com>
Fri, 1 Apr 2016 12:51:29 +0000 (14:51 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Fri, 1 Apr 2016 15:06:53 +0000 (17:06 +0200)
This reverts commit ee4cfb56436b50345b072c706b87aff82e06d760.

Since we're still not persisting our bookkeeping lists across
daemon restarts, we might have lost some information
virPCIDeviceReattach() relies on, for example whether the
device needs to be unbound from the stub driver.

As a result, if the daemon has been restarted in the meantime,
the device might end up remaining bound to the stub driver even
after 'virsh nodedev-reattach' or similar has been called, with
no way of giving it back to the host short of messing with
sysfs behind libvirt's back.

Revert back to the previous behavior of always trying to bind
the device to the host driver, regardless of its status when it
was detached, until persistent bookkeeping lists have been
implemented.

src/util/virhostdev.c

index b397b7917555e51035cdf46b3447716bc8a47ef6..933c94263c58a5653196524a7833ed11c8e7c580 100644 (file)
@@ -1658,7 +1658,6 @@ virHostdevPCINodeDeviceReAttach(virHostdevManagerPtr mgr,
                                 virPCIDevicePtr pci)
 {
     struct virHostdevIsPCINodeDeviceUsedData data = { mgr, NULL, false };
-    virPCIDevicePtr actual;
     int ret = -1;
 
     virObjectLock(mgr->activePCIHostdevs);
@@ -1667,12 +1666,11 @@ virHostdevPCINodeDeviceReAttach(virHostdevManagerPtr mgr,
     if (virHostdevIsPCINodeDeviceUsed(virPCIDeviceGetAddress(pci), &data))
         goto cleanup;
 
-    /* We need to look up the actual device because that's what
-     * virPCIDeviceReattach() expects as its argument */
-    if (!(actual = virPCIDeviceListFind(mgr->inactivePCIHostdevs, pci)))
-        goto cleanup;
+    virPCIDeviceSetUnbindFromStub(pci, true);
+    virPCIDeviceSetRemoveSlot(pci, true);
+    virPCIDeviceSetReprobe(pci, true);
 
-    if (virPCIDeviceReattach(actual, mgr->activePCIHostdevs,
+    if (virPCIDeviceReattach(pci, mgr->activePCIHostdevs,
                              mgr->inactivePCIHostdevs) < 0)
         goto cleanup;