Hi,
On 06/01/2011 02:32 PM, Gerd Hoffmann wrote:
On 05/31/11 11:35, Hans de Goede wrote:
So that we don't retry to open it every 2 seconds flooding stderr with
error messages.
The polling here is done intentionally, so the devices catched by the filter
show up in the guest automagically as soon as they are plugged in. Just zapping
the filter on failure isn't the right thing to do here.
Note I'm zapping the filter when we fail to open the device, not when it
is not present. This can happen for example when the qemu user does not
have rights on the usbfs device node.
It seems better to me to print the relevant error once, and then require
the user to redo the usb_add / device_add if necessary, then to flood
the monitor with repeating the same error every 2 seconds. Note that
something like a permission problem (which is the most likely case
for opening a device failing once we've found it) won't go away by
itself.
We could try to do something more clever than polling sysfs every two seconds
though, such using inotify to watch /sys/bus/usb/devices for new devices poping
up.
That would also result in trying to open the device ones, and if that
fails give up, I don't see the difference. Actually the user experience
would be worse, because the proper sequence in case of a permission
problem would go from:
usb_add
see error
fix permission
usb_add
to:
usb_add
see error
fix permission
usb_del
usb_add
Regards,
Hans