5.3. Using KVM virtio Drivers for GPU Devices

virtio drivers enable you to use virtualized graphics card devices. This feature, also known as virtio-gpu, significantly enhances performance when displaying the graphical console of a guest virtual machine using the virt-viewer, remote-viewer, or virt-manager utilities.

Enabling virtio-gpu

  1. Ensure that your system must has the following packages installed:
    • On the host machine:
      • qemu
      • virglrenderer
      • spice-server
      • spice-gtk
      • mesa
      • libepoxy
    • On the guest machine:
      • Linux kernel upstream version 4.4 or later
      • mesa upstream version 11.1 or later
      • xorg-x11-server-Xorg upstream version 1.19 or later
  2. Make sure the guest's XML file contains the following lines:
    <graphics type='spice'>
      <listen type='none'/>
      <gl enable='yes'/>
      <model type='virtio'/>
  3. When using virt-viewer or remote-viewer to display the guest's console, use the --attach option. This attaches a unix socket connection needed for the OpenGL service to work.
    # virt-viewer --attach {guest-name|id|uuid}
    For virt-manager, no additional options are needed.

Verifying virtio-gpu activation

To verify that activating virtio-gpu was successful, run the following commands on the guest and see if they have the corresponding output:
# dmesg | grep '\[drm\]'
[drm] virgl 3d acceleration enabled
# glxinfo | grep ^OpenGL
OpenGL renderer string: Gallium 0.4 on virgl