vga-passthrough: nvidia GTX 1050

A long time ago I wrote about vga-passthrough but now I make a little hardware upgrade.

Hardware
  • CPU: AMD FX 6100
  • Motherboard: MSI 970A-G43 PLUS (MS-7974)
  • Host VGA: Nvidia
  • Guest VGA: Nvidia GTX 1050
  • Host OS: Ubuntu 16.10 (4.8.0-46-generic)
  • Guest OS: Windows 7

Configuration

Basically the configuration procedure same as I wrote before but with few important nuances.

firs nuance:

You will need to use proprietary video card driver. I using nvidia-375 from Ubuntu repo.

second:

Because of I using two nvidia cards in my hardware configuration then I need to define it all into DRM soft dependencies

cat << EOF > /etc/modprobe.d/drm.conf  
softdep drm pre: vfio vfio_pci post: nvidiafb nouveau nvidia_375_drm nvidia_375  
softdep drm_kms_helper pre: vfio vfio_pci post: nvidiafb nouveau nvidia_375_drm nvidia_375

install drm /sbin/modprobe vfio; /sbin/modprobe vfio_pci  

And set same options for VFIO

cat << EOF > /etc/modprobe.d/nvidia-pre.conf  
softdep nvidiafb pre: vfio vfio_pci  
install nvidiafb /sbin/modprobe vfio; /sbin/modprobe vfio_pci

softdep nouveau pre: vfio vfio_pci  
install nouveau /sbin/modprobe vfio; /sbin/modprobe vfio_pci

softdep nvidia_375_drm pre: vfio vfio_pci  
install nvidia_375_drm /sbin/modprobe vfio; /sbin/modprobe vfio_pci

softdep nvidia_375 pre: vfio vfio_pci  
install nvidia_375 /sbin/modprobe vfio; /sbin/modprobe vfio_pci  

Stating VM with GTX 1050

Main difference with previously post is qemu startup options.

cat << EOF > ~/bin/qemu-windows-7  
qemu-system-x86_64 -enable-kvm -M q35 -m 4096 -cpu host,kvm=off -smp 4,sockets=1,cores=4,threads=1 \  
    -bios /usr/share/qemu/bios.bin -vga none \
    -device ioh3420,bus=pcie.0,addr=1c.0,multifunction=on,port=1,chassis=1,id=root.1 \
    -device piix4-ide,bus=pcie.0,id=piix4-ide \
    -netdev tap,id=net0 -device e1000,netdev=net0,mac=52:54:00:26:7F:96 \
    -device vfio-pci,host=02:00.0,bus=root.1,addr=00.0,multifunction=on,x-vga=on \
    -device vfio-pci,host=02:00.1,bus=pcie.0 \
    -usb -device usb-host,hostbus=8,vendorid=0x046d,productid=0xc326,id=hostdev0 \
    -usb -device usb-host,hostbus=8,vendorid=0x09da,productid=0x9033,id=hostdev1 \
    -soundhw hda \
    -drive file=/var/lib/libvirt/images/windows7.img,if=none,id=disk,format=$img_format -device ide-hd,bus=piix4-ide.0,drive=disk \
    -vnc :1