[libvirt] patch for pci passthrough

Mark McLoughlin markmc at redhat.com
Fri Dec 19 14:54:45 UTC 2008


On Fri, 2008-12-19 at 14:09 +0000, Daniel P. Berrange wrote:
> On Fri, Dec 19, 2008 at 02:04:43PM +0000, Mark McLoughlin wrote:
> > Hi Jason,
> > 
> > On Tue, 2008-12-16 at 03:02 +0100, Jason Krieg wrote:
> > > Hi,
> > > 
> > > This patch adds support for the -pcidevice host=bus:dev.func
> > > added in kvm-79
> > > 
> > > I used the structure as already defined in src/domain_conf.h
> > > 
> > > so analog to usb one now can add pci devices
> > > 
> > > as example:
> > > 
> > > lspci:  06:02.0 Network controller: Eicon Networks Corporation Diva 
> > > Server 2FX (rev 01)
> > > 
> > > 
> > > <hostdev mode='subsystem' type='pci'>
> > >     <source>
> > >         <address bus="0x06" slot="0x02" function="0x0"/>
> > >     </source>
> > > </hostdev>
> > > 
> > > 
> > > values are hex so for bus: 0 to ff, slot: 0 to 1f and function: 0 to 7
> > > 
> > > Hope this patch is useful it applies to libvirt-0.5.1 and cvs checkout
> > > from today (with some hunks)
> > 
> > The patch looks good to me and makes perfect sense; good stuff.
> > 
> > One thing that might be worth thinking about is whether we can
> > automatically unload host drivers for a device when assigning; e.g. if
> > you didn't do "rmmod e1000e" before assigning a NIC to a guest, then the
> > guest would just fail to start.
> 
> Unloading isn't correct because that impact alls devices associated
> with the device. You just want to unbind te specific device using
> the 'unbind' file in sysfs.

Yeah, and in 2.6.29 we have a pci-stub driver to prevent anything
re-attaching to the device, so e.g.

  $> echo "8086 10f5" > /sys/bus/pci/drivers/pci-stub/new_id                                                                 
  $> echo -n 0000:00:19.0 > /sys/bus/pci/drivers/e1000e/unbind                                                               
  $> echo -n 0000:00:19.0 > /sys/bus/pci/drivers/pci-stub/bind                 

>  I dont think we should do this automatically
> though - you wouldn't want to accidentally, automatically remotely
>  unbind your network. 
> 
> I think the node device driver APIs could report what driver is
> associated with each device they know, and provide an API to bind
> and unbind the device to/from the driver. Its easy enough for a mgmt
> app to automatically / seemlessly invoke such an API, after validating
> that the PCI device isn't asociated with the ethernet device its talking
> to libvirt over ..

The management app can do that validation when setting up the guest, but
not always when starting the guest - e.g. thinking about autostarted
guests ...

Cheers,
Mark.




More information about the libvir-list mailing list