[libvirt PATCH] nodedev: wait a bit longer for new node devices

Jonathon Jongsma jjongsma at redhat.com
Tue Aug 23 17:43:03 UTC 2022


Openstack developers reported that newly-created mdevs were not
recognized by libvirt until after a libvirt daemon restart. The source
of the problem appears to be that when libvirt gets the udev 'add'
event, the sysfs tree for that device might not be ready and so libvirt
waits 100ms for it to appear (max 100 waits of 1ms each). But in the
OpenStack environment, the sysfs tree for new mediated devices was
taking closer to 250ms to appear and therefore libvirt gave up waiting
and didn't add these new devices to its list of nodedevs.

By changing the wait time to 1 second (max 100 waits of 10ms each), this
should provide enough time to enable these deployments to recognize
newly-created mediated devices, but it shouldn't increase the delay for
more traditional deployments too much.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2109450

Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
---

Alternatively, we could switch to triggering off of the udev 'bind' event
rather than the 'add' event, but I wasn't able to convince myself that this
would result in 100% compatible behavior, so this felt like the safest
solution. If others can convince me that switching to 'bind' is safe, I can
re-submit this patch.


 src/node_device/node_device_udev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index e76c1a36b8..a06eaade5d 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1058,7 +1058,7 @@ udevProcessMediatedDevice(struct udev_device *dev,
 
     linkpath = g_strdup_printf("%s/mdev_type", udev_device_get_syspath(dev));
 
-    if (virFileWaitForExists(linkpath, 1, 100) < 0) {
+    if (virFileWaitForExists(linkpath, 10, 100) < 0) {
         virReportSystemError(errno,
                              _("failed to wait for file '%s' to appear"),
                              linkpath);
-- 
2.37.1



More information about the libvir-list mailing list