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 \
    ; do
    echo -n $pkg:
    ls -1 /var/log/packages/ | grep ^$pkg-[[:digit:]]
done; unset pkg

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 xen-$ver/
#make clean-xen >/dev/null && echo CLEANED
time nice make -j$j xen > ../make.xen.$HOST.log && echo BUILT
time nice make -j$j install-xen > ../make.install-xen.$HOSTNAME.log && echo INSTALLED
ll /boot/xen*
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.$HOST.log && echo BUILT
make install > ../make.acpicainstall.$HOST.log && echo INSTALLED
cd ../

need pixman (official pkg) and yajl (SBO). Eventually setup slackpkg+ against slackonly).

#ls -lhF /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 ../

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

mkdir compat142/
cd 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 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
ls -lhF /var/log/packages/ | grep ^compat32-tools-[[:digit:]]
ls -lhF /var/log/packages/ | grep ^glibc-[[:digit:]]
ls -lhF /var/log/packages/ | grep ^gcc-[[:digit:]]
cd ../../

Compiling the Tools

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

Fetch ipxe & seabios GIT repos through https://

./configure --help | less
./configure --enable-githttp

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

#make -j$j clean-tools
time nice make -j$(($j * 2 - 2)) tools >> ../tools.$HOST.log && echo BUILT
nice make -j$(($j * 2 - 2)) install-tools >> ../install-tools.$HOST.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

Tune the thing,

mv -i /etc/xen/xl.conf /etc/xen/xl.conf.dist
sed -r '/^[[:space:]]*(#|$)/d' /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"

But we want to enable the other daemons at boot time alright. Note that Credit2 is now the default scheduler (since 4.10 or 4.12). Note we keep using xendomains because otherwise guests live alone while dom0 shuts down.

ls -lhF /etc/rc.d/init.d/xencommons
cat >> /etc/rc.d/rc.local <<-EOF
#self verbose
/etc/rc.d/init.d/xencommons start
/etc/rc.d/init.d/xendomains start
/usr/local/sbin/xl sched-credit2 --domain=0 --weight=512
/usr/local/sbin/xl sched-credit2
EOF
cat /etc/rc.d/rc.local

cat >> /etc/rc.d/rc.local_shutdown <<-EOF
#self verbose
/etc/rc.d/init.d/xendomains stop
/etc/rc.d/init.d/xencommons stop
EOF
cat /etc/rc.d/rc.local_shutdown

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
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