[arch-general] Trouble with QEMU GPU Passthrough via OVMF

Maxence Sartiaux contact at makz.me
Mon Mar 27 21:13:40 UTC 2017


Hello, 

I'm currently working to setup a windows virtual machine with gpu passthrough on my archlinux host. 

So at first i created a basic VM with a custom qemu command and it work great. 

qemu-system-x86_64 -enable-kvm -m 8192 -cpu host,kvm=off,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,hv_vendor_id=whatever\
 -smp cores=4,threads=2\
 -device vfio-pci,host=02:00.0,x-vga=on\
 -device vfio-pci,host=02:00.1\
 -vga none\
 -soundhw hda\
 -drive file=/dev/sdb,id=diska,format=raw\
 -drive file=/dev/sdd,id=diskb,format=raw\
 -cdrom /dev/sr0\
 -usb -usbdevice host:1b1c:1b13\
 -usbdevice host:1b1c:1b12\
 -usbdevice host:1b1c:1c08\
 -usbdevice host:046d:0a1f\
 -usbdevice host:28de:1142 

Today i would to go use virt-manager to manage my virtual machine but if i create a basic virtual machine with only the gpu added the gpu is never used. 
I can see the GPU in the peripheral manager but it's in error 43. 
The -cpu argument have the same settings as my old setup ( 
-cpu host,kvm=off,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,hv_vendor_id=whatever) 

Before on my old setup if i didn't add those options, the gpu was working i had an image on my screen. 
Here, the screen remain in sleep mode, i have to use a spice screen to see what's going on the vm. 

FYI, guest graphic card is a gtx670 02:00.0 & 02:00.1   [ 10de:1189 & 10de:0e0a ] 

So here's the qemu command line started by virtmanager 

/usr/sbin/qemu-system-x86_64 -name guest=Windows_10,debug-threads=on -S\
 -object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-24-Windows_10/master-key.aes\
 -machine pc-i440fx-2.8,accel=kvm,usb=off,vmport=off,dump-guest-core=off\
 -cpu host,hv_time,hv_relaxed,hv_vapic,hv_spinlocks=0x1fff,hv_vendor_id=whatever,kvm=off\
 -drive file=/usr/share/ovmf/x64/ovmf_x64.bin,if=pflash,format=raw,unit=0,readonly=on\
 -drive file=/var/lib/libvirt/qemu/nvram/Windows_10_VARS.fd,if=pflash,format=raw,unit=1\
 -m 16386 -realtime mlock=off -smp 8,sockets=8,cores=1,threads=1 -uuid fc05f50e-8a97-4c51-a8c5-627824d8075c\
 -display none -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-24-Windows_10/monitor.sock,server,nowait\
 -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime -no-shutdown -global PIIX4_PM.disable_s3=1\
 -global PIIX4_PM.disable_s4=1 -boot strict=on\
 -device nec-usb-xhci,id=usb,bus=pci.0,addr=0x5\
 -drive file=/home/makz/virtio-win-0.1.134.iso,format=raw,if=none,id=drive-ide0-0-0,readonly=on\
 -device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0\
 -drive file=/dev/sdb,format=raw,if=none,id=drive-virtio-disk0,cache=writeback\
 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x8,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1\
 -drive file=/dev/sdd,format=raw,if=none,id=drive-virtio-disk1,cache=writeback\
 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x9,drive=drive-virtio-disk1,id=virtio-disk1\
 -netdev tap,fd=25,id=hostnet0,vhost=on,vhostfd=27\
 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:88:db:2f,bus=pci.0,addr=0x3\
 -device intel-hda,id=sound0,bus=pci.0,addr=0x4\
 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0\
 -device vfio-pci,host=02:00.0,id=hostdev0,bus=pci.0,addr=0xa,rombar=0\
 -device vfio-pci,host=02:00.1,id=hostdev1,bus=pci.0,addr=0xb,rombar=0\
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x7\
 -msg timestamp=on 


Here's my xml. 

<domain type='kvm'>
  <name>Windows_10</name>
  <uuid>fc05f50e-8a97-4c51-a8c5-627824d8075c</uuid>
  <memory unit='KiB'>16779264</memory>
  <currentMemory unit='KiB'>16779264</currentMemory>
  <vcpu placement='static'>8</vcpu>
  <os>
    <type arch='x86_64' machine='pc-i440fx-2.8'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/ovmf/x64/ovmf_x64.bin</loader>
    <nvram>/var/lib/libvirt/qemu/nvram/Windows_10_VARS.fd</nvram>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
      <vendor_id state='on' value='whatever'/>
    </hyperv>
    <kvm>
      <hidden state='on'/>
    </kvm>
    <vmport state='off'/>
  </features>
  <cpu mode='host-passthrough'>
    <topology sockets='8' cores='1' threads='1'/>
  </cpu>
  <clock offset='localtime'>
    <timer name='hypervclock' present='yes'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <pm>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
  </pm>
  <devices>
    <emulator>/usr/sbin/qemu-system-x86_64</emulator>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/home/makz/virtio-win-0.1.134.iso'/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source dev='/dev/sdb'/>
      <target dev='vda' bus='virtio'/>
      <boot order='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source dev='/dev/sdd'/>
      <target dev='vdb' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </disk>
    <controller type='usb' index='0' model='nec-xhci'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:88:db:2f'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <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'/>
      <gl enable='no'/>
    </graphics>
    <sound model='ich6'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' 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='0x0b' function='0x0'/>
    </video>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x02' slot='0x00' function='0x1'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </hostdev>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </memballoon>
  </devices>
</domain> 

I hope someone will help me :) 

Have a good day ! 


More information about the arch-general mailing list