SPICE · remote display protocol

On this page 8

SPICE (Simple Protocol for Independent Computing Environments) is a remote display protocol that gives a user interactive access to the graphical console of a virtual machine, carrying screen updates, keyboard and mouse input, audio, clipboard data and redirected USB devices between the hypervisor and a client application. In Linux virtualization it is the protocol most closely associated with QEMU and KVM, where the server side runs inside the QEMU process rather than inside the guest operating system.

Because the server lives in the hypervisor, a SPICE console is available from the first firmware screen onward, before the guest has booted, configured a network or started any remote desktop service. This makes it different in kind from protocols such as RDP or VNC servers that run inside the guest.

How the SPICE protocol is structured

SPICE splits the work into four cooperating components: a server library embedded in QEMU, a client such as remote-viewer or virt-viewer, an optional guest agent and a set of paravirtual guest drivers. The server captures what the emulated graphics device renders, encodes it and sends it to the client, while the client returns input events and device traffic.

Communication is divided into independent channels, each a separate TCP connection with its own purpose. This design lets a slow USB transfer coexist with a responsive pointer, and it allows the client to open only the channels it needs.

ChannelDirectionWhat it carries
MainBothSession setup, agent messages, migration control
DisplayServer to clientDrawing commands, images and video streams
InputsClient to serverKeyboard and mouse events
CursorServer to clientPointer shape and position
Playback and recordBothAudio output and microphone input
USB redirectionBothEncapsulated USB traffic from client devices
Smart cardClient to serverCard reader access for authentication
Main SPICE channels and their roles

The original design idea was to transmit high-level drawing commands produced by the QXL paravirtual graphics device instead of raw pixels, so that the client could render them locally. Modern guests increasingly use plain framebuffers, so in current deployments much of the traffic consists of compressed image regions and detected video streams.

Guest components and the QXL device

The guest side of SPICE is optional but strongly recommended, because it unlocks most convenience features. The spice-vdagent service talks to the host through a virtio-serial port and handles clipboard sharing, automatic resolution changes and multi-monitor layout.

The following table shows which guest component provides each capability and what happens when it is missing.

ComponentPurposeEffect if absent
QXL driverParavirtual 2D display adapterGeneric VGA output, fewer resolutions
spice-vdagentClipboard, resize, monitor layoutNo copy and paste, fixed resolution
virtio-serial portTransport for agent messagesAgent cannot reach the host
virtio-gpu with virglAccelerated 3D renderingSoftware rendering only
Guest-side SPICE components

Recent Linux guests often use virtio-gpu instead of QXL. With the virgl renderer and a local client, SPICE can deliver OpenGL acceleration through a shared memory path, but this mode works only when the client runs on the same host, not across a network.

Image compression and performance settings

SPICE adapts its encoding to the content, choosing lossless compression for text and interface elements and lossy compression for photographs and motion. Administrators tune this through QEMU or libvirt options, and the right settings depend heavily on available bandwidth.

SettingTypical valuesWhat it affects
image-compressionauto_glz, quic, lz, offLossless compression of screen regions
jpeg-wan-compressionauto, never, alwaysLossy JPEG for images on slow links
zlib-glz-wan-compressionauto, never, alwaysExtra zlib pass over dictionary output
streaming-videooff, all, filterDetection and encoding of video regions
playback-compressionon, offOpus audio compression
Common SPICE tuning parameters

The GLZ algorithm keeps a global dictionary of previously sent images, which saves bandwidth when the same icons and window elements repeat. On a gigabit LAN, a desktop session usually needs only a few megabits per second at idle, while full-screen video can consume tens of megabits or force noticeable quality loss.

SPICE compared with VNC and RDP

SPICE, VNC and RDP all deliver remote desktops, but they sit at different layers of the stack, which determines what each can see and do. The comparison below covers the points that matter most when choosing a console protocol for a KVM guest.

PropertySPICEVNC in QEMURDP inside guest
Server locationHypervisorHypervisorGuest operating system
Boot and firmware accessYesYesNo
AudioYesNoYes
USB redirectionYesNoLimited
Clipboard sharingWith agentLimitedYes
Client availabilityMostly Linux toolsVery broadVery broad
Remote display protocols for virtual machines

VNC remains the lowest common denominator that almost every client supports, while RDP generally performs better over the internet for Windows desktops. SPICE is strongest as a feature-rich local or LAN console for Linux-managed virtual machines.

Configuring SPICE with libvirt

Most administrators enable SPICE through libvirt, either in virt-manager or by editing the domain XML with virsh. A typical definition adds a graphics element of type spice, a QXL or virtio video device, a SPICE agent channel and optional USB redirection devices.

  • Set listen to 127.0.0.1 by default and reach the console through an SSH tunnel or a local socket.
  • Enable TLS with certificates through spice_tls in qemu.conf before exposing a port to other hosts.
  • Add a password or SASL authentication for any listener that is not local.
  • Use `autoport` so libvirt assigns free ports to multiple guests automatically.
  • Add two or three USB redirection slots if users need local devices in the guest.

Clients connect with remote-viewer spice://host:port or open the console directly from virt-manager. Platforms such as Proxmox VE and oVirt generate a connection file that the client opens with temporary credentials.

Limitations and common mistakes

The most serious mistake is exposing an unencrypted SPICE port on a public or shared network, because the plain channels carry keystrokes, passwords and screen content in readable form. The project has also seen reduced upstream development, and some distributions have deprecated SPICE support in favor of VNC or other approaches.

SymptomLikely causeFix
Resolution does not follow windowAgent not runningInstall and start spice-vdagent
No copy and pasteMissing virtio-serial channelAdd the spicevmc agent channel
Laggy video playbackStreaming disabled or slow linkEnable streaming-video filter
Connection refused remotelyListener bound to localhostUse an SSH tunnel or TLS listener
3D acceleration failsRemote client with virglUse a local client or disable GL
Typical SPICE problems and fixes

SPICE is not a replacement for GPU passthrough. Demanding games and professional 3D work need a dedicated GPU through VFIO, often viewed with tools such as Looking Glass rather than a network console.

In everyday language

SPICE is a way to see and use a virtual computer from a window on your own machine. It sends the picture of the virtual screen to you and sends your typing and mouse moves back.

Because it is built into the program that runs the virtual computer, it works even while the virtual machine is still starting up. It can also pass sound, copied text and plugged-in USB sticks between the two. Think of it as a long, smart cable between your monitor and a computer that only exists in software.

Seen in the real world

A university computer lab runs about forty Linux and Windows virtual machines on two KVM hosts managed with libvirt. Students need a full desktop for course software, including audio for language exercises and access to USB microphones and flash drives.

The administrator configures each guest with a QXL display, the spice-vdagent service and three USB redirection slots, binds SPICE to TLS on the lab network and distributes connection files through the virtualization portal. Students open the files with remote-viewer on thin clients.

The result is a responsive desktop with working sound and USB devices at a few megabits per second per active session. When a guest fails to boot, staff can watch the firmware and boot loader screens through the same console, which shortens troubleshooting considerably.