SPICE on Ubuntu 11.10 Oneiric Ocelot

Until recently the best way to connect to your KVM Virtual Machines was to install NoMachine's NX Server on each VM and run the NX Client over SSH. NX offers excellent keyboard, mouse and screen performance over slow connections and remains one of the best ways to access a remote system - virtual or otherwise.

Since 2008 Redhat, Inc. has been implementing a protocol called SPICE - the Simple Protocol for Independent Computing Environments. SPICE was originally developed by a company called Qumranet. Redhat purchased Qumranet in 2008 and open-sourced the SPICE protocol in 2009.

Thanks to the efforts of many volunteers it is now possible to install SPICE on K/Ubuntu 11.10. In this document I mention the dramatically improved video playback performance and the stereo audio playback over LAN but these are only some of the features of SPICE. You might want to take a look at the SPICE web site to find out more about it.

The necessary binaries are being compiled for Ubuntu by Boris Derzhavets. Of course Mr. Derzhavets is relying on the efforts of other volunteers and I would like to thank them all. I would also like to thank the folks at Redhat for all their work in the Open Source community.

Take the following steps to install and use SPICE with your KVM VM's:

  1. At the time of this writing (December 30th, 2011,) the main K/Ubuntu 11.10 repositories do not include the SPICE packages compiled by Boris Derzhavets. Until that happens you can add the repositories of Mr. Derzhavets to your software sources to pull his binaries into your system. Hopefully this step will not be necessary for much longer.
  2. Modify your VM's to use the SPICE-specific virtual hardware.
  3. Install any necessary drivers on the VM's so that they can make use of the new virtual hardware.
  4. Install the SPICE client on your network workstations so that you can remote-desktop using SPICE to your upgraded VM's.

Once this is done you will be able to enjoy high-performance video and audio playback between your workstation and your Virtual Machine over your office network. The performance is not absolutely perfect but it is a major improvement over VNC, RDP and NX.

Let's get started:

Pulling SPICE support into K/Ubuntu 11.10

Please note that the steps listed here are strictly for K/Ubuntu 11.10. K/Ubuntu will most likely incorporate SPICE support in the K/Ubuntu Proposed repository before Q-4 of 2012.

If you are reading this after mid-2012 it is likely that you already have SPICE support in your system. If you are using a version of K/Ubuntu prior to 11.10 you will want to read carefully Mr. Derzhavets's notes to determine which packages to pull from his various repo's. The following notes have only been tested on K/Ubuntu 11.10.

Start by adding two private repositories maintained by Mr. Boris Derzhavets to your software sources.

Detailed notes from Mr. Derzhavets about the packages in these repos are available at https://wiki.ubuntu.com/spice.

Here are some of the ways you can add Software Sources in K/Ubuntu:

  • In the new Muon Package Manager click on the Settings menu, then select Configurure Software Sources.
  • In Synaptic click on the Settings menu and select Repositories.
  • From the main KUbuntu Application Launcher (sometimes called the Start button,) click on the Settings menu and select Software Sources.

Once you have found the Software Sources dialog click on the Other Sources tab. Now press the ADD button at the bottom left of the dialog to add another software source. This will bring-up the Add Source dialog as shown in the image on the right. Copy and paste the following text into the APT Line box of that dialog:

deb http://ppa.launchpad.net/bderzhavets/spice-7/ubuntu oneiric main

Click the Add Source button and you will be returned to the Other Sources tab of the Software Sources dialog.

Once again, click on the ADD button at the bottom left of the dialog so that you can add the second PPA:

deb http://ppa.launchpad.net/bderzhavets/qemu-git/ubuntu oneiric main

Click the ADD Source button to complete the add operation and click the close button on the Software Sources dialog. Next, click the Reload button (or equivalent for your package manager,) to reload all the package lists from the various repositories.

At this point you will probably get an error message related to missing keys. This is because GPG does not yet know about the signing key that was used by Mr. Derzhavets when he packaged his binaries. You can double-click on the key signature in the error message window. This will cause the signature to be highlighted as in the image on the right. You can then right-click over the highlighted text to bring-up the speed menu. Select Copy to copy the signature to the clipboard. Next, open a shell and type the following command:

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5CC1785DC05C1EB5

Don't forget to substitute the key signature that you copied for the key signature shown above (in case they are different.) The apt-key utility will attempt to pull a copy of Mr. Derzhavets public key from a key server. This will allow the package manager to verify the signatures on the binaries packaged by Mr. Derzhavets.

At this point it should be possible to start pulling the SPICE compatible binaries into your system. Use your favorite package manager to install the desired packages. (The command line below uses the apt-get command but any package manager will do.) Note that the following list is from my main workstation and might include some packages that are not strictly necessary:

$ sudo apt-get install libcelt051 libspice-client libspice-server libspicegtk3-client qemu-common qemu-kvm spice spice-vdagent spice-gtk3-client

If you run into any package problems you can un-install the problem packages and then re-install the desired package. I ran into a problem with a loadable object module that was being provided by two different packages. The easy way to solve the problem was to un-install the two packages that contained copies of the same file. Then I installed the desired package again without any difficulty.

