Running games inside a virtual machine used to be a pipe dream, the kind of thing hobbyists would attempt only to be humbled by unplayable frame rates and driver nightmares. That’s no longer the case. With GPU passthrough on a modern hypervisor like XCP-NG, you can get performance that is genuinely hard to distinguish from a native install, while also reaping all the benefits that come with running an OS as a VM: snapshots, easy migration, and the ability to repurpose hardware on a whim.
This post walks through setting up Windows 11 Pro as a purpose-built gaming VM on XCP-NG, including how to stream games to any device on your network using Sunshine and Moonlight. It won’t cover installing XCP-NG or configuring Xen Orchestra from scratch, as that’s a topic for another day. Everything described below is done through the Xen Orchestra VM Console until Sunshine is up and running, at which point Moonlight can be used to stream the desktop.
This is an affiliate link; it helps support keeping my website content up to date.
Before starting, you’ll need to download a copy of the Windows 11 ISO and the Rescuezilla ISO. Ventoy is a great option for setting up the RescueZilla USB disk, and you’ll need the Windows ISO available in an ISO storage repository in Xen Orchestra if you’re starting a fresh install.
Host Machine Hardware #
For reference, here’s the physical machine this setup runs on:
- Motherboard / CPU / RAM: Aorus B550M PRO-P with an AMD Ryzen 9 5900X CPU and 32GB DDR4 RAM
- GPU: NVIDIA RTX 3060 with an HDMI dummy plug (more on why below)
- Storage: Samsung 970 Evo 500GB NVMe SSD (XCP-NG install and virtual disk storage repository) and a TeamGroup Vulkan Z 2TB SSD (for game libraries)
The HDMI dummy plug is an important component of making a headless gaming machine work. Without a display physically connected (or simulated), the GPU behaves oddly; the dummy plug tricks it into thinking a monitor is attached so it initializes correctly and gives you a “proper display” to stream from.
VM Configuration #
Before installing Windows, there are a few things to configure in Xen Orchestra for the VM under Host Advanced settings:
- GPU passthrough: Enable passthrough for both the RTX 3060’s video and audio functions. This hands the GPU directly to the VM, bypassing the hypervisor’s emulated graphics entirely.
- SATA Controller passthrough: Passing through the SATA controller lets the VM access physical SSDs and HDDs directly, including drives already NTFS formatted with games on them. This means your game libraries can be available inside the VM without any copying or conversion.
From this point you have two options depending on your situation: you can either take an image of your current OS setup or start from scratch. Both approaches are outlined below.
Option 1: Fresh Windows 11 Installation #
This is the straightforward path: install Windows 11 from scratch into the VM, configure it, and go play some games.
First, attach a Windows 11 ISO to the VM and boot from it. The installation process is mostly standard by following the prompts, but there’s one gotcha worth calling out: recent versions of Windows 11 have become more aggressive about requiring a Microsoft account during setup. To get around this and create a local account instead, choose Work or School account → Domain join when prompted for account sign-in. This bypasses the online account requirement entirely. If that doesn’t work for you, try following this method instead.
Once you’re at the OS desktop, download and install the NVIDIA drivers and let Windows Update run a few cycles, rebooting as prompted. With GPU passthrough active, the RTX 3060 should appear in Device Manager as if it were installed in a physical machine.
At this point there are a few optional steps worth considering: you can “debloat” Windows (there are a few great utilities out there to do this), and even install AtlasOS to further tailor the performance of the OS. AtlasOS is a Windows modification project focused on reducing background overhead and latency for gaming. It strips out telemetry, disables services that aren’t needed for gaming, and generally tightens things up without breaking compatibility. Apply it once the base drivers and updates are in place.
Apply your Windows 11 Pro license key before moving on. Once the VM is configured to your liking, it’s worth taking a snapshot here as a clean baseline, or even a backup.
Set Up Sunshine and Moonlight #
Sunshine is an open-source game streaming host, acting as a self-hosted alternative to Parsec or NVIDIA GameStream. Once installed, the web interface is accessible at https://localhost:47990, where applications, display settings, and streaming quality can be configured. On first launch, you’ll be prompted to create a username and password for the interface. No port forwarding is required for local network streaming, as Moonlight will discover the Sunshine host automatically via broadcast.
On each device you want to stream from, whether a laptop, Steam Deck, smartphone, or another PC, install Moonlight. When you launch Moonlight, it should detect the Sunshine host on your local network. Connect to it and complete the PIN pairing process.
With streaming working, install Steam, Epic, GOG, or whatever platforms you use and sign in. Your game library is ready to go by pointing each application at the respective library on the hard drive.
Option 2: Migrating an Existing Windows 11 Installation #
If you already have Windows 11 on a machine and you want to repurpose it as an XCP-NG host, you can clone the existing installation and run it as a VM instead. To do so, boot the machine from a RescueZilla USB drive and create a full disk image. It is recommended to shrink the disk volume prior to taking an image as there is a restriction of restoring to the same-sized drive.
Once the image has been taken, store it somewhere safe with enough space available, such as a NAS or external hard drive. It’s your fallback if anything goes wrong down the line.
Next, install XCP-NG on the machine as you normally would. Once it has been set up, connect it to Xen Orchestra as a new server, install any available patches, and configure the VM using the Windows 11 template making sure the virtual disk size is the same or larger than the disk the image was taken from.
When creating the VM, attach the RescueZilla ISO rather than a Windows ISO. By default, XCP-NG’s Windows VM template uses a device configuration that prevents Linux-based ISOs from booting correctly. Without the adjustment below, the display will appear scrambled or blank. The following commands temporarily switch the VM into a Linux-compatible mode so RescueZilla can boot normally.
On the XCP-NG host (either SSH into the machine or use the Host machine Console tab), get your VM’s UUID then set the VM to boot in Linux mode:
xe vm-list
xe vm-param-set uuid=<VM uuid> platform:device_id=0001
At this point, use RescueZilla to restore the image you created earlier to the VM’s virtual disk. Once the restore completes, shut the VM down then set the VM back to Windows boot mode:
xe vm-param-set uuid=<VM uuid> platform:device_id=0002
Detach the RescueZilla ISO then boot the VM from its disk. The migrated Windows installation should come up as if nothing happened and you will pick up in the OS where you left off prior to backing it up.
Real-World Performance #
After a few months of daily use, the gaming performance inside this VM is genuinely difficult to distinguish from a native install. There are no formal benchmarks here, but Moonlight’s built-in metrics show stable 1080p 60fps gameplay in Red Dead Redemption 2 even over wi-fi. Of course, using a wired connection will always yield better performance and your mileage will vary by game and network conditions, but the baseline is more than solid.
For a setup that lives entirely inside a hypervisor, it’s hard to ask for more.
Tips #
- Take snapshots liberally: One of the best parts of running your OS as a VM is the ability to snapshot before making any significant change like driver updates, new software, OS tweaks. If something breaks, you can roll back in seconds!
-
Disable the XCP-NG VNC console for the Windows VM: This is more of a personal preference, but by default the browser-based console in Xen Orchestra registers as an additional monitor inside Windows. This can cause application windows to open on a display that isn’t accessible through Moonlight. Disable it, run the following on the host with:
xe vm-param-set uuid=<VM UUID> other-config:disable_pv_vnc=1 - Configure your display settings carefully: Once connected via Moonlight, go into Windows Display Settings and set the GPU’s output as the only active display. If the XCP-NG VNC console isn’t disabled, Windows may try to span across it, and windows can end up on a display you can’t see.