[libvirt] [PATCH 02/10] pci: Remove 'reprobe' parameter from virPCIDeviceUnbind()

Andrea Bolognani abologna at redhat.com
Wed Dec 2 17:17:49 UTC 2015


The value is not inspected inside the function, so it makes more
sense for the caller to change the device's setting explicitly.
---
 src/util/virpci.c  | 10 ++++++----
 src/util/virpci.h  |  2 +-
 tests/virpcitest.c |  2 +-
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/util/virpci.c b/src/util/virpci.c
index f57070d..8094735 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1036,7 +1036,7 @@ virPCIProbeStubDriver(const char *driver)
 }
 
 int
-virPCIDeviceUnbind(virPCIDevicePtr dev, bool reprobe)
+virPCIDeviceUnbind(virPCIDevicePtr dev)
 {
     char *path = NULL;
     char *drvpath = NULL;
@@ -1062,7 +1062,6 @@ virPCIDeviceUnbind(virPCIDevicePtr dev, bool reprobe)
                                  dev->name, driver);
             goto cleanup;
         }
-        dev->reprobe = reprobe;
     }
 
     ret = 0;
@@ -1115,7 +1114,7 @@ virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
     if (!isStub)
         goto remove_slot;
 
-    if (virPCIDeviceUnbind(dev, dev->reprobe) < 0)
+    if (virPCIDeviceUnbind(dev) < 0)
         goto cleanup;
     dev->unbind_from_stub = false;
 
@@ -1229,9 +1228,12 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev)
         goto remove_id;
     }
 
-    if (virPCIDeviceUnbind(dev, reprobe) < 0)
+    if (virPCIDeviceUnbind(dev) < 0)
         goto remove_id;
 
+    /* If the device was bound to a driver we'll need to reprobe later */
+    dev->reprobe = reprobe;
+
     /* If the device isn't already bound to pci-stub, try binding it now.
      */
     if (!virFileLinkPointsTo(driverLink, stubDriverPath)) {
diff --git a/src/util/virpci.h b/src/util/virpci.h
index 6516f05..d9911d0 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -201,7 +201,7 @@ int virPCIDeviceAddressParse(char *address, virPCIDeviceAddressPtr bdf);
 int virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path,
                                  char **pfname, int *vf_index);
 
-int virPCIDeviceUnbind(virPCIDevicePtr dev, bool reprobe);
+int virPCIDeviceUnbind(virPCIDevicePtr dev);
 int virPCIDeviceGetDriverPathAndName(virPCIDevicePtr dev,
                                      char **path,
                                      char **name);
diff --git a/tests/virpcitest.c b/tests/virpcitest.c
index d4d3253..35b4781 100644
--- a/tests/virpcitest.c
+++ b/tests/virpcitest.c
@@ -341,7 +341,7 @@ testVirPCIDeviceUnbind(const void *opaque)
     if (!dev)
         goto cleanup;
 
-    if (virPCIDeviceUnbind(dev, false) < 0)
+    if (virPCIDeviceUnbind(dev) < 0)
         goto cleanup;
 
     ret = 0;
-- 
2.5.0




More information about the libvir-list mailing list