[PATCH 4/6] hostdev: Mark PCI devices as inactive as they're detached

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

 



We want to eventually factor out the code dealing with device detaching
and reattaching, so that we can share it and make sure it's called eg.
when 'virsh nodedev-detach' is used.

For that to happen, it's important that the lists of active and inactive
PCI devices are updated every time a device changes its state.

Instead of passing NULL as the last argument of virPCIDeviceDetach() and
virPCIDeviceReattach(), pass the proper list so that it can be updated.
---
 src/util/virhostdev.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index f9072a4..afacd4e 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -595,11 +595,17 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
     /* Loop 2: detach managed devices (i.e. bind to appropriate stub driver) */
     for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
         virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
+
         if (virPCIDeviceGetManaged(dev) &&
-            virPCIDeviceDetach(dev, hostdev_mgr->activePCIHostdevs, NULL) < 0)
-            goto reattachdevs;
+            virPCIDeviceDetach(dev,
+                               hostdev_mgr->activePCIHostdevs,
+                               hostdev_mgr->inactivePCIHostdevs) < 0)
+                goto reattachdevs;
     }
 
+    /* At this point, all devices are attached to the stub driver and have
+     * been marked as inactive */
+
     /* Loop 3: Now that all the PCI hostdevs have been detached, we
      * can safely reset them */
     for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
@@ -708,8 +714,9 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
         /* NB: This doesn't actually re-bind to original driver, just
          * unbinds from the stub driver
          */
-        ignore_value(virPCIDeviceReattach(dev, hostdev_mgr->activePCIHostdevs,
-                                          NULL));
+        ignore_value(virPCIDeviceReattach(dev,
+                                          hostdev_mgr->activePCIHostdevs,
+                                          hostdev_mgr->inactivePCIHostdevs));
     }
 
  cleanup:
-- 
2.5.0

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