XEN FROM SCRATCH

No Budget!

How many cores?

Compilation was done on some enterprise-class IBM servers dating 2007 with 4x4 Xeon processors and 96 GB to 128 GB of RAM. For 16 cores in total and with 1 thread per core (lscpu), I obtained the fastest results with -j16 for xen versus -j24 for tools and stubdom. Anyway, tune the number of make jobs according to your hardware.

Overall requirements (xen + tools + stubdom)

for pkg in \
    bison \
    flex \
    gcc \
    git \
    glibc \
    make \
    openssl \
    patch \
    pixman \
    pciutils \
    texinfo \
    zlib \
    lzo \
    ; do
    echo -n $pkg:
    ls -1 /var/log/packages/ | grep ^$pkg-[[:digit:]]
done; unset pkg

eventually setup slackpkg+ against slackonly

ls -lF /var/log/packages/yajl*
slackpkg install yajl-2

or fetch and build it yourself

#git clone git://github.com/lloyd/yajl
#wget -O yajl-2.1.0.tar.gz http://github.com/lloyd/yajl/tarball/2.1.0
#tar xzf tar xzf yajl-2.1.0.tar.gz
#cd lloyd-yajl-66cb08c/
#./configure
#nice make -j$j
#make install
#cd ../

Compiling XEN (the micro-kernel)

fetch the latest release tarball

ver=4.12.1
wget https://downloads.xenproject.org/release/xen/$ver/xen-$ver.tar.gz
wget https://downloads.xenproject.org/release/xen/$ver/xen-$ver.tar.gz.sig
#gpg --recv-key 57E82BD9
gpg xen-$ver.tar.gz.sig
# Primary key fingerprint: 23E3 222C 145F 4475 FA80  60A7 83FE 14C9 57E8 2BD9

note. if you want current,

#git clone git://xenbits.xen.org/xen.git

compile,

#rm -rf xen-$ver/
tar xzf xen-$ver.tar.gz
cd /data/kernels/xen/xen-$ver/
#make clean-xen >/dev/null && echo CLEANED
time nice make -j$j xen > ../make.xen.$HOSTNAME.log && echo BUILT #1m0.191s
time nice make install-xen > ../make.install-xen.$HOSTNAME.log && echo INSTALLED
ll /xen* /boot/xen*
ln -s boot/xen.gz /xen.gz
cd ../

Tools Requirements

installing the latest ACPICA (20180427 fails), for the xen tools to compile,

#Intel license
#wget https://acpica.org/sites/acpica/files/acpica-unix-20190816.tar.gz
#GPL
wget https://acpica.org/sites/acpica/files/acpica-unix2-20190816.tar.gz
tar xzf ...
cd ...
nice make -j$j > ../make.acpica.$HOSTNAME.log && echo BUILT
make install > ../make.acpicainstall.$HOSTNAME.log && echo INSTALLED
cd ../

installing the corresponding multilib version of gcc and glibc (and installing compat32-tools),

mkdir /data/kernels/xen/tftpboot/compat142/
cd /data/kernels/xen/compat142/
lftp -c 'open http://slackware.com/~alien/multilib/ ; mirror -c -e 14.2'
#lftp -c 'open http://slackware.com/~alien/multilib/ ; mget -c 14.2/*'
du -sh 14.2/ #343M

cd /data/kernels/xen/compat142/14.2/
#upgradepkg --reinstall --install-new *.t?z
upgradepkg --reinstall --install-new gcc-5.5.0_multilib-x86_64-1alien.txz
upgradepkg --reinstall --install-new glibc-2.23_multilib-x86_64-4alien.txz
upgradepkg --reinstall --install-new compat32-tools-3.8-noarch-6alien.tgz
#upgradepkg --reinstall --install-new glibc-solibs-2.23_multilib-x86_64-4alien.txz
ls -lF /var/log/packages/compat32-tools*
ls -lF /var/log/packages/glibc*
ls -lF /var/log/packages/gcc*
cd ../../

Compiling the Tools

Fetch ipxe & seabios GIT repos through https://

cd /data/kernels/xen/xen-$ver/
export PATH=$PATH:/usr/lib64/bcc
which bcc-cpp

./configure --enable-githttp

#make -j$j distclean
#time nice make -j$(($j * 2 - 1)) world > ../world.$HOSTNAME.log && echo BUILTWORLD

#make -j$j clean-tools
time nice make -j$(($j * 2 - 1)) tools > ~/tools.$HOSTNAME.log && echo BUILT #2m15.454s nfs/5m9.140s
nice make -j$(($j * 2 - 1)) install-tools > ~/install-tools.$HOSTNAME.log && echo INSTALLED

#make clean-stubdom
#time make -j24 stubdom > make.stubdom.log && echo done
#time make install-stubdom

