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:1b80and10de:10f0) - GPU (Secondary): AMD Radeon Pro WX3100 (at
0000:02:00.*, IDs are not relevant)
usage.nixcontains the relevant snippet of my configuration where I use preexisting modules and my custom ones.win_vm.xmlcontains thelibvirtdxml 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-glassin the section from Line 147- HID passthrough in Line 154-161
- Audio Passthrough in Line 162/163
virtualisation.nixis a module to augment thevirtualisationssubtree by the ability to create shared memory files. This is required forlooking-glassandpulseaudio-scream(orpulseaudio-ivshmem)- Audio integration is not tested by me. Last time I checked, neither
pa-screamnorpa-ivshmemwere 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.nixcontains the biggest part of the config. It allows setting a few properties like:IOMMUType, eitherinteloramd, sets the apropriate kernel parameters for IOMMUdevices, which is a list of PCI IDs that shall be bound tovfio-pcidisableEFIfbdisables the EFI framebuffer. I pass through my primary GPU, so I need to prevent the kernel from touching itblacklistNvidiaadditionally blacklistsnvidiaandnouveaukernel modulesignoreMSRstoggleskvm.ignore_msrsas a kernel parameterapplyACSpatchapplies the well known ACS patch to weaken the IOMMU grouping. IMPORTANT: This results in a kernel compilation in most cases.
libvirt.nixadds twovirtualisation.libvirtdoptionsdeviceACLadds devices to thecgroup_device_acloption, which is often required to access the devices from qemuclearEmulationCapabilitiestoggles theclear_emulation_capabilitiessetting forqemu
- DANGER: qemu still runs as root
- Add any shared memory audio solution
- Bake the
libvirtxml 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;