[Pkg-libvirt-maintainers] Bug#846173: Bug#846173: libvirt-daemon: Fails to locate existing usb device
Guido Günther
agx at sigxcpu.org
Tue Nov 29 07:14:03 UTC 2016
On Mon, Nov 28, 2016 at 10:56:33PM +0000, David Gilmour wrote:
>
> Package: libvirt-daemon
> Version: 2.4.0-1+b1
> Severity: important
>
> Dear Maintainer,
>
> I have a custom udev rule used to implement usb-hotplug support for the a guest, whose name is dgw.
>
> This is the contents of /etc/udev/rules.d/91-hotplug.rules:
> ---
> ACTION=="add", \
> SUBSYSTEM=="usb", \
> ENV{ID_VENDOR_ID}=="18ec", \
> ENV{ID_MODEL_ID}=="3399", \
> RUN+="/usr/bin/virsh attach-device dgw /home/david/udev/david-webcam-dgw.xml"
>
> ACTION=="remove", \
> SUBSYSTEM=="usb", \
> ENV{ID_VENDOR_ID}=="18ec", \
> ENV{ID_MODEL_ID}=="3399", \
> RUN+="/usr/bin/virsh detach-device dgw /home/david/udev/david-webcam-dgw.xml"
> ---
>
> This is the content of david-webcam-dgw.xml:
> ---
> <hostdev mode='subsystem' type='usb'>
> <source>
> <vendor id='0x18ec'/>
> <product id='0x3399'/>
> </source>
> </hostdev>
> ---
>
> The rule is correctly activated when the device is plugged in, but with udev logging set to debug level, the syslog trace is as follows:
>
> ---
> Nov 26 14:48:27 dgh systemd-udevd[8692]: Process 'mtp-probe
> /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3.1 1 67' succeeded.
> Nov 26 14:48:27 dgh systemd-udevd[8692]: RUN '/usr/bin/virsh attach-device dgw /home/david/udev/david-webcam-dgw.xml' /etc/udev/rules.d/91-dg-webcam-dgw-hotplug.rules:10
> Nov 26 14:48:27 dgh systemd-udevd[8692]: handling device node '/dev/bus/usb/001/067', devnum=c189:66, mode=0664, uid=0, gid=100 Nov 26 14:48:27 dgh systemd-udevd[8692]: set permissions /dev/bus/usb/001/067, 020664, uid=0, gid=100 Nov 26 14:48:27 dgh systemd-udevd[8692]:
> creating symlink '/dev/char/189:66' to '../bus/usb/001/067'
> Nov 26 14:48:27 dgh systemd-udevd[8692]: created db file '/run/udev/data/c189:66' for '/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3.1'
> Nov 26 14:48:27 dgh systemd-udevd[8694]: starting '/usr/bin/virsh attach-device dgw /home/david/udev/david-webcam-dgw.xml'
> Nov 26 14:48:27 dgh libvirtd[3841]: internal error: unable to execute QEMU command 'device_add':
> failed to find host usb device 1:67 Nov 26 14:48:27 dgh systemd-udevd[8692]: '/usr/bin/virsh attach- device dgw /home/david/udev/david-webcam-dgw.xml'(err) 'error: '
> Nov 26 14:48:27 dgh systemd-udevd[8692]: '/usr/bin/virsh attach-device dgw /home/david/udev/david-
> webcam-dgw.xml'(err) 'Failed to attach device from /home/david/udev/david-webcam-dgw.xml'
> Nov 26 14:48:27 dgh systemd-udevd[8692]: '/usr/bin/virsh attach-device dgw /home/david/udev/david-
> webcam-dgw.xml'(err) 'error: internal error: unable to execute QEMU command 'device_add': failed to find host usb device 1:67'
> Nov 26 14:48:27 dgh systemd-udevd[8692]: '/usr/bin/virsh attach-device dgw /home/david/udev/david-
> webcam-dgw.xml'(out) ''
> Nov 26 14:48:27 dgh systemd-udevd[8692]: Process '/usr/bin/virsh attach-device dgw /home/david/udev/david-webcam-dgw.xml' failed with exit code 1.
> ---
>
> As you can see, the error is that QEMU device_add fails, complaining it cannot find the usb device that was indeed created.
>
> Additional detail: The above log was generated after the addition of another rules file Thinking it might be a permission problem,I added another rules file 50-myusb.rules as follows:
> ---
> SUBSYSTEMS=="usb", GROUP="users", MODE="0666"
> ---
> but with or without this rules file the error reported is the same.
>
> Intrestingly, the commands
>
> virsh attach-devcice dgw /home/david/udev/david-webcam-dgw.xml
> and
> virsh detach-devcice dgw /home/david/udev/david-webcam-dgw.xml
>
> both work and successfully attach the device to the guest if the device is connected - but the udev script fails.
>
> USB hotplug on this host was working normally as recently as a couple of months ago; possibly a stretch update caused a regression. As of now, I am unable to make USB hotplug to guests work.
>
> Thanks so much for looking into this.
I won't have time to look into this, sorry. I suggest to:
* set libvirt debugging to debug
* check which monitor commands get issued to attach the device
Create a new script run from the udev rule that
* checks the necessary device nodes are actually there
* uses the above monitor commands via "virsh qemu-monitor-command"
if it still fails it's within qemu if not there's something broken in
libvirt.
Cheers,
-- Guido
More information about the Pkg-libvirt-maintainers
mailing list