The reprobe needs to be called multiple times for vfio devices for each
device in the iommu group in future patch. So split the reprobe into a
new function. No functional change.
Signed-off-by: Shivaprasad G Bhat <sbhat(a)linux.vnet.ibm.com>
---
src/util/virpci.c | 44 ++++++++++++++++++++++++++++----------------
1 file changed, 28 insertions(+), 16 deletions(-)
diff --git a/src/util/virpci.c b/src/util/virpci.c
index f401e1d..77ae455 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1098,6 +1098,33 @@ virPCIIsAKnownStub(char *driver)
return ret;
}
+static int virPCIDeviceReprobeHostDriver(virPCIDevicePtr dev, char *driver, char
*drvdir)
+{
+ char *path = NULL;
+ int result = -1;
+
+ /* 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
+ * re-bound to the stub.
+ */
+ if (driver && !(path = virPCIDriverFile(driver, "remove_id")))
+ goto cleanup;
+
+ if (!driver || !virFileExists(drvdir) || virFileExists(path)) {
+ if (virFileWriteStr(PCI_SYSFS "drivers_probe", dev->name, 0) < 0)
{
+ virReportSystemError(errno,
+ _("Failed to trigger a re-probe for PCI device
'%s'"),
+ dev->name);
+ goto cleanup;
+ }
+ }
+ result = 0;
+ cleanup:
+ VIR_FREE(path);
+ return result;
+}
+
static int
virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
{
@@ -1150,24 +1177,9 @@ virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
goto cleanup;
}
- /* 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
- * re-bound to the stub.
- */
- VIR_FREE(path);
- if (driver && !(path = virPCIDriverFile(driver, "remove_id")))
+ if (virPCIDeviceReprobeHostDriver(dev, driver, drvdir) < 0)
goto cleanup;
- if (!driver || !virFileExists(drvdir) || virFileExists(path)) {
- if (virFileWriteStr(PCI_SYSFS "drivers_probe", dev->name, 0) < 0)
{
- virReportSystemError(errno,
- _("Failed to trigger a re-probe for PCI device
'%s'"),
- dev->name);
- goto cleanup;
- }
- }
-
result = 0;
cleanup: