From nobody Mon Feb 9 00:10:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1734621471183163.13085059589957; Thu, 19 Dec 2024 07:17:51 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 0EAF115EB; Thu, 19 Dec 2024 10:17:49 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 91BB2162C; Thu, 19 Dec 2024 10:17:34 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 56CEB15EB; Thu, 19 Dec 2024 10:14:03 -0500 (EST) Received: from chinatelecom.cn (smtpnm6-07.21cn.com [182.42.151.156]) by lists.libvirt.org (Postfix) with ESMTP id 006F0157D for ; Thu, 19 Dec 2024 10:14:01 -0500 (EST) Received: from clientip-120.245.87.215 (unknown [192.168.138.117]) by chinatelecom.cn (HERMES) with SMTP id 922349F5CD; Thu, 19 Dec 2024 23:07:37 +0800 (CST) Received: from ([120.245.87.215]) by gateway-ssl-dep-84dfd8c7d7-bnxj5 with ESMTP id 537b55fdddb8498f88f6e48db3b6baa4 for devel@lists.libvirt.org; Thu, 19 Dec 2024 23:07:42 CST X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=FORGED_SPF_HELO, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.4 X-Greylist: delayed 370 seconds by postgrey-1.37 at lists.libvirt.org; Thu, 19 Dec 2024 10:14:01 EST HMM_SOURCE_IP: 192.168.138.117:0.1424913757 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP X-189-SAVE-TO-SEND: +tugy@chinatelecom.cn X-Transaction-ID: 537b55fdddb8498f88f6e48db3b6baa4 X-Real-From: tugy@chinatelecom.cn X-Receive-IP: 120.245.87.215 X-MEDUSA-Status: 0 Sender: tugy@chinatelecom.cn Message-ID: Date: Thu, 19 Dec 2024 23:07:35 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: devel@lists.libvirt.org From: Guoyi Tu Subject: [PATCH] nodedev: udev: Hook up virFileWaitForExist to address uevent, race of pci device Content-Transfer-Encoding: quoted-printable X-MailFrom: tugy@chinatelecom.cn X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0 Message-ID-Hash: ZL57ZZ4ZJQABQQWWSRNUYFB7QDTQYQ2K X-Message-ID-Hash: ZL57ZZ4ZJQABQQWWSRNUYFB7QDTQYQ2K X-Mailman-Approved-At: Thu, 19 Dec 2024 15:17:31 -0500 CC: tugy@chinatelecom.cn X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZM-MESSAGEID: 1734621474562116600 Content-Type: text/plain; charset="utf-8"; format="flowed" this commit addresses the same issue that as commit 1af45804 does. the following message is copying from that commit: If we find ourselves in the situation that the 'add' uevent has been fired earlier than the sysfs tree for a device was created, we should use the best-effort approach and give kernel some predetermined amount of time, thus waiting for the attributes to be ready rather than discarding the device from our device list forever. If those don't appear in the given time frame, we need to move on, since libvirt can't wait indefinitely. 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=20 b/src/node_device/node_device_udev.c index 1d8486f623..4a1786c21c 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 =3D NULL; virPCIDevice *pciDev =3D NULL; virPCIDeviceAddress devAddr =3D { 0 }; + g_autofree char *linkpath =3D NULL; int ret =3D -1; char *p; bool privileged =3D false; + linkpath =3D g_strdup_printf("%s/config",=20 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 =3D driver_state->privileged; } --=20 2.27.0 -- Guoyi