Skip to content

Add support for OpenGL/3D Acceleration (egl-headless, virgl) in QEMU to remotely view output through SPICE #546

@FGD-Garuda

Description

@FGD-Garuda

Page: Virtual Machines

--- Feature description ---

Hello!

This project has a LOT of potential. Your web interface/front-end is gorgeous too! With releases every 2 weeks that's quite agile and should help bring in new features all the time.

I'm hoping to contribute with the following feature request:

There is currently no convenient way in Cockpit to enable OpenGL/3D Acceleration to view the output through SPICE (as well as NoVNC but this one has limitations explained later below), both locally and remotely.

I've heard about using PCI Passthrough, if that works with Cockpit, but it has many limitations (like shutting down the screen when you are local) and opens up all kinds of other non-fixable issues for many use cases. Therefore 3D Acceleration through SPICE has become a well wanted solution for those use cases.

More and more OSes/Apps are leveraging OpenGL/3D Acceleration capabilities which makes this feature through SPICE high on demand, because SPICE is flexible, easy to use, doesn't require the guest to be connected to the network nor an RDP-like service running once the guest has booted up. Therefore SPICE gives access to GRUB menu, boot sequence and BIOS, just like a physical machine. SPICE also has unlimited window geometry (size) as it auto-resizes to your liking and needs and an excellent mouse integration. A simple Googling will return countless posts of people asking for this with other softwares. There's actually a bug in Virt-Manager 3.2 about that as 3D used to work before. I don't know if the bug has been logged, but here we're talking about Cockpit.

As for NoVNC it is tied into the browser front-end and therefore lacks the flexibility of SPICE, which is why I am focusing on SPICE here but the feature doesn't need to be dependent of it.

Support for that feature is already included in the Linux kernel since at least 4.16 I believe. Since a long time ago, Type 2 HyperVisors like VirtualBox already enable this feature by one single click (for both Linux and Windows guests), no other configuration required. As mentioned above Virt-Manager also has this feature, a bit more clicks, but it's there (buggy right now, that's a different story).

Also, to prove it works outside of Cockpit by using QEMU/KVM/libvirt, running locally the guest machine inside a Desktop Environment with the following command works perfectly:

sudo qemu-system-x86_64 -name [domain-name] -drive file=/var/lib/libvirt/images/[domain-name].qcow2 -m 5G -enable-kvm -M q35 -cpu host -smp 6,sockets=1,cores=6,threads=1 -display sdl,gl=on -device virtio-vga,virgl=on -spice unix=on,disable-ticketing=on,image-compression=off,addr=[domain-name].sock,seamless-migration=on

The key is the use of -display sdl,gl=on and -device virtio-vga,virgl=on. Other attributes may vary depending on your VM configuration, I am not sure about those following -spice.

Immediately a SPICE window, with auto-resize feature if supported by the guest, opens up and OpenGL with 3D Acceleration is working, making many modern Linux distros blistering fast and giving an unprecedented user experience.

Without this feature, those distros are laggy, some barely usable, and lack some compositor effects that require OpenGL/3D Acceleration. Even Windows 10/11 slows down a little bit. Some softwares, like rendering or games, require this too.

It is also possible to launch the VM with egl-headlessdisplay instead of sdl and then issue a remote-viewer command line to connect to the domain-name socket. This allows to pass 3D capabilities to the remote machine, although that is probably where most of the implementation challenge is. Working locally is one thing and probably much easier, working remotely is more challenging, but Cockpit is meant to work and maintain remotely.

Could you please consider including this feature in your backlog in order to help getting closer to achieve one of Cockpit's goal: making it intended to everyone, including those using OpenGL/3D acceleration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions