I’ve done GUI passthrough to system container instances as well as doing full GPU passthrough to virtual machines.
In the case of the former, it is possible to display graphical applications in an instance using the hosts wayland socket. A caveat however, you will also need to pass in X11 sockets as it doesn’t seem like, at least for fedora/42
and debian/13
, Xwayland sockets are created in the instance.
Without passing through the host X11 sockets, programs like Visual Studio Code fail to start, although I’m not sure if this is representative of all Electron based programs.
There is also some theme-ing issues, specifically with KDE applications, I’ve been able to fix this in Debian based instances with a theme package - the name of which elludes me at the moment - but I’ve been less fortunate on RHEL based instances. I’ll check my current instances and report back with an edit when I can.
You can refer to these two links for more details: Incus / LXD profile for GUI apps: Wayland, X11 and Pulseaudio and 🌳 Running Graphical Applications in Incus Containers - Regrow.Earth
In the case of the latter, then there are actually two approaches here. The first is paravirtualized graphics, which would be: virtio-gpu-gl-pci
[1] and Virtio-GPU Venus [1]. The two methods proxy OpenGL and Vulkan commands respectively to your GPU so you can get full 3D acceleration without the need of dedicating a GPU to your virtual machine.
Refer to this Collabora article for more details: The state of GFX virtualization using virglrenderer
And these two videos for a demonstration using games: https://www.youtube.com/watch?v=HmyQqrS09eo and https://www.youtube.com/watch?v=Vk6ux08UDuA&t=47s
That said, Virtio-GPU GL (same as virtio-gpu-gl
) is the current default in Incus, Venus will require some configuration changes using raw.qemu.conf
but it shouldn’t be too difficult to add in; the most concerning part, at least for me, is that I have been unable to replicate the performance in the listed demonstrations. Outside of these two, there is also Virtio-GPU Native Context, but you can refer to the Collabora article listed above for more details.
All of the above however requires running the latest kernel (6.14 at the minimum), latest Virglrenderer (v1.0.0 at the minimum [1]) and Qemu 9.2 and newer.
EDIT: as a follow-up to Virtio Native Context, this MR has been upstreamed for Native Context support for AMD GPUs: Making sure you're not a bot!, iirc Intel is either under review or has also been upstreamed. Qemu support for this will require a patch that is floating around in their mailing list, not sure on its status.
EDIT2: the patch in question: Making sure you're not a bot!
[1] virtio-gpu — QEMU documentation
The second approach is the generic, bog-standard, PCIe Passthrough using VFIO. As alluded to above this requires the passthrough of a GPU. If you’re usecase is having both the host and guest VM running in parallel then this option is a non-starter if you do not have two or more GPUs (not a major concern on AMD Zen 4 and newer and any Intel CPU without the F suffix).