cp -pi /etc/ld.so.conf /etc/ld.so.conf.dist
cat >> /etc/ld.so.conf <<-EOF
/usr/local/lib
EOF
cat /etc/ld.so.conf
ldconfig

and this will be useful for other pieces of software, since you’ve got compat32

vi /etc/profile

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig

Tools Setup

without autoballoon nor anything specific

mv -i /etc/xen/xl.conf /etc/xen/xl.conf.dist
egrep -v '^[[:space:]]*(#|$)' /etc/xen/xl.conf.dist #empty
vi /etc/xen/xl.conf

#https://xenbits.xen.org/docs/unstable/man/xl.conf.5.html
#autoballoon="on"
#vif.default.script="vif-openvswitch"

now we want to enable the XEN daemons at boot time alright.

ls -lF /etc/rc.d/init.d/xen*
vi /etc/rc.d/rc.local

the default scheduler is now Credit2, since 4.10 or 4.12

/usr/local/sbin/xl sched-credit2 --domain=0 --weight=512
/usr/local/sbin/xl sched-credit2

we keep using xendomains because otherwise, guests live alone while dom0 shuts down.

#self verbose
/etc/rc.d/init.d/xencommons start
/etc/rc.d/init.d/xendomains start

and shutdown

vi /etc/rc.d/rc.local_shutdown

#!/bin/sh

#self verbose
/etc/rc.d/init.d/xendomains stop
/etc/rc.d/init.d/xencommons stop

chmod +x /etc/rc.d/rc.local_shutdown
grep rc.local_shutdown /etc/rc.d/rc.*

Dom0 kernel

http://pub.nethence.com/xen/kernel

Booting

Index of /booting/ http://pub.nethence.com/booting/

Networking

mv -i /etc/rc.d/rc.inet1 /etc/rc.d/rc.inet1.dist
chmod -x /etc/rc.d/rc.inet1.dist
ls -lF /bin/ksh
vi /etc/rc.d/rc.inet1

#!/bin/ksh

if [[ $1 = stop ]]; then
        route delete default
        ifconfig pubbr0 down
        ifconfig xenbr0 down
        ifconfig eth0 down
        ifconfig eth1 down
        ifconfig lo down
        exit 0
fi

echo -n lo...
ifconfig lo up && echo done

echo -n public bridge...
brctl addbr pubbr0
brctl addif pubbr0 eth1
ifconfig pubbr0 up && echo done
ifconfig eth1 up

echo -n internal bridge...
brctl addbr xenbr0
brctl addif xenbr0 eth0
ifconfig xenbr0 x.x.x.x/xx up && echo done
ifconfig eth0 up

echo -n default route...
route add default gw x.x.x.x && echo done

brctl show

chmod +x /etc/rc.d/rc.inet1

Ready to go

cat /sys/hypervisor/properties/capabilities
cat /proc/xen/capabilities
/etc/rc.d/init.d/xencommons status
xl li

Tuning

more loops

0How to add more /dev/loop* devices on Fedora 19 https://unix.stackexchange.com/questions/98742/how-to-add-more-dev-loop-devices-on-fedora-19

  1. Adding Support for More Loop Devices https://www.tldp.org/HOWTO/CDServer-HOWTO/addloops.html

libvirt capable (optional)

slackpkg install libpciaccess
sbopkg -i libvirt
sbopkg -i libvirt-python
sbopkg -i virt-manager
sbopkg -i virt-viewer

cat /etc/sysctl.d/60-libvirtd.conf
sysctl fs.aio-max-nr=1048576

/usr/sbin/libvirtd -d
cat >> /etc/rc.local <<-EOF

echo -n starting libvirt...
/usr/sbin/libvirtd -d && echo done
EOF

virsh list

Resources

Dom0 Kernels for Xen https://wiki.xenproject.org/wiki/Dom0_Kernels_for_Xen

Compiling Xen From Source https://wiki.xenproject.org/wiki/Compiling_Xen_From_Source

Xen Project Repositories https://wiki.xenproject.org/wiki/Xen_Project_Repositories

Getting Started with Xen on Slackware http://amree.github.io/2012/09/12/getting-started-with-xen-on-slackware/

OBSOLETE

mounted by xencommons,

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

eventually fix an anoying bug into seabios,

grep -r BXSSDTSUSP *
vi tools/firmware/seabios-dir-remote/src/fw/ssdt-misc.dsl

BXSSDTSUSP --> BXSSDTSU

grep -r BXSSDTPCIHP *
vi tools/firmware/seabios-dir-remote/src/fw/ssdt-pcihp.dsl

BXSSDTPCIHP --> BXSSDTPC

Nethence | Pub | Lab | Pbraun | SNE Russia | xhtml