On 9/22/22 3:59 AM, Erik Skultety wrote:
On Tue, Sep 20, 2022 at 02:23:23PM -0500, Jonathon Jongsma wrote:
> Rather than listening to 'add' udev events, listen for 'bind' events
> instead. When we get an 'add' event, the sysfs tree for the device is
> often not ready yet. In that case we sleep in a loop until the sysfs
> tree appears, or give up after a timeout.
>
> udev added the 'bind' event to give userspace a signal that indicated
> when driver-specific attributes were available to be used. In other
> words, the sysfs tree *should* be ready and usable at this point.
> But just to be safe, we'll leave the wait loop in the code to handle
> corner cases, with the hope that it'll never be used.
>
> The udev 'bind' event was added in kernel 4.14 and the oldest platform
> we support has kernel 4.18, so it should be safe to make this change.
>
> Previous discussion on the mailing list:
>
https://listman.redhat.com/archives/libvir-list/2022-August/233933.html
>
> Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
> ---
Unfortunately I don't have an mdev-configured machine at hand anymore to try
this out, but based on the trivial change and assuming you've at least tried
the patch, you can have my:
Reviewed-by: Erik Skultety <eskultet(a)redhat.com>
I have tried it with several devices including usb and mdev.
But I'm no longer sure whether this is a safe change. For example,
imagine I have a device configured to not load a driver (e.g. perhaps
something like `driverctl set-override $DEVICE none`). If this device is
hotplugged, we should get a udev 'add' event but no 'bind' event. So,
previously this driverless device would have showed up in `virsh
nodedev-list`, but after this change it will not.
Also note that this creates a difference between startup and hotplug. At
libvirt startup we enumerate all devices and add them to our nodedev
list. The enumerated devices will include devices both with bound
drivers and those without. But if we only listen to the 'bind' event,
hotplugged devices will need drivers bound to be added to the list. So
if you hotplug a driverless device, it will not show up in the nodedev
list until libvirt is restarted.
Note that the above description is based only on my analysis of the
code, not testing.
I'm inclined to withdraw this patch.
Jonathon