Set up Qemu&Spice USB Redirection support on Ubuntu 11.10 (Oneiric)

************************************************************************************************************************
UPDATE on 10/14/2011. Works on final release Ubuntu 11.10 . View also Set up Qemu&Spice&Libvirt 0.9.6 USB Redirection on Ubuntu 11.10
************************************************************************************************************************

Following bellow is attempt to reproduce Hans de Goede blog entry at http://planet.spice-space.org/ on Ubuntu 11.10 with intent to build Qemu-kvm 0.15.0 with usb redirection network support per http://planet.spice-space.org/ via git repository git://people.freedesktop.org/~jwrdegoede/qemu :-

$ 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
$ git log|more

Spice-Gtk-0.7.4X 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.9.1. Build done on Ubuntu Oneiric.Packaged version version of Spice-Gtk-0.7.4X is built up on mentioned git repository with GTK2 and GTK3 as two sets of packages. Details may be viewed here .
Libusb-1.0-2:1.0.9-3ubuntu9 is built up on git://people.freedesktop.org/~jwrdegoede/libusb (pre 1.0.9). Usbredir-0.3.1-1ubuntu5 is built up on official release usbredir-0.3.1.tar.gz.
*********************************************************************************************************************
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.It has been already done as well. View:-
Spice-Gtk-0.7.46-314c been built per debian’s 0-7.3 schema
*********************************************************************************************************************

Currently two PPAs are ready to go :
1. Set up Qemu&Spice USB Redirection on Ubuntu 11.10 (Oneiric) v.1
2. Set up Qemu&Spice USB Redirection on Ubuntu 11.10 (Oneiric) v.2
*****************************
To install packages from PPA
*****************************
$ sudo add-apt-repository ppa:bderzhavets/lib-usbredir16
$ 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

To install Livbirt and virtinst tools :-

$ 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
$ sudo adduser $USER kvm

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)

Spicy should be run by root, view http://planet.spice-space.org/. Make sure you’ve done on server

$ sudo apt-get install ipxe

Per Hans de Goede :-
Select the options menu entry and make sure that the “auto redirect newly plugged in USB devices” option is checked. After this make sure the vm has keyboard focus (so close the options menu), plug in a new USB device and watch it show up in your vm



Connection to remote KVM Spice enabled Server with USB Redirection on Oneiric :-



Copy from USB pen to remotely running qemu-kvm VM via spicy session issued by root on local box



