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





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


Set up Qemu&Spice&Libvirt 0.9.6 USB Redirection on Ubuntu 11.10

October 16, 2011

***********************************************************************************************
UPDATE on 11/12/2011. Experimental build libvirt 0.9.7 via git://anonscm.debian.org/pkg-libvirt/libvirt.git
tip commit e49612bea22c681aff95c974d36d009a5ae08a21 for Oneiric, seems to fix bug with VirtManager disconnection at domain shuts down (on Oneiric with kernel 3.1.0-030100-generic) View PPA: https://launchpad.net/~bderzhavets/+archive/xen-next6
***************************************************************************************************
UPDATE on 10/30/2011. View Qemu-kvm 0.15.1 & Spice USB Redirection support for Ubuntu Oneiric
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

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
***************************************************************************************************
UPDATE on 10/26/2011. After publishing I renamed this PPA as “Libvirt 0.9.6 for Oneiric”. View also :-
“Show PPAs matching Libvirt”
“Show PPAs matching Qemu-kvm”
“Libvirt” 0.9.6-1ubuntu3 was published in precise https://launchpad.net/ubuntu/+source/libvirt/0.9.6-1ubuntu3 on 10/24/2011. View for back ported version of libvirt in PPA :
Qemu&Spice USB Redirection with back ported Libvirt 0.9.6 (as of 10/24/11), new seabios 1.6.3 for Ubuntu Oneiric
***************************************************************************************************
I’ve built locally and uploaded to Launchpad Libvirt 0.9.6 via Debian Unstable, applying standard set of Ubuntu’s patches updated for 0.9.6.

Link to page at Launchpad



Build log for amd64 is attached

Build log for i386 is attached

To start default network :-

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

Looks like :-

boris@boris-P5Q-E:~$ sudo virsh net-start default
Network default started
boris@boris-P5Q-E:~$ sudo virsh net-autostart default
Network default marked as autostarted
boris@boris-P5Q-E:~$ brctl show
bridge name bridge id STP enabled interfaces
virbr0 8000.000000000000 yes

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.6X 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.6X 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.6 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 :-

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

Manage VMs via virsh or Virt Manager having USB redirection support active in Spicy’s sessions.
VirtManager :-





Virsh :-





USB redirection on F16 (TC)



*************************************************************************************************************
UPDATE on 11/14/2011 Issue fixed via upgrade Libvirt up to 0.9.7-2. That’s a link to PPA.
*************************************************************************************************************
VirtManager seems not to be ready for this kind of operations now. Spicy session with KVM started
via VirtManager runs fine working with USB pen. But on domain shutdown following error shows up :-

Error polling connection ‘qemu:///system’: Unable to read from monitor: Connection reset by peer

Traceback (most recent call last):
File “/usr/share/virt-manager/virtManager/engine.py”, line 440, in _tick
conn.tick()
File “/usr/share/virt-manager/virtManager/connection.py”, line 1507, in tick
vm.tick(now)
File “/usr/share/virt-manager/virtManager/domain.py”, line 1541, in tick
pcentHostCpu, pcentGuestCpu) = self._sample_cpu_stats(info, now)
File “/usr/share/virt-manager/virtManager/domain.py”, line 1158, in _sample_cpu_stats
guestcpus = self.vcpu_count()
File “/usr/share/virt-manager/virtManager/domain.py”, line 831, in vcpu_count
return int(self._get_guest().vcpus)
File “/usr/share/virt-manager/virtManager/domain.py”, line 339, in _get_guest
xml = self._get_domain_xml(inactive, refresh_if_necc)
File “/usr/share/virt-manager/virtManager/domain.py”, line 331, in _get_domain_xml
refresh_if_necc=refresh_if_necc)
File “/usr/share/virt-manager/virtManager/libvirtobject.py”, line 95, in get_xml
self.refresh_xml()
File “/usr/share/virt-manager/virtManager/libvirtobject.py”, line 105, in refresh_xml
self._xml = self._XMLDesc(self._active_xml_flags)
File “/usr/share/virt-manager/virtManager/domain.py”, line 764, in _XMLDesc
return self._backend.XMLDesc(flags)
File “/usr/lib/python2.7/dist-packages/libvirt.py”, line 381, in XMLDesc
if ret is None: raise libvirtError (‘virDomainGetXMLDesc() failed’, dom=self)
libvirtError: Unable to read from monitor: Connection reset by peer

Final draft and instructions to install are in PPA Qemu&Spice USB Redirection and Libvirt 0.9.6 on Ubuntu 11.10 (Oneiric)
When working with the most recent PPA Qemu-kvm 0.15.1 & Spice USB Redirection support for Ubuntu Oneiric with virt-manager,
patched by RH against previous issue. Another error shows up on VM shutdown :-

Error polling connection ‘qemu:///system’: Unable to read from monitor: Connection reset by peer
Traceback (most recent call last):
File “/usr/share/virt-manager/virtManager/engine.py”, line 440, in _tick
conn.tick()
File “/usr/share/virt-manager/virtManager/connection.py”, line 1507, in tick
vm.tick(now)
File “/usr/share/virt-manager/virtManager/domain.py”, line 1531, in tick
info = self._backend.info()
File “/usr/lib/python2.7/dist-packages/libvirt.py”, line 1411, in info
if ret is None: raise libvirtError (‘virDomainGetInfo() failed’, dom=self)
libvirtError: Unable to read from monitor: Connection reset by peer

Consider option downgrade seabios 1.6.3 => 0.6.2-qxl to get more or less stable F15 KVM guest behavior.
It doesn’t help F16 RC1 KVM guest.


Follow

Get every new post delivered to your Inbox.