RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1874740 - usb redirection using spice-usbredir-redirect-on-connect option doesn't take effect
Summary: usb redirection using spice-usbredir-redirect-on-connect option doesn't take ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: spice-gtk
Version: 8.3
Hardware: Unspecified
OS: Unspecified
high
medium
Target Milestone: rc
: 8.3
Assignee: Default Assignee for SPICE Bugs
QA Contact: SPICE QE bug list
URL:
Whiteboard:
: 1858655 1876714 (view as bug list)
Depends On:
Blocks: 1876714
TreeView+ depends on / blocked
 
Reported: 2020-09-02 06:56 UTC by yduan
Modified: 2021-05-18 15:42 UTC (History)
14 users (show)

Fixed In Version: spice-gtk-0.38-4.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1876714 (view as bug list)
Environment:
Last Closed: 2021-05-18 15:42:39 UTC
Type: ---
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
tcpdump trace (653.85 KB, application/octet-stream)
2020-09-22 08:32 UTC, Gerd Hoffmann
no flags Details
usb.log (91.05 KB, text/plain)
2020-09-22 12:45 UTC, zhoujunqin
no flags Details
usb_replug.log (911.19 KB, text/plain)
2020-09-22 12:48 UTC, zhoujunqin
no flags Details
usb_work_well.log (615.60 KB, text/plain)
2020-09-23 13:54 UTC, zhoujunqin
no flags Details
failed__spice_gtk3.log (72.04 KB, text/plain)
2020-09-23 13:56 UTC, zhoujunqin
no flags Details
client_dmesg (84.17 KB, text/plain)
2020-09-23 14:21 UTC, yduan
no flags Details
client_messages (243.58 KB, text/plain)
2020-09-23 14:22 UTC, yduan
no flags Details
client_rv_spice_debug (83.36 KB, text/plain)
2020-09-23 14:23 UTC, yduan
no flags Details

Description yduan 2020-09-02 06:56:12 UTC
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

Comment 2 Gerd Hoffmann 2020-09-22 08:32:32 UTC
Created attachment 1715667 [details]
tcpdump trace

Comment 3 Gerd Hoffmann 2020-09-22 08:53:26 UTC
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.

Comment 4 Frediano Ziglio 2020-09-22 11:47:05 UTC
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?

Comment 5 zhoujunqin 2020-09-22 12:42:43 UTC
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.

Comment 6 zhoujunqin 2020-09-22 12:45:52 UTC
Created attachment 1715695 [details]
usb.log

Comment 7 zhoujunqin 2020-09-22 12:48:58 UTC
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.

Comment 8 Uri Lublin 2020-09-22 16:46:24 UTC
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.

Comment 12 zhoujunqin 2020-09-23 13:54:36 UTC
Created attachment 1716056 [details]
usb_work_well.log

Comment 13 zhoujunqin 2020-09-23 13:56:43 UTC
Created attachment 1716067 [details]
failed__spice_gtk3.log

Comment 14 yduan 2020-09-23 14:21:46 UTC
Created attachment 1716076 [details]
client_dmesg

Comment 15 yduan 2020-09-23 14:22:27 UTC
Created attachment 1716077 [details]
client_messages

Comment 16 yduan 2020-09-23 14:23:23 UTC
Created attachment 1716078 [details]
client_rv_spice_debug

Comment 18 yduan 2020-09-23 14:39:21 UTC
(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

Comment 19 Frediano Ziglio 2020-09-23 15:20:53 UTC
The patch causing the regression is

commit 3e20f17b90598e740c4e274b81d99f28187da800
Author: Yuri Benditovich <yuri.benditovich>
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>
    Signed-off-by: Frediano Ziglio <fziglio>

Comment 20 Frediano Ziglio 2020-09-23 16:06:36 UTC
Proposed a fix at https://gitlab.freedesktop.org/spice/spice-gtk/-/merge_requests/75

Comment 23 Radek Duda 2020-10-20 17:15:14 UTC
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.

Comment 29 Gerd Hoffmann 2021-01-25 08:36:11 UTC
*** Bug 1858655 has been marked as a duplicate of this bug. ***

Comment 30 Gerd Hoffmann 2021-01-25 08:39:34 UTC
*** Bug 1876714 has been marked as a duplicate of this bug. ***

Comment 32 errata-xmlrpc 2021-05-18 15:42:39 UTC
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


Note You need to log in before you can comment on or make changes to this bug.