Bug 1375417

Summary: Libvirt should give the range for the configurable ports in nec-usb-xhci
Product: Red Hat Enterprise Linux 7 Reporter: Pei Zhang <pzhang>
Component: libvirtAssignee: Ján Tomko <jtomko>
Status: CLOSED ERRATA QA Contact: jiyan <jiyan>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: dyuan, jtomko, rbalakri, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-3.1.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 17:14:13 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 Pei Zhang 2016-09-13 04:02:05 UTC
Description of problem:
USB controller nec-xhci has a configurable option ports, libvirt 
should limit the range of it.

Version-Release number of selected component (if applicable):
libvirt-2.0.0-8.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. define and configure a guest like following, 
configuring the ports valued 16 and plugging a redirect USB to the port.

# virsh dumpxml vm3 | grep usb -A 4

    <controller type='usb' index='0' model='nec-xhci' ports='16'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <channel type='spicevmc'>
--
    <redirdev bus='usb' type='spicevmc'>
      <address type='usb' bus='0' port='16'/>
    </redirdev>
 
2. start guest, guest fails to start.

# virsh start vm3 
error: Failed to start domain vm3
error: internal error: qemu unexpectedly closed the monitor: us=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -drive file=/tmp/zp/beaker/vm2.qcow2,format=qcow2,if=none,id=drive-virtio-disk0,serial=eca38821-c430-48a1-a932-a4814198f24d,cache=none,werror=stop,rerror=stop,aio=threads -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x6,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -chardev spicevmc,id=charchannel0,name=vdagent -device virtserialport,bus=virtio-serial0.0,nr=3,chardev=charchannel0,id=channel0,name=com.redhat.spice.0 -spice port=5901,addr=0.0.0.0,disable-ticketing,seamless-migration=on -device qxl-vga,id=video0,ram_size=67108864,vram_size=33554432,vram64_size_mb=0,vgamem_mb=16,bus=pci.0,addr=0x2 -chardev spicevmc,id=charredir0,name=usbredir -device usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=16 -msg timestamp=on
2016-09-13T03:56:34.673060Z qemu-kvm: -device usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=16: usb port 16 (bus usb.0) not found (in use?)


Actual results:
As above, guest with nec-usb-xhci having ports valued 16 will fail to start.

Expected results:
Libvirt should give an error to limit the value of ports.

Additional info:

Comment 1 Ján Tomko 2017-01-31 14:09:06 UTC
Upstream patch:
https://www.redhat.com/archives/libvir-list/2017-January/msg01174.html

Comment 2 Ján Tomko 2017-02-13 15:39:43 UTC
Pushed as:
commit 723fef99c0e29d1a327aaea4cef477609f6ccbc2
Author:     Ján Tomko <jtomko>
CommitDate: 2017-02-13 16:34:09 +0100

    qemu: enforce maximum ports value for nec-xhci
    
    This controller only allows up to 15 ports.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1375417

git describe: v3.0.0-183-g723fef9

Comment 4 jiyan 2017-05-08 09:43:37 UTC
Version-Release number of selected component (if applicable):
libvirt-3.2.0-4.el7.x86_64
qemu-kvm-rhev-2.9.0-3.el7.x86_64
kernel-3.10.0-663.el7.x86_64

step to verify:
1.edit the vm's dumpxml file as follows:
    # virsh edit vm
    <controller type='usb' index='0' model='nec-xhci' ports='16'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <channel type='spicevmc'>
    ...
    <redirdev bus='usb' type='spicevmc'>
      <address type='usb' bus='0' port='16'/>
    </redirdev>

2.try to save the dumpxml file in the step 1
   # virsh edit vm
   Failed. Try again? [y,n,i,f,?]: 
   error: unsupported configuration: 'nec-xhci' controller only supports up to '15' ports


3.And verify other value of ports in controller
while "<controller type='usb' index='0' model='nec-xhci' ports='0'>"
# virsh edit cow
error: XML error: Missing USB bus 0

while "<controller type='usb' index='0' model='nec-xhci' ports='1'>"
# virsh edit cow
error: XML error: requested USB port 2 not present on USB bus 0

while "<controller type='usb' index='0' model='nec-xhci' ports='15'>"
# virsh edit cow
Domain cow XML configuration edited.
# virsh start cow
Domain cow started

Comment 5 errata-xmlrpc 2017-08-01 17:14:13 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://access.redhat.com/errata/RHEA-2017:1846

Comment 6 errata-xmlrpc 2017-08-01 23:55:08 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://access.redhat.com/errata/RHEA-2017:1846

Comment 7 errata-xmlrpc 2017-08-02 01:27:35 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://access.redhat.com/errata/RHEA-2017:1846