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 | 54 +++++++++++++++++++++++++++++++----------------------
1 file changed, 32 insertions(+), 22 deletions(-)
diff --git a/src/util/virpci.c b/src/util/virpci.c
index eba285a..2709ddd 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1097,6 +1097,37 @@ static bool virPCIIsAKnownStub(char *driver)
return ret;
}
+static int virPCIDeviceReprobeHostDriver(virPCIDevicePtr dev, char *driver, char
*drvdir)
+{
+ char *path = NULL;
+ int result = -1;
+
+ if (!dev->reprobe)
+ return 0;
+
+ /* 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);
+ dev->reprobe = false;
+ return result;
+}
+
static int
virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
{
@@ -1144,28 +1175,8 @@ virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
dev->remove_slot = false;
reprobe:
- if (!dev->reprobe) {
- result = 0;
+ if (virPCIDeviceReprobeHostDriver(dev, driver, drvdir) < 0)
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")))
- 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;
@@ -1173,7 +1184,6 @@ virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
/* do not do it again */
dev->unbind_from_stub = false;
dev->remove_slot = false;
- dev->reprobe = false;
VIR_FREE(drvdir);
VIR_FREE(path);