pci-e passthrough with QEMU on intel / nvidia platform
11 Jun 2017
I will tell you some “success story” about pci-e passthrough Geforce 980 GTX
videocard with QEMU / KVM to Windows 10 guest system for gaming. As the
result you’ll get system almost with no overhead(1-10%). If you are
interested in this welcome under cut.
The config of my desktop:
CPU: Quad core Intel Core i7-4790K (-HT-MCP-)
Mobo: ASUSTeK model: SABERTOOTH Z97 MARK 1 v: Rev 1.xx
A couple of wd black hdd and other things which doesn't matter here
Also we need monitor which support simultaneous working with several outputs
as hdmi/dvi or whatever, for example my asus pa249q supports
that. Also you may simply use a couple of monitors.
Soft which we need:
I've used Kernel: 4.11.3-1-ARCH x86_64 (64 bit) and arch linux
qemu 2.9.0-1
ovmf-git 21772.5225084439-1 from git, for better sound quality
Then you can use following script to get IOMMU groups:
For my system I’ve the following output:
The minimal unit which can be passed by qemu is IOMMU group, if you have
several devices on the same group you may try to use acs-patch, but use it
carefully. I don’t recomment to apply this hack to non-videocard devices. And
also you will probably need patched linux kernel:
linux-vfio(AUR)
You can read better explaination of this on vfio blog:
But leave pci-e controller to the host system. To get it add this to your
/etc/modprobe.d/vfio.conf:
And that’s it. Now you bypassed your GPU to the vfio driver.
Now you need to reboot. Then check it with
If you get Kernel driver in use: vfio-pci then everything is ok any you can
to go further.
I’ve installed Windows 10 for that.
Here is my main qemu parameters for that:
We are need to use KVM instead of emulation of course
I’ve bypassed half of my host memory to vm.
And also copy all my CPU topology here
We are using host cpu with kvm=off to trick out nvidia which
prevents to be used on the latest versions of nvidia driver.
We need it for faster hdd/ssd io-performance.
For my config you need virtio-scsi driver for better io performance. To get it you need to download iso from here
and then use options like this:
Also we need ovmf binary and vars, you may alsa copy it from ovmf_code_x64.bin
to your vm directory as me. To find location of it you may use pacaur -Ql ovmf-git or
mlocate stuff.
And here we added hdd drive itself. You can create it with s qemu-img create
-f qcow2 w7.qcow2 320G
Now you can to install Windows 10.
When you’ve installed that you may bypass your GPU with
respecting ids from virtio driver which we added later using IOMMU Groups
info.
Also you will get some problem with keyboard and mouse, because of vm cannot
to see it. You may to add something like this. But by carefull, because of
while vm is running you will loose your keyboard/mouse on the host.
The one of the biggest troubles here is sound quality. To prevent this
I recommend you -soundhw ac97. Also you need to enable test-singning free
mode. To enable test-signing use Bcdedit.exe -set TESTSIGNING ON. Then
install ac97 driver for windows 7 x64 as usual. Also I’ve get best result
with pulseaudio and following options:
Also here is my client.conf for Pulseaudio:
Here is daemon.conf:
And here is default.pa:
Also you need to calculate opts
for yourself, here is the method:
Where 192000@24 bits are settings for my pulseadio and soundcard.
Here we have 227.55 msesc for device.buffering.buffer_size and 113.7773 msecs for
device.buffering.fragment_size.
To compute default fragments count we are using:
And default-fragment-size-msec is device.buffering.fragment_size
So we got:
After all this manipulations all sound should be clear. Also Winwdows
7 haven’t this problem. Maybe this is because of new high-performance sound
engine inside Windows 8.1/10.