[libvirt] [PATCH v2 9/9] pci: Add debug messages when unbinding from stub driver

Andrea Bolognani abologna at redhat.com
Mon Jan 25 16:21:04 UTC 2016


Unbinding a PCI device from the stub driver can require several steps,
and it can be useful for debugging to be able to trace which of these
steps are performed and which are skipped for each device.
---
 src/util/virpci.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/util/virpci.c b/src/util/virpci.c
index f56dbe6..51a3f88 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1106,26 +1106,37 @@ virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
 
     if (!driver) {
         /* The device is not bound to any driver and we are almost done. */
+        VIR_DEBUG("PCI device %s is not bound to any driver", dev->name);
         goto reprobe;
     }
 
-    if (!dev->unbind_from_stub)
+    if (!dev->unbind_from_stub) {
+        VIR_DEBUG("Unbind from stub skipped for PCI device %s", dev->name);
         goto remove_slot;
+    }
 
     /* If the device isn't bound to a known stub, skip the unbind. */
     if (virPCIStubDriverTypeFromString(driver) < 0 ||
-        virPCIStubDriverTypeFromString(driver) == VIR_PCI_STUB_DRIVER_NONE)
+        virPCIStubDriverTypeFromString(driver) == VIR_PCI_STUB_DRIVER_NONE) {
+        VIR_DEBUG("Unbind from stub skipped for PCI device %s because of "
+                  "unknown stub driver", dev->name);
         goto remove_slot;
+    }
 
-    VIR_DEBUG("Found stub driver %s", driver);
+    VIR_DEBUG("Found stub driver %s for PCI device %s", driver, dev->name);
+    VIR_DEBUG("Unbinding PCI device %s", dev->name);
 
     if (virPCIDeviceUnbind(dev) < 0)
         goto cleanup;
     dev->unbind_from_stub = false;
 
  remove_slot:
-    if (!dev->remove_slot)
+    if (!dev->remove_slot) {
+        VIR_DEBUG("Slot removal skipped for PCI device %s", dev->name);
         goto reprobe;
+    }
+
+    VIR_DEBUG("Removing slot for PCI device %s", dev->name);
 
     /* Xen's pciback.ko wants you to use remove_slot on the specific device */
     if (!(path = virPCIDriverFile(driver, "remove_slot")))
@@ -1141,10 +1152,13 @@ virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
 
  reprobe:
     if (!dev->reprobe) {
+        VIR_DEBUG("Reprobe skipped for PCI device %s", dev->name);
         result = 0;
         goto cleanup;
     }
 
+    VIR_DEBUG("Reprobing for PCI device %s", dev->name);
+
     /* Trigger a re-probe of the device is not in the stub's dynamic
      * ID table. If the stub is available, but 'remove_id' isn't
      * available, then re-probing would just cause the device to be
-- 
2.5.0




More information about the libvir-list mailing list