Qemu-kvm 1.0 & Spice 0.10.0 & Spice-Gtk-0.7.81 USB redirection for Ubuntu Precise, Oneiric and Linux Mint 12 (Lisa)

November 29, 2011

Following bellow is attempt to reproduce Hans de Goede blog entry at http://planet.spice-space.org/ on Ubuntu 12.04 and 11.10 with intend to build Qemu-kvm 1.0 with usb redirection network support per http://planet.spice-space.org/. Current build qemu-kvm for Ubuntu Precise is based on branch http://cgit.freedesktop.org/~jwrdegoede/qemu/. View similar PPA for Ubuntu Oneiric and Linux Mint 12 (Lisa) Qemu-kvm 1.0 & Spice 0.10.0 & Spice-Gtk-0.7.81 USB redirection and Libvirt 0.9.7-2 for Ubuntu Oneiric(v.6).Spice-Gtk-0.7.81 has been built up on current snapshot of git://anongit.freedesktop.org/spice/spice-gtk to obtain Spice-Gtk with usb redirection support working stable with Spice 0.10.0. Builds have been done on Ubuntu Precise and Oneiric as well.Packaged version version of Spice-Gtk-0.7.81 is built up on mentioned git repository. Running autogen.sh with exported environment variable NOCONFIGURE allows to perform it in one build per Debian’s Spice-Gtk-0.7-3 building schema, however requiring several updates to debian/control and debian/rules due to snapshots have to be done from current git tree.Upgrade version of Libvirt up to 0.9.7-2 allows to avoid using “qemu” command line (libvirt 0.9.2) and follow http://planet.spice-space.org/ update VM’s XML profile under /etc/libvirt/qemu/ as suggested in second blog entry of Hans de Goede.

$ git clone git://people.freedesktop.org/~jwrdegoede/qemu
$ cd qemu
$ git checkout -B qemu-kvm-1.0-usbredir origin/qemu-kvm-1.0-usbredir
$ cd ..
$ cp -R qemu qemu-kvm-1.0-usbredir

Intermediate release :-

http://cgit.freedesktop.org/~jwrdegoede/qemu/log/?h=qemu-kvm-1.0-usbredir

clearly demonstrates that all usb redirection patches won’t be in Qemu-kvm 1.0 release

Libusb build is based on libusb-1.0.9-rc3 official package
Qemu-kvm 1.0 debian/rules contains:-

./configure \
–target-list=”x86_64-softmmu i386-softmmu x86_64-linux-user i386-linux-user” \
–prefix=/usr \
–interp-prefix=/etc/qemu-binfmt/%M \
–disable-blobs \
–disable-strip \
–enable-spice \
–enable-usb-redir \
$(conf_arch)

VirtFS support is available.

*****************************************
To install packages from Precise PPA
*****************************************
$ sudo add-apt-repository ppa:bderzhavets/lib-usbredir56
$ sudo apt-get update
$ sudo apt-get install qemu-kvm qemu qemu-common qemu-utils \
spice-client libusb-1.0-0 libusb-1.0-0-dev \
libusbredir libusbredir-dev usbredir-server \
libspice-protocol-dev libspice-server-dev \
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 \
gir1.2-spice-client-glib-2.0 \
gir1.2-spice-client-gtk-2.0 \
gir1.2-spice-client-gtk-3.0

$ sudo apt-get install virtinst virt-manager virt-viewer
$ sudo adduser $USER libvirtd
$ sudo ln -s /etc/apparmor.d/usr.sbin.libvirtd /etc/apparmor.d/disable/

Successful install looks like :-

boris@UbuntuPrecise:~$ dpkg -l |grep libspice
ii  libspice-client-glib-2.0-4         0.7.81~4f76-2ubuntu6    GObject for communicating with Spice servers (runtime library)
ii  libspice-client-glib-2.0-dev       0.7.81~4f76-2ubuntu6    GObject for communicating with Spice servers (development files)
ii  libspice-client-gtk-2.0-1          0.7.81~4f76-2ubuntu6    GTK2 widget for SPICE clients (runtime library)
ii  libspice-client-gtk-2.0-dev        0.7.81~4f76-2ubuntu6    GTK2 widget for SPICE clients (development files)
ii  libspice-client-gtk-3.0-1          0.7.81~4f76-2ubuntu6    GTK3 widget for SPICE clients (runtime library)
ii  libspice-client-gtk-3.0-dev        0.7.81~4f76-2ubuntu6    GTK3 widget for SPICE clients (development files)
ii  libspice-protocol-dev              0.10.0-2ubuntu2         SPICE protocol headers
ii  libspice-server-dev                0.10.0-2ubuntu7         Header files and development documentation for spice-server
ii  libspice-server1                   0.10.0-2ubuntu7         Implements the server side of the SPICE protocol

boris@UbuntuPrecise:~$ dpkg -l |grep qemu
ii  qemu                                1.0-usbredir-2ubuntu3   dummy transitional package from qemu to qemu-kvm
ii  qemu-common                         1.0-usbredir-2ubuntu3   qemu common functionality (bios, documentation, etc)
ii  qemu-kvm                            1.0-usbredir-2ubuntu3   Full virtualization on i386 and amd64 hardware

boris@UbuntuPrecise:~$ dpkg -l |grep libvirt
ii  libvirt-bin                         0.9.7-2ubuntu2         programs for the libvirt library
ii  libvirt0                            0.9.7-2ubuntu2         library for interfacing with different virtualization systems
ii  python-libvirt                      0.9.7-2ubuntu2         libvirt Python bindings



boris@boris-System-Product-P5Q3:~$ virsh version
Compiled against library: libvir 0.9.7
Using library: libvir 0.9.7
Using API: QEMU 0.9.7
Running hypervisor: QEMU 0.15.92

Per Hans de Goede – first create file /etc/qemu/ich9-ehci-uhci.cfg

