Set up Ubuntu 11.04 ,10.10 KVM to run in spice session on Fedora 14 KVM Server ( Libvirt Preview Env)

The most recent patches to Fedora’s Qemu 0.14 went into qemu-0.14.0-6.fc14.src.rpm on 03/31/2011. Following bellow is brief description of F14 KVM and Spice Server set up via “Libvirt Preview” ( http://repos.fedorapeople.org/repos/jforbes/virt-preview/fedora-14/SRPMS/). Configured KVM Server allows to create Ubuntu 10.10, 11.04 Desktop KVM beta 1 (64 bit), which may run in spice session. Notice that Virt-Manager 0.8.7-2 does have SPICE support. It allows to switch particular VM from VNC Server to SPICE Server and run spice session via GUI or connect to VM via command line locally or remotely.
**********************************************************************************************************************************************
In this case Spice Display Screen will show address 127.0.0.1 and connections to VM 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
***********************************************************************************************************************************************
Ubuntu 10.10 Desktop,11.04 Desktop KVM beta 1 require “apt-get update,apt-get upgrade” to run stable in SPICE session

Configure fedora-virt-preview.repo :-
[root@fedorakvm yum.repos.d]# cat fedora-virt-preview.repo

# Place this file in your /etc/yum.repos.d/ directory
[fedora-virt-preview]

name=Virtualization Preview Repository for Fedora 14 Users
baseurl=http://repos.fedorapeople.org/repos/jforbes/virt-preview/fedora-$releasever/$basearch/
enabled=1
skip_if_unavailable=1
gpgcheck=0

[fedora-virt-preview-source]
name=Virtualization Preview Repository for Fedora 14 Users – Source
baseurl=http://repos.fedorapeople.org/repos/jforbes/virt-preview/fedora-$releasever/SRPMS
enabled=0
skip_if_unavailable=1
gpgcheck=0

Then run :-
# yum update

Make sure :-

[root@fedorakvm ~]# rpm -qa|grep virt
virt-manager-0.8.7-2.fc14.noarch
python-virtkey-0.50-8.fc14.x86_64
libvirt-client-0.8.8-2.fc14.x86_64
libvirt-0.8.8-2.fc14.x86_64
libvirt-python-0.8.8-2.fc14.x86_64
virt-viewer-0.3.1-1.fc14.x86_64
python-virtinst-0.500.6-1.fc14.noarch

[root@fedorakvm ~]# rpm -qa|grep qemu
qemu-system-x86-0.14.0-6.fc14.x86_64
qemu-kvm-0.14.0-6.fc14.x86_64
qemu-common-0.14.0-6.fc14.x86_64
qemu-img-0.14.0-6.fc14.x86_64
gpxe-roms-qemu-1.0.1-3.fc14.noarch

Install spice :-
# yum install spice-protocol spice-server spice-client

Make sure :-

# rpm -qa |grep spice
spice-server-devel-0.8.0-1.fc14.x86_64
spice-protocol-0.8.0-1.fc14.noarch
spice-gtk-python-0.5-1.fc14.x86_64
spice-client-0.8.0-1.fc14.x86_64
spice-glib-0.5-1.fc14.x86_64
spice-server-0.8.0-1.fc14.x86_64
spice-gtk-0.5-1.fc14.x86_64

Create via virt-manager Ubuntu 11.04 Desktop (betta 1) KVM and run :-

# apt-get update
# apt-get upgrade

Due to presence SPICE support in Virt-Manager 0.7.2 switch to SPICE DISPLAY and start SPICE session via Virt-Manager :-





Connection to VM via command line :-



Automatically generated XML profile :-

[root@fedora14sp ~]# virsh dumpxml Natty
<domain type='kvm' id='7'>
<name>Natty</name>
<uuid>18260de6-7958-046a-7bc6-cd5e6d15bff5</uuid>
<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='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-kvm</emulator>
<disk type='block' device='disk'>
<driver name='qemu' type='raw'/>
<source dev='/dev/sda9'/>
<target dev='vda' bus='virtio'/>
<alias name='virtio-disk0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
<disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='hdc' bus='ide'/>
<readonly/>
<alias name='ide0-1-0'/>
<address type='drive' controller='0' bus='1' unit='0'/>
</disk>
<controller type='ide' index='0'>
<alias name='ide0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<interface type='bridge'>
<mac address='52:54:00:63:5d:a9'/>
<source bridge='br0'/>
<target dev='vnet0'/>
<model type='virtio'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<source path='/dev/pts/0'/>
<target port='0'/>
<alias name='serial0'/>
</serial>
<console type='pty' tty='/dev/pts/0'>
<source path='/dev/pts/0'/>
<target type='serial' port='0'/>
<alias name='serial0'/>
</console>
<input type='mouse' bus='ps2'/>
<graphics type='spice' port='5900' tlsPort='-1' autoport='yes' listen='0.0.0.0'/>
<sound model='ac97'>
<alias name='sound0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</sound>
<video>
<model type='cirrus' vram='9216' heads='1'/>
<alias name='video0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<alias name='balloon0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</memballoon>
</devices>
</domain>

Graphics section now looks like :-

<graphics type='spice' port='5900' tlsPort='-1' autoport='yes' listen='0.0.0.0'/>

Old way with modifying XML definition and connecting via command would work as well.
Create script /usr/tmp/qemu-spice :
cat /usr/tmp/qemu-spice
#!/bin/bash

exec /usr/bin/qemu-kvm $* \
-vga qxl \
-spice port=5930,disable-ticketing

# chmod 755 /usr/tmp/qemu-spice

and add to root’s .bashrc
export PATH=/usr/tmp:$PATH

Create via virt-manager Ubuntu 11.04 Desktop (alpha 3) KVM and install QXL driver via Synaptic manager. Say name of VM created is NATTY. Then run :-
# virsh dumpxml NATTY > Natty.xml
Edit XML file as follows

1. Change emulator to /usr/tmp/qemu-spice
2. Remove VIDEO section
3. Remove UUID section
4. Change VM’s name

[root@fedorakvm ~]# cat Natty.xml
<domain type='kvm'>
<name>NATSP</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='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/tmp/qemu-spice</emulator>
<disk type='block' device='disk'>
<driver name='qemu' type='raw'/>
<source dev='/dev/sdb6'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
<disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='hdc' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='1' unit='0'/>
</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:c5:81:45'/>
<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='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes'/>
<sound model='ac97'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</sound>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</memballoon>
</devices>
</domain>

Run :-
# virsh define Natty.xml
and new NATSP entry in Virt-Manager will be created. Start NATSP and connect via
# spicec -h localhost -p 5930
to NATSP






About these ads

3 Responses to Set up Ubuntu 11.04 ,10.10 KVM to run in spice session on Fedora 14 KVM Server ( Libvirt Preview Env)

  1. Jim Jenkins says:

    This has been a life saver! I’ve got the tutorial in place and running spice (though only through TLS port 5901).

    How can I allow outside access to the Spice enabled VM? For example if the following works…

    spicec -h localhost -p 5901

    How can I make it so that this works from other machines on the network?….

    spicec -h 192.168.0.81 -p 5901

    • Lauro Balderas says:

      Hi Jim,

      If you want other machines on your network to have access to your KVM first you need to bridge your ethernet connection. Open a terminal session, change to root and type (Assuming you are using Fedora):

      chkconfig NetworkManager off
      chkconfig network on
      service NetworkManager stop
      service network start

      Create ifcfg-eth0 in /etc/sysconfig/network-scripts with the following values:

      DEVICE=eth0
      # change the hardware address to match your NIC address
      HWADDR=00:16:76:D6:C9:45
      ONBOOT=yes
      BRIDGE=br0

      Create also file ifcfg-br0
      DEVICE=br0
      TYPE=Bridge
      BOOTPROTO=dhcp
      ONBOOT=yes
      DELAY=0

      On the terminal session as root type following commands:
      service network restart
      iptables -I FORWARD -m physdev –physdev-is-bridged -j ACCEPT
      service iptables save
      service iptables restart
      service libvirtd reload

      Then locate the XML profile (file located in /etc/libvirt/qemu/SOMETHING.xml) and change listen=’0.0.0.0′ to match your IP. Save changes and run:

      virsh define /etc/libvirt/qemu/SOMETHING.xml

  2. [...] Here is a good tutorial show you how to Set up Ubuntu 11.04 ,10.10 KVM to run in spice session on Fedora 14 KVM Server: The most recent patches to Fedora’s Qemu 0.14 went into qemu-0.14.0-6.fc14.src.rpm on 03/31/2011. Following bellow is brief description of F14 KVM and Spice Server set up via “Libvirt Preview” ( http://repos.fedorapeople.org/repos/jforbes/virt-preview/fedora-14/SRPMS/). Configured KVM Server allows to create Ubuntu 10.10, 11.04 Desktop KVM beta 1 (64 bit), which may run in spice session. Notice that Virt-Manager 0.8.7-2 does have SPICE support. It allows to switch particular VM from VNC Server to SPICE Server and run spice session via GUI or connect to VM via command line locally or remotely. [...]

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: