Play games in Windows on Linux! PCI passthrough quick guide

First of all, nice video and post!

I am currently using dual boot (win10, ubuntu 16.10) but this seems very promising. Actually I keep windows only for 2-3 games and this would be very helpful..

My setup is:
Intel 4790k,
Asus Z97-A
EVGA GeForce 970gtx
GSkill 16 GB

Is it possible to support this for high performance games (like NBA 2k17)? I do not have a spare GPU.
And something else, If I use my CPU graphics when the VM is running with the 970, which graphics are there going to be used when the VM is not been used? The CPU's or the GPU's??

Thanks in advance.

With the current limitations, you'll be using the cpu-integrated GPU 100% of the time, since you detach the 970 from the Linux drivers. That said, I've heard of people hot-swapping the GPU.

If you need more help you should check out reddit.com/r/vfio and their discord channel for realtime best-effort assistance: https://discord.gg/Kvbz5

Thanks for the reply,

So do you propose to add a second GPU to my system? In my point of view, isn't this a waste for the 970?

depends on what you're doing. if you want to game on the host and the guest, then you need 2 gpus. if not, no harm, no foul. If you do go the 2 gpu route, get an AMD card for the guest and keep the 970 on the host, because having the same card or cards from the same vendor can have you running into gotchas, and nvidia support (at present) is better in linux if you don't care about using closed drivers. I use a 1070 in my host system and a fury in my guest, for example.

1 Like

I have gotten thru the guide but at the part where you suppose to start the VM after removing all the video splice, etc, I keep running into this error:

Error starting domain: internal error: qemu unexpectedly closed the monitor: warning: host doesn't support requested feature: CPUID.01H:EDX.ds [bit 21]
warning: host doesn't support requested feature: CPUID.01H:EDX.acpi [bit 22]
warning: host doesn't support requested feature: CPUID.01H:EDX.ht [bit 28]
warning: host doesn't support requested feature: CPUID.01H:EDX.tm [bit 29]
warning: host doesn't support requested feature: CPUID.01H:EDX.pbe [bit 31]
warning: host doesn't support requested feature: CPUID.01H:ECX.dtes64 [bit 2]
warning: host doesn't support requested feature: CPUID.01H:ECX.monitor [bit 3]
warning: host doesn't support requested feature: CPUID.01H:ECX.ds-cpl [bit 4]
warning: host doesn't support requested feature: CPUID.01H:ECX.vmx [bit 5]
warning: host doesn't support requested feature: CPUID.01H:ECX.est [bit 7]
warning: host doesn't support requested feature: CPUID.01H:ECX.tm2 [bit 8]
warning: host doesn't support requested feature: CPUID.01H:ECX.xtpr [bit 14]
warning: host doesn't support requested feature: CPUID.01H:ECX.pdcm [

Traceback (most recent call last):
File "/usr/share/virt-manager/virtManager/asyncjob.py", line 88, in cb_wrapper
callback(asyncjob, *args, **kwargs)
File "/usr/share/virt-manager/virtManager/asyncjob.py", line 124, in tmpcb
callback(*args, **kwargs)
File "/usr/share/virt-manager/virtManager/libvirtobject.py", line 83, in newfn
ret = fn(self, *args, **kwargs)
File "/usr/share/virt-manager/virtManager/domain.py", line 1404, in startup
self._backend.create()
File "/usr/lib/python2.7/dist-packages/libvirt.py", line 1035, in create
if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
libvirtError: internal error: qemu unexpectedly closed the monitor: warning: host doesn't support requested feature: CPUID.01H:EDX.ds [bit 21]
warning: host doesn't support requested feature: CPUID.01H:EDX.acpi [bit 22]
warning: host doesn't support requested feature: CPUID.01H:EDX.ht [bit 28]
warning: host doesn't support requested feature: CPUID.01H:EDX.tm [bit 29]
warning: host doesn't support requested feature: CPUID.01H:EDX.pbe [bit 31]
warning: host doesn't support requested feature: CPUID.01H:ECX.dtes64 [bit 2]
warning: host doesn't support requested feature: CPUID.01H:ECX.monitor [bit 3]
warning: host doesn't support requested feature: CPUID.01H:ECX.ds-cpl [bit 4]
warning: host doesn't support requested feature: CPUID.01H:ECX.vmx [bit 5]
warning: host doesn't support requested feature: CPUID.01H:ECX.est [bit 7]
warning: host doesn't support requested feature: CPUID.01H:ECX.tm2 [bit 8]
warning: host doesn't support requested feature: CPUID.01H:ECX.xtpr [bit 14]
warning: host doesn't support requested feature: CPUID.01H:ECX.pdcm [

So changed some settings and seem to be getting this now?

Unable to complete install: 'internal error: qemu unexpectedly closed the monitor: 2017-01-31T02:32:07.612457Z qemu-system-x86_64: -device vfio-pci,host=01:00.0,id=hostdev0,bus=pci.0,addr=0x6: vfio error: 0000:01:00.0: failed to setup INTx fd: Operation not permitted'

Traceback (most recent call last):
File "/usr/share/virt-manager/virtManager/asyncjob.py", line 88, in cb_wrapper
callback(asyncjob, *args, **kwargs)
File "/usr/share/virt-manager/virtManager/create.py", line 2288, in doasync_install
guest.start_install(meter=meter)
File "/usr/share/virt-manager/virtinst/guest.py", line 461, in start_install
doboot, transient)
File "/usr/share/virt-manager/virtinst/guest.py", line 396, in createguest
self.domain = self.conn.createXML(install_xml or final_xml, 0)
File "/usr/lib/python2.7/dist-packages/libvirt.py", line 3517, in createXML
if ret is None:raise libvirtError('virDomainCreateXML() failed', conn=self)
libvirtError: internal error: qemu unexpectedly closed the monitor: 2017-01-31T02:32:07.612457Z qemu-system-x86_64: -device vfio-pci,host=01:00.0,id=hostdev0,bus=pci.0,addr=0x6: vfio error: 0000:01:00.0: failed to setup INTx fd: Operation not permitted