[device "ehci"]
driver = "ich9-usb-ehci1"
addr = "1d.7"
multifunction = "on"

[device "uhci-1"]
driver = "ich9-usb-uhci1"
addr = "1d.0"
multifunction = "on"
masterbus = "ehci.0"
firstport = "0"

[device "uhci-2"]
driver = "ich9-usb-uhci2"
addr = "1d.1"
multifunction = "on"
masterbus = "ehci.0"
firstport = "2"

[device "uhci-3"]
driver = "ich9-usb-uhci3"
addr = "1d.2"
multifunction = "on"
masterbus = "ehci.0"
firstport = "4"

Upgrade version of Libvirt up to 0.9.7 allows to avoid using “qemu” command line (libvirt 0.9.2) and follow http://planet.spice-space.org/ update VM’s XML profile under /etc/libvirt/qemu/ as suggested in second blog entry of Hans de Goede (September 09, 2011):-
Change the first line from: <domain type=’kvm’> to:
<domain type=’kvm’ xmlns:qemu=’http://libvirt.org/schemas/domain/qemu/1.0′&gt;
And add the following lines at the end, above the “</domain>” line:
<qemu:commandline>
<qemu:arg value=’-readconfig’/>
<qemu:arg value=’/etc/qemu/ich9-ehci-uhci.cfg’/>
<qemu:arg value=’-chardev’/>
<qemu:arg value=’spicevmc,name=usbredir,id=usbredirchardev1′/>
<qemu:arg value=’-device’/>
<qemu:arg value=’usb-redir,chardev=usbredirchardev1,id=usbredirdev1,bus=ehci.0,debug=3′/>
<qemu:arg value=’-chardev’/>
<qemu:arg value=’spicevmc,name=usbredir,id=usbredirchardev2′/>
<qemu:arg value=’-device’/>
<qemu:arg value=’usb-redir,chardev=usbredirchardev2,id=usbredirdev2,bus=ehci.0,debug=3′/>
<qemu:arg value=’-chardev’/>
<qemu:arg value=’spicevmc,name=usbredir,id=usbredirchardev3′/>
<qemu:arg value=’-device’/>
<qemu:arg value=’usb-redir,chardev=usbredirchardev3,id=usbredirdev3,bus=ehci.0,debug=3′/>
</qemu:commandline>

Then run :-

# /etc/init.d/libvirt-bin restart







Remote Qemu&Spice USB redirection. WIN7 VM is running on Server. USB pen plugged in workstation located on the same LAN, with Spice-Gtk-0.7.81 installed. Connection installed via spicy running by root.





Virt-install Oneiric PV DomU at Xen 4.1.2 Oneiric Dom0 via remote HTTP mirror

November 20, 2011

RH’s opensource distros ISO images (Fedora,CentOS) have a nice feature,been loop mounted on apache folder /var/www/domain, they allow to create local mirror to virt-install corresponding paravirtual guest. Not customized Ubuntu ISOs don’t have this feature, however virt-install still works for Oneiric, Natty, Lucid utilizing remote system HTTP source. Virt-install Oneiric PV DomU is possible via remote official HTTP source :-

http://ca.archive.ubuntu.com/ubuntu/dists/oneiric/main/installer-amd64/.

Start install by command :-

virt-install --connect xen:/// -n OneiricPV \
--nographics \
-p -r 2048 --vcpus=2 -f /dev/sdb6 \
-l http://ca.archive.ubuntu.com/ubuntu/dists/oneiric/main/installer-amd64/

proceed with text mode install









Diring tasksel run I’ve selected “Basic Ubuntu Server”,”SSH”,”Ubuntu Desktop”



all done domain reboots



Open Virt-Manager and add VNC Server to graphics section



Start updated DomU via Virt-Manager:-





Virt-install Debian Squeeze PV DomU at Xen 4.1.2 Oneiric Dom0

November 19, 2011

RH’s opensource distros ISO images (Fedora,CentOS) have a nice feature,been loop mounted on apache folder /var/www/domain, they allow to create local mirror to virt-install corresponding paravirtual guest. Not customized Debian ISOs don’t have this feature, however virt-install still works for Debian Squeeze utilizing remote system HTTP source. Virt-install Debian PV DomU is possible via remote official HTTP source.Begin via virt-install command line

