Hide Forgot
Description of problem: usb redirection using spice-usbredir-redirect-on-connect option doesn't take effect Version-Release number of selected component (if applicable): 4.18.0-234.el8.x86_64 qemu-kvm-5.1.0-4.module+el8.3.0+7846+ae9b566f.x86_64 libusbx-1.0.23-4.el8.x86_64 virt-viewer-9.0-3.el8.x86_64 How reproducible: 100% Steps to Reproduce: 1.Boot VM with usb-redir device: /usr/libexec/qemu-kvm \ ... -device qemu-xhci,id=usbtest,bus=pcie-root-port-1,addr=0x0 \ -device usb-tablet,id=usb-tablet1,bus=usbtest.0,port=1 \ -chardev spicevmc,name=usbredir,id=usbredirchar \ -device usb-redir,id=usbredir,chardev=usbredirchar,bus=usbtest.0,port=2 \ -spice port=5900,disable-ticketing \ ... 2.Start remote-viewer with spice-usbredir-redirect-on-connect option on CLient: # lsusb Bus 002 Device 002: ID 0951:1666 Kingston Technology DataTraveler 100 G3/G4/SE9 G2 Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 002: ID 03f0:094a HP, Inc Optical Mouse [672662-001] Bus 001 Device 006: ID 1604:10c0 Tascam Bus 001 Device 005: ID 1604:10c0 Tascam Bus 001 Device 004: ID 1604:10c0 Tascam Bus 001 Device 003: ID 03f0:0d4a HP, Inc SK-2025 Keyboard Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub # remote-viewer spice://IP:5900 --spice-usbredir-redirect-on-connect='-1,0x0951,0x1666,-1,1' 3.Check usb device in guest: # lsusb Actual results: Cannot find the redirected usb device in guest. Expected results: spice-usbredir-redirect-on-connect option should take effect. Additional info: 1. This is also reproducible with qemu-kvm-4.2.0-33.module+el8.3.0+7705+f09d73e4.x86_64. 2. This is not reproducible on a RHEL 8.2 host: 4.18.0-193.el8.x86_64 qemu-kvm-4.2.0-29.module+el8.2.1+7712+3c3fe332.2.x86_64 libusbx-1.0.22-1.el8.x86_64 virt-viewer-7.0-9.el8.x86_64
Created attachment 1715667 [details] tcpdump trace
Something is fishy on the virt-viewer side. Open the trace (comment #2) in wireshark, filter for spice packets. There are two usbredir streams (right-click on a packet -> colorize conversation -> tcp -> pick some color will highlight the streams). Initial handshake happens. Then two PING messages, followed by two PONG responses. Then silence on the usbredir streams, even though virt-viewer should send a "usb device connect" message at this point. On the display stream one can see the boot display updates. Reassigning to virt-viewer for investigation.
It looks like the client is not redirecting the device. Maybe is was locked by the kernel? Can you enable and post client logs? Can you also post kernel logs?
I can reproduce bug issue with packages: libvirt-6.6.0-5.module+el8.3.0+8092+f9e72d7e.x86_64 qemu-kvm-5.1.0-6.module+el8.3.0+8041+42ff16b8.x86_64 virt-viewer-9.0-4.el8.x86_64 spice-gtk3-0.38-3.el8.x86_64 libusbx-1.0.23-4.el8.x86_64 Steps: 1. Plug usb device to your host, then use # lsusb -vvv to find the information of your usb device. # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 238.5G 0 disk ... sdb 8:16 1 28.9G 0 disk ├─sdb1 8:17 1 4.2G 0 part /run/media/juzhou/RHEL-7.8 Server.x86_6 └─sdb2 8:18 1 8.6M 0 part Note: sdb is an usb device. # lsusb Bus 002 Device 002: ID 0951:1666 Kingston Technology DataTraveler 100 G3/G4/SE9 G2 ... 2. Prepare a health spice vm and start it. #virsh dumpxml spice ... <graphics type='spice' port='5900' autoport='yes' listen='127.0.0.1'> <listen type='address' address='127.0.0.1'/> <image compression='off'/> </graphics> ... <video> <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/> <alias name='video0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/> </video> <redirdev bus='usb' type='spicevmc'> <alias name='redir0'/> <address type='usb' bus='0' port='2'/> </redirdev> <redirdev bus='usb' type='spicevmc'> <alias name='redir1'/> <address type='usb' bus='0' port='3'/> </redirdev> 3. Run virt-viewer to connect to the vm with option: --spice-usbredir-redirect-on-connect=<filter-string> Filter selecting USB devices to redirect on connect # virt-viewer --spice-usbredir-redirect-on-connect="0x8,0x0951,0x1666,0x100,1" spice Result: 3.1 Check on the host where "virt-viewer" command runs, we can't the usb device. ]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 238.5G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 237.5G 0 part ├─rhel-root 253:0 0 70G 0 lvm / ├─rhel-swap 253:1 0 5.7G 0 lvm [SWAP] └─rhel-home 253:2 0 161.9G 0 lvm /home 3.2 Check on the vm 3.2.1 Click 'File'->'USB device selection', then 'Select USB devices for redirection' window pops up, we can find 'Kingston DataTraveler 3.0' is checked already, then click 'Close' button. 3.2.2 Run #lsblk in the vm, but we find there is no usb device in guest. # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda 252:0 0 8G 0 disk ├─vda1 252:1 0 1G 0 part /boot └─vda2 252:2 0 7G 0 part ├─rhel-root 253:0 0 6.2G 0 lvm / └─rhel-swap 253:1 0 820M 0 lvm [SWAP] 4. Close the virt-viewer window, then finding the usb is released to the host again. # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 238.5G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 237.5G 0 part ├─rhel-root 253:0 0 70G 0 lvm / ├─rhel-swap 253:1 0 5.7G 0 lvm [SWAP] └─rhel-home 253:2 0 161.9G 0 lvm /home sdb 8:16 1 28.9G 0 disk ├─sdb1 8:17 1 4.2G 0 part /run/media/root/RHEL-7.8 Server.x86_64 └─sdb2 8:18 1 8.6M 0 part I will attached the debug log, named usb.log.
Created attachment 1715695 [details] usb.log
Created attachment 1715697 [details] usb_replug.log Replug the usb device into the host when running # virt-viewer --spice-usbredir-redirect-on-connect="0x8,0x0951,0x1666,0x100,1" spice --debug --spice-debug |& tee>usb_replug.log Then we can see the usb device in the vm, thanks.
I can reproduce on Fedora 32 client/host/guest spice-gtk3-0.38-1.fc32.x86_64 virt-viewer-9.0-1.fc32.x86_64 $ lsusb | grep -i disk Bus 003 Device 006: ID 0781:5567 SanDisk Corp. Cruzer Blade $ remote-viewer --spice-usbredir-redirect-on-connect="-1,0x0781,0x5567,-1,1" spice://localhost:5932 [guest] $ lsusb # does not show the SanDisk device remote-viewer menu File -> Usb device selection shows the device is marked as shared with the guest. If on the USB device selection menu I unshare the device and share it again then it works. Running lsusb on the guest shows it.
Created attachment 1716056 [details] usb_work_well.log
Created attachment 1716067 [details] failed__spice_gtk3.log
Created attachment 1716076 [details] client_dmesg
Created attachment 1716077 [details] client_messages
Created attachment 1716078 [details] client_rv_spice_debug
(In reply to Frediano Ziglio from comment #4) > It looks like the client is not redirecting the device. Maybe is was locked > by the kernel? > Can you enable and post client logs? Do you mean to add '--debug' and '--spice-debug' options to remote-viewer? If yes, please check client_rv_spice_debug. > Can you also post kernel logs? Client dmesg and /var/log/messages are attached. Thanks
The patch causing the regression is commit 3e20f17b90598e740c4e274b81d99f28187da800 Author: Yuri Benditovich <yuri.benditovich@daynix.com> Date: Thu Sep 19 16:11:21 2019 +0200 usb-redir: extend USB backend to support emulated devices Redirection of emulated devices requires special approach, as usbredirhost can't be used for that (it works only with libusb devices). For emulated devices we create instance of usbredirparser that implements USB redirection protocol. In order to work with the same set of protocol capabilities that usbredirhost sets up with remote side, the parser shall: - not send its own 'hello' to the server - initialize the same capabilities that usbredirhost - receive the same 'hello' response For that we analyze 'hello' sent by USB redir parser and extract set of capabilities from it and upon receive of 'hello' response we provide it also to the parser. When libusb device is redirected via a channel, instance of usbredirhost serves it. When emulated device is redirected via a channel, instance of usbredirparser does the job. Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com> Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Proposed a fix at https://gitlab.freedesktop.org/spice/spice-gtk/-/merge_requests/75
I can reproduce with packages on rhel 8.4 client: spice-gtk3-0.38-3.el8.x86_64 virt-viewer-9.0-4.el8.x86_64 usbredir-0.8.0-1.el8.x86_64 Bus 002 Device 003: ID 0951:1666 Kingston Technology DataTraveler 100 G3/G4/SE9 G2 remote-viewer --spice-usbredir-redirect-on-connect="-1,0x0951,0x1666,-1,1" spice://localhost:5900 After USB redirection USB device is no available in guest nor client.
Patch accepted upstream, https://gitlab.freedesktop.org/spice/spice-gtk/-/commit/afc5872bff1eb327dd299bacdc4eec5e26d37a10
*** Bug 1858655 has been marked as a duplicate of this bug. ***
*** Bug 1876714 has been marked as a duplicate of this bug. ***
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 (spice-gtk 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:1821