Bug 1035128

Summary: Stable guest ABI doesn't check redirected usb device
Product: Red Hat Enterprise Linux 7 Reporter: tingting zheng <tzheng>
Component: libvirtAssignee: Ján Tomko <jtomko>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: dyuan, lcheng, lsu, mzhan, rbalakri, tzheng, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-1.2.7-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1035529 (view as bug list) Environment:
Last Closed: 2015-03-05 07:28:31 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:
Bug Depends On:    
Bug Blocks: 1035529    

Description tingting zheng 2013-11-27 06:46:32 UTC
Description
Stable guest ABI doesn't check redirected usb device

Version:
libvirt-1.1.1-13.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Prepare a guest.
2.Plug in a usb device on host with usbredir packages installed.
# lsusb
Bus 006 Device 003: ID 15e1:2007 RSA RSA SecurID (R) Authenticator
 
# usbredirserver -p 4000 15e1:2007

3. Configure the guest with Redirected USB Device in virt-manager,
Add Hardware-> USB Redirection-> type: tcp, Address:&hostip,port as 4000.

4. Boot the guest.

5.Use virsh dumpxml to get the xml of the guest.
# virsh dumpxml mig > mig.xml
……
    <redirdev bus='usb' type='tcp'>
      <source mode='connect' host='$ip' service='4000'/>
      <protocol type='raw'/>
    </redirdev>
……

6.Change the type in xml from 'tcp' to 'spicevmc'.
change xml from:
    <redirdev bus='usb' type='tcp'>
      <source mode='connect' host='$ip' service='4000'/>
      <protocol type='raw'/>
    </redirdev>
to:
    <redirdev bus='usb' type='spicevmc'>
      <source mode='connect' host='$ip' service='4000'/>
      <protocol type='raw'/>
    </redirdev>

5.Do migrate,no error shows.
# virsh migrate --live mig qemu+ssh://$ip/system --xml mig.xml


Actual results:
As step 5 describes.

Expected results:
Error shows when type of redirected usb device in xml is different with guest.
eg:error: unsupported configuration: Target redirected usb device type 'spicevmc' does not match source 'tcp'

Comment 2 Ján Tomko 2014-04-02 12:04:19 UTC
Upstream patch proposed:
https://www.redhat.com/archives/libvir-list/2014-April/msg00076.html

Comment 3 Ján Tomko 2014-04-03 13:25:02 UTC
Now fixed upstream:
commit c9123fbe85430dab5e737b20f5657aab650a5d45
Author:     Ján Tomko <jtomko>
CommitDate: 2014-04-03 15:21:38 +0200

    Add redirdevs to ABI stability check
    
    Check the bus, type of the source device (tcp vs. spicevmc)
    and the device address visible in the guest.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1035128

git describe: v1.2.3-38-gc9123fb

Comment 6 lcheng 2014-11-27 08:39:00 UTC
Verify the bug as follows. The result is expected.


Version:
libvirt-1.2.8-9.el7.x86_64
qemu-kvm-rhev-2.1.2-13.el7.x86_64
qemu-kvm-1.5.3-82.el7.x86_64


Preparation:

1. Plug in a usb device on host.
# lsusb
Bus 001 Device 007: ID 8644:8303
 
# usbredirserver -p 4000 8644:8303

2. Configure the guest with Redirected USB Device in virt-manager,
Add Hardware-> USB Redirection-> type: tcp, Address: 10.66.5.123, port: 4000.

3. Boot the guest.

4. Get the xml of the guest.
# virsh dumpxml r7 > mig.xml
...
    <redirdev bus='usb' type='tcp'>
      <source mode='connect' host='10.66.5.123' service='4000'/>
      <protocol type='raw'/>
      <alias name='redir4'/>
    </redirdev>
...


Steps:

Scenario 1: change type

1.1 Change the type in mig.xml from 'tcp' to 'spicevmc'.
change xml from:
    <redirdev bus='usb' type='tcp'>
      <source mode='connect' host='10.66.5.123' service='4000'/>
      <protocol type='raw'/>
      <alias name='redir4'/>
    </redirdev>
to:
    <redirdev bus='usb' type='spicevmc'>
      <source mode='connect' host='10.66.5.123' service='4000'/>
      <protocol type='raw'/>
      <alias name='redir4'/>
    </redirdev>

1.2 Do migrate.
# virsh migrate --live r7 qemu+ssh://10.66.106.26/system --xml mig.xml
root.106.26's password: 
error: unsupported configuration: Target redirected device source type spicevmc does not match source device source type tcp


Scenario 2: change bus

2.1 Change the bus in mig.xml from 'usb' to 'pci'.
change xml from:
    <redirdev bus='usb' type='tcp'>
      <source mode='connect' host='10.66.5.123' service='4000'/>
      <protocol type='raw'/>
      <alias name='redir4'/>
    </redirdev>
to:
    <redirdev bus='pci' type='spicevmc'>
      <source mode='connect' host='10.66.5.123' service='4000'/>
      <protocol type='raw'/>
      <alias name='redir4'/>
    </redirdev>


2.2 Do migrate.
# virsh migrate --live r7 qemu+ssh://10.66.106.26/system --xml mig.xml
root.106.26's password: 
error: unsupported configuration: unknown redirdev bus 'pci'


Scenario 3: change devices count 

3.1 Change the mig.xml as following.
change xml from:
    <redirdev bus='usb' type='tcp'>
      <source mode='connect' host='10.66.5.123' service='4000'/>
      <protocol type='raw'/>
      <alias name='redir4'/>
    </redirdev>
to:
    <redirdev bus='usb' type='tcp'>
      <source mode='connect' host='10.66.5.123' service='4000'/>
      <protocol type='raw'/>
      <alias name='redir4'/>
    </redirdev>
    <redirdev bus='usb' type='tcp'>
      <source mode='connect' host='10.66.5.123' service='4000'/>
      <protocol type='raw'/>
      <alias name='redir4'/>
    </redirdev>


3.2 Do migrate.
# virsh migrate --live r7 qemu+ssh://10.66.106.26/system --xml mig.xml
root.106.26's password: 
error: unsupported configuration: Target domain redirected devices count 2 does not match source 1


Scenario 4: no change

4.1 Don't modify mig.xml
    <redirdev bus='usb' type='tcp'>
      <source mode='connect' host='10.66.5.123' service='4000'/>
      <protocol type='raw'/>
      <alias name='redir4'/>
    </redirdev>

4.2 Do migrate, no error shows.
# virsh migrate --live r7 qemu+ssh://10.66.106.26/system --xml mig.xml
root.106.26's password:

Comment 8 errata-xmlrpc 2015-03-05 07:28:31 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/RHSA-2015-0323.html