root@boris-System-P5Q3:~# virt-install --connect xen:/// --debug -n SQUEEZE --vnc \
> -p -r 2048 --vcpus=2 -f /dev/sdb7 \
> -l http://ftp.at.debian.org/debian/dists/squeeze/main/installer-amd64/
Sat, 19 Nov 2011 19:23:20 DEBUG Launched with command line:
/usr/bin/virt-install --connect xen:/// --debug -n SQUEEZE --vnc -p -r 2048 --vcpus=2 -f /dev/sdb7 -l http://ftp.at.debian.org/debian/dists/squeeze/main/installer-amd64/
Sat, 19 Nov 2011 19:23:20 DEBUG Requesting libvirt URI xen:///
Sat, 19 Nov 2011 19:23:20 DEBUG Received libvirt URI xen:///
Sat, 19 Nov 2011 19:23:20 DEBUG Requesting virt method 'xen', hv type 'default'.
Sat, 19 Nov 2011 19:23:20 DEBUG Received virt method 'xen'
Sat, 19 Nov 2011 19:23:20 DEBUG Hypervisor name is 'xen'
Sat, 19 Nov 2011 19:23:20 DEBUG --graphics compat generated: vnc
Sat, 19 Nov 2011 19:23:20 DEBUG DistroInstaller location is a network source.
Sat, 19 Nov 2011 19:23:20 DEBUG Attempting to detect distro:
Sat, 19 Nov 2011 19:23:22 DEBUG Fetching URI: http://ftp.at.debian.org/debian/dists/squeeze/main/installer-amd64/current/images/MANIFEST
Sat, 19 Nov 2011 19:23:22 DEBUG Saved file to /var/tmp/virtinst-MANIFEST.1GW1wt
Sat, 19 Nov 2011 19:23:22 DEBUG Detected a Debian distro
Sat, 19 Nov 2011 19:23:22 DEBUG Guest.has_install_phase: True
Starting install...
Sat, 19 Nov 2011 19:23:22 DEBUG scratchdir=/var/lib/xen
Sat, 19 Nov 2011 19:23:23 DEBUG Attempting to detect distro:
Sat, 19 Nov 2011 19:23:25 DEBUG Fetching URI: http://ftp.at.debian.org/debian/dists/squeeze/main/installer-amd64/current/images/MANIFEST
Sat, 19 Nov 2011 19:23:25 DEBUG Saved file to /var/lib/xen/virtinst-MANIFEST.rh1eGO
Retrieving file MANIFEST... | 3.3 kB 00:00 ...
Sat, 19 Nov 2011 19:23:25 DEBUG Detected a Debian distro
Sat, 19 Nov 2011 19:23:25 DEBUG Fetching URI: http://ftp.at.debian.org/debian/dists/squeeze/main/installer-amd64/current/images/netboot/xen/vmlinuz
Sat, 19 Nov 2011 19:23:36 DEBUG Saved file to /var/lib/xen/virtinst-vmlinuz.5Or9oh 00:00 ETA
Retrieving file vmlinuz... | 4.6 MB 00:10 ...
Sat, 19 Nov 2011 19:23:36 DEBUG Fetching URI: http://ftp.at.debian.org/debian/dists/squeeze/main/installer-amd64/current/images/netboot/xen/initrd.gz
Sat, 19 Nov 2011 19:24:51 DEBUG Saved file to /var/lib/xen/virtinst-initrd.gz.T9hVje 00:00 ETA
Retrieving file initrd.gz... | 37 MB 01:15 ...
Sat, 19 Nov 2011 19:24:51 DEBUG Auto detected OS type as: linux
Sat, 19 Nov 2011 19:24:51 DEBUG Have access to local system scratchdir so nothing to upload
Sat, 19 Nov 2011 19:24:51 DEBUG Could not open "/etc/sysconfig/keyboard" [Errno 2] No such file or directory: '/etc/sysconfig/keyboard'
Sat, 19 Nov 2011 19:24:51 DEBUG Could not open "/etc/X11/xorg.conf": [Errno 2] No such file or directory: '/etc/X11/xorg.conf'
Sat, 19 Nov 2011 19:24:51 DEBUG Could not open "/etc/sysconfig/keyboard" [Errno 2] No such file or directory: '/etc/sysconfig/keyboard'
Sat, 19 Nov 2011 19:24:51 DEBUG Could not open "/etc/X11/xorg.conf": [Errno 2] No such file or directory: '/etc/X11/xorg.conf'
Sat, 19 Nov 2011 19:24:51 DEBUG Generated install XML:
<domain type='xen'>
<name>SQUEEZE</name>
<uuid>3978d7ce-454b-103e-d9df-a486052bf6ce</uuid>
<memory>2097152</memory>
<currentMemory>2097152</currentMemory>
<vcpu>2</vcpu>
<os>
<type arch='x86_64'>linux</type>
<kernel>/var/lib/xen/virtinst-vmlinuz.5Or9oh</kernel>
<initrd>/var/lib/xen/virtinst-initrd.gz.T9hVje</initrd>
<cmdline>method=http://ftp.at.debian.org/debian/dists/squeeze/main/installer-amd64/</cmdline>
</os>
<features>
<acpi/><apic/>
</features>
<on_poweroff>destroy</on_poweroff>
<on_reboot>destroy</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<disk type='block' device='disk'>
<source dev='/dev/sdb7'/>
<target dev='xvda' bus='xen'/>
</disk>
<interface type='bridge'>
<source bridge='br0'/>
<mac address='00:16:3e:da:f5:3f'/>
</interface>
<input type='mouse' bus='xen'/>
<graphics type='vnc' port='-1' keymap='en-us'/>
<video>
<model type='cirrus'/>
</video>
</devices>
</domain>
Sat, 19 Nov 2011 19:24:51 DEBUG Generated boot XML:
<domain type='xen'>
<name>SQUEEZE</name>
<uuid>3978d7ce-454b-103e-d9df-a486052bf6ce</uuid>
<memory>2097152</memory>
<currentMemory>2097152</currentMemory>
<vcpu>2</vcpu>
<bootloader>/usr/lib/xen-default/bin/pygrub</bootloader>
<features>
<acpi/><apic/>
</features>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<disk type='block' device='disk'>
<source dev='/dev/sdb7'/>
<target dev='xvda' bus='xen'/>
</disk>
<interface type='bridge'>
<source bridge='br0'/>
<mac address='00:16:3e:da:f5:3f'/>
</interface>
<input type='mouse' bus='xen'/>
<graphics type='vnc' port='-1' keymap='en-us'/>
<video>
<model type='cirrus'/>
</video>
</devices>
</domain>
Creating domain... | 0 B 00:01
Sat, 19 Nov 2011 19:24:53 DEBUG Started guest, connecting to console if requested
Sat, 19 Nov 2011 19:24:53 DEBUG Launching virt-viewer for graphics type 'vnc'
Sat, 19 Nov 2011 19:24:53 DEBUG Running: /usr/bin/virt-viewer --connect xen:/// --wait 1
(virt-viewer:2892): Gtk-WARNING **: Unable to locate theme engine in module_path: "pixmap",
Sat, 19 Nov 2011 19:24:53 DEBUG XML fetched from libvirt object:
<domain type='xen' id='1'>
<name>SQUEEZE</name>
<uuid>3978d7ce-454b-103e-d9df-a486052bf6ce</uuid>
<description></description>
<memory>2097152</memory>
<currentMemory>2097152</currentMemory>
<vcpu>2</vcpu>
<bootloader></bootloader>
<bootloader_args></bootloader_args>
<os>
<type>linux</type>
<kernel>/var/lib/xen/virtinst-vmlinuz.5Or9oh</kernel>
<initrd>/var/lib/xen/virtinst-initrd.gz.T9hVje</initrd>
<cmdline>method=http://ftp.at.debian.org/debian/dists/squeeze/main/installer-amd64/</cmdline>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>destroy</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/lib/xen-4.1/bin/qemu-dm</emulator>
<disk type='block' device='disk'>
<driver name='phy'/>
<source dev='/dev/sdb7'/>
<target dev='xvda' bus='xen'/>
</disk>
<interface type='bridge'>
<mac address='00:16:3e:da:f5:3f'/>
<source bridge='br0'/>
<script path='/etc/xen/scripts/vif-bridge'/>
<target dev='vif1.0'/>
</interface>
<console type='pty' tty='/dev/pts/2'>
<source path='/dev/pts/2'/>
<target type='xen' port='0'/>
</console>
<input type='mouse' bus='xen'/>
<graphics type='vnc' port='5900' autoport='yes' keymap='en-us'/>
</devices>
</domain>







