12. GL acceleration (virgl)

OpenGL acceleration is currently local only (it has to go through a Unix socket) and it needs guest support. It’s currently limited to recent linux distributions (for example Fedora 24).

Host-side, you need qemu 2.6, libvirt 1.3.3 and spice 0.13.1, as well as a 4.4 Linux kernel and Mesa 11.1.

Client-side, you need spice-gtk 0.31.

Guest-side, you need Mesa 11.1 and a 4.4 Linux kernel.

12.1. Configuration

Using libvirt. You need to add a virtio-gpu video device to your virtual machine instead of QXL.

<video>
  <model type='virtio' heads='1'>
    <acceleration accel3d='yes'/>
  </model>
</video>

Then you need to enable OpenGL on your SPICE graphics node:

<graphics type='spice' autoport='no'>
  <gl enable='yes'/>
</graphics>

You don’t need any port/address as they won’t be usable with GL.

Using QEMU. You need to add a virtio-gpu device on QEMU command line, as well as enable GL with SPICE. port/tls-port/addr arguments won’t be used in this setup. You need to configure a Unix socket to connect to the VM display.

-device virtio-vga,virgl=on -spice gl=on,unix,addr=/run/user/1000/spice.sock

12.2. Connecting to the guest

Connecting to the guest when virgl is in use is slightly different than usual

If libvirt is being used. 

client$ virt-viewer -a $vmname

If a Unix socket has been set on QEMU command line. 

client$ remote-viewer spice+unix:///run/user/1000/spice.sock