Hopefully by the time you read this the packages will have been moved into the proposed repository and any package issues will have been resolved.

Restart KVM and Virt-Manager

At this point the desired software is on the workstation filesystem but the previous copies of the software are still loaded in the system. To correct this problem:

  • Exit the Virt Manager
  • Open a shell.
  • Stop and restart the libvirt-bin and qemu-kvm services. There are two different ways to do this. I prefer the service command but, if you don't have it installed, you will want to just call the init scripts manually:
    • Using the service command:
      $ sudo service libvirt-bin stop
      $ sudo service qemu-kvm stop
      $ sudo service qemu-kvm start
      $ sudo service libvirt-bin start
    • Or, if you have not installed the service command, you can accomplish the same using the init scripts:
      $ sudo /etc/init.d/libvirt-bin stop
      $ sudo /etc/init.d/qemu-kvm stop
      $ sudo /etc/init.d/qemu-kvm start
      $ sudo /etc/init.d/libvirt-bin start
  • Finally: restart the virt-manager.

The first time that I ran through the above procedure I discovered that I had missed a few details and got some error messages. Thankfully the messages were informative enough that I was able to quickly work through them. Hopefully you will have a similar experience and the above process will proceed smoothly for you, too. Of course if you are reading this after mid-2012 there is a very real chance that the desired software will be included in the proposed software repository and you won't have to think about the packages at all.

Downloading any necessary drivers

Most likely you already have the drivers you will need for any modern Linux based Virtual Machine. The QXL video driver package is already part of the XORG collection in both the Fedora and Ubuntu repositories. As such one might hope to find it in other distributions of Linux. Drivers for the AC97 audio device have been available in Linux for quite some time.

In practice this means that you will probably be able to boot your modern Linux Virtual Machines and get the correct drivers installed and running with little or no effort. If your Virtual Machine is running an older version of Linux you will probably want to continue to connect using VNC and/or NX. On the other hand you might find, as I did, that the basic VGA or VESA video devices work fairly well with the SPICE backend.

Windows Virtual Machines will detect the QXL video device. When you first boot the VM the Found New Hardware Wizard will appear. There is no doubt that video performance will improve dramatically if you direct the wizard to install the Windows QXL Virtual Device Drivers.

As such if you expect to try using SPICE on a Windows VM you will first want to visit the SPICE project web site and download the most recent driver files. Copy them to a convenient Samba share or create an ISO file that you can connect to the VM's as a CD-ROM.

The desired files can be found on the download page of the SPICE web site:


Look for the Windows Binaries about three-quarters of the way down the page. Remember to unpack the files and save them to a network-accessible samba share or use a program like K3b to copy them into an ISO file that can be connected as a CD-ROM to a VM.

Modifying a VM's Hardware Configuration

In the past I configured my KVM Virtual Machines to use a virtual video card called VMVGA. I then used VNC to display the image that was written to the virtual VMVGA device. I also found that the ES1370 virtual sound device gave me good results through the pulse audio setup on my workstation.

When I started trying to get SPICE to work I found it best to change the virtual hardware. The VMVGA device does work with SPICE but the results are dramatically better with the SPICE-specific QXL device. Also I found that there was no sound over SPICE unless I switched to the AC97 virtual sound device. In fact the sound might work with other virtual hardware - I don't know yet if the virtual AC97 device is somehow tied to the current SPICE software.

For sure it is always necessary to remove the VNC (or SDL) display backend and install the new SPICE backend.

If you are using the Virt Manager as shown in the images here you will find that editing your virtual hardware setup involves only a few seconds of effort.

  1. Open the Virtual Machine in the Virt Manager and select the Details View as shown in the image to the right.
  2. Click on the Video item in the left panel of the Details View. Select the SPICE compatible virtual video device which is called QXL. This is the device that your VM will see when you boot it. Don't worry - the QXL device is VESA compatible. If your VM is running a relatively modern operating system it will boot and you will be able to install the QXL drivers.

  3. Now that we have enabled the QXL virtual device we need to set the backend to use the SPICE protocol. Click on the DISPLAY item in the left panel of the Details view. You will see the currently configured backend. Most likely this will be VNC but it might also be SDL. In either case click the [Remove] Remove Button Graphic button to delete this backend. (Scroll down the page to continue.)

  4. Now click on the [Add Hardware] Add Hardware button to add the SPICE protocol Display backend. Select the Graphics item in the left panel. Set the Type of Graphics Backend to SPICE Server.

    If you are on a private network and plan on accessing this Virtual Display over your network you might want to check the Listen on all public network interfaces option. Set the port numbers as desired or check the Automatically Allocated option to let the system allocate the next available port at run time. Click Finish to save your changes.

    Your Display Spice / Spice Server backend should look something like the image on the left when you are done.

    At this point you have selected the QXL virtual video card and the SPICE display backend for your Virtual Machine.

    Next we will work on the Sound configuration. Please scroll down the page to see the next step.

  5. Next: Click on the Sound device in the left panel of the Detail View for your Virtual Machine. It is possible that the device you have currently selected will work fine. For me, on my workstation, I was only able to get sound out of my VM's when I selected the AC97 device. This may not be an issue for you. You can change the setting to AC97 or leave it alone. If the sound doesn't work properly for you it's easy to change again later.

