QEMU-KVM 1.0 patching to support USB Redirection for Ubuntu Precise as of 12/29/2011

December 30, 2011

************************************************************************************
UPDATE on 01/13/2012 Libvirt 0.9.9-1 and 0.9.8-2 on Ubuntu Precise (libnl3 > 3.2)

View Build libvirt 0.9.9-1 Build-Depend on libnl-3-dev on Precise
View Build libvirt 0.9.8-2 Build-Depend on libnl-3-dev on Precise
*************************************************************************************
Two options of building patched QEMU-KVM 1.0 are considered bellow.

First one : Qemu-kvm 1.0 has been built based on branch qemu-kvm-1.0-usbredir as of 12/29/2011. It contains all required usb redirection patches on top of QEMU-KVM 1.0 release

Second one : Patching QEMU-KVM 1.0 (core git tree) via extracted patches set to support USB redirection on Ubuntu Precise. Generating patches set via commands
$ git clone git://people.freedesktop.org/~jwrdegoede/qemu
$ cd qemu
$ git checkout -B qemu-kvm-1.0-usbredir origin/qemu-kvm-1.0-usbredir
$ git format-patch -M -C –output-directory \
/tmp/patches 30c044521889195f54a9f2c21310894f545994e8

First option) Qemu-kvm 1.0 has been built based on branch qemu-kvm-1.0-usbredir
as of 12/29/2011. It contains all required usb redirection patches on
top of QEMU-KVM 1.0 release

$ 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-usbredir1

Environment:-
Libusb 1.0.9~rc3 (official version)
Spice 0.10.0
Spice-Gtk-0.7.159
Libvirt 0.9.8
************************************
Setting up system via PPA
************************************
$ sudo add-apt-repository ppa:bderzhavets/lib-usbredir53
$ 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

For 0.7.159 spice-client-gtk.install updated to accommodate
/usr/bin/spice-client-glib-usb-acl-helper

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

To start default network :-

sudo virsh net-start default
sudo virsh net-autostart default

*************************************************************************************************
Second option) Patching QEMU-KVM 1.0 (core git tree) via extracted patches set to support USB redirection on Ubuntu Precise
*************************************************************************************************
Patching QEMU-KVM 1.0 (core git tree) via extracted patches set from
http://cgit.freedesktop.org/~jwrdegoede/qemu/log/?h=qemu-kvm-1.0-usbredir

$ git clone git://people.freedesktop.org/~jwrdegoede/qemu
$ cd qemu
$ git checkout -B qemu-kvm-1.0-usbredir origin/qemu-kvm-1.0-usbredir
$ git format-patch -M -C –output-directory \
/tmp/patches 30c044521889195f54a9f2c21310894f545994e8

$ ls /tmp/patches
0001-usb-redir-Clear-iso-irq-error-when-stopping-the-stre.patch
0002-usb-redir-Dynamically-adjust-iso-buffering-size-base.patch
0003-usb-redir-Pre-fill-our-isoc-input-buffer-before-send.patch
0004-usb-redir-Try-to-keep-our-buffer-size-near-the-targe.patch
0005-usb-redir-Improve-some-debugging-messages.patch
0006-char-Split-out-tcp-socket-close-code-in-a-separate-f.patch
0007-char-Add-a-QemuChrHandlers-struct-to-initialise-char.patch
0008-iohandlers-Add-enable-disable_write_fd_handler-funct.patch
0009-char-Add-framework-for-a-write-unblocked-callback.patch
0010-char-Update-send_all-to-handle-nonblocking-chardev-w.patch
0011-char-Equip-the-unix-tcp-backend-to-handle-nonblockin.patch
0012-char-Throttle-when-host-connection-is-down.patch
0013-virtio-console-Enable-port-throttling-when-chardev-i.patch
0014-spice-qemu-char.c-add-throttling.patch
0015-spice-qemu-char.c-remove-intermediate-buffer.patch
0016-usb-redir-Add-flow-control-support.patch
0017-virtio-serial-bus-replay-guest_open-on-migration.patch
0018-char-Disable-write-callback-if-throttled-chardev-is-.patch