i'm having trouble with the $ patch -p1 < [acs patch location here]
I keep getting the errors
can't find file to patch at input line 4
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:


|diff -uNr linux-source-4.7/Documentation/kernel-parameters.txt linux-source-4.7-acs/Documentation/kernel-parameters.txt
|--- linux-4.2.5/Documentation/kernel-parameters.txt 2015-10-26 17:53:59.000000000 -0700
|+++ linux-4.2.5-acs/Documentation/kernel-parameters.txt 2015-11-02 18:02:28.643526086 -0800


File to patch:

and when i provide the patch it says :
File to patch: '/home/name/Downloads/acs-patch-4.7.patch'
'/home/name/Downloads/acs-patch-4.7.patch' : No such file or directory
Skip this patch? [y]

any idea what I should do?

You could try with this patch if your using a kernel 4.8+ might fix you're problem. https://www.reddit.com/r/VFIO/comments/59t2zd/acs_override_on_ubuntu_1610_kernel_480_patch_hunk/

1 Like

I have this working on Ubuntu 16.10 with 1 last hoop to jump through and 1 limitation.

I can't get sound quality to be acceptable on a Win10 x64 guest. I tried with ICH6, ICH9, MSI interrupts, bluetooth sound (passing adapter through to vm), USB sound (tried passing through device as well as host controller), and passing guest sound through to pulseaudio, but I'm still having huge latency and distortion issues.

Final trick will be to install a PCI sound card and pass that through to the host. If that does not work, I'm pausing this for now as gaming makes no sense this way. Sound over DP is not an option, my screen doesn't have audio out.

"Fun" fact/limitation: AppArmor did not play nice with USB passthrough, so I removed it for now. If I get sound figured out I'll set this up passing through the USB host controller, and re-enable apparmor.

i had try it via pci sound card a while back and it did work well for me now im currently redoing my kvm set up in Debian stretch with kernel 4.9.0 i might also add a usb pci card to my set up.

thanks that worked, now its running into problems running the " make -j4 deb-pkg " command
errors:
scripts/package/Makefile:91: recipe for target 'deb-pkg' failed
make[1]: *** [deb-pkg] Error 2
Makefile:1346: recipe for target 'deb-pkg' failed
make: *** [deb-pkg] Error 2

That not the error just like @GrayBoltWolf said to me earlier in this thread it just mean the entire built fail the error is further up the output. If your having the same error i had it related to a certificate. i comment out the following to fix it in the ACS patch:

#CONFIG_SYSTEM_TRUSTED_KEYRING=Y
#CONFIG_SYSTEM_TRUSTED_KEYS="debian/certs/[email protected]"

Hope it helps,
Cheers

any idea why it might crash when i start the vm?
the gpu fans spin up. then slow down and then spin up once more, then it says the vm has crashed.
link to log file: http://pastebin.com/6GSkaBgd
it seems that qemu 2.8 has problems when you pass through usb devices. removing these causes the vm to boot.
now I just need to figure out why I don't have video.

Interesting im having the same problem if i have a usb passthrough to the vm it crash if i remove the usb passthrough it boot but can install windows. Mabie a work around could be installing a pci 1x usb controller and pass that to the windows vm if not im not sure how to install windows.

This happens if you switch the controller to USB3. I'm not sure why but this is a recent issue.

@pl9090

1 Like

Nice work there! Just subbed for future videos but I also have a question. How are things with Windows 10 OEM Keys? If you change your mainboard or CPU (which I have done with my 7700k upgrade) the Windows OEM license expires and you have to buy a new one. Now my question is: Will the hardware change inside the KVM and will Windows recognize these changes (and disable my license) or will my mainboard and CPU show up exactly as the same one as the host system?

Hi! I have done everything same way as you in the tutorial. I am using gtx 970 and everything works flawless until the boot of VM. When i boot the wm, the installation goes straight to UEFI shell. Do you have any idea why this would be happening? Thanks for the great guide!

EDIT: i have tested it with different combinations, and now i know there is something wrong with OVMF bios. It works with normal bios (not the pci passthrough ofc) but when i change it tho OVMF it only goes to UEFI shell...

My guess is OVMF is not finding the Windows iso to boot from. You should have two disks, one being for Windows itself, mine is /var/lib/libvirt/images/win10.qcow2, this is SATA Disk 1.The other one I have is SATA CDROM 1 which points to the Windows10.iso. If I click on disconnect on the SATA drive so the Source Path points to nowhere, I can replicate your issue. Also make sure your Disk 1 and CDROM1 are both enabled under 'Boot Options'.

Hi and thanks for the quiock answer! I got the windows 10 up and running but now i have second problem. I have tried to install nvidia drivers normally through the geforce experience, and it says that it has succesfully installed the drivers, but the gtx 970 isn't working.

Device manager shows the NVIDIA gtx 970 with errorcode 43 and the "pci device" and "multimedia audio device" also with error? Any idea what's wrong with this?

EDIT: Hmm very strange. I edited my vm configuration and got the gpu working. Ten i shut down the vm and installed synergy to my debian host(not sure if this is related) But now the gpu ain't working again after i rebooted the win VM :/