When modules.alias is not available (e.g. monolithic kernel),
virPCIDeviceFindBestVFIOVariant() would fail, causing the entire
 PCI device detach to abort.

Instead, log a warning and return success with no variant found,
allowing the caller to fall back to the generic vfio-pci driver.

Signed-off-by: Baptiste Daroussin <[email protected]>
Reviewed-by: Peter Krempa <[email protected]>
---
 src/util/virpci.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/util/virpci.c b/src/util/virpci.c
index d43fa1ef54..fa04264a95 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1459,6 +1459,12 @@ virPCIDeviceFindBestVFIOVariant(virPCIDevice *dev,
 
     uname(&unameInfo);
     modulesAliasPath = g_strdup_printf("/lib/modules/%s/modules.alias", 
unameInfo.release);
+    if (!virFileExists(modulesAliasPath)) {
+        /* on monolithic kernel this file does not exist */
+        VIR_DEBUG("modules.alias not available (%s), skipping VFIO variant 
detection",
+                 modulesAliasPath);
+        return 0;
+    }
     if (virFileReadAll(modulesAliasPath, 8 * 1024 * 1024, 
&modulesAliasContent) < 0)
         return -1;
 
-- 
2.43.0

Reply via email to