From 8674faaf32be89f8b8ae9371d643d08fe810050b Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Tue, 13 Apr 2021 11:50:11 +0200 Subject: [PATCH] nodedev: Don't fail device enumeration if MDEVCTL is missing 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 Reviewed-by: Erik Skultety --- 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.47.2