Normal guest start via qemu-kvm with enabled usb redirection looks like :-
boris@boris-System-P5Q3:~$ sudo /usr/bin/kvm -cpu host -enable-kvm \
> -name VF15HQ -m 2048 \
> -drive file=/dev/sdb5,if=virtio,media=disk,aio=native,cache=off \
> -net nic,model=virtio -net user -localtime \
> -usb -vga qxl -spice port=5900,disable-ticketing \
> -device virtio-serial \
> -chardev spicevmc,id=vdagent,name=vdagent \
> -device virtserialport,chardev=vdagent,name=com.redhat.spice.0 \
> -readconfig /etc/qemu/ich9-ehci-uhci.cfg \
> -chardev spicevmc,name=usbredir,id=usbredirchardev1 \
> -device usb-redir,chardev=usbredirchardev1,id=usbredirdev1,debug=3 \
> -chardev spicevmc,name=usbredir,id=usbredirchardev2 \
> -device usb-redir,chardev=usbredirchardev2,id=usbredirdev2,debug=3 \
> -chardev spicevmc,name=usbredir,id=usbredirchardev3 \
> -device usb-redir,chardev=usbredirchardev3,id=usbredirdev3,debug=3
do_spice_init: starting 0.9.1
spice_server_add_interface: SPICE_INTERFACE_KEYBOARD
spice_server_add_interface: SPICE_INTERFACE_MOUSE
spice_server_add_interface: SPICE_INTERFACE_QXL
red_worker_main: begin
ensure_display_channel_created: create display channel
ensure_cursor_channel_created: create cursor channel
*** EHCI support is under development ***
spice_server_char_device_add_interface: CHAR_DEVICE usbredir
spice_server_char_device_add_interface: CHAR_DEVICE usbredir
spice_server_char_device_add_interface: CHAR_DEVICE usbredir
handle_dev_input: start
spice_server_char_device_add_interface: CHAR_DEVICE vdagent
reds_handle_auth_mechanism: Auth method: 1
reds_handle_main_link:
reds_disconnect:
reds_show_new_channel: channel 1:0, connected successfully, over Non Secure link
main_channel_link: add main channel client
reds_handle_main_link: NEW Client 0x2687990 mcc 0x26f8e30 connect-id 1804289383
main_channel_handle_parsed: agent start
handle_dev_input: mouse mode 2
main_channel_handle_parsed: net test: latency 0.292000 ms, bitrate 10893617021 bps (10388.962766 Mbps)
main_channel_release_pipe_item: SPICE_MSG_MAIN_AGENT_DATA 0x26f8d90 0x2687a20, 0
reds_handle_auth_mechanism: Auth method: 1
reds_show_new_channel: channel 4:0, connected successfully, over Non Secure link
red_dispatcher_set_cursor_peer:
reds_handle_auth_mechanism: Auth method: 1
handle_dev_input: cursor connect
red_connect_cursor: add cursor channel client
listen_to_new_client_channel: NEW ID = 0
reds_show_new_channel: channel 2:0, connected successfully, over Non Secure link
red_dispatcher_set_display_peer:
handle_dev_input: connect
reds_handle_auth_mechanism: Auth method: 1
handle_new_display_channel: add display channel client
handle_new_display_channel: New display (client 0x2687990) dcc 0x2b76160 stream 0x26f8aa0
handle_new_display_channel: jpeg disabled
handle_new_display_channel: zlib-over-glz disabled
listen_to_new_client_channel: NEW ID = 0
reds_show_new_channel: channel 3:0, connected successfully, over Non Secure link
inputs_connect: inputs channel client create
display_channel_client_wait_for_init: creating encoder with id == 0
display_channel_release_item: not pushed (101)
spice_server_char_device_remove_interface: remove CHAR_DEVICE vdagent
handle_dev_input: mouse mode 1
spice_server_char_device_add_interface: CHAR_DEVICE vdagent
handle_dev_input: mouse mode 2
main_channel_handle_parsed: agent start
main_channel_release_pipe_item: SPICE_MSG_MAIN_AGENT_DATA 0x274a830 0x2725900, 0
main_channel_release_pipe_item: SPICE_MSG_MAIN_AGENT_DATA 0x26fddb0 0x2725900, 0
reds_handle_auth_mechanism: Auth method: 1
reds_show_new_channel: channel 9:0, connected successfully, over Non Secure link
kvm: usbredirparser info: Peer version: spice-gtk 0.7.46-314c-dirty

red_channel_client_disconnect: 0x3879d80 (channel 0x23f36d0 type 9 id 0)
spice_server_char_device_remove_interface: remove CHAR_DEVICE vdagent
handle_dev_input: mouse mode 1

KVM itself may run ( via qemu command line) on any Oneiric box on the LAN with Qemu-kvm 0.15.0 with usb network redirection support (say address IP01).Spice-Gtk-0.7.46 should be installed on your local machine. Then run :-

# spicy -h IP01 -p 5900

Plug in USB pen on local box . It will be opened in Spicy session with remote qemu-kvm process.

Libvirt 0.9.6 is required to avoid qemu command line vm start and managing VMs via virsh XML definitions, what consequently allows to start VMs via virt-manager. Current version of libvirt in Oneiric is 0.9.2. I am not sure what version of libvirt will be choosed for Precise (12.04).Debian Unstable already contains 0.9.6.

Fedora 15 KVM running native spice-vdagent started via qemu command line







Oneiric KVM running built for Ubuntu spice-vdagent started via qemu command line






References
1. qemu-kvm-0.15.0-usbredir

One Response to Set up Qemu&Spice USB Redirection support on Ubuntu 11.10 (Oneiric)

  1. eko says:

    WoW! you did a great job friend…. by the way, why did you use qemu? why don’t you pick v-box?

    Thanks,
    Sincerely

Leave a comment