From 8a9249359691db57e708c2ac5a5e0c1a172efb97 Mon Sep 17 00:00:00 2001 From: Guoyi Tu Date: Thu, 19 Dec 2024 23:07:35 +0800 Subject: [PATCH] nodedev: udev: Hook up virFileWaitForExist to address uevent race of pci device 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 Reviewed-by: Martin Kletzander --- src/node_device/node_device_udev.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 94e8626aee..7b4ff80f8f 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -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; } -- 2.47.3