Set up KVM/QEMU/SPICE on Ubuntu 11.04 via ppa:serge-hallyn/spice2

UPDATE on 09/21/11 Ubuntu 11.10 beta-2 will be released tomorrow.
Ubuntu 11.10 final release (Oneiric Ocelot) on 10/14/11
1. Set up Qemu-kvm 0.15.0(spice enabled), Spice Server(0.8.2), Spice-Gtk-0.7-2(via Debian) for Oneiric
Qemu-kvm-0.15.0+noroms (spice enabled), Spice Server&Client 0.8.2, Spice-Gtk-0.7-2 (via Debian)

2. Set up Qemu-kvm 0.15.1 & Spice USB Redirection support for Ubuntu Oneiric
Patches set for debian build may be generated as follows :

$ git clone git://
$ cd qemu
$ git checkout -B qemu-kvm-0.15.0-usbredir origin/qemu-kvm-0.15.0-usbredir
$ mkdir -p /tmp/patches
$ git format-patch -M -C --output-directory \
/tmp/patches ea2798c1ebe0c12d5feb7d7471a999ea0671ef2f

Kernel installed is 3.1.0-030100-generic
Consider option downgrade seabios 1.6.3 => 0.6.2-qxl if some things go wrong for you. It won’t affect USB Redirection support

UPDATE on 08/27/2011. In meantime the best way to solve the problem on Ubuntu 11.10 (Oneiric) is to work via PPA Building Spice-Gtk-0.7 via Debian Unstable with Gobject-introspection enabled. View for details Implementation Spice on Ubuntu 11.10 KVM Server the most recent approach.
Qemu-kvm 0.15.0 was built with changed dependencies in the same PPA
Packages from installed with no conflicts on Oneiric daily build 08/27/11. Spice sessions (via VirtManager) in QXL mode (64M vram) for install and for runtime have been run.

To install packages from PPA

$ sudo add-apt-repository ppa:bderzhavet/test-deb2
$ sudo apt-get update
$ sudo apt-get install qemu-kvm qemu qemu-common \
libspice-client-glib-2.0-4 libspice-client-glib-2.0-dev \
libspice-client-gtk-2.0-1 libspice-client-gtk-2.0-dev \
libspice-client-gtk-3.0-1 libspice-client-gtk-3.0-dev \
python-spice-client-gtk spice-client-gtk spice-client \

$ sudo apt-get install virtinst virt-manager virt-viewer

You might have to disable apparmor profile for libvirtd

$ sudo ln -s /etc/apparmor.d/usr.sbin.libvirtd /etc/apparmor.d/disable/
$ sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.libvirtd
$ sudo adduser $USER kvm
Packages installed via ppa:serge-hallyn/spice2 have been tested for F14, W7 KVMs installs and runtime. Package qemu-kvm-spice (0.14.0+noroms-0ubuntu4qxl2) is based on the most recent RH’s QXL patches sets for qemu-kvm-0.14.tar.gz. Disabling AppArmor’s profile for libvirtd allows to manage and create domains via virt-manager 0.8.6-1 installed on Ubuntu Natty Narwhal. However, first domain install with option “-spice port=5900,disable-ticketing -vga qxl” has been been performed via qemu-kvm command line keeping original restrictions in place.
Add new repository to system :-

# add-apt-repository ppa:serge-hallyn/spice2
# apt-get update

Install packages from PPA on your system :-

Verify install via “dpkg -l” :

root@boris-System-P5Q3:~# dpkg -l |grep spice
ii libspice-client 0.6-0ubuntu1 Spice GTK+ Library
ii libspice-client-dev 0.6-0ubuntu1 Spice GTK+ Library (development files)
ii libspice-server 0.8.1-0ubuntu1 Spice Server-Side Library
ii libspice-server-dev 0.8.1-0ubuntu1 Spice Server-Side Library (development files)
ii qemu-kvm-spice 0.14.0+noroms-0ubuntu4qxl2 Full virtualization on i386 and amd64 hardware
ii spice 0.8.1-0ubuntu1 Spice Client
ii spice-protocol-dev 0.8.0-0ubuntu1 SPICE protocol headers

AppArmor’s restriction for libvirtd profile on Natty Narwhal brings us initially to qemu-kvm command line installation.
Open terminal session and issue :-

/usr/bin/kvm-spice -cpu host -enable-kvm \
-name W7 -m 2048 \
-drive file=/dev/sdb7,if=virtio,media=disk,aio=native,cache=off \
-drive file=/usr/tmp/virtio-win-1.1.16.vfd,if=floppy \
-net nic,model=rtl8139 -net user -localtime \
-usb -vga qxl -spice port=5900,disable-ticketing \
-cdrom /usr/tmp/Win7_64.iso -boot d

Connect to console via “spicec -h localhost -p 5900″ and proceed with install :-

When done load W7 KVM as follows :-

/usr/bin/kvm-spice -cpu host -enable-kvm \
-name W7 -m 2048 \
-drive file=/dev/sdb7,if=virtio,media=disk,aio=native,cache=off \
-net nic,model=virtio -net user -localtime \
-usb -vga qxl -spice port=5900,disable-ticketing \
-cdrom /usr/tmp/virtio-win-1.1.16.iso

and set up VirtIO Net Driver

Finally runtime command line will look like :-

/usr/bin/kvm-spice -cpu host -enable-kvm \
-name W7 -m 2048 \
-drive file=/dev/sdb7,if=virtio,media=disk,aio=native,cache=off \
-net nic,model=virtio -net user -localtime \
-usb -vga qxl -spice port=5900,disable-ticketing

Now disable AppArmor profile for libvirtd :-

# ln -s /etc/apparmor.d/usr.sbin.libvirtd /etc/apparmor.d/disable/
# apparmor_parser -R /etc/apparmor.d/usr.sbin.libvirtd
# reboot

Next step

# cd /usr/bin
# cp qemu-system-x86_64-spice qemu-system-x86_64
# cp qemu-x86_64-spice qemu-x86_64

Invoke virt-manager with option "Import Existing Image"

and update XML definition of W7 as follows.

<domain type='kvm'>
<type arch='x86_64' machine='pc-0.14'>hvm</type>
<boot dev='hd'/>
<clock offset='localtime'/>
<disk type='block' device='disk'>
<driver name='qemu' type='raw' cache='none'/>
<source dev='/dev/sdb7'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
<interface type='bridge'>
<mac address='52:54:00:7d:5d:dc'/>
<source bridge='br0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
<serial type='pty'>
<target port='0'/>
<console type='pty'>
<target type='serial' port='0'/>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<graphics type='spice' autoport='yes' listen=''/>
<sound model='ac97'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
<model type='qxl' vram='32768' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>

# virsh define W7.xml

Now start domain via Virt-Manger :-

Actually at this point domains may be created in VNC mode via virt-manager 0.8.6-1. SPICE Server activated invoking "Add Hardware" wizard -> "Graphics->Spice Server , previously removing VNC Server. Switching domain to "QXL" mode is also possible via virt-manager.


About these ads

8 Responses to Set up KVM/QEMU/SPICE on Ubuntu 11.04 via ppa:serge-hallyn/spice2

  1. FX says:

    Nice Article! Very useful for testing!

    By the way spicec is (or will be soon) deprecated you should use spicy instead of it.

  2. Shawn Zhu says:

    I reailised that spice server runs on 64-bit platform only

    • Lilian says:

      “Building Spice server on 32-bit machine is not supported because Spice server is dependent on 64-bit atomic operations. However, you can build Spice client for a 32-bit machine by cding into client directory and executeing the make command from there. “

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: