Adding Spice support to an existing virtual machine

This section will assume that you already have a running QEMU virtual machine, and that you are running it either through virt-manager, libvirt or through direct QEMU use, and that you want to enable Spice support for this virtual machine.

Using virt-manager

Double-click on the virtual machine you are interested in, go to View/Details. If the left pane has a "Display Spice" entry, then the virtual machine already has Spice support, and you can check the connection details (port number) by clicking on it. If it has no Spice entry, click on "Add Hardware", and add a "Graphics" element of type "Spice server". If the host and the client are not the same machine, you should check the "Listen on all public network interfaces" checkbox, otherwise you don't need to make any changes.

You should also add a QXL video device. It can be done by double-clicking on a virtual machine, then by going to View/Details, and by clicking on "Add Hardware" if the virtual machine does not have a "Video QXL" item in its left pane. From the "Add hardware" dialog, you should then create a "Video" device whose model is "QXL".

After stopping and restarting the virtual machine, it should be accessible with a Spice client.

You can remove non-Spice display entries and non-QXL video entries from the virtual machine configuration.

If you go to Edit/Preferences/VM Details in the main virt-manager window, you can set Spice graphics type as the default setting for new virtual machines.

Using libvirt

All libvirt examples will assume that the virtual machine to modify is $vmname and that virsh is using the correct libvirt connection by default.

To add Spice support to an existing virtual machine managed by libvirt, you need to edit it:

host# virsh edit $vmname

and then add a Spice graphics element:

<graphics type='spice'/>

You should also add a QXL video device

    <model type='qxl'>

After stopping and restarting the virtual machine $vmname, it should be accessible through Spice. You can check the connection parameters with:

host# virsh domdisplay $vmname

Using QEMU

To enable Spice support to your virtual machine, you only need to append the following to your QEMU command line:

-spice port=3001,disable-ticketing

This will setup a Spice session listening on port 3001 exporting your virtual machine display.

You can also add a QXL device by appending this to the command line:

-vga qxl

Connecting to guest

The following section will show you basic usage of the Spice client. The example connection will be related to the qemu instance started in the previous section.

Be aware that the port used for spice communication (port 3001 in our case) should not be blocked by firewall. Host myhost is referring to the machine which is running our qemu instance.

client# remote-viewer spice://myhost:3001

Figure 2.1. Established connection to Windows 2008 guest

Established connection to Windows 2008 guest