[libvirt PATCH 15/15] qemu: automatically bind to a vfio variant driver, if available

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

 



Rather than always binding to the vfio-pci driver, use
virPCIDeviceFindBestVFIOVariant() to see if the running kernel has a
VFIO variant driver available that is a better match for the device,
and if one is found, use that instead.

If a specific driver is named, that will still be used; this makes it
possible to force binding of vfio-pci if there is an issue with the
auto-selected variant driver.

Signed-off-by: Laine Stump <laine@xxxxxxxxxx>
---
 src/util/virpci.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/util/virpci.c b/src/util/virpci.c
index 70fcedc4a5..ff5349b70d 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1426,6 +1426,7 @@ static int
 virPCIDeviceBindToStub(virPCIDevice *dev)
 {
     g_autofree char *stubDriverPath = NULL;
+    g_autofree char *autodetectModuleName = NULL;
     g_autofree char *driverLink = NULL;
 
 
@@ -1436,6 +1437,20 @@ virPCIDeviceBindToStub(virPCIDevice *dev)
         return -1;
     }
 
+    if (dev->stubDriverType == VIR_PCI_STUB_DRIVER_VFIO
+        && !dev->stubDriverName) {
+        /*  automatically use a VFIO variant driver if available for
+         *  this device.
+         */
+
+        if (virPCIDeviceFindBestVFIOVariant(dev, &autodetectModuleName) < 0)
+            return -1;
+
+        g_free(dev->stubDriverName);
+        dev->stubDriverName = g_steal_pointer(&autodetectModuleName);
+    }
+
+    /* if a driver name hasn't been decided by now, use default for this type */
     if (!dev->stubDriverName) {
 
         const char *stubDriverName = NULL;
-- 
2.41.0




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

  Powered by Linux