[PATCH v2 3/3] nodedev: Don't fail device enumeration if MDEVCTL is missing

Michal Privoznik mprivozn at redhat.com
Tue Apr 13 15:57:15 UTC 2021


After all devices were enumerated, the enumeration thread call
nodeDeviceUpdateMediatedDevices() to refresh the state of
mediated devices. This means that 'mdevctl' will be executed. But
it may be missing on some systems (e.g. mine) in which case we
should just skip the update of mdevs instead of failing whole
device enumeration.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/node_device/node_device_driver.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 7aee8201e8..180d9da529 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -42,9 +42,12 @@
 #include "virnetdev.h"
 #include "virutil.h"
 #include "vircommand.h"
+#include "virlog.h"
 
 #define VIR_FROM_THIS VIR_FROM_NODEDEV
 
+VIR_LOG_INIT("node_device.node_device_driver");
+
 virNodeDeviceDriverState *driver;
 
 virDrvOpenStatus
@@ -1604,9 +1607,15 @@ nodeDeviceUpdateMediatedDevices(void)
 {
     g_autofree virNodeDeviceDef **defs = NULL;
     g_autofree char *errmsg = NULL;
+    g_autofree char *mdevctl = NULL;
     virMdevctlForEachData data = { 0, };
     size_t i;
 
+    if (!(mdevctl = virFindFileInPath(MDEVCTL))) {
+        VIR_DEBUG(MDEVCTL " not found. Skipping update of mediated devices.");
+        return 0;
+    }
+
     if ((data.ndefs = virMdevctlListDefined(&defs, &errmsg)) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("failed to query mdevs from mdevctl: %s"), errmsg);
-- 
2.26.3




More information about the libvir-list mailing list