The Trivial Guide™ to
Virtual Machines for Gaming

Normally when you run a virtual machine the graphics performance will suffer because a virtual graphics card has to be emulated. But it's possible to let the VM directly access a real graphics card.

You can play games on your computer or use Steam In-Home Streaming to play them on another computer, on the Steam Link or even on an Android device while the games are actually running on a virtual machine. With more cards it's even possible to run multiple virtual machines at once.

Finally this means you can run a secure and modern system that respects your freedom and also play any Windows exclusive title that you can’t live without, today.

Enter at your own risk

Hardware virtualization extensions

Example motherboard for an Intel CPU:

ASUS Z170-P

  1. F2 Enter BIOS at startup
  2. F7 Advanced Mode
    1. Advanced
      1. CPU Configuration
        1. Enable Intel Virtualization Technology
      1. System Agent (SA) Configuration
        1. Enable VT-d (IOMMU)
  3. F10 Save & restart
For AMD it might be known as AMD-V and AMD-Vi or IOMMU

Find and consult your mothersboard's manual when necessary

inxi -M
Machine:
Type: Desktop Mobo: ASUSTeK model: Z170-P v: Rev X.0x
serial: UEFI: American Megatrends v: 3805 date: 05/16/2018
List some machine data including motherboard model

IOMMU grouping

ls /sys/class/iommu
dmar0
Ensure IOMMU is enabled by successfully listing any units lspci | grep VGA
01:00.0 VGA compatible controller: NVIDIA Corporation GP107 [GeForce GTX 1050 Ti] (rev a1)
List PCI video devices ls /sys/bus/pci/devices/0000\:01\:00.0/iommu_group/devices/
0000:00:01.0 0000:01:00.0 0000:01:00.1
List all devices in the same IOMMU group lspci -ks 01:00
01:00.0 VGA compatible controller: NVIDIA Corporation GP107 [GeForce GTX 1050 Ti] (rev a1)
Subsystem: Micro-Star International Co., Ltd. [MSI] GP107 [GeForce GTX 1050 Ti]
Kernel driver in use: nouveau
01:00.1 Audio device: NVIDIA Corporation GP107 HDMI Audio Controller (rev a1)
Subsystem: Micro-Star International Co., Ltd. [MSI] GP107 HDMI Audio Controller
Kernel driver in use: snd_hda_intel
Show kernel drivers in use on a selected bus and slot I recommended using nano instead of vim below

Device reservation

Override all drivers, on a bus above zero, in the same IOMMU group

Driver interception, a simpler way to install the vfio-pci driver early

sudo mkdir /etc/modprobe.d Make the directory modprobe.d in /etc sudo vim /etc/modprobe.d/intercept.conf install nouveau "/sbin/intercept-vfio-nouveau.sh"
install snd_hda_intel "/sbin/intercept-vfio-intel-audio.sh"
    1. Edit a new configuration file
    2. Refer to shell scripts that should run a custom module installation
sudo vim /sbin/intercept-vfio-nouveau.sh echo vfio-pci > /sys/bus/pci/devices/0000:01:00.0/driver_override;
modprobe vfio-pci;
modprobe --ignore-install nouveau;
    1. Edit a new shell script
    2. Override the graphics driver with the vfio-pci module, then install any remaining graphics as normal
sudo vim /sbin/intercept-vfio-intel-audio.sh echo vfio-pci > /sys/bus/pci/devices/0000:01:00.1/driver_override;
modprobe vfio-pci;
modprobe --ignore-install snd_hda_intel;
    1. Edit a new shell script
    2. Override the HDMI audio driver and install any remaining compatible audio as normal
sudo chmod +x /sbin/intercept-vfio-nouveau.sh sudo chmod +x /sbin/intercept-vfio-intel-audio.sh Change file modes to allow the scripts to be executed sudo shutdown -r now Reboot now lspci -ks 01:00
01:00.1 VGA compatible controller: NVIDIA Corporation GP107 [GeForce GTX 1050 Ti] (rev a1)
Subsystem: Micro-Star International Co., Ltd. [MSI] GP107 [GeForce GTX 1050 Ti]
Kernel driver in use: vfio-pci
01:00.1 Audio device: NVIDIA Corporation GP107 HDMI Audio Controller (rev a1)
Subsystem: Micro-Star International Co., Ltd. [MSI] GP107 HDMI Audio Controller
Kernel driver in use: vfio-pci
Show kernel drivers in use on a selected bus and slot

Virtual Machine Manager

One for all Linux games and the other for Windows exclusives

