Disclaimer: Nobody else tested my setup so far, so this is a "works on my machine" scenario. I am not responsible for anything you break on your machine (although I'd not expect much harm).
My system has the following hardware:
- Board: Asus ROG Strix Z270G
- Processor: Intel i7-7700k (4 x 4,2GHz)
- GPU (Primary): Palit GeForce GTX1080 Dual OC (at
0000:01:00.*
, IDs are10de:1b80
and10de:10f0
) - GPU (Secondary): AMD Radeon Pro WX3100 (at
0000:02:00.*
, IDs are not relevant)
usage.nix
contains the relevant snippet of my configuration where I use preexisting modules and my custom ones.win_vm.xml
contains thelibvirtd
xml dump of my Windows 10 guest- It is customized to my setup, I only use this one for gaming
- Line ~37 was required to prevent the classical nvidia qemu driver problem
- GPU Passthrough in Line 124-130
- I use a custom rom file for my GPU (Line 128) - this might be dangerous to do
looking-glass
in the section from Line 147- HID passthrough in Line 154-161
- Audio Passthrough in Line 162/163
virtualisation.nix
is a module to augment thevirtualisations
subtree by the ability to create shared memory files. This is required forlooking-glass
andpulseaudio-scream
(orpulseaudio-ivshmem
)- Audio integration is not tested by me. Last time I checked, neither
pa-scream
norpa-ivshmem
were available and it did not annoy me enough to play around with it
- Audio integration is not tested by me. Last time I checked, neither
vfio.nix
contains the biggest part of the config. It allows setting a few properties like:IOMMUType
, eitherintel
oramd
, sets the apropriate kernel parameters for IOMMUdevices
, which is a list of PCI IDs that shall be bound tovfio-pci
disableEFIfb
disables the EFI framebuffer. I pass through my primary GPU, so I need to prevent the kernel from touching itblacklistNvidia
additionally blacklistsnvidia
andnouveau
kernel modulesignoreMSRs
toggleskvm.ignore_msrs
as a kernel parameterapplyACSpatch
applies the well known ACS patch to weaken the IOMMU grouping. IMPORTANT: This results in a kernel compilation in most cases.
libvirt.nix
adds twovirtualisation.libvirtd
optionsdeviceACL
adds devices to thecgroup_device_acl
option, which is often required to access the devices from qemuclearEmulationCapabilities
toggles theclear_emulation_capabilities
setting forqemu
- DANGER: qemu still runs as root
- Add any shared memory audio solution
- Bake the
libvirt
xml file into the system configuration - I have a strange bug where I need to destroy the VM once, elsewise it won't boot
- After doing that once, I can start/stop as often as I want (although I can not use the reboot function out of the guest system)
- I suspect that there is some windows/nvidia/pcie voodoo required to resolve it, but it did not bother me enough to try to fix it
- Basically, I start the VM once per boot with these steps:
virsh -c 'qemu:///system' start vm_gaming;
sleep 3;
virsh -c 'qemu:///system' destroy vm_gaming;
sleep 3;
virsh -c 'qemu:///system' start vm_gaming;