Sat, 19 Nov 2011 20:04:50 DEBUG Removing /var/lib/xen/virtinst-vmlinuz.5Or9oh
Sat, 19 Nov 2011 20:04:50 DEBUG Removing /var/lib/xen/virtinst-initrd.gz.T9hVje
Guest installation complete... restarting guest.
Sat, 19 Nov 2011 20:04:56 DEBUG Launching virt-viewer for graphics type 'vnc'
Sat, 19 Nov 2011 20:04:56 DEBUG Running: /usr/bin/virt-viewer --connect xen:/// --wait 2
(virt-viewer:3705): Gtk-WARNING **: Unable to locate theme engine in module_path: "pixmap",




root@boris-System-P5Q3:~# virsh list –all
Id Name State
———————————-
0 Domain-0 running
– OneiricPV shut off
– SQUEEZE shut off
– VF16PV shut off
– VF16RC5 shut off

root@boris-System-P5Q3:~# virsh start SQUEEZE
Domain SQUEEZE started

root@boris-System-P5Q3:~# vncviewer localhost:0

VNC Viewer Free Edition 4.1.1 for X – built Sep 7 2011 11:16:25
Copyright (C) 2002-2005 RealVNC Ltd.
See http://www.realvnc.com for information on VNC.

Sat Nov 19 20:11:30 2011
CConn: connected to host localhost port 5900
CConnection: Server supports RFB protocol version 3.8
CConnection: Using RFB protocol version 3.8
TXImage: Using default colormap and visual, TrueColor, depth 24.
CConn: Using pixel format depth 6 (8bpp) rgb222
CConn: Using ZRLE encoding
CConn: Throughput 20006 kbit/s – changing to hextile encoding
CConn: Throughput 20006 kbit/s – changing to full colour
CConn: Using pixel format depth 24 (32bpp) little-endian rgb888
CConn: Using hextile encoding

VNC window pops up nicely.

Domain also is manageable via VirtManager :-




Qemu-kvm 0.15.1 & Spice(0.10.0) & Libvirt 0.9.7-2 USB Redirection support for Ubuntu Precise and Oneiric

November 14, 2011

***********************************************************************
Update on 11/29/2011 . View also build based on Qemu-kvm-1.0-rc2
***********************************************************************
$ gir clone git://people.freedesktop.org/~jwrdegoede/qemu
$ cd qemu
$ git checkout -B qemu-kvm-1.0-usbredir origin/qemu-kvm-1.0-usbredir
$ cp -R qemu qemu-kvm-1.0-usbredir
Libusb build is based on git://git.libusb.org/libusb.git – 1.0.9-rc1
libusb-1.0.9-rc1 release candidate
Qemu-kvm 1.0 & Spice 0.10.0 & Spice-Gtk-0.7.81 USB redirection for Ubuntu Precise (v.6)
***********************************************************************
Following bellow is attempt to reproduce Hans de Goede blog entry at http://planet.spice-space.org/ on Ubuntu 12.04 and 11.10 with intend to build Qemu-kvm 0.15.1 with usb redirection network support per http://planet.spice-space.org/ via git repository git://people.freedesktop.org/~jwrdegoede/qemu.
Qemu-kvm 0.15.1 has been patched via top 28 commits from

http://cgit.freedesktop.org/~jwrdegoede/qemu/log/?h=qemu-kvm-0.15.0-usbredir

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

Spice-Gtk-0.7.81 has been built up on current snapshot of git://anongit.freedesktop.org/spice/spice-gtk to obtain Spice-Gtk with usb redirection support working stable with Spice 0.10.0. Builds have been done on Ubuntu Precise and Oneiric as well.Packaged version version of Spice-Gtk-0.7.81 is built up on mentioned git repository. Running autogen.sh with exported environment variable NOCONFIGURE allows to perform it in one build per Debian’s Spice-Gtk-0.7-3 building schema, however requiring several updates to debian/control and debian/rules due to snapshots have to be done from current git tree.Upgrade version of Libvirt up to 0.9.7-2 allows to avoid using “qemu” command line (libvirt 0.9.2) and follow http://planet.spice-space.org/ update VM’s XML profile under /etc/libvirt/qemu/ as suggested in second blog entry of Hans de Goede.
Per Daniel Berrange: In the same way that SSH allows you to setup hostname aliases in $HOME/.ssh/config, libvirt will now allow you to setup URI aliases in $HOME/.libvirt/libvirt.conf (if you are running unprivileged) or /etc/libvirt/libvirt.conf (if you are running as root). NB do not confuse this file with libvirtd.conf which is a server side libvirtd daemon config file. Due to spice upgrade users should be able to run Spice server on 32-bit OS (Precise daily builds). View also Qemu-kvm 0.15.1 & Spice(0.10.0) & Libvirt 0.9.7-2 USB Redirection support for Ubuntu Oneiric.
Libvirt upgrade is based on
$ git clone git://anonscm.debian.org/pkg-libvirt/libvirt.git
Tip commit bd0fbb5542d8f96209611bb2db4f58a5176275bb.
View : http://anonscm.debian.org/gitweb/?p=pkg-libvirt/libvirt.git

