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

April 27, 2011

*****************************************************************************************************************
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://people.freedesktop.org/~jwrdegoede/qemu
$ 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 https://launchpad.net/~bderzhavets/+archive/test-deb2 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 \
seabios

$ 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'>
<name>W7</name>
<memory>2097152</memory>
<currentMemory>2097152</currentMemory>
<vcpu>2</vcpu>
<os>
<type arch='x86_64' machine='pc-0.14'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='localtime'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/kvm</emulator>
<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'/>
</disk>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<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'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<graphics type='spice' autoport='yes' listen='0.0.0.0'/>
<sound model='ac97'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</sound>
<video>
<model type='qxl' vram='32768' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</memballoon>
</devices>
</domain>

Run
# 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.

References
1. https://launchpad.net/~serge-hallyn/+archive/spice2


Backport Virt-manager 0.8.7-3 (without spice) & python-virtinst-0.500.6-2 to Scientific Linux 6

April 19, 2011

Primary target is to get virt-install supporting options “–graphics spice”,”–video qxl”,”–channel spicevmc”.
Virt-manager-0.8.7-3.fc15.src.rpm has to be installed and it’s spec’s file updated :-

%define with_spice 0

then rebuild and perform virt-manager-0.8.7-3.el6.noarch.rpm install, having python-virtinst-0.500.6-2 already in place :-

yum install virt-manager-0.8.7-3.el6.noarch.rpm

It seems running smoothly with python-virtinst-0.500.6-2 ( rebuilt and reinstalled in the same way). Obviously there is no access to spice console via virt-manager. I also upgraded spice-client up to 0.6.3 , what requires pixman-0.18.4-1.fc14.src.rpm rebuilt on SL 6 and install pixman & pixman-devel. In particular, “Add Hardware” wizard Graphics->Spice Server allows
to avoid manual updating XML VM’s profile as suggested in [1].
Two KVMs have been tested positive :-

virt-install --connect qemu:///system --virt-type kvm \
--os-type=linux --os-variant=virtio26 \
--name NattyB2 --ram 1024 --disk path=/dev/sdb3 \
--graphics spice --video qxl --channel spicevmc \
--cdrom /usr/tmp/ubuntu-11.04-beta2-desktop-amd64.iso --vcpus 2







virt-install --connect qemu:///system --virt-type kvm \
--name W7 --ram 4096 \
--disk path=/dev/sdb11,bus=virtio \
--disk /usr/tmp/virtio-win-1.1.16.vfd,device=floppy \
--os-variant win7 \
--graphics spice --video qxl --channel spicevmc \
--cdrom /usr/tmp/Win7_64.iso --vcpus 2







XML profile after virt-install looks like :-

<domain type='kvm'>
<name>W7</name>
<memory>4194304</memory>
<currentMemory>4194304</currentMemory>
<vcpu>2</vcpu>
<os>
<type arch='x86_64' machine='rhel6.0.0'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='localtime'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='block' device='disk'>
<driver name='qemu' type='raw'/>
<source dev='/dev/sdb11'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
<disk type='file' device='floppy'>
<driver name='qemu' type='raw'/>
<source file='/usr/tmp/virtio-win-1.1.16.vfd'/>
<target dev='fda' bus='fdc'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='/usr/tmp/virtio-win-1.1.16.iso'/>
<target dev='hdc' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='1' unit='0'/>
</disk>
<controller type='fdc' index='0'/>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<controller type='virtio-serial' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</controller>
<interface type='bridge'>
<mac address='52:54:00:f1:01:e9'/>
<source bridge='br0'/>
<target dev='vnet0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target port='0'/>
</console>
<channel type='spicevmc'>
<target type='virtio' name='com.redhat.spice.0'/>
<address type='virtio-serial' controller='0' bus='0' port='0'/>
</channel>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<graphics type='spice' port='5900' tlsPort='-1' autoport='yes' />
<video>
<model type='qxl' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</memballoon>
</devices>
</domain>

Updated via “virsh edit W7″ :-

<graphics type='spice' port='5900' tlsPort='-1' autoport='yes' listen='0.0.0.0'/>
<video>
<model type='qxl' vram='32768' heads='1'/>
. . . .

Same XML may be automatically generated via Virt-Manager 0.8.7-3 after normal VNC install :-
1. Remove VNC Server
2. “Add hardware”->”Graphics”->”SPICE Server”



Package “spice-gtk” is expected only in RHEL 6.2
References
1. http://www.server-world.info/en/note?os=Scientific_Linux_6&p=kvm&f=6


Attempt to manage Fedora 15 KVM Server via Gnome 3 shell

April 9, 2011

Following bellow is brief exercise managing Gnome 3 Desktop to create Ubuntu Maverick Meerkat KVM and run it in spice session.First of all after “yum update” i verified current “qemu” and “libvirt” status on Fedora 15. Virtualization Group has been selected during initial install.

[root@fedora15 ~]# rpm -qa |grep qemu
qemu-common-0.14.0-7.fc15.x86_64
qemu-kvm-0.14.0-7.fc15.x86_64
qemu-img-0.14.0-7.fc15.x86_64
qemu-system-x86-0.14.0-7.fc15.x86_64
gpxe-roms-qemu-1.0.1-4.fc15.noarch

[root@fedora15 ~]# rpm -qa |grep virt
redland-virtuoso-1.0.12-3.fc15.x86_64
virtuoso-opensource-6.1.2-3.fc15.x86_64
python-virtkey-0.50-9.fc15.x86_64
libvirt-0.8.8-4.fc15.x86_64
virt-manager-0.8.7-2.fc15.noarch
python-virtinst-0.500.6-1.fc15.noarch
virt-viewer-0.3.1-1.fc15.x86_64
libvirt-python-0.8.8-4.fc15.x86_64
libvirt-client-0.8.8-4.fc15.x86_64

Then added Virt-Manager to favourites to avoid several mouse clicks at every start up :-






Start Ubuntu 10.10 KVM install :-





Run “apt-get update; apt-get upgrade” in VNC session :-



Switch to SPICE Server



**********************************************************************************************************************************************
In this case Spice Display Screen will show address 127.0.0.1 and connection to via spicec will be available only locally.
To get spicec working remotely remove Display VNC and “Add hardware” Display Spice. It will show you address 0.0.0.0.
In this case connections via spicec will be available remotely
**********************************************************************************************************************************************
Started Ubuntu 10.10 KVM and activated command window via ALT+F2





Follow

Get every new post delivered to your Inbox.