Why does ssh change virgl OpenGL renderer back to llvmpipe software renderer? Can I keep virgl in ssh session?

Solution 1:

The output shows me that the OpenGL renderer is "virgl". But if I ssh into the guest Ubuntu with -X option and type glxinfo -B, the output says the OpenGL renderer is "llvmpipe (LLVM 13.0.0, 128 bits)" which is a software OpenGL renderer.

So, why does ssh change virgl OpenGL renderer back to llvmpipe software renderer? Is there any way to keep the original "virgl" OpenGL renderer in ssh session as I see in Qemu window?

Because the -X option makes glxinfo talk to the host's X server, not the guest's. As GLX is "GL over X11", this means glxinfo will show the capabilities available from the host's Xorg – constrained by the fact that it's communicating over the network, therefore no direct SHM or DRI access. (For example, modern X11 programs rely a lot on being able to directly exchange bitmaps with the X server via MIT-SHM.)

If you want to use the guest's X server, do not use -X nor -Y but instead define DISPLAY (and possibly also XAUTHORITY) to point at the X server already running inside the guest.

(Most often it is display :0, but the Xauth path may change, so you really should check the DISPLAY and XAUTHORITY values through a "local" terminal within the guest. On recent versions you might also find this information in systemctl --user show-environment – that's a reliable source.)

But if you want to use the guest's virtual GPU while still displaying X windows on the host through SSH, I suspect you might not be able to use GLX but might need EGL-based software (see if eglinfo is able to access the virgl GPU).

Alternatively run the applications on the guest, but control them through VNC (x0vncserver) or through Qemu's SPICE remoting protocol (which can be used through the network just like VNC/RDP).