Qemu-kvm debian/rules contains:-

./configure \
–target-list=”x86_64-softmmu i386-softmmu x86_64-linux-user i386-linux-user” \
–prefix=/usr \
–interp-prefix=/etc/qemu-binfmt/%M \
–disable-blobs \
–disable-strip \
–enable-spice \
–enable-usb-redir \
$(conf_arch)

VirtFS support is available.

*****************************
To install packages from PPA
*****************************
$ sudo add-apt-repository ppa:bderzhavets/spice-010
$ sudo apt-get update
$ sudo apt-get install qemu-kvm qemu qemu-common \
spice-client seabios \
libusb-1.0-0 libusb-1.0-0-dev \
libusbredir libusbredir-dev \
libspice-protocol-dev libspice-server-dev \
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 \
gir1.2-spice-client-glib-2.0 \
gir1.2-spice-client-gtk-2.0 \
gir1.2-spice-client-gtk-3.0

$ sudo groupadd libvirtd
$ sudo adduser $USER libvirtd
RELOGIN
$ 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





Rebuilding 3.1 & 3.0 Linux Kernel in Ubuntu style to support PV-on-HVM

November 6, 2011

*********************************************************************************************************************
Stock kernel for Oneiric (3.0.X.Y) has same Xen configuration as 3.1. I have filed bug against 3.1 at Launchpad regarding kernel configuration fix,however, in meantime i had to pass through procedure bellow with intend to benefit from PV-on-HVM feature providing by Xen 4.1.X Hypervisor and properly built 3.0 or 3.1 linux kernel. I follow [1] step by step updating config.flavour.pvhvm as required to perform kernel rebuild. In meantime status of bug at Launchpad is “Triaged”.There is another attractive option – just add driver xen-platform-pci.ko to initrd.img as post installation procedure. Then reboot with xen_platform_pci=1. I choosed kernel rebuild as option following core development [2]
**********************************************************************************************************************

A) To rebuild 3.1 :-
$ git clone git://kernel.ubuntu.com/ubuntu/ubuntu-precise.git source
B) To rebuild 3.0 :-
$ git clone git://kernel.ubuntu.com/ubuntu/ubuntu-oneiric.git source
$ cd source
$ git tag|grep Ubu|sort -V
Ubuntu-3.1.0-1.0
Ubuntu-3.1.0-1.1
Ubuntu-3.1.0-2.2
Ubuntu-3.1.0-2.3
Checkout branch and give it name "pvhvm"
$ git checkout Ubuntu-3.1.0-2.3 -b pvhvm
$ cp debian.master/config/amd64/config.flavour.generic debian.master/config/amd64/config.flavour.pvhvm
$ fakeroot debian/rules clean
$ debian/rules updateconfigs
$ debian/rules editconfigs
*************************************************************
$ Do you want to edit config: amd64/config.flavour.pvhvm? [Y/n]
*************************************************************
#
# Config options for config.flavour.pv automatically generated by splitconfig.pl
#
CONFIG_DEFAULT_CFQ=y
# CONFIG_DEFAULT_DEADLINE is not set
CONFIG_DEFAULT_IOSCHED="cfq"
CONFIG_FB_SYS_COPYAREA=y
CONFIG_FB_SYS_FILLRECT=y
CONFIG_FB_SYS_FOPS=y
CONFIG_FB_SYS_IMAGEBLIT=y
CONFIG_INTEL_IDLE=y
CONFIG_NR_CPUS=256
# CONFIG_PREEMPT_NONE is not set
CONFIG_PREEMPT_VOLUNTARY=y
CONFIG_VIRTIO=m
CONFIG_VIRTIO_BLK=m
CONFIG_VIRTIO_NET=m
CONFIG_VIRTIO_PCI=m
CONFIG_VIRTIO_RING=m
CONFIG_XEN_BLKDEV_FRONTEND=m
CONFIG_XEN_FBDEV_FRONTEND=y
CONFIG_XEN_NETDEV_FRONTEND=m
CONFIG_XEN_PLATFORM_PCI=y
CONFIG_XEN_XENBUS_FRONTEND=y






Make sure you have updated config.flavour.pvhvm before proceed.
****************
Backup config
****************

$ cp debian.master/config/amd64/config.flavour.pvhvm ../.
$ git reset --hard
$ git clean -df
To pick up number of previous version.
$ ls debian.master/abi
3.1.0-2.2
$ cp debian.master/abi/3.1.0-2.2/amd64/generic debian.master/abi/3.1.0-2.2/amd64/pvhvm
$ cp debian.master/abi/3.1.0-2.2/amd64/generic.modules debian.master/abi/3.1.0-2.2/amd64/pvhvm.modules

***************
Restore config
***************

cp ../config.flavour.pvhvm debian.master/config/amd64/

File: debian.master/etc/getabis

Search for the line:
getall amd64 generic server virtual
Change it in:
getall amd64 generic server virtual pvhvm

File: debian.master/rules.d/amd64.mk

Search for the line:
flavours = generic server virtual
Change it in:
flavours = generic server virtual pvhvm

File: debian.master/control.d/vars.pv
This files does not exist and in order to make the compilation process aware of our own flavor we want to compile we need to create it.

