[libvirt-users] Why does libvirt insert USB controller automagically?

Cole Robinson crobinso at redhat.com
Tue Dec 1 14:59:31 UTC 2015


On 11/30/2015 07:30 PM, Sundar Nadathur wrote:
> Hello all,
> 
>      I find this curious behavior that libvirt will automatically insert a USB
> controller and a memballoon virtio driver into the domain’s XML, when
> defineXML is called. IOW, the original XML did not have these 2 devices but
> they are present right after defineXML is called. Why should libvirt add a USB
> controller?
> 
>  

Historical compatibility. Older qemu would provide these devices automatically
with no way for libvirt to disable them. Eventually qemu grew to support
disabling these devices, but libvirt qemu users were already expecting them to
be added automatically, so we are stuck with that API contract.

If you want to disable them, you have to explicitly add

<controller type='usb' model='none'/>
<memballoon model='none'/>

- Cole

> 
> DETAILS:
> 
> Here is a little Python snippet to show that behavior:
> 
> import libvirt
> 
>  
> 
> conn = libvirt.open('qemu:///system')
> 
> xml_list = open('/tmp/vm.xml', "r").readlines()
> 
> in_xml = ''.join(xml_list) ß*This XML string does not have a USB or a memballoon*
> 
> dom = conn.defineXML(in_xml)
> 
> out_xml = dom.XMLDesc() ß*But this XML string does!*
> 
> print out_xml
> 
>  
> 
> The file /tmp/vm.xml does not have a memballoon or a USB device. Neither, of
> course, does in_xml string. But out_xml has:
> 
>     <controller type='usb' index='0'>
> 
>       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
> 
>     </controller>
> 
>     <memballoon model='virtio'>
> 
>       <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
> 
>     </memballoon>
> 
>  
> 
> I don’t see anything in libvirt.conf that explains this. This is libvirt
> version: 1.2.8, package: 16.el7_1.5 (Red Hat, Inc....). The host is RHEL 7.1.
> 
>  
> 
> The memballoon part is understandable once I found:
> https://www.redhat.com/archives/libvir-list/2010-August/msg00132.html
> 
>  
> 
> However, why should libvirt add a USB controller gratuitously? Is this
> controllable from the conf file?
> 
>  
> 
> Cheers,
> 
> Sundar
> 
>  
> 
> 
> ------------------------------------------------------------------------------
> 
> Confidentiality Notice.
> This message may contain information that is confidential or otherwise
> protected from disclosure. If you are not the intended recipient, you are
> hereby notified that any use, disclosure, dissemination, distribution, or
> copying of this message, or any attachments, is strictly prohibited. If you
> have received this message in error, please advise the sender by reply e-mail,
> and delete the message and any attachments. Thank you.
> 
> 
> _______________________________________________
> libvirt-users mailing list
> libvirt-users at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-users
> 




More information about the libvirt-users mailing list