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

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

 



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@xxxxxxxxxx>
---
 src/node_device/node_device_driver.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 2bb83c19f2..fab830c596 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");
+
 virNodeDeviceDriverStatePtr driver;
 
 virDrvOpenStatus
@@ -1605,6 +1608,13 @@ nodeDeviceUpdateMediatedDevices(void)
     virMdevctlForEachData data = { 0, };
     size_t i;
 
+    /* The code below assumes MDEVCTL to exist. Well, if it doesn't then exit
+     * early. */
+    if (!virFileExists(MDEVCTL)) {
+        VIR_DEBUG(MDEVCTL " does not exist. 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




[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