Controlling virtual machines with VNC and Spice

Well Seasoned

Layer Cake

Spice comprises three components:

  • The Spice server is indicated directly in QEMU/KVM. It is responsible for external communication – that is, for letting the user control the virtual machine across a network connection. For the virtual machine, the Spice server looks like a VGA graphics card.
  • The Spice client (on current distributions, this is the spicy command from the spice-gtk-tools package; on older distributions, the spicec command from the spice-client package) is comparable to a VNC viewer, which displays the graphics system from the virtual machine in a window. Current versions of the Virtual Machine Managers, from virt-viewer or vinagre, are also Spice compatible. The Spice client is also available as a Windows program.
  • The QXL driver is installed on the virtual machine and ensures that the virtual machine supports the graphics system efficiently and with high resolutions. The QXL driver is currently available both for X (Linux) and for Windows. Spice also works without the QXL driver; however, only with resolutions of up to 1024x768 pixels on the virtual machine. Additionally, Spice then offers no speed benefits compared with other graphics solutions.

With current versions of RHEL or Fedora, you can use Spice directly with Virtual Machine Manager: To do so, set Type = Spice in the Display tab of the detailed view. Additionally, you need to set Model = qxl in the Video tab. After starting, the graphics system is displayed in the normal way in the Virtual Machine Manager's console window. From a purely visual point of view, you will not notice any difference from VNC.

For optimum support of QXL by the guest, you need to install a QXL driver on the guest. On current Linux distributions, this is often the default. On some Linux distributions, you will need to install the QXL driver package yourself (i.e., xserver-xorg-video-qxl or xorg-x11-drv-qxl). If the driver is not automatically enabled the next time you start X, add the following lines to /etc/X11/xorg.conf or /etc/X11/xorg.conf.d/spice.conf on the guest:

Section "Device"
 Identifier "device0"
 Driver "qxl"
EndSection

On the network, the same rules basically apply for Spice as for VNC: Libvirt assigns the Spice server on a newly launched virtual machine the first free port above 5900 and an IP address of 127.0.0.1 by default. You can change various global Spice settings for the Libvirt tools in /etc/libvirt/qemu.conf.

On Fedora and RHEL, the firewall, which is enabled by default, blocks external Spice connections. To change this, use SSH with port forwarding as for a VNC connection, or add an exception to your firewall ruleset. You will find predefined rules in the Other Ports tab of the firewall configuration program.

Spice up your Ubuntu

The best Spice support is available with the Fedora and RHEL Linux distributions. Ubuntu, as of Version 12.04 at least, provides a Spice-compatible version of QEMU/KVM. To use the Spice-ready version, you will need to install the required packages manually:

apt-get install qemu-kvm-spice spice-client-gtkpython-spice-client-gtk

On Ubuntu 12.04, use of Spice in the Virtual Machine Manager fails because the program does not call the Spice variant of qemu-kvm. On Ubuntu, the Spice support resides in a separate program (qemu-kvm-spice). Thus, the only way to use Spice in Ubuntu 12.04 is at the command line.

The Virt-manager version on Ubuntu 12.10 has a better configuration, so at least everything works on the host side. An attempt to run Ubuntu 12.10 Beta 2 as a guest on a virtual machine with Spice and QXL graphics failed because of an issue with the QXL driver (at least the driver is enabled). Whether this bug (Launchpad #1056381) will be fully addressed in Ubuntu 12.10 is still not clear at the time I am writing this article.

Windows

The previous examples all assumed that a Linux distribution was running on the virtual machines. However, KVM is also Windows compatible. Virtual Machine Manager automatically selects the vga graphics driver for Windows guests (Figure 1). This is a good choice: Both Windows XP and Windows 7 have no problems with the driver and support virtually unlimited resolutions (tested up to 2560x1600). On Windows 7, you will need to do without the Aero effects.

Figure 1: The graphics settings in Virtual Machine Manager are distributed across two dialogs.

Theoretically, you could use Spice for Windows guests. QXL Windows drivers are available online [2] (search for "windows guest tools").

In practical terms, QXL driver 0.1 on Windows 7 fails because of signature issues (Figure 2). The Device Manager tells you that the driver is not correctly signed (Error 52).

Figure 2: QXL driver problems on Windows 7.

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Secure Your KVM Virtual Machines
    A common misconception posits that software cannot cause mischief if you lock the system away in a virtual machine, because even if an intruder compromises the web server on the virtual machine, it will only damage the guest. If you believe this, you are in for a heap of hurt.
  • Open Source VDI solution with RHEV and oVirt
    Red Hat introduces a management system for KVM-based virtualization based on Red Hat Enterprise Virtualization and open source project oVirt. Now, solutions for desktop virtualization can be implemented without using proprietary software.
  • Virsh Libvert Tool

    With the command-line tool virsh, a part of the libvirt library, you can query virtual machines to discover their state of health, launch or shut down virtual machines, and perform other tasks – all of which can be conveniently scripted.

  • Virtualization with KVM
    KVM continues to gain popularity in the world of Linux – so much so, that it has become Red Hat and Ubuntu's preferred virtualization solution. In contrast to Xen, setting up KVM involves just a couple of steps, and the guest operating systems can run without special patches.
  • Building Virtual Images with BoxGrinder and VMBuilder

    Creating a virtual machine manually is straightforward but too time consuming if you regularly need to set up many virtual machines. The BoxGrinder and VMBuilder programs let you automate this process.

comments powered by Disqus