Saturday, October 30, 2010

Xen Installation & Compilation


Installation from source

Xen 4.0 source code mercurial (hg) repository and changelog: http://xenbits.xen.org/xen-4.0-testing.hg
You can get Xen 4.0 with mercurial using the following command:
hg clone http://xenbits.xen.org/xen-4.0-testing.hg
Note that this will give you the LATEST version in xen-4.0-testing.hg repository! It might be a release candidate for next release or just some developer snapshot. See the changelog above for current status. You can also get a specific 'tag' from the repository like this:
hg clone -r RELEASE-4.0.1 http://xenbits.xen.org/xen-4.0-testing.hg
Alternatively you can download the Xen 4.0.x source tarball from http://www.xen.org/products/xen_source.html . Note that if you're planning to use Xen 4.0.0 tarball please see the Known Issues below for a note about supported pvops dom0 kernel versions.
NOTE!! during the Xen build process outbound git-protocol needs to be open in your network firewall! Xen build scripts need to access git:// repositories on git.kernel.org and xenbits.xen.org. Some people have reported issues accessing the remote repositories - these problems are most often caused by a broken Internet connection, broken firewall, or a broken NAT router you use.
This example will only build the new Xen 4.0 hypervisor and tools. This method does NOT download or build a (dom0) kernel from the xen.git repository. "make tools" part will download the xen qemu-dm ioemu for hvm guests from xenbits git repository and tools tarballs (unless you've already downloaded them yourself before building).
cd xen-4.0-testing.hg 
make xen 
make tools 
make stubdom
When the compilation process finishes you'll have the Xen hypervisor/tools binaries in "dist/" directory ready for installation:
make install-xen 
make install-tools 
make install-stubdom
And then compile your chosen new dom0 kernel, or use your existing dom0 kernel. Also update grub.conf to use the newly installed Xen 4.0 hypervisor.
See XenDom0Kernels wiki page for information about all the available Xen Dom0 capable kernels, and XenParavirtOps wiki page for more detailed information about Xen pvops dom0 kernels.
You can also compile Xen 4.0 together with the new default pvops dom0 kernel (Linux 2.6.32.x in Xen 4.0.1 and newer versions). This method downloads the kernel sources from xen.git repository during the build process:
make world
This will download the latest pvops dom0 kernel 2.6.32.x from Jeremy's xen.git repository during the build process. See the XenParavirtOps wiki page for more information about different pvops dom0 kernel versions. Also see the Known Issues below for supported pvops dom0 kernel versions.
NOTE about the old Xenlinux linux-2.6.18-xen kernels:
make kernels KERNELS="linux-2.6-xen0 linux-2.6-xenU"

Xen compilation

When I was trying to compile Xen-4.0.1, I got these messages:

make[1]: Entering directory `/xen-4.0-testing.hg/xen'
make -f Rules.mk _install
make[2]: Entering directory `/xen-4.0-testing.hg/xen'
make -C tools
make[3]: Entering directory `/xen-4.0-testing.hg/xen/tools'
[ -d figlet ] && make -C figlet
make[4]: Entering directory `/xen-4.0-testing.hg/xen/tools/figlet'
make[4]: `figlet' is up to date.
make[4]: Leaving directory `/xen-4.0-testing.hg/xen/tools/figlet'
make symbols
make[4]: Entering directory `/xen-4.0-testing.hg/xen/tools'
make[4]: `symbols' is up to date.
make[4]: Leaving directory `/xen-4.0-testing.hg/xen/tools'
make[3]: Leaving directory `/xen-4.0-testing.hg/xen/tools'
make -f /xen-4.0-testing.hg/xen/Rules.mk include/xen/compile.h
make[3]: Entering directory `/xen-4.0-testing.hg/xen'
 __  __            _  _    ___   ____              _                   
 \ \/ /___ _ __   | || |  / _ \ |___ \    _ __ ___/ |   _ __  _ __ ___ 
  \  // _ \ '_ \  | || |_| | | |  __) |__| '__/ __| |__| '_ \| '__/ _ \
  /  \  __/ | | | |__   _| |_| | / __/|__| | | (__| |__| |_) | | |  __/
 /_/\_\___|_| |_|    |_|(_)___(_)_____|  |_|  \___|_|  | .__/|_|  \___|
                                                       |_|             
make[3]: Leaving directory `/xen-4.0-testing.hg/xen'
[ -e include/asm ] || ln -sf asm-x86 include/asm
make -f /xen-4.0-testing.hg/xen/Rules.mk -C include
make[3]: Entering directory `/xen-4.0-testing.hg/xen/include'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/xen-4.0-testing.hg/xen/include'
make -f /xen-4.0-testing.hg/xen/Rules.mk -C arch/x86 asm-offsets.s
make[3]: Entering directory `/xen-4.0-testing.hg/xen/arch/x86'
make[3]: `asm-offsets.s' is up to date.
make[3]: Leaving directory `/xen-4.0-testing.hg/xen/arch/x86'
make -f /xen-4.0-testing.hg/xen/Rules.mk include/asm-x86/asm-offsets.h
make[3]: Entering directory `/xen-4.0-testing.hg/xen'
make[3]: `include/asm-x86/asm-offsets.h' is up to date.
make[3]: Leaving directory `/xen-4.0-testing.hg/xen'
make -f /xen-4.0-testing.hg/xen/Rules.mk -C arch/x86 /xen-4.0-testing.hg/xen/xen
make[3]: Entering directory `/xen-4.0-testing.hg/xen/arch/x86'
make -f /xen-4.0-testing.hg/xen/Rules.mk -C /xen-4.0-testing.hg/xen/arch/x86/boot built_in.o
make[4]: Entering directory `/xen-4.0-testing.hg/xen/arch/x86/boot'
RELOC=0x7c000 XEN_BITSPERLONG=64 make -f build32.mk reloc.S
make[5]: Entering directory `/xen-4.0-testing.hg/xen/arch/x86/boot'
make[5]: *** ../../../../.config: Is a directory.  Stop.
make[5]: Leaving directory `/xen-4.0-testing.hg/xen/arch/x86/boot'
make[4]: *** [reloc.S] Error 2
make[4]: Leaving directory `/xen-4.0-testing.hg/xen/arch/x86/boot'
make[3]: *** [/xen-4.0-testing.hg/xen/arch/x86/boot/built_in.o] Error 2
make[3]: Leaving directory `/xen-4.0-testing.hg/xen/arch/x86'
make[2]: *** [/xen-4.0-testing.hg/xen/xen] Error 2
make[2]: Leaving directory `/xen-4.0-testing.hg/xen'
make[1]: *** [install] Error 2
make[1]: Leaving directory `/xen-4.0-testing.hg/xen'
make: *** [install-xen] Error 2

The message showed me that it was expecting the .config exist in the root folder. I copied the file from /usr/src/linux (kernel source) and recompile. it worked!

USB plug-in rule for TI MSP-EXP43xx LaunchPad Kit

Content of file /etc/udev/rules.d/udev/46-TI_launchpad.rules:

ATTRS{idVendor}=="0451", ATTRS{idProduct}=="2036", MODE="0660", GROUP="plugdev"
ATTRS{idVendor}=="0451", ATTRS{idProduct}=="F432", MODE="0660", GROUP="plugdev"

Friday, October 29, 2010

Script to remove tailing "(00)" in filenames

#!/usr/bin/tclsh

foreach f [glob *.*] {
    if {[regexp -all -nocase {(.*)\.(.*)} $f dummy fullname ext] } {
        if { [regexp -all -nocase {(.*)\(00\)} $fullname dummy name ] } {
             set cmd "file rename -force \"$f\" \"$name.$ext\""
             puts $cmd
             eval $cmd
        }
    }
}

Thursday, October 28, 2010

To find function declaration in static library

The following command finds a reference to function "gtk_widget_get_pango_context" in static library libwxOil.a:

linux-bvhg:~/> nm -l -C libwxOil.a  | grep gtk_widget_get_pango_context
                 U gtk_widget_get_pango_context(_GtkWidget*)  /home/myname/src/XaraLX/wxOil/ftfonts.cpp:868

GLIB and wxWidget Class conflict

When compiling XaraLX, there is a conflict between GLIB-2.0 and  wxWidget 2.8 as shown below:

/usr/local/include/glib-2.0/gio/giotypes.h:127:47: error: conflicting declaration `typedef struct _GSocket GSocket'
/usr/include/wx-2.8/wx/unix/gsockunx.h:41:1: error: `class GSocket' has a previous declaration as `class GSocket'

The quick solution is to modify <XaraLX directory>/wxOil/ftfonts.cpp.  Edit this file and change from:

#ifdef __WXGTK20__
#include <gtk/gtk.h>
extern GtkWidget *wxGetRootWindow();
#endif

to:

#ifdef __WXGTK20__
//#include <gtk/gtk.h>
extern PangoContext *gtk_widget_get_pango_context    (GtkWidget   *widget);
extern GtkWidget *wxGetRootWindow();
#endif