From: Guoyi Tu Date: Thu, 19 Dec 2024 15:07:35 +0000 (+0800) Subject: nodedev: udev: Hook up virFileWaitForExist to address uevent race of pci device X-Git-Tag: v11.1.0-rc1~98 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8a9249359691db57e708c2ac5a5e0c1a172efb97;p=thirdparty%2Flibvirt.git 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 --- 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; }