Qemu/KVM + vfio = Virtual machine for gaming with 95% of native performance = no more dual booting

preview_player
Показать описание
Hi guys,

here's a demo of how I'm using Qemu/KVM + vfio to play Windows games in a VM running on Linux.

If you are dual-booting and hate loosing access to all you'r Linux apps while playing read on! If you're hardware support's it(2 gpus, VT-d) you might be able to do the same thing.

I start Linux and X.org using the onboard gpu and display a simple xfce on both monitors(xinerama).
Whenever I feel like playing Windows games I disable the left monitor using xrandr and start qemu which uses the passed-through pcie gpu as vga.

Now I have Windows on the left and Linux on the right. Keyboard and mouse are shared using synergy.

After finishing playing I simply shutdown Windows and extend the Linux desktop back to both screen(xrandr).

As you can tell by looking at the benchmarks(linked below) I get about 95% performance in the VM compared to native playing.
I still haven't maxed out the Linux configuration, so I might be able to get even more out of it, something close to 98% should be possible.

Please note that you'll need both a VT-d capable CPU and mainboard(or the AMD equivalent). And of course, 2 gpus, for example 1 dedicated PCIe card the onboard gpu of a core i* processor.

Hardware used:
- CPU: Core i7 4771
- Mainboard: ASRock Fatal1ty Z87 Killer
- GPU 1: Onboard Intel HD Graphics 4600 (i915), HDMI connected to left monitor, DVI-D connected to right monitor
- GPU 2: Gigabyte Windforce GTX 770, DVI-I connected to left monitor

Software used:
- Base: Gentoo Linux ~amd64
- Qemu: Git version of 2014-02-02 (1.7.50). 1.7.0 is too old and won't work, at least not with nvidia cards.

Benchmarks:
Рекомендации по теме
Комментарии
Автор

I dream of a future where this kind of thing is simple and we can all use our Linux, Mac OS Hackintoshe's and just have windows for the games...

D-One
Автор

I use Gentoo because it's my personal distro if choice. It's possible with any distro, the only thing to consider is that you need very recent software, so you may have to compile the kernel and/or qemu manually.

I started the VM with "-soundhw hda", this way Windows is just another sound source for pulseaudio running on the host.
With vfio you can basicly passthrough any pci(and pcie) card. The most complicated thing to do is vga, because these require special initialization. Passing through a pci sound card and connecting it to a second set of speakers or a sound switch should be really easy.

blubird
Автор

Paige Thompson cool, didn't know about those hyper-v enlightements, managed to squeeze yet a bit more performance out of it, now I'm at 99.6% compared to native :-)

blubird
Автор

Nah KVM has been around for this long holy shit

ISAK.M
Автор

So freaking awesome! my openSUSE will rule my desktop at last!

EduardoAbantoB
Автор

Very cool. Think I'm going to have to do this.

fboyd
Автор

This just made me drool ... awesome work man :)

atkhan
Автор

Really cool! I'm working on a similar solution too just now. I've tried it before but I didn't get it to work but since the software has matured a bit I'm trying again. It's looking good so far, I am installing Windows right now.

procrastinator
Автор

That 5% would probably make me to install windows again (unless I have a great hardware), but its great to see how good windows runs virtualized.

edocamoro
Автор

Wow, this is amazing :) I've been looking for a while for such arrangement for my desktop. Can we run CAD softwares this way? Like Solidworks, Catia etc.

soc
Автор

can you please do a tutorial on that this is fucking sick! Then i could finally switch to linux, gaming is the only thing that holds me on windwos ...

HSGEntertainment
Автор

For Linux's User who can't live without windows.

NattaponPanrob
Автор

Hey Awesome desktop I'm going to build my own computer soon and was looking for the best parts (prob going to wait for intel broadwell k edition [should i get this or wait for the tick cycle?]) maybe nvidia gtx 780 or a new card released by early 2015 (future proof 4k [is sli possible?]). I am more of a Ubuntu/Arch fan and haven't really looked further than those two distros since i am new to linux, can you link to a guide or upload a guide to apply the  patches to the kernel, or how to use git (I really only use git for android source so im not sure how to use it outside of that context) to pull the lastest and compile the source for my system. Thanks, again, awesome video! 

GabrielGabeRodriguez
Автор

Awesome! I was just wondering if the virtual win will survive gaming. 

altar
Автор

Hi dude. Can you share the xrandr scripts you used? Im planning to make sth like yours

Utku
Автор

hi blu3bird84 is there any tutorials or tips tricks how to configure multiple monitor with xrandr or somethin, cause my xrandr didn't detec auto

agustriberry
Автор

Great video and nice setup. I have similar setup with yours and i was thinking to create the same virtualization with yours but more seats(multiseat-more usb keyboars/mice, vgas). The second monitor after nvidia vga is passthroughed shows the signal from the vga, doesn't it? May i ask why you have used unix socket and you netcat to that one in your script?I didn't understand the comment in the script(# connect user to monitor).

Thanks in advance. BR

poseidonasgr
Автор

@blu3bird84
How big is the performance drop compared to running the game and windows directly on the real hardware without KVM?

OpenGLever
Автор

Just curious. Are you still using qemu 1.7.50 now, or have you jumped to 2.x?
Also I'm curios about your audio setup. I read in the comments that you use pulseaudio but my experience with it was not what I would call ideal. Under what user do you run pulse on your system and under what user do you run you VM? Did you make any changes to pulse config?

Anyway I want to thank you for posting this video and sharing the information about your particular setup, it helped me a lot.

darthbanana
Автор

hi man, i am so sorry bother u here, i just have some qestion about synergy, u means synergy install after windows install over?and synergy must use network to use, if synergy have a detail install process is better, , thanks!

syweywang