[vfio-users] Linux guest passthrough

Alex Williamson alex.l.williamson at gmail.com
Wed Jan 18 04:18:51 UTC 2017


On Tue, Jan 17, 2017 at 8:54 PM, Daniel Browne <jairuncaloth at gmail.com>
wrote:

> Hi guys,
> I've got a new Fedora 25 host setup and I am attempting to get an Ubuntu
> 16.40 guest running with VGA passthrough. On the guest, I've installed the
> official nvidia driver via the Ubuntu drivers tool. The nvidia driver
> loads, but xorg.log shows the error "failed to initialize glx extension
> (compatible nvidia x driver not found)"
>
> Based on an e-mail to this list from the last time I attempted this, it is
> my understanding that you need a Q35 machine and a valid pci-e bus setup to
> make this all work.
>

I'm not sure how much this is true, that you need a "valid pci-e bus
setup", but you haven't got one.  AFAIK, the PCI-e root port issues are
limited to Radeon.


I *believe* I have a valid pci-e setup with Q35, but I'm honestly not
> entirely sure. Most of what I've found regarding the subject is a bit light
> on details. I would appreciate it if someone could look over my domain XML
> below and help me figure out what I'm doing wrong.
>
> <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0
> '>
>   <name>ubuntu16.04</name>
>   <uuid>80e1008f-b83c-47c7-a334-c9a07577751c</uuid>
>   <memory unit='KiB'>4184064</memory>
>   <currentMemory unit='KiB'>4184064</currentMemory>
>   <vcpu placement='static'>2</vcpu>
>   <os>
>     <type arch='x86_64' machine='pc-q35-2.7'>hvm</type>
>     <loader readonly='yes' type='pflash'>/usr/share/edk2/
> ovmf/OVMF_CODE.fd</loader>
>     <nvram>/var/lib/libvirt/qemu/nvram/ubuntu16.04_VARS.fd</nvram>
>     <boot dev='hd'/>
>   </os>
>   <features>
>     <acpi/>
>     <apic/>
>     <kvm>
>       <hidden state='on'/>
>     </kvm>
>     <vmport state='off'/>
>   </features>
>   <cpu mode='custom' match='exact'>
>     <model fallback='allow'>Haswell-noTSX</model>
>   </cpu>
>   <clock offset='utc'>
>     <timer name='rtc' tickpolicy='catchup'/>
>     <timer name='pit' tickpolicy='delay'/>
>     <timer name='hpet' present='no'/>
>   </clock>
>   <on_poweroff>destroy</on_poweroff>
>   <on_reboot>restart</on_reboot>
>   <on_crash>restart</on_crash>
>   <pm>
>     <suspend-to-mem enabled='no'/>
>     <suspend-to-disk enabled='no'/>
>   </pm>
>   <devices>
>     <emulator>/usr/bin/qemu-kvm</emulator>
>     <disk type='file' device='disk'>
>       <driver name='qemu' type='raw'/>
>       <source file='/var/lib/libvirt/images/ubuntu.img'/>
>       <target dev='vda' bus='virtio'/>
>       <address type='pci' domain='0x0000' bus='0x02' slot='0x04'
> function='0x0'/>
>     </disk>
>     <disk type='file' device='cdrom'>
>       <driver name='qemu' type='raw'/>
>       <target dev='sda' bus='sata'/>
>       <readonly/>
>       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
>     </disk>
>     <controller type='usb' index='0' model='ich9-ehci1'>
>       <address type='pci' domain='0x0000' bus='0x00' slot='0x1d'
> function='0x7'/>
>     </controller>
>     <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>
>     <controller type='usb' index='0' model='ich9-uhci2'>
>       <master startport='2'/>
>       <address type='pci' domain='0x0000' bus='0x00' slot='0x1d'
> function='0x1'/>
>     </controller>
>     <controller type='usb' index='0' model='ich9-uhci3'>
>       <master startport='4'/>
>       <address type='pci' domain='0x0000' bus='0x00' slot='0x1d'
> function='0x2'/>
>     </controller>
>     <controller type='sata' index='0'>
>       <address type='pci' domain='0x0000' bus='0x00' slot='0x1f'
> function='0x2'/>
>     </controller>
>     <controller type='pci' index='0' model='pcie-root'/>
>     <controller type='pci' index='1' model='dmi-to-pci-bridge'>
>       <model name='i82801b11-bridge'/>
>       <address type='pci' domain='0x0000' bus='0x00' slot='0x1e'
> function='0x0'/>
>     </controller>
>     <controller type='pci' index='2' model='pci-bridge'>
>       <model name='pci-bridge'/>
>       <target chassisNr='2'/>
>       <address type='pci' domain='0x0000' bus='0x01' slot='0x00'
> function='0x0'/>
>     </controller>
>