$ cp debian.master/control.d/vars.generic debian.master/control.d/vars.pvhvm
$ git add .
$ git commit -a -m "pv Modifications"
Checkout branch "work" for build
$ git checkout -b work
$ fakeroot debian/rules clean
$ skipabi=true skipmodule=true fakeroot debian/rules binary-indep
$ skipabi=true skipmodule=true fakeroot debian/rules binary-perarch
$ skipabi=true skipmodule=true fakeroot debian/rules binary-pvhvm

If all went OK, then
~/KERNEL02/source$ ls -l ../
total 54208
-rw-rw-r– 1 boris boris 606 2011-11-06 16:39 config.flavour.pvhvm
-rw-r–r– 1 boris boris 4496196 2011-11-06 16:52 linux-doc_3.1.0-2.3_all.deb
-rw-r–r– 1 boris boris 11586658 2011-11-06 16:52 linux-headers-3.1.0-2_3.1.0-2.3_all.deb
-rw-r–r– 1 boris boris 965564 2011-11-06 17:19 linux-headers-3.1.0-2-pvhvm_3.1.0-2.3_amd64.deb
-rw-r–r– 1 boris boris 37880092 2011-11-06 17:19 linux-image-3.1.0-2-pvhvm_3.1.0-2.3_amd64.deb
-rw-r–r– 1 boris boris 63952 2011-11-06 16:52 linux-source-3.1.0_3.1.0-2.3_all.deb
-rw-r–r– 1 boris boris 382278 2011-11-06 16:53 linux-tools-3.1.0-2_3.1.0-2.3_amd64.deb
-rw-r–r– 1 boris boris 112558 2011-11-06 16:52 linux-tools-common_3.1.0-2.3_all.deb
drwxr-xr-x 27 boris boris 4096 2011-11-06 16:53 source

Changes done to kernel been rebuilt .

--- xenconf.3.1.0-030100-generic 2011-11-06 11:03:39.225828270 +0400
+++ xenconf.3.1.0-2-vnc 2011-11-06 11:04:58.621827223 +0400
@@ -16,19 +16,20 @@
CONFIG_INPUT_XEN_KBDDEV_FRONTEND=m
CONFIG_HVC_XEN=y
CONFIG_XEN_WDT=m
-CONFIG_XEN_FBDEV_FRONTEND=m
+CONFIG_XEN_FBDEV_FRONTEND=y
CONFIG_XEN_BALLOON=y
-# CONFIG_XEN_SELFBALLOONING is not set
+CONFIG_XEN_SELFBALLOONING=y
+CONFIG_XEN_BALLOON_MEMORY_HOTPLUG=y
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_XEN_DEV_EVTCHN=m
CONFIG_XEN_BACKEND=y
CONFIG_XENFS=m
CONFIG_XEN_COMPAT_XENFS=y
CONFIG_XEN_SYS_HYPERVISOR=y
-CONFIG_XEN_XENBUS_FRONTEND=m
+CONFIG_XEN_XENBUS_FRONTEND=y
CONFIG_XEN_GNTDEV=m
CONFIG_XEN_GRANT_DEV_ALLOC=m
-CONFIG_XEN_PLATFORM_PCI=m
+CONFIG_XEN_PLATFORM_PCI=y
CONFIG_SWIOTLB_XEN=y
CONFIG_XEN_TMEM=y
CONFIG_XEN_PCIDEV_BACKEND=m

References
1. http://blog.avirtualhome.com/2011/10/28/how-to-compile-a-new-ubuntu-11-10-oneiric-kernel/
2. http://xen.1045712.n5.nabble.com/PATCH-xen-remove-XEN-PLATFORM-PCI-config-option-td4833154.html


Set up Oneiric PVHVM at Xen 4.1.2 Ubuntu Oneiric Dom0 (3.1.0-030100-generic)

November 2, 2011

This post is sample of utilizing optimized paravirtualized PVHVM drivers (also called PV-on-HVM drivers) with Xen fully virtualized HVM guests running Ubuntu 3.1 kernels at Xen 4.1.2 Dom0. Xen PVHVM drivers completely bypass the Qemu emulation and provide much faster disk- and network IO performance. First thing I had to do it was rebuild the recent Ubuntu kernel for precise Ubuntu-3.1.0-3 ( follow [1]) with CONFIG_XEN_PLATFORM_PCI=y. As result following debian packages gets created.

root@boris-System-P5Q3:/mnt/root/precise# ls -l
total 54196
-rw-r--r-- 1 root root 484 2011-11-02 17:44 config.flavour.pvhvm
-rw-r--r-- 1 root root 4496134 2011-11-02 17:53 linux-doc_3.1.0-2.3_all.deb
-rw-r--r-- 1 root root 11586896 2011-11-02 17:53 linux-headers-3.1.0-2_3.1.0-2.3_all.deb
-rw-r--r-- 1 root root 966630 2011-11-02 18:29 linux-headers-3.1.0-2-pvhvm_3.1.0-2.3_amd64.deb
-rw-r--r-- 1 root root 37869094 2011-11-02 18:29 linux-image-3.1.0-2-pvhvm_3.1.0-2.3_amd64.deb
-rw-r--r-- 1 root root 63952 2011-11-02 17:53 linux-source-3.1.0_3.1.0-2.3_all.deb
-rw-r--r-- 1 root root 382274 2011-11-02 17:55 linux-tools-3.1.0-2_3.1.0-2.3_amd64.deb
-rw-r--r-- 1 root root 112522 2011-11-02 17:53 linux-tools-common_3.1.0-2.3_all.deb
drwxr-xr-x 27 root root 4096 2011-11-02 17:55 source

I’ve updated only “git clone” to get 3.1 kernel.

git clone git://kernel.ubuntu.com/ubuntu/ubuntu-precise.git source

