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 or 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 \
    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 e.g.,

cd ~/
#wget https://downloads.xenproject.org/release/xen/4.11.0-rc6/xen-4.11.0-rc6.tar.gz
wget https://downloads.xenproject.org/release/xen/4.10.0/xen-4.10.0.tar.gz
wget https://downloads.xenproject.org/release/xen/4.10.0/xen-4.10.0.tar.gz.sig
gpg xen-4.10.0.tar.gz.sig
gpg --recv-key 57E82BD9
gpg xen-4.10.0.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,

tar xzf xen-4.10.0.tar.gz
cd xen-4.10.0/
#make clean-xen
time make -j16 xen > ../make.xen.$HOSTNAME.log && echo done
time make install-xen > /dev/null && echo done
ls -lhF /boot/xen.gz
ls -lhF /boot/xen-4.10.0.gz

Tools Requirements

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

#wget https://acpica.org/sites/acpica/files/acpica-unix-20180427.tar.gz
wget https://acpica.org/sites/acpica/files/acpica-unix-20171215.tar.gz
tar xzf acpica-unix-20171215.tar.gz
cd acpica-unix-20171215
time make -j$j > ../acpica-unix.make.$HOSTNAME.log && echo done
make install
cd ../

installing pixman using Slackpkg, assuming it has been setup already,

ls -lhF /var/log/packages/pixman*                
#slackpkg install pixman

installing yajl using either slackpkg+, in case you got it,

ls -lhF /var/log/packages/yajl*

draft

#slackpkg search yajl
#slackpkg install yajl

or using sbopkg,

sbopkg -s yajl
sbopkg -i yajl

or much brutally using SlackBuild binaries from SlackOnly,

wget https://slackonly.com/pub/packages/14.2-x86_64/libraries/yajl/yajl-2.1.0-x86_64-2_slonly.txz
installpkg yajl-2.1.0-x86_64-2_slonly.txz

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/ ; mget -c 14.2/*'
upgradepkg --reinstall --install-new *.t?z
ls -1 /var/log/packages/ | grep ^compat32-tools-[[:digit:]]
ls -1 /var/log/packages/ | grep ^glibc-[[:digit:]]
ls -1 /var/log/packages/ | grep ^gcc-[[:digit:]]
cd ../

Compiling the Tools

cd ~/xen-4.10.0/
which bcc-cpp
export PATH=$PATH:/usr/lib64/bcc
./configure #already uses git for seabios
#./configure --enable-githttp

#make distclean
#time make -j24 world > ../make.world.$HOSTNAME.log && echo done

#make clean-tools
time make -j24 tools > ../make.tools.$HOSTNAME.log && echo done
time make -j24 install-tools

We do not want to manage save/restore that way,

chmod -x /etc/rc.d/init.d/xendomains 

But we want to enable the other daemons at boot time alright,

ls -lhF /etc/rc.d/init.d/xencommons
cat >> /etc/rc.d/rc.local <<-EOF
#self verbose
/etc/rc.d/init.d/xencommons start
EOF

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

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

Compiling the Linux dom0 kernel

See Compiling a XEN dom0 Linux kernel.

this does not harm even though we might switch to extlinux,

ls -l /boot/vmlinuz.old
mv /etc/lilo.conf /etc/lilo.conf.dist
sed '/^$/d; /^#/d' /etc/lilo.conf.dist > /etc/lilo.conf
cat >> /etc/lilo.conf <<-EOF
#image = /boot/vmlinuz-huge-4.4.88
image = /boot/vmlinuz.old
  root = /dev/sda1
  label = slack4488
  read-only
EOF
make install
ls -l /boot/config
mv /boot/config /boot/config.old
cp .config /boot/config

note. assuming lba32 and timeout = 100 (10 seconds) have already been set up.

(optional) – eventually try to boot this xen-enabled kernel w/o xen as hypervisor,

#sync
#shutdown -r now

Preparing the initrd

The XEN-enabled kernel needs an initrd to avoid kernel panic (attempted to kill init!),

cd /boot/
mkinitrd -c -o initrd.gz -k 4.4.88 -r /dev/sda1

Booting with mbootpack

slackpkg search mbootpack
sbopkg -s mbootpack
sbopkg -i mbootpack
cd /boot/
zcat xen-4.10.0.gz > xen-4.10.0
zcat initrd.gz > initrd
mbootpack -o xenvmlinuz -m vmlinuz -m initrd xen-4.10.0
vi /etc/lilo.conf

default = xen4488
#default = slack4488

image = /boot/xenvmlinuz
  root = /dev/sda1
  initrd = /boot/initrd.gz
  label = xen4488
  read-only

lilo
sync
shutdown -r now

notes.

refs.

Booting with SYSLINUX/EXTLINUX

See Booting Linux or XEN with EXTLINUX

Networking

See XEN // Networking

Ready to go

cat /sys/hypervisor/properties/capabilities

cat /proc/xen/capabilities
xl li

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

Troubleshooting

when making tools,

make[7]: *** No rule to make target '/usr/lib64/gcc/x86_64-slackware-linux/5.5.0/include/stdarg.h', needed by 'out/src/output.o'.  Stop.
make[6]: *** [subdir-all-seabios-dir] Error 2
make[5]: *** [subdirs-all] Error 2
make[4]: *** [all] Error 2
make[3]: *** [subdir-install-firmware] Error 2
make[2]: *** [subdirs-install] Error 2
make[1]: *** [install] Error 2
make: *** [install-tools] Error 2

==> you skipped the part about multilib/compat

References

OBSOLETE

installing latest YAJL,

#cd ~/
#git clone git://github.com/lloyd/yajl
#./configure
#make -j24
#make install

mbootpack from source,

#cd ~/
#git clone https://github.com/timdeegan/mbootpack.git
#cd mbootpack/
#make
#cp mbootpack /usr/local/bin/

install,

#cp xen/xen.gz /xen4100.gz
#ls -lhF /xen.gz
#ln -sf xen4100.gz /xen.gz

mounted by xencommons,

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