Download Solus Budgie, Windows 10 64-bit and VirtIO drivers Direct link from Fedora

sudo eopkg install virt-manager Install Virtual Machine Manager sudo eopkg install ovmf Install Open Virtual Machine Firmware sudo systemctl enable --now libvirtd.service Start the libvirt daemon now and enable autostart sudo mv ~/Downloads/*.iso /var/lib/libvirt/images Move all downloaded iso files to a more convenient directory

Virtual Machines Creation

They can be installed and run simultaneously until they have been assigned the GPU

Go ahead and proceed unless mentioned

    1. File
    2. New Virtual Machine
    1. Browse...
    2. Choose the Solus or Win10 iso respectively
  1. Customize configuration before install

Configuration customization

    1. Add Hardware
    2. Storage
    3. Device type: CDROM device
    4. Manage...
    5. Choose the virtio-win iso
    Add the virtio Windows driver disc (not necessary for Linux)
  1. ✔ Begin Installation
    1. View
    2. Resize to VM
    3. Improve visibility when needed

Solus installation

  1. Install OS Launch it when the desktop is fully loaded
    1. Just follow the instructions or proceed with defaults
    2. Restart now

Solus upgrade

sudo eopkg upgrade && sudo shutdown now Upgrade to the latest release and shutdown

Windows installation

Press any key to boot from CD or DVD

If you're late on your first attempt, do the following:

    1. Virtual Machine
    2. Shutdown
    3. Force off
    1. View
    2. 🔘 Details
    1. CDROM 1
    2. Connect
    3. Browse...
    4. Choose the Win10 iso
    1. View
    2. 🔘 Console
    1. Virtual Machine
    2. Run

Unless mentioned proceed with defaults and localization

  1. I don´t have a product key It's more reliable to activate after the hardware stops changing
  2. Custom: Install Windows only (advanced)
Loading VFIO drivers
    1. Load driver
    2. Browse
    3. CD Drive (E:) virtio-win
    4. viostor
    5. w10
    6. amd64
    1. Load driver
    2. Browse
    3. CD Drive (E:) virtio-win
    4. NetKVM
    5. w10
    6. amd64
Account (Optional)
  1. Offline account
  2. Sign in with Microsoft Instead? No
  3. Create a really memorable password Next Leave empty to login automatically
Services (optional)

Protect your data and integrity. Just say no.

  1. Do more with your voice Don't use speech recognition
  2. Let Microsoft use your location No
  3. Find my device No
  4. Send diagnostic data to Microsoft Basic
  5. Improve inking & typing recognition No
  6. Get tailored experiences with diagnostic data No
  7. Let apps use advertising ID No

Driver workaround (NVIDIA only)

You can successfully install the official NVIDIA driver if you disguise the VM

sudo virsh --connect qemu:///system Connect the virtual shell to a system instance virsh # edit generic Edit the virtual machine named generic <features> <hyperv> <vendor_id state='on' value='SurelyNotKVM'/> </hyperv> <kvm> <hidden state='on'/> </kvm> </features> Insert any missing XML elements where indicated

Adding real hardware to a VM

The device is already in use by other guests Yes
    1. Select a VM
    2. Open
    3. View
    4. 🔘 Details
    1. Add Hardware
    2. PCI Host Device
    3. 0000:01:00.0 NVIDIA Corporation GP107 [GeForce GTX 1050 Ti]
    1. Add Hardware
    2. PCI Host Device
    3. 0000:01:00.1 NVIDIA Corporation GP107 HDMI Audio Controller
    1. Add Hardware
    2. USB Host Device
    3. 001:003 Logitech, Inc. Classic Keyboard 200
    1. Add Hardware
    2. USB Host Device
    3. 001:007 Holtek Semiconductor, Inc. USB Gaming Mouse
    1. Display Spice
    2. Remove
    1. Video QXL
    2. Remove
    1. Serial 1
    2. Remove
    1. Virtual Machine
    2. Run
  1. Switch your monitor input to the VM's GPU Not needed with LookingGlass

The host devices will be exclusively available to the VM when it runs

More content to come below

Check that 3D works

Unigine Heaven for Linux or Windows

Installing proprietary drivers

sudo eopkg install nvidia-glx-driver-current Install the proprietary NVIDIA driver for the current kernel sudo eopkg install nvidia-glx-driver-32bit Install the 32-bit proprietary NVIDIA driver for steam

Steam

sudo eopkg install steam Install Steam (including Linux Steam Integration) Use Steam In-Home Streaming to stream games, with sound, to the host

Has this been helpful to you? Any token amount is appreciated. [Button]