At this point the first step, configuring your VM to use SPICE, is complete. Next you will boot your VM and install any required virtual device drivers. Finally you will install the Spice client and remote-desktop into your VM's using the SPICE protocol.

Booting a Windows VM

For those who skim quickly through these documents I mention again that your modern Linux VM's will probably boot and run very nicely with little or no effort on your part. This should be true, at least, for your Fedora and Ubuntu derived distributions. It may also be true of other distros as the open source code provided by Redhat is readily available.

Windows VM's, on the other hand, will boot and detect the new hardware but not find the required drivers for that hardware. The Found New Hardware Wizard will appear and you will want to direct it to the Virtual Device Drivers that you previously downloaded. See the start of this document for details on where to find the drivers. Be prepared to find the drivers. One way is to copy them to a samba share on your network. Another is to copy them into an ISO file and connect that ISO file as a CD-ROM on the VM.

At this point you can boot the VM and log into an Administrator account. After a short delay the Found New Hardware Wizard will appear. The first page of the Wizard will ask if you want to use Windows Update to find the desired drivers. Select the No, not this time option. Click the Next button to move to the next page.

The second page will ask you where it should look for the necessary driver files. Select Install from a List or Specific Location (Advanced) so that you can specify where you want the Wizard to look for the drivers.

The third page of the Wizard allows you to specify the locations that the Wizard will search to find the QXL video drivers. Choose the appropriate options and browse as needed to find the appropriate files for your version of Windows and your architecture. The snapshot to the right of this text was taken on a 32-bit Windows XP VM with the drivers on a NAS share.

Windows will warn you that the driver you are installing has not been certified by Microsoft. In practice it is true that buggy drivers are the cause of many troubles. I hope that you will install these drivers and take the time to report any problems that you trace back to them. Over time they will, no doubt, develop into the high-performance and high-reliability software that we all need.

In my case I found the installation process was relatively quick and painless.

According to this Redhat Guide from December of 2009 the Found New Hardware Wizard might appear again. This time it will be asking for your help to find and install VDI Port Drivers. I did not get this on my Windows VM's so I'm guessing that the VDI Port Drivers are now included with the QXL drivers.

One last item to install is the Spice Agent. The SPICE for Newbies [pdf] document describes the agent as "an optional component for enhancing user experience and performing guest-oriented tasks. For example, the agent injects mouse position and state to the guest when using client mouse mode. In addition, it is used for configuration of the guest display settings. Future features include copying and pasting objects from/to the guest. The Windows agent consistss of a system service and a user process."

You can download the agent software from the same download page on which you found the Windows drivers. See Install the SPICE agent in this Redhat Guide for details on how to do this.

Connecting to your VM via SPICE

Finally we can get to the last step in this process: Connecting to the VM through a SPICE client.

There are two clients to choose from: The Redhat GTK+ client (called spicy, note the missing 'e',) and the more basic Spice Client (called spicec.) I have played with both of them and prefer the many features of the Redhat client - but it is slower than the more simple Spice Client.

The first thing to do is to install one or both of the clients.

NOTE: At the time of this writing (December 30th, 2011,) there are two spice client packages containing spicec, the simple spice client. One of them is called spice and the other is called spice-client. Do not install the second one as it depends on a package that conflicts with a codec package. Install only the spice package to avoid this conflict.

If you are installing one or both SPICE clients on a different workstion you can follow again the notes in the section Pulling SPICE support into K/Ubuntu 11.10 above. You can also download a SPICE client for Windows from the SPICE web site. Of course the Redhat repositories contain SPICE clients for the Fedora distributions of Linux.

If you configured your VM to automatically assign an available port number you will need to find out what number was assigned. Simply boot the VM and check the port number in Virt-Manager's Detail View for the VM. See the sample image to the right of this text. The port number is the highlighted text in the configuration for the Display backend for the VM.

At this point you can try the two clients. Each client wants a host name and port number. Clearly the Redhat client has more features but, in my personal case, I was using SPICE mostly because I wanted to watch Netflix at night. For this use-case the more basic Spice Client demonstrates better performance.

If you check your Pulse Audio volume control after connecting with your VM you may not see the Spice Client as one of the sound sources. This is because the client will not connect to the pulse subsystem until a sound is sent from the VM. On Windows VM's you can click on the volume control in the task bar to cause the VM to emit a ding sound. After that you should see a Spice Audio source as at the bottom of the image to the right of this text. If you do not hear any sound you can shutdown your VM and try a different virtual sound device.

Questions or Comments?

If you have any questions or comments about this FAQ please take a moment to email me at sam [at] azertech [dot] net. I look forward to hearing from you!