Bug 1177237

Summary: redirfilter with version='1.1' allows a USB 3.0 device
Product: Red Hat Enterprise Linux 7 Reporter: lcheng
Component: libvirtAssignee: Ján Tomko <jtomko>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: medium    
Version: 7.1CC: dyuan, honzhang, pzhang, rbalakri, shyu, zhwang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-1.2.14-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 06:05:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description lcheng 2014-12-25 10:09:15 UTC
Description of problem:
When start guest without 'version' element or with 'version=1.10' element, redirecting usb 3.0 device can be find in guest. But when start guest with 'version=1.0' or 'version=2.0', redirecting usb 3.0 device can not be find in guest.


Version-Release number of selected component (if applicable):
qemu-kvm-rhev-2.1.2-17.el7.x86_64
libvirt-1.2.8-11.el7.x86_64


How reproducible:
100%


Steps to Reproduce:
1. Plug a usb 3.0 device to host. Run 'usbredirserver' command on terminal.

[root@localhost ~]# lsusb
...
Bus 001 Device 007: ID 0951:1656 Kingston Technology DataTraveler Ultimate G2

[root@localhost ~]# usbredirserver -p 4000 0951:1656


2. On another terminal, start guest without 'version' element.

[root@localhost ~]# virsh start r7
Domain r7 started

[root@localhost ~]# virsh dumpxml r7
    <redirdev bus='usb' type='tcp'>
      <source mode='connect' host='localhost' service='4000'/>
      <protocol type='raw'/>
      <alias name='redir0'/>
    </redirdev>
    <redirfilter>
      <usbdev class='0x08' vendor='0x0951' product='0x1656' allow='yes'/>      <== do not set version
      <usbdev allow='no'/>
    </redirfilter>
...

[root@localhost ~]# ps -aux | grep qemu
-device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x5.0x7 -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x5 -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x5.0x1 -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x5.0x2  ... -chardev socket,id=charredir0,host=localhost,port=4000 -device usb-redir,chardev=charredir0,id=redir0,filter=0x08:0x0951:0x1656:-1:1|-1:-1:-1:-1:0 ...


3. Check the usb device in guest. Can find the usb device.

[root@localhost ~]# lsusb
Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd
Bus 001 Device 003: ID 0951:1656 Kingston Technology DataTraveler Ultimate G2     <== can find the usb device
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub



4. Start guest with 'version=1.10' element.

[root@localhost ~]# virsh destroy r7
Domain r7 destroyed

[root@localhost ~]# virsh edit r7
Domain r7 XML configuration edited.


[root@localhost ~]# virsh start r7
Domain r7 started

[root@localhost ~]# virsh dumpxml r7
...
    <redirdev bus='usb' type='tcp'>
      <source mode='connect' host='localhost' service='4000'/>
      <protocol type='raw'/>
      <alias name='redir0'/>
    </redirdev>
    <redirfilter>
      <usbdev class='0x08' vendor='0x0951' product='0x1656' version='1.10' allow='yes'/>
      <usbdev allow='no'/>
    </redirfilter>
...

5. Check the usb device in guest. Can find the usb device.

[root@localhost ~]# lsusb
Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd
Bus 001 Device 003: ID 0951:1656 Kingston Technology DataTraveler Ultimate G2         <== can find the usb device
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub


6. Start guest with 'version=2.0' or 'version=1.0' element.

[root@localhost ~]# virsh destroy r7
Domain r7 destroyed

[root@localhost ~]# virsh edit r7
Domain r7 XML configuration edited.

[root@localhost ~]# virsh start r7
Domain r7 started

[root@localhost ~]# ps -aux | grep qemu
... -chardev socket,id=charredir0,host=localhost,port=4000 -device usb-redir,chardev=charredir0,id=redir0,filter=0x08:0x0951:0x1656:0x0200:1|-1:-1:-1:-1:0 ...

[root@localhost ~]# virsh dumpxml r7
...
    <redirdev bus='usb' type='tcp'>
      <source mode='connect' host='localhost' service='4000'/>
      <protocol type='raw'/>
      <alias name='redir0'/>
    </redirdev>
    <redirfilter>
      <usbdev class='0x08' vendor='0x0951' product='0x1656' version='2.0' allow='yes'/>    <== or version='1.0'
      <usbdev allow='no'/>
    </redirfilter>
...

7. Check the usb device in guest. Can not find the usb device.

[root@localhost ~]# lsusb
Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
                                  <== can not find the usb device


Actual results:
As steps.


Expected results:
For step 7, the usb 3.0 device should be exist in guest.


Additional info:

Comment 3 Ján Tomko 2015-03-12 12:30:57 UTC
The 'version' field refers to the revision of the device (bcdDevice in lsusb output), not the revision of the USB protocol (bcdUSB).

Its documentation does not seem clear to me, I've sent a patch to improve it:
https://www.redhat.com/archives/libvir-list/2015-March/msg00620.html

Comment 4 Ján Tomko 2015-03-13 14:42:47 UTC
Pushed upstream:
commit 76a2a5ce8ba319c63e5c5572d41d768a48d371b5
Author:     Ján Tomko <jtomko>
CommitDate: 2015-03-13 14:05:02 +0100

    Clarify the meaning of version in redirdev filters
    
    The version attribute in redirdev filters refers to the revision
    of the device, not the version of the USB protocol.
    
    Explicitly state that this is not the USB protocol and remove references
    to those round version numbers that resemble USB protocol versions.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1177237

git describe: v1.2.13-155-g76a2a5c

Comment 6 Pei Zhang 2015-05-21 06:18:11 UTC
Verify version :
libvirt-1.2.15-2.el7.x86_64

steps :
1.yum install all libvirt-1.2.15-2.el7 packets
2.check in formatdomain.html
# firefox /usr/share/doc/libvirt-docs-1.2.15/html/formatdomain.html
and 
http://libvirt.org/formatdomain.html#elementsRedir

......
  <usbdev class='0x08' vendor='0x1234' product='0xbeef' version='2.56' allow='yes'/>  
......
redirfilter
......version is the device revision from the bcdDevice field (not the version of the USB protocol). ......

It has a clear documentation now .
move to verified .

Comment 8 errata-xmlrpc 2015-11-19 06:05:54 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, 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://rhn.redhat.com/errata/RHBA-2015-2202.html