Patches set applies to snapshot of git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git
checkout tag qemu-kvm-1.0.
$ git clone git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git
$ cd qemu-kvm
$ git checkout qemu-kvm-1.0 -b work
$ cd ..
$ cp -R qemu-kvm qemu-kvm-1.0-release
The last folder is snapshot for patching during debian build

Environment:-
Libusb 1.0.9~rc3 (official version)
Spice 0.10.0
Spice-Gtk-0.7.159
Libvirt 0.9.8

******************************
Setting up system via PPA
******************************
$ sudo add-apt-repository ppa:bderzhavets/lib-usbredir54
$ 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

For 0.7.159 spice-client-gtk.install updated to accommodate
/usr/bin/spice-client-glib-usb-acl-helper

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

To start default network :-

sudo virsh net-start default
sudo virsh net-autostart default


Qemu-kvm 1.0 & Spice 0.10.0 & Spice-Gtk 0.7.159 & Libusb 1.0.9-rc3 (official) for Ubuntu Precise

December 27, 2011

**********************************************************************************************
UPDATE on 12/29/2011
**********************************************************************************************
View PPA https://launchpad.net/~bderzhavets/+archive/lib-usbredir53
Qemu-kvm 1.0 (in this PPA) has been built based on branch qemu-kvm-1.0-usbredir as of 12/29/2011. It contains all required usb redirection patches on top of QEMU-KVM 1.0 release

$ 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-usbredir1

********************************************************************************************
Procedure following bellow set up Qemu-kvm 1.0 & Spice 0.10.0 & Spice-Gtk 0.7.159 & Libusb 1.0.9-rc3 (official) on daily build of Ubuntu Precise (kernel 3.2.0-6). Qemu-kvm has been built via git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git, tag qemu-kvm-1.0. There is only one change to official libusb 1.0.9~rc3.

CFLAGS = -fPIC -Wall vs CFLAGS = -Wall in debian/rules.

*****************************
Set up system via PPA
*****************************

$ sudo add-apt-repository ppa:bderzhavets/lib-usbredir51
$ 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

For Spice-Gtk-0.7.159 spice-client-gtk.install updated to accommodate
/usr/bin/spice-client-glib-usb-acl-helper. Packaging schema follows [1]
to support gobject-introspection.

$ sudo groupadd libvirtd
$ sudo adduser $USER libvirtd

RELOGIN

To set up Libvirt 0.9.8 and related packages via PPA mentioned above :-
$ sudo apt-get install virtinst virt-manager virt-viewer
$ sudo ln -s /etc/apparmor.d/usr.sbin.libvirtd /etc/apparmor.d/disable/

To start default network :-

sudo virsh net-start default
sudo virsh net-autostart default

Works with QEMU-KVM 1.0 with no special patch.
To succeed with with Spice-Gtk-0.7.159 build I had to spleet GTK2 and GTK3 builds
into two set of packages.
GTK2 build debian/rules contains :-

override_dh_auto_configure:
./configure \
--enable-vala --disable-smartcard \
--enable-introspection --enable-werror=no \
--with-gtk="2.0" --prefix=/usr --libdir=/usr/lib \
LIBUSB_CFLAGS=-I/usr/include/libusb-1.0 \
LIBUSB_LIBS='-L/usr/lib/*-linux-gnu -lusb-1.0' \
LIBUSBREDIRHOST_CFLAGS=-I/usr/include \
LIBUSBREDIRHOST_LIBS='-L/usr/lib -lusbredirhost'

GTK3 build debian/rules contains :-

override_dh_auto_configure:
./configure \
--enable-vala --disable-smartcard \
--enable-introspection --enable-werror=no \
--with-gtk="3.0" --prefix=/usr --libdir=/usr/lib \
LIBUSB_CFLAGS=-I/usr/include/libusb-1.0 \
LIBUSB_LIBS='-L/usr/lib/*-linux-gnu -lusb-1.0' \
LIBUSBREDIRHOST_CFLAGS=-I/usr/include \
LIBUSBREDIRHOST_LIBS='-L/usr/lib -lusbredirhost'

I was not expecting Qemu&Spice USB redirection to work.
However, it seems to be working.





Snapshot on Server



Snapshot on remote WS



Follow

Get every new post delivered to your Inbox.

Join 31 other followers