I’m using Linux as my main OS for some time now and I’m almost perfectly happy about it. Why almost? Because I’m a gamer and I don’t like compromises. So even if I totally support Linux-gaming revolution which Steam/Valve brought I won’t quit playing games which I’d like to play just because they don’t have Linux version. I was WINE using a lot, but it still didn’t support a lot of my games.
For some time I dual-booted with Windows. It was very irritating, because it forced me to close all my opened software, wait to shutdown first OS, wait to boot my computer and then start second OS… It was so irritating that when I bought notebook capable of ‘so-so’ running games, I connected it to the second input of my main monitor and played games like Diablo 3 on it (running Synergy for comfort).
That, of course, wasn’t best solution – two machines running instead of one and also my laptop’s GPU is way worse then my desktop one (no surprise). However I haven’t figured out better way until I found some info about VGA Passthrough.
That magic solution was my remaining piece – with help of KVM and Qemu, it allows to create virtual machine with its own, fully accessible graphic card. Passing CPU power and memory wasn’t problem for VMs for years but for PCI devices such as GPU it’s kinda revolution.
How does it work exactly? I’ve got two graphic cards, but I’m not using SLI neither Crossfire – my Arch Linux (primary OS) only sees GeForce 9800 GTX+ card and it’s using it exclusively. Second GPU – AMD Radeon 4850 in my case – is visible only for virtual machine with Windows and is available only for it – which means it’s properly detected by AMD drivers without any performance drops which happens when GPU’s emulated.
I’ve not actually ran any benchmarks, because it works just great. When I installed Diablo 3 and it just flew on high settings, I knew that’s exactly the solution I was looking for. Some other games I tested, like Disciples 3 or Assassin’s Creed 3 (which is rather GPU-heavy) also run with no difference than on the Windows-only system.
Instalation wasn’t pretty and it forced me to compile kernel with custom patches for Linux, add few kernel parameters into GRUB, some script-fiddling and also I was fighting for while to use nvidia proprietary driver instead of open-source one. On the other hand, I used virt-manager tool to configure VM and it was very nice and easy to use. Just set-up how much CPU cores and memory I want to add, create file image for disk, few more click to passthrough some devices like mouse, keyboard, integrated sound and GPU obviously – then it’s ready.
The only really painful thing about this technology is required hardware. It requires VT-x (or AMD-V on AMD processors) which are quite common CPU extensions, but also VT-D (or IOMMU), which are not. It’s easy to check which Intel chips have them (sad thing for powergamers – almost none with overlocking abilities), but it’s very hard to find motherboards which must also support both of them. It’s so risky business that people are making lists of working hardware.
I went with AsRock Z77 Extreme4 motherboard and Core i5 3550 CPU, which both were confirmed few times to work with VGA Passthrough and I can say that it was very good decision. They aren’t so pricey, yet I like them both very much already. :) I gave 2 of 4 cores and 3 of my 8 GiBs RAM to VM, but I’m going to buy another 4 GiBs and give it exclusively for VM(s). I’m also going to change Radeon 4850 for some more powerful, eyefinity-capable GPU in next year. I’ll also setup “Lintendo” gaming VM (propably with SteamOS) so I don’t need to change both GPUs. ;)
What can I say more? I highly suggest all Linux-loving gamers to take a look at this technology and build it for yourself if you’re tech-savy enough – it took me about 1,5 days to set this up, but a lot of work was done thanks to excellent creators of guides which I link below.
Guides and other helpful links:
VT-D How-To [Xen Wiki]
Some tips from me:
- There’s big “battle” between Xen and KVM/Qemu – I was going to start with Xen, but it lost compatibility with Nvidia blob driver some time ago.
- Don’t give up when Radeon GPU is passed through and it gives “Code 43” error with Microsoft’s default drivers – just install AMD one and you’re set! Lost some hours when trying to fix non-existing issue.
- It’s rather obvious to me now, but it’s needed to use DKMS on self-compiled kernels for Nvidia driver.
- Virt-manager has good VNC viewer built-in which is helpful especially when you’re configuring input devices.
Synergy’s great for optimising number of input devices in that setup, but it had some weird behaviour when cursor was passed from Linux host to Windows guest – now I passthrough USB mouse and KB, then I run Synergy server on virtual machine to control Linux on other then center monitors.Just use “relative mouse movement” and “lock cursor to screen” in Synergy, works excellent.