Bug 1069590

Summary: Lack of "<master startport='0'/>" section while start one guest with 'ehci' + 'vt82c686b-uhci' model usb companion controllers
Product: Red Hat Enterprise Linux 7 Reporter: Xuesong Zhang <xuzhang>
Component: libvirtAssignee: Martin Kletzander <mkletzan>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: dyuan, mzhan, ngu, pzhang, rbalakri, shyu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-1.2.17-4.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 05:44:41 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 Xuesong Zhang 2014-02-25 11:02:01 UTC
Description of problem:
While define one guest with 2 usb companion controller, which model are 'ehci' + 'vt82c686b-uhci', the guest can't start up successfully due to lack of "<master startport='0'/>" section.

Version-Release number of selected component (if applicable):
libvirt-1.1.1-23.el7.x86_64
qemu-kvm-rhev-1.5.3-45.el7.x86_64
kernel-3.10.0-86.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Add 'ehci' + 'ich9-uhci1' model usb companion controller to guest, do not add addresses to them:
 # virsh edit test
 "
    <controller type='usb' index='0' model='ehci'>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
    </controller>
 "
save 
2. the guest can be started up successfully, and the section "<master startport='0'/>" can be generated automatically by libvirt.
# virsh start a
Domain a started

# virsh dumpxml a |grep usb -A3
    <controller type='usb' index='0' model='ehci'>
      <alias name='usb0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <alias name='usb0'/>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0' multifunction='on'/>
    </controller>

3. destroy the guest
# virsh destroy a
Domain a destroyed

4. revise the usb controller to model companion 'ehci' + 'vt82c686b-uhci' in the guest, Note: do not add addresses also:
 # virsh edit test
 "
    <controller type='usb' index='0' model='ehci'>
    </controller>
    <controller type='usb' index='0' model='vt82c686b-uhci'>
    </controller>
 "
save 
5. start the guest, it will report error.
# virsh start a
error: Failed to start domain a
error: internal error: process exited while connecting to monitor: qemu-kvm: -device vt82c686b-usb-uhci,id=usb,bus=pci.0,addr=0x7: Duplicate ID 'usb' for device

6. check the dumpxml, find libvirt didn't add "<master startport='0'/>" automatically will start the guest.
# virsh dumpxml a |grep usb -A3
    <controller type='usb' index='0' model='ehci'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </controller>
    <controller type='usb' index='0' model='vt82c686b-uhci'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </controller>

7. add the "<master startport='0'/>" in guest, then start the guest again.
# virsh start a
Domain a started

Actual results:
As step 5.
In the libvirt.org, you can find the following reference sentence. So the index value must be same if using companion controllers.
"A companion controller is on the same bus as its master, so the companion index value should be equal."
http://libvirt.org/formatdomain.html#elementsControllers

Expected results:
the guest should be started up successfully at step5, and the master section should be added automatically.

Additional info:

Comment 3 Martin Kletzander 2015-07-10 12:31:20 UTC
ich9-uhci1 - ich9-uhci3 are special companion controllers that have predefined values of master startport defined.  These are, however, the only ones that get that value specified automatically.  Nobody should rely on that, however.  I'd mark this as NOTABUG.  Feel free to object, but if not, I'm going to close it later on.

Comment 4 Pei Zhang 2015-07-13 12:34:17 UTC
(In reply to Martin Kletzander from comment #3)
> ich9-uhci1 - ich9-uhci3 are special companion controllers that have
> predefined values of master startport defined. These are, however, the only
> ones that get that value specified automatically. 

Hi,martin
I tried to reproduce and test this issue again as your comment. and I found that  ich9-uhci1 - ich9-uhci3 are special companion controllers and now they just can be used with ich9-ehci1  not echi ( in bug description ).

If I use " ehci + ich9-uhci3 " as a special companion , ich9-uhci3 will get "<master startport='4'/>" as it has been predefined . but qemu will give an error that "it doesn't support companion controllers" when I try to start guest .

#virsh start usb 
error: Failed to start domain usb
error: internal error: process exited while connecting to monitor: 2015-07-13T11:50:01.300313Z qemu-kvm: -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0xb.0x2: Can't use USB bus 'usb.0' as masterbus, it doesn't support companion controllers
2015-07-13T11:50:01.300350Z qemu-kvm: -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0xb.0x2: Device 'ich9-usb-uhci3' could not be initialized

So If I can say that "ich9-echi1 + ich9-uchi1~ich9-uhci3 " is the only useful and valid usb companion controllers . 
If it's right , the answer why we think this scenario deserves a bug is that we get misconceptions about companion controllers .

Perhaps It should give more information in libvirt.org to avoid user problem.
http://libvirt.org/formatdomain.html#elementsControllers

Thanks !

Comment 5 Martin Kletzander 2015-07-13 12:47:18 UTC
(In reply to Pei Zhang from comment #4)
Unfortunately, I don't think we can replicate all device information from qemu.  For example whether it supports usage as a companion controller or not.  The user is welcomed to try any combination as qemu might add/remove a support for some controller being companion one.  However, the one described is the preferred one.  Do you thing saying something along these lines in the documentation would be enough?

Comment 6 Martin Kletzander 2015-07-16 11:48:31 UTC
Patch proposed upstream:

https://www.redhat.com/archives/libvir-list/2015-July/msg00603.html

Comment 7 Martin Kletzander 2015-07-17 07:18:34 UTC
Fixed upstream by commit v1.2.17-121-gb84a2cd87dad:

commit b84a2cd87dad4a10e3a0064c30ac3df037048101
Author: Martin Kletzander <mkletzan>
Date:   Mon Jul 13 15:51:25 2015 +0200

    docs: Document how libvirt handles companion controllers

Comment 10 Pei Zhang 2015-09-02 07:33:56 UTC
verified version :
libvirt-1.2.17-6.el7.x86_64
qemu-kvm-rhev-2.3.0-21.el7.x86_64


steps:

check doc :
/usr/share/doc/libvirt-docs-1.2.17/html/formatdomain.html#elementsControllers
......
Not all controller models can be used as companion controllers and libvirt might provide some sensible defaults (settings of master startport and function of an address) for some particular models. Preferred companion controllers are ich-uhci[123]. 
......

move this bug to verified.

Comment 11 Ján Tomko 2015-09-10 11:54:55 UTC
*** Bug 1260599 has been marked as a duplicate of this bug. ***

Comment 13 errata-xmlrpc 2015-11-19 05:44:41 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