Enabling Virglrenderer in QEMU

Virglrenderer is library that accelerates 3D rendering in QEMU for Guests that use virtio-gpu.

The picture below depicts how 3D acceleration works:

However virt-manager doesn't automatically enable virglrenderer when virtio-gpu is used. It can be checked on Guest side by printing memory map of the 3D appliation's process:

To disable DRI software rasterizer and enable virglrenderer acceleration in Display Spice section OpenGL checkbox shall be checked and the following option shall be added to Guest config:

<listen type="socket" socket="/tmp/spice.socket"/>

In the end XML section shall look like the following:

<graphics type="spice">
  <listen type="socket" socket="/tmp/spice.socket"/>
  <gl enable="yes" rendernode="/dev/dri/by-path/pci-0000:09:00.0-render"/>

where rendernode shall be chosen from dropdown list in OpenGL checkbox to point to desired DRI node on your host.

Checking that what qemu process uses for 3D acceleration on the host:

Check load on integrated GPU:

And run VM rendering on discrete video card: