[libvirt-users] Using hostdev to plug a PCI-E host device into Q35 pcie-root port

Thomas Kuther tom at kuther.net
Fri Nov 15 13:35:12 UTC 2013


Hello,

I'm trying to migrate a working qemu command line configuration to 
libvirt.
The part I'm currently failing on is:

$ qemu-system-x86_64 -M Q35 ... -device vfio-pci,host=05:00.0,bus=pcie.0

The right way to translate this into libvirt XML seems to be using 
<hostdev>, but I seem to be unable to plug it into the pcie-root port

This is how the interesting part looks like when I let "virsh edit" 
generate an <address>

     <controller type='pci' index='0' model='pcie-root'/>
     <controller type='pci' index='1' model='dmi-to-pci-bridge'>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x02' 
function='0x0'/>
     </controller>
     <controller type='pci' index='2' model='pci-bridge'>
       <address type='pci' domain='0x0000' bus='0x01' slot='0x01' 
function='0x0'/>
     </controller>
     [...]
     <hostdev mode='subsystem' type='pci' managed='yes'>
       <driver name='vfio'/>
       <source>
         <address domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
       </source>
       <address type='pci' domain='0x0000' bus='0x02' slot='0x06' 
function='0x0'/>
     </hostdev>
     [...]

To my understanding, this will plug the host device into the pci-bridge 
controller.
The guest OS doesn't boot with this and resets right after bios.

Manually setting
<address type='pci' domain='0x0000' bus='0x00' slot='0x1E' 
function='0x0'/>
cause XML validation failure.

Is there any way in libvirt XML to plug a host's PCI-E device directly 
into the pcie-root port, like it works on qemu command line?

I'm aware I could use something like

   <qemu:commandline>
     <qemu:arg value='-device'/>
     <qemu:arg value='vfio-pci,host=05:00.0,bus=pcie.0'/>
   </qemu:commandline>

but I insist on running the VM as non-root, and if I got that right I 
need to configure at least one vfio device (or memory locking) in order 
for libvirt to set a proper RLIMIT_MEMLOCK value.

Any help would be be appreciated.

Regards,
Thomas




More information about the libvirt-users mailing list