There is another attractive option – just add driver xen-platform-pci to initrd.img as post installation procedure. Then reboot with xen_platform_pci=1. I choosed kernel rebuild option following core development [2]
Regardless [1] is written for Oneiric , it works for Precise kernel with minimal change above.Details may be viewed in Rebuilding 3.1 Linux Kernel in Ubuntu’s style
Next install regular HVM domain via profile :-

kernel ='/usr/lib64/xen/boot/hvmloader'
builder='hvm'
device_model = '/usr/lib64/xen/bin/qemu-dm'
name = "OneiricPV-HVM"
memory = 2048
vcpus=2
pae=1
acpi=1
apic=1
vif = [ 'type=ioemu, mac=00:16:3f:03:01:14, bridge=virbr0, model=e1000' ]
disk = [ 'phy:/dev/sda7,hda,w', 'phy:/dev/loop0,hdc:cdrom,r' ]
# disk = [ 'phy:/dev/sda7,hda,w']
boot='d'
xen_platform_pci=0
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
sdl=0
vnc=1
vncpasswd=''
stdvga=0
serial='pty'
tsc_mode=0
usb=1
usbdevice='tablet'


Then three debian packages (result of standard Ubuntu 3.1 kernel rebuild):

linux-headers-3.1.0-2_3.1.0-2.3_all.deb
linux-headers-3.1.0-2-pvhvm_3.1.0-2.3_amd64.deb
linux-image-3.1.0-2-pvhvm_3.1.0-2.3_amd64.deb

have been scp’ed to Oneiric HVM DomU and new 3.1 Ubuntu kernel has been installed.

sudo dpkg -i linux-headers-3.1.0-2_3.1.0-2.3_all.deb \
linux-headers-3.1.0-2-pvhvm_3.1.0-2.3_amd64.deb \
linux-image-3.1.0-2-pvhvm_3.1.0-2.3_amd64.deb

Following xen front end’s drivers were included into /boot/initrd.img-3.1.0-2-pvhvm

root@boris-HVM-domU:~# echo "xen-blkfront" >> /etc/initramfs-tools/modules
root@boris-HVM-domU:~# echo "xen-netfront" >> /etc/initramfs-tools/modules
root@boris-HVM-domU:~# vi /etc/initramfs-tools/modules
root@boris-HVM-domU:~# update-initramfs -u
update-initramfs: Generating /boot/initrd.img-3.1.0-2-pvhvm

Domain has been shutdown and restarted with updated profile,having
xen_platform_pci=1
Runtime profile

kernel ='/usr/lib64/xen/boot/hvmloader'
builder='hvm'
device_model = '/usr/lib64/xen/bin/qemu-dm'
name = "OneiricPV-HVM"
memory = 2048
vcpus=2
pae=1
acpi=1
apic=1
vif = [ 'mac=00:16:3f:03:01:14, bridge=virbr0, model=e1000' ]
# disk = [ 'phy:/dev/sda7,hda,w', 'phy:/dev/loop0,hdc:cdrom,r' ]
disk = [ 'phy:/dev/sda7,hda,w']
boot='c'
xen_platform_pci=1
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
sdl=0
vnc=1
vncpasswd=''
stdvga=0
serial='pty'
tsc_mode=0
usb=1
usbdevice='tablet'

This time HVM domU gets loaded ( vs using regular kernel) and dmesg report contains following messages which are the fair of success PVHVM domain loading :-

[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Linux version 3.1.0-2-pvhvm (root@boris-System-P5Q3) (gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3) ) #3 SMP Wed Nov 2 15:15:13 MSK 2011 (Ubuntu 3.1.0-2.3-pvhvm 3.1.0)
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-3.1.0-2-pvhvm root=UUID=bff48eed-20df-4abf-b788-935c75ea6226 ro quiet splash vt.handoff=7
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[ 0.000000] AMD AuthenticAMD
[ 0.000000] Centaur CentaurHauls
[ 0.000000] BIOS-provided physical RAM map:
[ 0.000000] BIOS-e820: 0000000000000000 - 000000000009e000 (usable)
[ 0.000000] BIOS-e820: 000000000009e000 - 00000000000a0000 (reserved)
[ 0.000000] BIOS-e820: 00000000000e0000 - 0000000000100000 (reserved)
[ 0.000000] BIOS-e820: 0000000000100000 - 000000003f800000 (usable)
[ 0.000000] BIOS-e820: 00000000fc000000 - 0000000100000000 (reserved)
[ 0.000000] NX (Execute Disable) protection: active
[ 0.000000] DMI 2.4 present.
[ 0.000000] DMI: Xen HVM domU, BIOS 4.1.2 10/20/2011
[ 0.000000] Hypervisor detected: Xen HVM
[ 0.000000] Xen version 4.1.
[ 0.000000] Xen Platform PCI: I/O protocol version 1
[ 0.000000] Netfront and the Xen platform PCI driver have been compiled for this kernel: unplug emulated NICs.
[ 0.000000] Blkfront and the Xen platform PCI driver have been compiled for this kernel: unplug emulated disks.
[ 0.000000] You might have to change the root device
[ 0.000000] from /dev/hd[a-d] to /dev/xvd[a-d]



Managing domains via xm ( Xen 4.1.2)

# apt-get install python-lxml
# xm new oneiric7.hvm
# xm list
Name ID Mem VCPUs State Time(s)
Domain-0 0 7199 4 r----- 9276.7
OneiricPV-HVM 2048 2 0.0
# xm start OneiricPV-HVM
# vncviewer localhost:0

Several useful commands per http://wiki.xen.org/xenwiki/XenLinuxPVonHVMdrivers

