Bug 1166452

Summary: Report better error message for reordered companion controllers
Product: Red Hat Enterprise Linux 7 Reporter: Hu Jianwei <jiahu>
Component: libvirtAssignee: Pavel Hrdina <phrdina>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: dyuan, jdenemar, mzhan, pzhang, rbalakri
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.3.1-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-03 18:11:14 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 Hu Jianwei 2014-11-21 01:59:19 UTC
Description of problem:
Reorder right positions for companion controllers in domain xml

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

How reproducible:
100%

Steps to Reproduce:
Edit domain xml, put "ich9-ehci1" usb controller to a new position, for example, at the bottom of <device>, after a "ich9-uhci" controller at least.
[root@ibm-x3850x5-01 ~]# virsh dumpxml r7| grep "controller type='usb'"
    <controller type='usb' index='0' model='ich9-uhci1'>
    <controller type='usb' index='0' model='ich9-uhci2'>
    <controller type='usb' index='0' model='ich9-ehci1'>

[root@ibm-x3850x5-01 ~]# virsh start r7
error: Failed to start domain r7
error: internal error: early end of file from monitor: possible problem:
2014-11-19T08:46:31.330359Z qemu-kvm: -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x5: Parameter 'masterbus' expects an USB masterbus
2014-11-19T08:46:31.330477Z qemu-kvm: -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x5: Device initialization failed.
2014-11-19T08:46:31.330496Z qemu-kvm: -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x5: Device 'ich9-usb-uhci1' could not be initialized


Actual results:
As shown above steps, failed to start doamin due to generate a wrong qemu command line.

-device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x5 -device ich9-usb-uhci2,masterbus=usb.0,firstport=3,bus=pci.0,addr=0x5.0x1 -device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x5.0x7

Expected results:
The "ich9-ehci" controller should stand in front of all "ich9-uhci" controllers.

like:
[root@ibm-x3850x5-01 ~]# virsh dumpxml r7| grep "controller type='usb'"
    <controller type='usb' index='0' model='ich9-ehci1'>    
    <controller type='usb' index='0' model='ich9-uhci1'>
    <controller type='usb' index='0' model='ich9-uhci2'>
    
Additional info:

Comment 2 Jiri Denemark 2014-11-21 08:47:28 UTC
I don't think we should try to reorder the controllers. However, we should probably try to check if master is already known when we encounter a companion and report a better error message.

Comment 5 Pavel Hrdina 2015-07-15 13:27:54 UTC
Moving to RHEL-7.3, it's not a critical bug.

Comment 7 Pavel Hrdina 2015-11-11 14:39:54 UTC
Upstream commit:

commit fc03eb53c0bf3f654b3c0a10e349d87eb2f511e6
Author: Pavel Hrdina <phrdina>
Date:   Wed Nov 11 15:20:15 2015 +0100

    domain-conf: reorder usb controllers so the master is first
    
    USB controllers can share the same 'index' which indicates, that there
    is some sort of master-companion relationship.  Reorder the controllers
    in XML in to place the master controller before its companions.  This is
    required by QEMU to not fail with error message:
    
    error: internal error: process exited while connecting to monitor:
    2015-10-26T16:25:17.630265Z qemu-system-x86_64:
    -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x6:
    USB bus 'usb.0' not found
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1166452
    
    Signed-off-by: Pavel Hrdina <phrdina>

Comment 9 Shanzhi Yu 2016-02-24 08:09:22 UTC
verify this bug with libvirt-1.3.1-1.el7.x86_64

1. prepare a guest xml with usb as below

# cat r7.xml |grep usb
    <controller type='usb' index='0' model='ich9-uhci1'/>
    <controller type='usb' index='0' model='ich9-uhci2'/>
    <controller type='usb' index='0' model='ich9-ehci1'/>

2. create guest with above xml
# virsh create r7.xml 
Domain r7 created from r7.xml

3. check guest live xml and qemu cmd line

# virsh dumpxml r7|grep usb
    <controller type='usb' index='0' model='ich9-ehci1'>
      <alias name='usb'/>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <alias name='usb'/>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <alias name='usb'/>
# ps aux|grep usb
qemu     30600  166  7.9 1559216 304936 ?      Sl   16:05   1:09 /usr/libexec/qemu-kvm -name r7 -S -machine pc-i440fx-rhel7.2.0,accel=kvm,usb=off -m 1024 -realtime mlock=off -smp 8,sockets=8,cores=1,threads=1 -uuid 78b51f58-b5ea-4aa6-b971-3e89f68dfad5 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-r7/monitor.sock,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc,driftfix=slew -global kvm-pit.lost_tick_policy=discard -no-hpet -no-shutdown -global PIIX4_PM.disable_s3=1 -global PIIX4_PM.disable_s4=1 -boot strict=on -device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x6.0x7 -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x6 -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x6.0x1

Comment 11 errata-xmlrpc 2016-11-03 18:11:14 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-2016-2577.html