Setting up a virtual machine with virgil support

Recently I wanted to try how virgil, the OpenGL solution for KVM/Qemu, works with KWin. Virgil (sometimes also referred to as virgl) is a wonderful solution, but so far I hadn’t been able to test it. Especially I was interested in seeing how it works with Wayland. Unfortunately I did not find much information on how to setup a VM which supports virgil, so a good reason to write a blog post.

As base setup I used Debian testing, as guest system KDE Neon Developer edition, for virtual machine management Virt-Manager. To enable virgil support one needs to configure the Video device with Model “Virtio” instead of QXL which was common in past. When using the Virtio driver there is a checkbox “3D acceleration” which needs to be checked.

But this is not the only place where adjustment is required. In the “Display Spice” section one needs to check the “OpenGL” checkbox. It allows to select the graphics device. For me “Auto” just worked fine, but I only have one GPU installed. On “Listen type” one needs to select the “None” entry. Otherwise you get a very cryptic error when trying to start the virtual machine.

With these adjustments the virtual machine was ready to go and I got the sddm screen (which uses OpenGL). So all good? Unfortunately not: sddm seemed frozen. Disabled virgl, booted again, reconfigured sddm to do auto-login, enabled virgl and restart. The desktop loaded, KWin was picking up OpenGL, Plasma was properly blurred. Also a restart into Wayland worked without any problems. But KWin of course does not really know about virgl yet and just shows an unknown device when checking the support information.

As I had installed a developer edition, I wanted to give this a try. Started kdevelop, checked out KWin, edited the relevant sources, compiled, installed, committed. I was very pleased with the out-of-box experience for hacking on KDE software on KDE neon developer edition. In less than 2 hours I went from setting up a VM to pushing the accepted change to the git repository. And the largest challenge was setting up phabricator (arc is not installed, though migration to gitlab…) and getting my ssh key into the VM. The result is KWin detecting the virgil renderer in support information (screenshot taken on X11):

I hope to find some time to investigate why sddm seemed frozen – this is unfortunately currently quite a little bit of a showstopper for using virgil. Otherwise I am very pleased with the results. Having a working virtualized GPU is a big step for Linux as it allows to run modern desktop environments such as KDE Plasma and GNOME on a full free software virtualization stack.