Set up Oneiric PV DomU at Xen 4.1.2 Oneiric Dom0 (3.1.0-030100-generic)

October 27, 2011

Procedure is standard Debian’s network PV install. Download configuration file from following location. Debian and consequently Ubuntu still consider Libvirt and virtinst tools like virt-manager and command line utility virt-install as way to manage RH’s Xen domains like F15,F16,CentOS 6 either to be utilized with remote system mirrors

# wget http://ca.archive.ubuntu.com/ubuntu/dists/oneiric/main/installer-amd64/current/images/netboot/xen/xm-debian.cfg

# cp xm-debian.cfg xm-debian1.cfg

I had to patch xm-debian1.cfg via xm-debian1.patch to make it working

--- xm-debian1.cfg.orig	2011-10-27 17:17:17.333111002 +0400
+++ xm-debian1.cfg	2011-10-27 16:33:24.985110998 +0400
@@ -38,10 +38,10 @@
 # Standard variables
 
 # Initial memory allocation (in megabytes) for the new domain.
-memory = 128
+memory = 2048
 
 # A name for your domain. All domains must have different names.
-name = "ExampleDomain"
+name = "OneiricPVD"
 
 # 128-bit UUID for the domain.  The default behavior is to generate a new UUID
 # on each call to 'xm create'.
@@ -53,7 +53,7 @@
 #cpus = "0-3,5,^1" # run on cpus 0,2,3,5
 
 # Number of Virtual CPUS to use, default is 1
-#vcpus = 1
+vcpus = 2
 
 #----------------------------------------------------------------------------
 # Define network interfaces.
@@ -69,9 +69,9 @@
 #
 # or more than one interface may be configured:
 #
-# vif = ['', 'bridge=xenbr1']
+vif = ['', 'bridge=br0']
 
-vif = ['']
+# vif = ['']
 
 #----------------------------------------------------------------------------
 # Define the disk devices you want the domain to have access to, and
@@ -82,7 +82,7 @@
 #
 # NB: Only xvd devices are supported by the kernel in Debian Lenny and later.
 
-disk = ['file:/path/to/disk.img,xvda,w']
+disk = ['phy:/dev/sda7,xvda,w']
 
 #----------------------------------------------------------------------------
 # Define frame buffer device.
@@ -175,7 +175,7 @@
 xm_vars.check()
 
 if not xm_vars.env.get('install'):
-    bootloader="pygrub"
+    bootloader="/usr/lib64/xen/bin/pygrub"
 elif xm_vars.env['install-method'] == "network":
     import os.path
     print "Install Mirror: %s" % xm_vars.env['install-mirror']
@@ -192,12 +192,16 @@
     print
 
     if xm_vars.env.get('install-kernel'):
-        kernelurl = xm_vars.env['install-kernel']
+#       kernelurl = xm_vars.env['install-kernel']
+        kernelurl = installer + "/netboot/xen/vmlinuz"
+        print "Kernel to load: %s" % kernelurl
     else:
         kernelurl = installer + "/netboot/xen/vmlinuz"
-
+        
     if xm_vars.env.get('install-ramdisk'):
-        ramdiskurl = xm_vars.env['install-ramdisk']
+#       ramdiskurl = xm_vars.env['install-ramdisk']
+        ramdiskurl = installer + "/netboot/xen/initrd.gz"
+        print "Ramdisk to load: %s" %  ramdiskurl
     else:
         ramdiskurl = installer + "/netboot/xen/initrd.gz"
 
@@ -244,7 +248,7 @@
     disk.insert(0, 'file:%s,%s:cdrom,r' % (xm_vars.env['install-media'],
                                            xm_vars.env['install-cdrom-device']))
 
-    bootloader="pygrub"
+    bootloader="/usr/lib64/xen/bin/pygrub"
     bootargs="--kernel=%s --ramdisk=%s" % (kernelpath, ramdiskpath)
     print "From CD"
 else:


# xm create -f xm-debian1.cfg -c install=true \
install-kernel="vmlinuz" install-ramdisk="initrd.gz" \
install-mirror="http://ca.archive.ubuntu.com/ubuntu" \
install-arch=amd64 install-method=network

Network installation starts :-









Create file for XML PV Guest definition

# cat OneiricPVD.xml
<domain type='xen' id='7'>
<name>OneiricPVD</name>
<description></description>
<memory>2097152</memory>
<currentMemory>2097152</currentMemory>
<vcpu>2</vcpu>
<bootloader>/usr/lib64/xen/bin/pygrub</bootloader>
<bootloader_args>-q</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:63:7d:40'/>
<source bridge='br0'/>
<script path='/etc/xen/scripts/vif-bridge'/>
<target dev='vif7.0'/>
</interface>
<console type='pty' tty='/dev/pts/3'>
<source path='/dev/pts/3'/>
<target type='xen' port='0'/>
</console>
<input type='mouse' bus='xen'/>
<graphics type='vnc' port='5900' autoport='yes'/>
</devices>
</domain>

# virsh define OneiricPVD.xml





Virt-install Fedora 16 PV Guest at Xen 4.1.2 Ubuntu Oneiric Dom0

October 23, 2011

Install Xen Hypervisor via PPA Xen 4.1.2 with pygrub gpt support for Ubuntu Oneiric not regular one.Pygrub gpt support patches, published @xen-devel, have been back ported to Xen 4.1.2 for build in PPA mentioned above. Next: mount loop Fedora-16-TC1-x86_64-DVD.iso on /var/www/f16 run virt-install in VNC mode :-

virt-install --connect xen:/// --debug -n VF16 \
--vnc -p -r 2048 --vcpus=2 \
-f /dev/sda7 -l http://192.168.0.175/f16

Series of screen-shots bellow should be a fair




Done. Pygrub is loading F16 DomU with gnu partitioning







Start domain via virsh and connect with vncviewer localhost:0



Start domain via virt-manager and connect with vncviewer localhost:0



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.


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

October 9, 2011

************************************************************************************************************************
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 0×2687990 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 0×2687990) 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 0×2725900, 0
main_channel_release_pipe_item: SPICE_MSG_MAIN_AGENT_DATA 0x26fddb0 0×2725900, 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


Follow

Get every new post delivered to your Inbox.