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

[Libvir] RFC: format for mapping host devices to guest



I'm considering the problem of mapping host USB devices through to the guest
as one of the 2 remaining bits of USB support needed (the other being the
mapping disks through as USB mass storage). I have previously mentioned some
ideas in this mail, though looking back on this I don't much like them

  https://www.redhat.com/archives/libvir-list/2007-March/msg00205.html

Also, there was just the message about a desire to support mapping of
PCI devices. The USB stuff I want todo with both Xen and QEMU.

In Xen, USB device passthrough is based on:

  usbdevice=host:[bus id].[device id]

    eg usbdevice=host:003.001

Or

  usbdevice=host:[vendor id]:[product id]

     eg usbdevice=host:0483:2016

In QEMU, USB device passthrough is pretty much the same with command line
args:

  -usbdevice host:[bus id].[device id]

     eg -usbdevice host:003.001

Or

  -usbdevice host:[vendor id]:[product id]

     eg -usbdevice host:0483:2016

Finally, in Xen, PCI device passthrough is done with

  pci=['pci device id',....] 

     eg pci=['00:1f.3']


So we need some form of element under the <devices> section per device to
map through. At minimum this will need the source device info. If we are
to support unplugging of USB devices in QEMU it is neccessary to have the
target device id - this is generated by QEMU when attaching the USB device.

So to attach a device:

   <host bus='usb'>
      <source device="003.001"/>
   </host>

Or

   <host bus='usb'>
     <source vendor='0483' product='2016'>
   </host>

The first form is useful for live hotplug - where you know the exact device
instance. The second form is useful for permanent config - you don't know
what device id it'll have since it may be plugged into the host in any order.

When splitting the XML back out, QEMU would fill in the target info giving
us either:

   <host bus='usb'>
      <source dev='003.001'/>
      <target dev='001.005'/>
   </host>

Or

   <host bus='usb'>
      <source vendor='0483' product='2016'/>
      <target dev='001.005'/>
   </host>

This is suitable for giving to virDomainDetachDevice() - we use the target
dev for the QEMU monitor 'usb-detach' command. 

Now PCI would be similar - no hotplug to worry about here though, and no
need (or availability) or target info. So the XML would simply be

   <host bus='pci'>
      <source dev='00:1f.3'/>
   </host>


NB I choose 'host' as the element name since we're basically giving the
guest an arbitrary host device.  My previous email had thought about
calling it 'bus' but we're not really defining a bus in this context and
there may very well be some scenario in the future where we do need to
represent the concept of a 'bus' in the XML directly.

Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 


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