# dmesg | egrep -i 'xen|front'
[ 0.000000] DMI: Xen HVM domU, BIOS 4.1.2 10/20/2011
[ 0.000000] Hypervisor detected: Xen HVM
[ 0.000000] Xen version 4.1.
[ 0.000000] Xen Platform PCI: I/O protocol version 1
[ 0.000000] Netfront and the Xen platform PCI driver have been compiled for this kernel: unplug emulated NICs.
[ 0.000000] Blkfront and the Xen platform PCI driver have been compiled for this kernel: unplug emulated disks.
[ 0.000000] ACPI: RSDP 00000000000ea020 00024 (v02 Xen)
[ 0.000000] ACPI: XSDT 00000000fc0134f0 0003C (v01 Xen HVM 00000000 HVML 00000000)
[ 0.000000] ACPI: FACP 00000000fc0132d0 000F4 (v04 Xen HVM 00000000 HVML 00000000)
[ 0.000000] ACPI: DSDT 00000000fc003440 0FE05 (v02 Xen HVM 00000000 INTL 20100528)
[ 0.000000] ACPI: APIC 00000000fc0133d0 000D8 (v02 Xen HVM 00000000 HVML 00000000)
[ 0.000000] ACPI: HPET 00000000fc0134b0 00038 (v01 Xen HVM 00000000 HVML 00000000)
[ 0.000000] Booting paravirtualized kernel on Xen HVM
[ 0.000000] Xen HVM callback vector for event delivery is enabled
[ 0.087915] Xen: using vcpuop timer interface
[ 0.087922] installing Xen timer for CPU 0
[ 0.176052] installing Xen timer for CPU 1
[ 0.631112] xen/balloon: Initialising balloon driver.
[ 0.631125] xen-balloon: Initialising balloon driver.
[ 0.636079] Switching to clocksource xen
[ 0.647494] xen: --> pirq=16 -> irq=8 (gsi=8)
[ 0.647569] xen: --> pirq=17 -> irq=12 (gsi=12)
[ 0.647619] xen: --> pirq=18 -> irq=1 (gsi=1)
[ 0.647665] xen: --> pirq=19 -> irq=6 (gsi=6)
[ 0.647719] xen: --> pirq=20 -> irq=4 (gsi=4)
[ 0.647792] xen: --> pirq=21 -> irq=7 (gsi=7)
[ 0.731857] xen: --> pirq=22 -> irq=28 (gsi=28)
[ 0.731861] xen-platform-pci 0000:00:03.0: PCI INT A -> GSI 28 (level, low) -> IRQ 28
[ 0.833848] xen: --> pirq=23 -> irq=23 (gsi=23)
[ 1.255228] blkfront device/vbd/768 num-ring-pages 1 nr_ents 32.
[ 1.258186] blkfront: xvda: flush diskcache: enabled
[ 1.274037] Initialising Xen virtual ethernet driver.
# ethtool -i eth0
driver: vif
version:
firmware-version:
bus-info: vif-0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: no
# cat /proc/partitions
major minor #blocks name
202 0 20480000 xvda
202 1 19439616 xvda1
202 2 1 xvda2
202 5 1037312 xvda5

At this point domain may be loaded via pygrub as PV guest :-

<domain type='xen' id='3'>
<name>OneiricPV</name>
<description></description>
<memory>2097152</memory>
<currentMemory>2097152</currentMemory>
<vcpu>2</vcpu>
<bootloader>/usr/lib/xen-default/bin/pygrub</bootloader>
<bootloader_args></bootloader_args>
<os>
<type>linux</type>
<kernel></kernel>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<disk type='block' device='disk'>
<driver name='phy'/>
<source dev='/dev/sda7'/>
<target dev='xvda' bus='xen'/>
</disk>
<interface type='bridge'>
<mac address='00:16:3e:35:61:47'/>
<source bridge='br0'/>
<script path='/etc/xen/scripts/vif-bridge'/>
<target dev='vif3.0'/>
</interface>
<console type='pty' tty='/dev/pts/2'>
<source path='/dev/pts/2'/>
<target type='xen' port='0'/>
</console>
<input type='mouse' bus='xen'/>
<graphics type='vnc' port='5900' autoport='yes' keymap='en-us'/>
</devices>
</domain>

# virsh define OneiricPV.xml
# virsh start OneiricPV



References
1. http://blog.avirtualhome.com/2011/10/28/how-to-compile-a-new-ubuntu-11-10-oneiric-kernel/
2. http://xen.1045712.n5.nabble.com/PATCH-xen-remove-XEN-PLATFORM-PCI-config-option-td4833154.html


Qemu-kvm 0.15.1 & Spice USB Redirection support for Ubuntu Oneiric

November 1, 2011

Qemu-kvm 0.15.1 has been patched via top 28 commits from

http://cgit.freedesktop.org/~jwrdegoede/qemu/log/?h=qemu-kvm-0.15.0-usbredir

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

Qemu-kvm debian/rules contains:-

./configure \
–target-list=”x86_64-softmmu i386-softmmu x86_64-linux-user i386-linux-user” \
–prefix=/usr \
–interp-prefix=/etc/qemu-binfmt/%M \
–disable-blobs \
–disable-strip \
–enable-spice \
–enable-usb-redir \
$(conf_arch)

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

Spicy should be run by root, view http://planet.spice-space.org/

Spice-Gtk-0.7.6X build in general follows Debian’s 0.7-3 packaging schema, however several changes have been done to debian/control and debian/rules
**********************************
To install packages from PPA
**********************************
$ sudo add-apt-repository ppa:bderzhavets/0151-usbredir
$ sudo apt-get update
$ sudo apt-get install qemu-kvm qemu qemu-common \
spice-client seabios \
libusb-1.0-0 libusb-1.0-0-dev \
libusbredir libusbredir-dev \
libspice-protocol-dev libspice-server-dev \
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 \
gir1.2-spice-client-glib-2.0 \
gir1.2-spice-client-gtk-2.0 \
gir1.2-spice-client-gtk-3.0

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

It should result install libvirt 0.9.6 along with dependent packages
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


Follow

Get every new post delivered to your Inbox.