VM screen of unraid
Saturday

I am giving up on VM Gaming

By Norbert TakΓ‘cs Β·

6 years ago I got lured into the promises of VM gaming with the original 2 Gaming Rigs, 1 Tower Linus Tech Tips video. It described how one could use virtualisation software (Unraid or Proxmox) on the host, spawn virtual machines with physical graphics cards using PCIe passthrough, and achieve near identical gaming performance. You could even slice up your existing storage and CPU easily or pass them as is.


Like many others I also owned an under utilised gaming pc. Most of the times the hardware was sitting idly waiting to be turned on for those hourly gaming sessions.

1 Gaming PC, 1 NAS

Unlike what Linus ended up doing I wasn't drawn to the idea because I had more than one player wanting to play games and was constrained by hardware. It was the potential to utilise my gaming pc as a network attached server mainly and gaming pc secondly. At the time I already owned the beefiest consumer 8 bay Synology 1817+ NAS money could buy and was not pleased with the performance it's Intel Atom C2538 CPU provided.

Unraid host OS

I opted for Unraid since it had a more mature PCIe passthrough experience out of the box compared to Proxmox and it was also the OS that the original video used. Both systems use the same KVM/QEMU/Virtio stack. The performance boost my docker workloads received after switching to an Unraid host gaming PC NAS combo were night and day compared to the Intel Atom Synology NAS.

Gaming VM issues

Only draw back was that VM gaming was a bit of a nuance to use. Some of it was expected since I was running an experimental setup, and I don't shy away from tinkering, I brushed them off as issues that can be solved.

πŸ’Ύ SOLVED: VM State management

To start out, managing the VMs state has to be done through the UI of the host OS. Every time you want to turn on/off/restart the VM, you have to preform a bit of click-ops on a website. There are creative ways around this using third party devices which would interact with the API directly, I have used home-assistant to control the state of the VM.

πŸ’½ SOLVED: USB passthrough

To be able to use USB devices you need to attach them to the VM. This can be done in the web UI, but it means every time you attach a new usb drive you have to click yourself through to attach the device. If the device glitches and disconnects, you have to do it over again. Instead if you pass through a PCIe USB controller, Fresco Logic FL1100 in my case, you get to have the plug and play experience you are used to.

Fl1100 can be found from 2 port to 8 port and works with VIRTIO!

🐧 SOLVED: NVIDIA VBIOS patching

This is not required anymore but it's worth mentioning. There used to be an arbitrary error from NVIDIA created to prevent users running GeForce GPUs in virtual environments. To bypass it you had to extract the VBIOS, patch it and load it on runtime in the host os, otherwise the NVIDIA driver would fail to install with an Error 43.

Nvidia purposefully blocking the usage of the GPU in VM-s

🍨 UNSOLVED: GPU sharing with docker and VMs

I was hoping I could use the GPU if the VM was not used for docker containers. This is possible but not user friendly, the GPU has to be bound to VFIO at boot. Meaning if you have setup the GPU for the Gaming VM by binding it to VFIO, and want to test out some docker local LLM, you must first unbind it in the UI, then restart the computer. Trying to use the GPU for both use cases at the same time either results in the docker container not starting, or in worse case the system locking up.

Handy VFIO binding tool in unraid

πŸ—‚οΈ UNSOLVED: Multi VM GPU sharing

Another interesting use case would have been running multiple VMs using a single GPU. You can attach the GPU to multiple VMs but by default only one VM can be running which utilises the GPU. Running multiple VMs simultaneously requires a hardware splitting technology SR-IOV which is already used by many network cards. For GPU-s SR-IOV exists mostly on enterprise Nvidia Ampere level cards which I don't own, and the functionality is further locked into the NVIDIA vGPU stack and require annual licensing. There are supposedly vGPU workarounds but it adds another layer of annoyance on top of the enterprise GPU cost which might not be optimised for gaming, alternatively you could use vgpu_unlock and turn your consumer grade GeForce GPU into its Quadro equivalent.

πŸ₯€ UNSOLVED: Stability, lags, corrupt VMs and dread

There are plenty of fixes you have to perform to get the VM usable, from fixing audio glitches by setting interrupts correctly in MSI manager. CPU Pinning, reserving RAM and passing in real drives have helped with speed and stability. KVM XML tuning became a constant maintenance task to avoid regressions, lag and lockups. I experienced VM degradation, Windows VMs that used to work properly became unbearably slow for no apparent reason. It was also hard for me to evaluate if I was making the right choices with so many variables and I gradually started dreading using the gaming VM more and more. Unraid includes a handy UI for most of the XML changes.

VM screen of unraid

πŸ«‚ UNSOLVED: Multiplayer games and anti-cheat

Most, if not all multiplayer games with anti-cheat won't work, you will get kicked or worse. Easily the biggest issue for most gamers and this can be true across all linux gaming, but it's much worse when using VMs. Most multiplayer anti-cheat software has been blanket blocking all VM players from starting matches. This is because of claims that VMs can be used for cheating by reading the memory from outside of the system as, also mentioned in DEF CON 33 - Playing Dirty w/o Cheating - Getting Banned for Fun but anyone playing multiplayer games knows that there are plenty of cheaters even with the blanket banning of current VM players.

You can spoof BIOS/UEFI headers to bypass these VM checks but inevitably it's a cat and mouse game.

  • BattleEye, the company behind the most popular anti-cheat that even Ubisoft uses, has support for Linux and Mac but the game publisher has to opt-in and this might not cover the VM use case.
  • With Google Stadia (shut down) and Steam Proton I expected the game companies eventually allowing VM usage but I won't hold my breath anymore.
  • Valve is promoting the Epic Games' more forgiving Easy Anti-cheat for linux which is currently used by 594 games and even this solution has been blocking VM usage.
  • Valve's VAC is also kicking players who use VMs, and you don't want to get a VAC ban.

πŸͺ΅ UNSOLVED: Resource starvation

Running a NAS and a gaming PC on single hardware requires balancing the resource usage. I am currently running 60 docker containers and idle at 14GB/32GB free RAM with a cpu usage of 10% across all 6 cores, starting the VM reserves my RAM usage to near max, and would reserve 3 out of 6 cores making the docker unstable if they would need to perform heavy operations such as archive unpacking.

πŸ’Έ UNSOLVED: Time cost tradeoff

Depending on how much you value your time vs cost, VM gaming might make sense on the surface. It sure made sense when I started out, before I understood all the nuances that came with it. Today I wouldn't recommend it to anyone unless you are severely constrained in your budget or space. I am going to split out my GPU into a separate machine which will be used for gaming alone.

Closing remarks

None of these issues mentioned are Unraid specific but rather VM specific. I grew to love Unraid with its opinionated stack and exceptional community, it's by far the easiest and best single host hypervisor in my opinion, have even maintained a third party unraid API before the official one was released and at one point interviewed for an ill fitting position at Unraid.

Since I started using this system I have also learned a lot about computers and I did end up achieving my goal of fully utilising my gaming PC, except it wasn't for gaming.


Join the Discussion on github