Archive for the ‘Xen’ Category

Time to put things together. Xen orchestra has now got a ‘vnc‘ link (like http://localhost/xo/htdocs/vnc.php?url= which opens gtk vnc plugin (amd64 binary here). – This link is placed in section Misc of xen orchestra’s virtual machine detail window.

The configuration file of xen orchestra, xen-orchestra.conf, has got a section to control gtk vnc plugin. If a windows vm needs mouse grabbing, it can be set in this file. The handling of these settings is done in htdocs/vnc.php. If virtual machine w7b needs even more specific settings an additional file vnc_w7b.php can be used.

Compared to the description in this post vnc gtk plugin does now automatically grab the focus (keyboard immediately active after loading of html page; no need to click into vnc viewer window first) and a send keys menu has been added (0103-add_autofocus_and_sendkeys.diff).

(Build instructions remain the same except that after (updated) colortoolbar.patch.gz a second patch colortoolbar2.patch.gz has to be applied; updated amd64 debian archive: mozilla-gtk-vnc_0.3.10-6_amd64.deb).

There is one little additional patch to xen orchestra (03-add_vm_name_to_vnc_link.diff). The main changes are in vnc.php (compare previous post about xen orchestra). An updated zip archive with patched xen orchestra is here.

Xen virtual machines transmit their screen contents by vnc. A browser based viewer is the java vnc viewer plugin (see previous post). Advantage of java is that it runs on many platforms. However java tends to use a lot of RAM. On ubuntu 10.04 there is an alternative browser plugin which is gtk based: gtk viewer plugin.

The gtk vnc plugin offers only very basic functions: just an authentication dialog and the vnc viewer window. – This post adds a minimalistic toolbar to the plugin (test.html,,

Steps to build the plugin described above:

Looking for a graphical, browser based tool to manage xen 4.0 virtual machines I tried xen orchestra):

  • pro: needs only a web server with php (mysql optional); user interface not overloaded;  open source, well structured code.
  • con: only one detail window can be opened at the same time – needs patch; needs on ubuntu 10.04 a workaround for command xm new (see previous post).

The patch for multiple detail windows just had to replace some html tag id fields in htdocs/scripts/xo.js (01-xo.js.wId.diff).

Because I found it convenient to inspect my virtual machines with a browser based vnc viewer, I added a line to the detail window which displays the id and a link to vnc:
Domain id: 1 (vnc)
This patch uses the xen api to query the consoles of the virtual machine and looks up the ip address and the port of the vnc server connected to the console (02-add_vnc_link.diff, to be applied after 01-xo.js.wId.diff).

Patched version of xen orchestra: (local version of original file:; local version of tightvnc java viewer: VncViewer.jar)

Minor, negligible bugs:

  • Network and Storage section of detail windows are empty.
  • If the machine running xen orchestra is too busy, xen orchestra displays an empty window; just press the refresh button of the browser to get the main window back.
  • ‘Login again’ button of java vnc viewer window does not reconnect (but refresh button of browser does).
  • Error messages are not displayed if a virtual machine fails to start (open a terminal and use the command xm start yourvm).
  • the vnc viewer window has a fixed hardcoded size (800×600 in htdocs/vnv.php); as workaround add &w=1024&h=798 to the browser address line to display a 1024×768 virtual machine.
  • non captured mouse does not work well in windows, unless graphics tablet mouse driver is installed (see next post about gtk-viewer plugin on linux).

Conclusion: I really appreciate the work of Olivier Lambert, the author of xen orchestra!

Virtual machines of xen can be created with xen-builtin command xm create which uses a config file in /etc/xen. There is a second command to create xen virtual machines: xm new

Virtual machines created with xm new are permanently added to xen (virtual machines created with xm create get removed from xen when the virtual machine is shut down). – Some xen monitoring tools, like xen orchestra, rely on permanently added virtual machines.

But xm new is broken in debian (and ubuntu) because xm uses an outdated xml python library. And the corresponding debian  bug report is closed with status ‘won’t fix’. Debian maintainers support  only xen create.

Using virsh as workaround for xen new:

  • xm create myvm (from file /etc/xen/myvm)
  • virsh dumpxml myvm > /etc/xen/myvm.xml
  • xm shutdown myvm
  • virsh define /etc/xen/myvm.xml

Debian sid has the source package of libvirt (currently 0.8.1-1), but package 0.8.1-1 does not work with xen 4.0.  However the build service of opensuse factory includes as well libvirt-0.8.1 and they have xen 4.0 patches included.

To get a libvirt package for ubuntu 10.04 which is compatible with xen 4.0 the patches of opensuse had to be combined with the debian sid package (patch: debian.diff; local copy of debian sources: libvirt_0.8.1.orig.tar.gz, libvirt_0.8.1-1.debian.tar.gz, libvirt_0.8.1-1.dsc).

Build process:

  • download sources and patch into new directory and open terminal in this directory
  • tar -xzf libvirt_0.8.1.orig.tar.gz
  • cd libvirt-0.8.1
  • tar -xzf ../libvirt_0.8.1-1.debian.tar.gz
  • patch -p0 < ../debian.diff
  • ./debian/rules binary

And to install the new packages (ubuntu amd64 packages: libvirt-bin_0.8.1-1_amd64.deb, libvirt0_0.8.1-1_amd64.deb, libvirt-dev_0.8.1-1_amd64.deb, libvirt-doc_0.8.1-1_amd64.deb, python-libvirt_0.8.1-1_amd64.deb, libvirt0-dbg_0.8.1-1_amd64.deb):

  • cd ..
  • dpkg -i libvirt0_0.8.1-1_amd64.deb libvirt-bin_0.8.1-1_amd64.deb python-libvirt_0.8.1-1_amd64.deb

The resulting virsh command seems to work with xen 4.0 (tested with subcommands dumpxml and define). – You should use Package/Force version in synaptic package manager to protect these manually installed packages.

  • Adding and removing of hard disks  and cdrom devices works fine
    (guest not running)
  • Acronis Trueimage works well inside hvm virtual machines
    (if empty block devices are not recognized as hard disks, e.g. /dev/sdb7:
    dd if=/dev/zero of=/dev/sdb7 bs=1M count=100
    echo ‘w’ |fdisk /dev/sdb7
    This zeros out the beginning of block device /dev/sdb7 and writes a new partition table into /dev/sdb7; all existing data in /dev/sdb7 is overwritten – you have been warned.)
  • Sometimes the window opened by virt-manager fails to display a running virtual machine (does not connect by vnc to the running vm).
    Closing both windows (that of the vm and virt-manager itself) and reopening them usually helps (the vm continues to run).

Found in xen wiki a remark of Jeremy Fitzhardinge about the performance of Xen 4.0 (Xen Summit at Intel Shanghai Nov 19-20, 2009, Slide 7):

Performance still needs attention

  • Seems to be ~10-20% hit vs 2.6.18-xen

… but you get a current 2.6.31/32/… Linux kernel.

Preparations to boot a Xen 4.0 dom0  kernel: 2.6.18-to-2.6.31-and-higher

Status of Xen features in Linux kernel: XenParavirtOps

Thanks to the detailed posts on [A, B, C ] virt-manager is running xen 4.0 on ubuntu 10.04
(installation of ubuntu server plus apt-get install xubuntu-desktop).

Program virt-manager has to be started as root and switching with su to root shell does not work, the login version su – has to be used (to avoid error: Failed to contact configuration server).

To create a hvm virtual machine virt-install is used:

  • virt-install -connect xen:/// -n ti2010 –r 512 –hvm –vnc -f /dev/sdb -c /root/mnt/ti2010.iso –debug –force

Parameter –force is only neccessary if the block device used as hard disk is already part of another vm.

Once the new vm gets displayed in virt-manager all properties of this vm can be edited (click ‘Open’; ‘Add Hardware’, ‘Remove’, …).