How to enable 3d acceleration in KVM?

As for the disappointing performance…

Maybe we’re still having the wrong QEMU command line? (Because our libvirt XML files configuration files might be non-ideal.)

Quote QEMU - ArchWiki

virtio-vga / virtio-gpu is a paravirtual 3D graphics driver based on virgl. It’s mature, currently supporting only Linux guests with mesa compiled with the option gallium-drivers=virgl.

To enable 3D acceleration on the guest system, select this vga with -device virtio-vga-gl and enable the OpenGL context in the display device with -display sdl,gl=on or -display gtk,gl=on for the SDL and GTK display output respectively. Successful configuration can be confirmed looking at the kernel log in the guest:

To check

sudo dmesg | grep drm

[drm] pci: virtio-vga detected
[drm] virgl 3d acceleration enabled

Note: DRM is referring to Direct Rendering Manager. Unrelated to Digital Restrictions Management.