this is obsolete doc -- see http://doc.nethence.com/ instead

XEN4 Slackware Linux XEN dom0/pv_ops installation 

 

 

Introduction 

Note. it's possible to build both, XEN and dom0/domU kernel with 'make world && ./install.sh', but it's best to build the kernel seperately to easyly customize and (re)compile it. 

 

Once the XEN hypervisor and dom0/domU kernel are in place, you'll have to choose between one of those bootloaders : 

- GRUB2 

- LILO with mbootpack 

Note. GRUB1 doesn't compile on Slackware64 (there's a patch into extra/source tho) 

 

 

Requirements 

To compile the XEN tools you'll need the basic sets (say A and D having ADD and REC tagged packages), and those ones too: proceed with slackinst (http://slackinst.nethence.com), 

querypkg.ksh \
glibc \
gcc \
make \
libX11 \
libXft \
openssl \
pciutils \
patch \
texinfo \
flex \
bison \
| grep ^package
#installpkg.ksh ...

 

Prepare IASL (http://acpica.org/downloads/unix_source_code.php), 

cd ~/
wget http://acpica.org/download/acpica-unix-20100806.tar.gz
tar xzf acpica-unix-20100806.tar.gz
cd acpica-unix-20100806/compiler/
make
cp iasl /usr/local/bin/
cd ../../

 

Make sure you've got git available, 

which git

 

 

XEN hypervisor & tools 

Fetch (http://www.xen.org/products/xen_source.html) and build latest XEN hypervisor and tools, 

cd ~/
#wget http://bits.xensource.com/oss-xen/release/4.0.1/xen-4.0.1.tar.gz
#tar xzf xen-4.0.1.tar.gz
#cd xen-4.0.1/
wget http://bits.xensource.com/oss-xen/release/4.1.0/xen-4.1.0.tar.gz
tar xzf xen-4.1.0.tar.gz
cd xen-4.1.0/
make xen && make tools && make stubdom

 

Put the XEN micro-kernel in place and install the userland tools, 

#make install-xen
#cp xen/xen.gz /boot/xen-4.0.1.gz
cp xen/xen.gz /boot/xen-4.1.0.gz
make install-tools
make install-stubdom

 

 

Custom dom0/domU kernel 

Checkout Jeremy's repo, 

cd ~/
git clone git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git
cd xen/
git branch -r
git checkout -b xen/stable-2.6.32.x origin/xen/stable-2.6.32.x
git branch
git pull

Note. -r to list remote-tracking branches 

Note. some branches' details : 

- #xen/master is 2.6.31.x 

- xen/stable-2.6.32.x 

- xen/next-2.6.32 (default) 

Ref. http://git.kernel.org/?p=linux/kernel/git/jeremy/xen.git;a=heads 

Note. Slackware64 13.1 has v2.6.33.4 

 

See http://pbraun.nethence.com/doc/sysutils_linux/kernel.html for general configuration and building. Configure your dom0/domU linux kernel with the following additionnal settings. 

 

Allow HVM guests to use virtual network emulation (tun) and take the change to enable the dummy network driver and bonding, 

cat >> .config <<EOF9
CONFIG_DUMMY=m
CONFIG_TUN=m
CONFIG_BONDING=m
EOF9
make silentoldconfig

Note. only works as module, donno why 

Note. otherwise inside qemu-dm-xen1.log you would get, 

warning: could not open /dev/net/tun: no virtual network emulation
Could not initialize device 'tap'

 

Enable paravirtualization, 

  cat >> .config <<EOF9
CONFIG_PARAVIRT_GUEST=y
CONFIG_XEN=y
CONFIG_XEN_DOM0=y
CONFIG_XEN_NETDEV_BACKEND=y
CONFIG_XEN_BLKDEV_BACKEND=y
CONFIG_XEN_BLKDEV_TAP=y
CONFIG_XEN_GNTDEV=y
CONFIG_XEN_PLATFORM_PCI=y
EOF9
make silentoldconfig
# (press enter for the defaults)

 

Eventually add some tag to your kernel, 

vi Makefile

change, 

EXTRAVERSION = .39xen

 

Build and install, 

time nice make
ls -l /lib/modules/
make modules_install
cp -f arch/x86_64/boot/bzImage /boot/2.6.32.39xen
#cp -f arch/x86_64/boot/bzImage /data/shared/2.6.32.39.xenu

 

 

GRUB2 

Get GRUB2 (ftp://alpha.gnu.org/gnu/grub/) and install it, 

cd ~/
wget ftp://alpha.gnu.org/gnu/grub/grub-1.98.tar.gz
tar xzf grub-1.98.tar.gz
cd grub-1.98/
./configure
make
make install
cd ../

Note. to compile you need zlib bison m4 

 

Write to MBR and install /boot/grub files, 

grub-install --no-floppy /dev/sda

 

To get a template GRUB2 config, 

#grub-mkconfig > /boot/grub/grub.cfg.sample

Note. with GRUB2 it's not menu.lst anymore, it's grub.cfg 

 

Create or edit GRUB2 configuration, 

vi /boot/grub/grub.cfg

like (here /boot isn't separated), 

set default=xen
set timeout=3

 

menuentry Linux {
  insmod ext2
  set root=(hd0,1)
  linux /boot/vmlinuz lala=lala root=/dev/sda1 ro gfxpayload=1024x768
}

 

menuentry xen {
  insmod ext2
  set root=(hd0,1)
  multiboot /boot/xen-4.1.0.gz lala=lala dom0_mem=256M
  module /boot/2.6.32.37xen lala=lala root=/dev/sda1 ro nomodeset noreboot
}

 

menuentry "xen/stable-2.6.32.x usb serial" {
  insmod ext2
  set root=(hd0,1)
  multiboot /boot/xen-4.0.1.gz lala=lala dom0_mem=256M

module /boot/stable-2.6.32.x lala=lala root=/dev/sda1 ro nomodeset noreboot console=tty0 console=ttyUSB0,9600n8 

}

Note. to find out the right hdX,X you'll eventually have to reboot and 'ls -l' at grub's command line 

Note. lala=lala is a bug workaround as the first argument get skipped (bug still present on 1.97.1) 

 

Reboot, 

sync
shutdown -r now

 

 

The LILO/mbootpack way 

Otherwise get Mbootpack (http://www.tjd.phlegethon.org/software/#mbootpack) and use it to join xen.gz, vmlinuz and the initrd, 

wget http://www.tjd.phlegethon.org/software/mbootpack-0.6a.tar.gz
tar xzf mbootpack-*.tar.gz
cd mbootpack-*/
...

 

Ref. http://wpkg.org/Running_Xen_with_LILO 

 

 

Post-installation 

Once the dom0 has booted. 

 

Check gntdev and evtchn are running, 

cat /proc/misc | grep xen

 

Mount XENFS, 

cat >> /etc/fstab <<EOF9
xenfs            /proc/xen      xenfs           defaults        0 0
EOF9
mount /proc/xen

check, 

mount | grep xen

 

Check your kernel as bridging, 

grep BRIDGE /boot/next/.config

 

 

XEN daemon 

Start XEN and check everything's alright, 

which xend
xend start

check, 

ps ax | grep xen

 

Eventually enable it at boot time, 

cd /etc/rc.d
vi rc.local

add, 

#/sbin/sysctl -w net.netfilter.nf_conntrack_acct=1

 

echo -n starting xend...
/usr/sbin/xend start && echo done

 

storage=/data
echo starting xen guests...
for guest in `ls -1 /etc/xen/auto/`; do
        /usr/sbin/xm cr $storage/guests/$guest/$guest
done && echo done
unset storage

 

And for shutdown, 

cd /etc/rc.d
vi rc.local_shutdown

add, 

echo shutting down xen guests...
guests=`/usr/sbin/xm li \
        | awk '{print $1}' \
        | egrep -v '^Domain-0|^Name'`
for guest in $guests; do
        /usr/sbin/xm shu $guest && echo -n $guest...
done && echo done
sleep 20

 

echo -n shutting down xend...
/usr/sbin/xend stop && echo done

 

 

Ready to go 

Check everything's fine, 

brctl show
xm dmesg

 

You can now proceed, 

xm li
...

 

 

Misc 

Enable your serial console e.g. gor ttyUSB0, 

vi /etc/inittab

add, 

s0:12345:respawn:/sbin/agetty -L ttyUSB0 9600 vt100

 

You might want to increase the possible amount of loop mounts. Add this to your kernel arguments, 

max_loop=64

or to modprobe.conf, 

loop max_loop=64

 

Eventually add this to your .screenrc, 

vi ~/.screenrc

add, 

screen -t "xen" 1 tail -F /var/log/xen/xend.log
screen -t "dm" 2 tail -F /var/log/xen/qemu-dm-xen1.log
screen -t "sensors" 3 watch sensors
screen -t "freqs" 4 watch 'xenpm get-cpufreq-para | grep ^cpuinfo'

 

 

Troubleshooting 

In case you experience some troubles starting the dom0, 

mount /dev/sda1 /mnt/
cd /mnt/boot/grub/
vi grub.cfg
cd /
umount mnt
shutdown -r now

Note. don't forget to remove the LiveCD or turn off the rescue mode 

 

If you get the following error when starting xend, 

ERROR Internal error: Could not obtain handle on privileged command interface (2 = No such file or directory)

make sure XENFS is mounted and both xen modules are running (see above). 

 

If you get this warning when starting xend, 

add bridge failed: Package not installed

togeather with syslog message, 

Forced to steal lock on /var/run/xen-hotplug/network-bridge

make sure bridging is enabled in your kernel (see above). 

 

If you get this error when starting a guest, 

Error: Device 0 (vif) could not be connected. Hotplug scripts not working.

make sure : 

- NETDEV and BLKDEV* are enabled in the kernel (see above) 

- the bridge is up and running (check its name, eth0 or br0), 

brctl show

- check vif= is either empty or points to the right bridge name 

 

 

References 

http://wiki.xensource.com/xenwiki/XenParavirtOps 

http://wiki.xensource.com/xenwiki/XenDom0Kernels 

http://wiki.xensource.com/xenwiki/2.6.18-to-2.6.31-and-higher 

http://markmail.org/thread/tww7aqawwn4r4fnk 

http://www.faqs.org/docs/Linux-HOWTO/Remote-Serial-Console-HOWTO.html 

 

Download 

http://www.xen.org/products/xen_source.html 

http://git.kernel.org/?p=linux/kernel/git/jeremy/xen.git;a=summary 

http://git.kernel.org/?p=linux/kernel/git/jeremy/xen.git;a=shortlog;h=xen/next 

 

DomU 

http://enmingteo.wordpress.com/2009/11/01/picture-tutorial-how-to-setup-slackware64-13-0-hvm-domu-with-xen-3-5-unstable-pv-ops-dom0-kernel-2-6-31-4-in-fedora-11-x86-64-dom0/ 

 

Git 

http://smalltalk.gnu.org/blog/bonzinip/using-git-without-feeling-stupid-part-1 

 

Troubbleshooting 

http://wiki.xen.org/xenwiki/XenCommonProblems 

http://wiki.archlinux.org/index.php/Xen