]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
nodedev: Only set up mdevctl monitors if mdevctl.d exist
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 12 Apr 2021 15:26:06 +0000 (17:26 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 13 Apr 2021 07:34:14 +0000 (09:34 +0200)
During its initialization, the nodedev driver tries to set up
monitors for /etc/mdevctl.d directory, so that it can register
mdevs as they come and go. However, if the file doesn't exist
there is nothing to monitor and therefore we can exit early. In
fact, we have to otherwise monitorFileRecursively() fails and
whole driver initialization fails with it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/node_device/node_device_udev.c

index 18219175c569f7e95d2395df63a3f2c60c161328..44f96f5ff991c073ba6e1374f4b619543653d25a 100644 (file)
@@ -2122,7 +2122,13 @@ monitorFileRecursively(udevEventData *udev,
 static int
 mdevctlEnableMonitor(udevEventData *priv)
 {
-    g_autoptr(GFile) mdevctlConfigDir = g_file_new_for_path("/etc/mdevctl.d");
+    g_autoptr(GFile) mdevctlConfigDir = NULL;
+    const char *mdevctlDir = "/etc/mdevctl.d";
+
+    if (!virFileExists(mdevctlDir))
+        return 0;
+
+    mdevctlConfigDir = g_file_new_for_path(mdevctlDir);
 
     /* mdevctl may add notification events in the future:
      * https://github.com/mdevctl/mdevctl/issues/27. For now, fall back to