[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] Auto-assignment of USB devices and auto-creation of USB hubs

On Mi, 2013-09-18 at 07:33 -0400, Jamie Bainbridge wrote:
> Hello,
> I've been helping a customer out this week with assigning specific devices to specific USB controllers inside his KVM VMs. He's got USB1 devices which need a UHCI controller (because of rubbishy Windows device drivers) and USB2 devices which need a EHCI controller ("speed mismatch" on a UHCI hub).
> I've suggested config similar to this:
>     <controller type='usb' index='0' model='ehci'>
>     </controller>
>     <controller type='usb' index='1' model='piix3-uhci'>
>     </controller>

You can also do this:

    <controller type='usb' index='0' model='ich9-ehci1'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d'
function='0x7' multifunction='on'/>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d'
function='0x0' multifunction='on'/>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d'
function='0x1' multifunction='on'/>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d'
function='0x2' multifunction='on'/>

Gives you a ehci controller with uhci companions.  It's a single usb
bus, with 6 ports, supporting both usb1 and usb2.  Makes device
attachment a bit easier as you don't have to worry about the device
speed then.

>     <input type='tablet' bus='usb'/>

You can also do this here:

    <input type='tablet' bus='usb'>
      <address type='usb' bus='0' port='2.8'/>

>     <hub type='usb'>
>       <address type='usb' bus='1' port='2'/>
>     </hub>

The qemu hub supports usb1.1 only, so any usb 2.0 devices must be
plugged into a ehci root port.  The hub has 8 downstream ports btw.

> My observation is that you can either:
>  a) let libvirt plug everything into the UHCI controller, regardless of what other controllers are there and what order they appear in
>  or
>  b) find out how many ports a controller/hub has through trial and error, manually create USB hubs, and map every single device and port out manually
> with no middle ground in between.

Correct.  And if you hotplug usb devices you have to do (b) to make sure
live migration works.

>       <address type='usb' bus='1'/>

> then save the XML, and "virsh edit" again, and all the port/hub stuff would already be there pre-made as required.
> Any thoughts? Is this worth logging an RFE for?

Sure.  It's done for PCI, for good reasons.
IMO libvirt should likewise create usb addresses.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]