Tuesday, December 06, 2011


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



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 git://git.libusb.org/libusb.git – 1.0.9-rc1
libusb-1.0.9-rc1 release candidate.

Qemu-kvm 1.0-rc2 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-usbredir38
$ sudo apt-get update
$ sudo apt-get install qemu-kvm qemu qemu-common \
spice-client 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
$ 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

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


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