Add a PCIe root port here:

    <controller type='pci' index='3' model='pcie-root-port'>
      <address type='pci' domain='0x0' bus='0x0' slot='0x1c' function='0'/>
    </controller>


    <controller type='virtio-serial' index='0'>
>       <address type='pci' domain='0x0000' bus='0x02' slot='0x03'
> function='0x0'/>
>     </controller>
>     <interface type='network'>
>       <mac address='52:54:00:11:00:b1'/>
>       <source network='default'/>
>       <model type='virtio'/>
>       <address type='pci' domain='0x0000' bus='0x02' slot='0x01'
> function='0x0'/>
>     </interface>
>     <serial type='pty'>
>       <target port='0'/>
>     </serial>
>     <console type='pty'>
>       <target type='serial' port='0'/>
>     </console>
>     <channel type='spicevmc'>
>       <target type='virtio' name='com.redhat.spice.0'/>
>       <address type='virtio-serial' controller='0' bus='0' port='1'/>
>     </channel>
>     <input type='mouse' bus='ps2'/>
>     <input type='keyboard' bus='ps2'/>
>     <graphics type='spice' autoport='yes'>
>       <listen type='address'/>
>       <image compression='off'/>
>     </graphics>
>     <sound model='ich6'>
>       <address type='pci' domain='0x0000' bus='0x02' slot='0x02'
> function='0x0'/>
>     </sound>
>     <video>
>       <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1'
> primary='yes'/>
>       <address type='pci' domain='0x0000' bus='0x00' slot='0x01'
> function='0x0'/>
>     </video>
>

Hmm, you have emulated QXL graphics too, this alone could be the source of
your problem.  Generally the xorg.conf needs a BusID to pick the right
device in this sort of setup, but I can't vouch for GeForce working as
secondary in a Linux guest.


>     <hostdev mode='subsystem' type='pci' managed='yes'>
>       <driver name='vfio'/>
>       <source>
>         <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
>       </source>
>       <address type='pci' domain='0x0000' bus='0x02' slot='0x06'
> function='0x0'/>
>     </hostdev>
>

Chance the address to:

<address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>

Bus = 3 puts it on the index = 3 pcie-root-port above



>     <hostdev mode='subsystem' type='pci' managed='yes'>
>       <driver name='vfio'/>
>       <source>
>         <address domain='0x0000' bus='0x01' slot='0x00' function='0x1'/>
>       </source>
>       <address type='pci' domain='0x0000' bus='0x02' slot='0x07'
> function='0x0'/>
>     </hostdev>
>     <redirdev bus='usb' type='spicevmc'>
>       <address type='usb' bus='0' port='1'/>
>     </redirdev>
>     <redirdev bus='usb' type='spicevmc'>
>       <address type='usb' bus='0' port='2'/>
>     </redirdev>
>     <memballoon model='virtio'>
>       <address type='pci' domain='0x0000' bus='0x02' slot='0x05'
> function='0x0'/>
>     </memballoon>
>   </devices>
>   <qemu:commandline>
>     <qemu:arg value='-set'/>
>     <qemu:arg value='device.hostdev0.x-vga=on'/>
>   </qemu:commandline>
>

Kudos for good use of <qemu:arg>, but you're running an OVMF VM, so you
don't want to use this.  Thanks,

Alex


> </domain>
>
> Thanks,
> Daniel
>
> _______________________________________________
> vfio-users mailing list
> vfio-users at redhat.com
> https://www.redhat.com/mailman/listinfo/vfio-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/vfio-users/attachments/20170117/e9afbfdd/attachment.htm>


More information about the vfio-users mailing list