]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
nodedev: udev: Hook up virFileWaitForExist to address uevent race of pci device
authorGuoyi Tu <tugy@chinatelecom.cn>
Thu, 19 Dec 2024 15:07:35 +0000 (23:07 +0800)
committerMartin Kletzander <mkletzan@redhat.com>
Thu, 6 Feb 2025 09:50:40 +0000 (10:50 +0100)
Similarly to commit 1af45804 we should be safer by waiting for the whole
sysfs tree is created for the device.

Signed-off-by: Guoyi Tu <tugy@chinatelecom.cn>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/node_device/node_device_udev.c

index 94e8626aee1706a97156c2476575146fafc2642d..7b4ff80f8fb49b1292f5a4c1d7d17fe4ffdc0cc2 100644 (file)
@@ -427,10 +427,19 @@ udevProcessPCI(virNodeDeviceDriverState *driver_state,
     virPCIEDeviceInfo *pci_express = NULL;
     virPCIDevice *pciDev = NULL;
     virPCIDeviceAddress devAddr = { 0 };
+    g_autofree char *linkpath = NULL;
     int ret = -1;
     char *p;
     bool privileged = false;
 
+    linkpath = g_strdup_printf("%s/config", udev_device_get_syspath(device));
+    if (virFileWaitForExists(linkpath, 10, 100) < 0) {
+        virReportSystemError(errno,
+                             _("failed to wait for file '%1$s' to appear"),
+                             linkpath);
+        goto cleanup;
+    }
+
     VIR_WITH_MUTEX_LOCK_GUARD(&driver_state->lock) {
         privileged = driver_state->privileged;
     }