Play games in Windows on Linux! PCI passthrough quick guide

Thanks Wolfman, i've subbed and look forward to more vids in the future!

1 Like

Nice tutorial, just as a quick note, you don't NEED an extra mouse and keyboard, you can just install the OS as you normally would in a VM, the shut it down, add the card in the config, and then run the VM again, and install your drivers, the virtual-screen will act as a secondary screen after that (if you decide to keep using it). Also, if you keep you virtual screen you can actually just click on it so the VM grab mouse and keyboard, just as in a regular non-passthrough scenario; it may feel laggy for some people though.

That won't work. (At least with Nvidia)

As soon as you pass the GPU through it has to be the spice server or the gpu. The GPU won't be recognized by Windows with the spice video still attached.

But I do that with my 960, what are you using?

980 If I pass both through the 980 shows up as "Microsoft Basic Display Adapter" in device mansger and doesnt work. Only when I remove spice video does the driver kick in.

That happened to me when I tried windows 7 (so no ovmf) without the linux-vfio kernel.
I'm currently just using the windows 10 enterprise evaluation and it works fine with ovmf on the vanilla kernel.

I'm using Arch, if that matters.

Distribution shouldn't matter but it might be windows 10 that does it.

What changes is the version of the packages, specially with rolling distros, maybe that was a bug fixed on a qemu version ( or some of it's dependencies ) that your distro still hasn't officially updated yet, but if you were using windows 7 that's probably the problem, you could try 8.1 too if you don't want to try 10, I haven't had any problems with 8.1.

It's debian stretch, that's what I wrote the guide with and I say to use.

Stretch is on virtmanager 1.4.0, libvirt 2.4.0, and qemu 1.2.7. What are your versions?

for PCI pass-through is it better to set the VM to use 3 cores and have 1 dedicated to linux or can I set the VM to share all 4 cores between linux and windows?

Depends. If you are going to be doing stuff on the host at the same time allowing it to have a free core is not a bad idea.

However Linux is very good at scheduling so giving the VM 4 cores will have almost no difference in performance.

I'm using just plain qemu, without virt-manager, it's on version 2.7.0-2

So I'll just jump in here and ask for help. My VM broke after doing an update yesterday morning, and I haven't been able to figure out what happened. For reference here is my thead: my thread

Quick backstory: Started doing hardware passthrough almost a year ago. Been using it the entire time to play games on and off. System is an Asus Z170-A, i7-6700k, 32GB RAM. Host OS is Fedora 23. VM storage is a 128GB img file and a ~200GB img file for more (game) storage, both on a separate 1TB hard drive. Performance and stability have both been excellent.

After doing some troubleshooting (thanks to @The_Cable and @Deathright82 for the help) I am leaning towards the OVMF UEFI getting borked somehow. I know it updated, and both VMs that use it can't boot now.

Not really sure where to go next. Any help would be greatly appreciated.

edit: Oh, and the guide I used to set my passthrough up is here: link It is very similar to your @GrayBoltWolf guide.

So what are the symptoms? When you try to boot the VM what happens?

I did use that guide for some input. if you followed that guide exactly I am going to assume that the startup script that redirects the GPU to vfio is broken. Make sure that it is still loaded with vfio in the output of lspci -k.

Symptoms are three of four cores assigned to the VM are maxed a few seconds after starting the VM and the monitor attached to the video card goes to sleep or does not wake. If I remove the video card from the VM and set up video all I get is a black screen in the window.

I have checked to see what driver is attached to the video card, and it is indeed VFIO.

So my recommendation is to get it working without the GPU passed through first.

Can you attach your libvirt config? Should be in /etc/libvirt/qemu/

That's basically where I am now. Trying to get it working without the passthrough.

Here's a pastebin: link redacted

Everything looks good. Do you need the ACS patch and what kernel version are you on?

Kernel 4.7.0 broke VFIO. 4.7.5 works. If you try VFIO on 4.7.0 it gives you a black screen.

My kernel is 4.9 rc5. I had been on 4.9 rc3 for a week or two, and it worked fine. It worked fine all through the 4.7 rc and 4.8 rc kernels too. I tried booting into rc3 again, but it still won't work.

And just to make sure the kernel driver in use is vfio-pci, not just the kernel module?

Subsystem: eVga.com. Corp. GM204 [GeForce GTX 980]
Kernel driver in use: vfio-pci
Kernel modules: nouveau