]> xenbits.xensource.com Git - libvirt.git/commitdiff
hostdev: Use actual device when reattaching
authorAndrea Bolognani <abologna@redhat.com>
Fri, 18 Mar 2016 17:03:52 +0000 (18:03 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Wed, 23 Mar 2016 10:38:20 +0000 (11:38 +0100)
Instead of forcing the values for the unbind_from_stub, remove_slot
and reprobe properties, look up the actual device and use that when
calling virPCIDeviceReattach().

This ensures the device is restored to its original state after
reattach: for example, if it was not bound to any driver before
detach, it will not be bound forcefully during reattach.

src/util/virhostdev.c

index 933c94263c58a5653196524a7833ed11c8e7c580..b397b7917555e51035cdf46b3447716bc8a47ef6 100644 (file)
@@ -1658,6 +1658,7 @@ virHostdevPCINodeDeviceReAttach(virHostdevManagerPtr mgr,
                                 virPCIDevicePtr pci)
 {
     struct virHostdevIsPCINodeDeviceUsedData data = { mgr, NULL, false };
+    virPCIDevicePtr actual;
     int ret = -1;
 
     virObjectLock(mgr->activePCIHostdevs);
@@ -1666,11 +1667,12 @@ virHostdevPCINodeDeviceReAttach(virHostdevManagerPtr mgr,
     if (virHostdevIsPCINodeDeviceUsed(virPCIDeviceGetAddress(pci), &data))
         goto cleanup;
 
-    virPCIDeviceSetUnbindFromStub(pci, true);
-    virPCIDeviceSetRemoveSlot(pci, true);
-    virPCIDeviceSetReprobe(pci, true);
+    /* 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;
 
-    if (virPCIDeviceReattach(pci, mgr->activePCIHostdevs,
+    if (virPCIDeviceReattach(actual, mgr->activePCIHostdevs,
                              mgr->inactivePCIHostdevs) < 0)
         goto cleanup;