This is the qemu fix: commit 9f815e83e983d247a3cd67579d2d9c1765adc644 Author: Gerd Hoffmann <kraxel> Date: Fri Jun 5 14:59:52 2020 +0200 usb: add hostdevice property to usb-host The new property allows to specify usb host device name. Uses standard qemu_open(), so both file system path (/dev/bus/usb/$bus/$dev on linux) and file descriptor passing can be used. Requires libusb 1.0.23 or newer. The hostdevice property is only present in case qemu is compiled against a new enough library version, so the presence of the property can be used for feature detection. Signed-off-by: Gerd Hoffmann <kraxel> Message-Id: <20200605125952.13113-1-kraxel> libvirt should use usb-host.hostdevice + filedescriptor passing if available.
I've posted patches upstream: https://www.redhat.com/archives/libvir-list/2020-September/msg00772.html Note, they don't implement FD passing but they use usb-host.hostdevice attribute. This is enough to fix the bug beacuse libvirt does mknod() /dev/bus/usb/... nodes in the namespace. I'm working on the FD passing though and probably post it as a separate patch set.
Merged upstream as: bfb1ab1df1 qemu: Use .hostdevice attribute for usb-host 66c5674e79 qemu_capabilities: Add QEMU_CAPS_USB_HOST_HOSTDEVICE v6.8.0-21-gbfb1ab1df1
verify the bug with libvirt-7.0.0-3.el8.x86_64 and qemu-kvm-5.2.0-4.module+el8.4.0+9676+589043b9.x86_64 1. Prepare a host with usb device and a running VM # lsusb Bus 001 Device 002: ID 2a4b:0400 # virsh list Id Name State ---------------------- 1 juan running 2. Attach/detach a non-existed 'optional' host usb [root@lenovo-sr630-06 opt]# cat non-usb.xml <hostdev mode='subsystem' type='usb' managed='yes'> <source startupPolicy='optional'> <vendor id='0x2a4b'/> <product id='0x0401'/> </source> </hostdev> [root@lenovo-sr630-06 opt]# virsh attach-device juan non-usb.xml Device attached successfully [root@lenovo-sr630-06 opt]# virsh detach-device juan non-usb.xml Device detached successfully 3.attach/detach the existed host usb [root@lenovo-sr630-06 opt]# cat usb.xml <hostdev mode='subsystem' type='usb' managed='yes'> <source> <vendor id='0x2a4b'/> <product id='0x0400'/> </source> </hostdev> [root@lenovo-sr630-06 opt]# virsh attach-device juan usb.xml Device attached successfully in the guest: [root@localhost ~]# lsusb Bus 001 Device 019: ID 2a4b:0400 [root@lenovo-sr630-06 opt]# virsh detach-device juan usb.xml Device detached successfully In the guest, there is not the usb device.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (virt:av bug fix and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2021:2098