Set up KVM/QEMU/SPICE on Ubuntu 11.04

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 :-

shppa-installed.png?w=450&h=360

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 :-

w7-1.png?w=450&h=360

w7-2.png?w=450&h=360

w7-3.png?w=450&h=360

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

w7-5.png?w=450&h=360


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

finalrun.png?w=450&h=360

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"

importexistingimage.png?w=450&h=360

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 :-

libv1.png?w=450&h=360

libv2.png?w=450&h=360

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

Reproduced in: https: //www.cnblogs.com/licheng/archive/2011/05/26/2057856.html

Guess you like

Origin blog.csdn.net/weixin_33860553/article/details/92627475