Ubuntu 18.04 comes with xen-hypervisor 4.9 and Ubuntu 20.04 comes with xen-hypervisor 4.11
To get latest version to protect your system or use zstd-compressed Kernels you can build your xen-hypervisor from source.
This howto based on this official howto.
Updated to xen 4.16: Added ninja-build to build environment (2021-12-16)
Updates to xen 4.15: Added libzstd1-dev / libzstd-dev for zstd-compressed Kernels.
Xen-Hypervisor
Install requirements for build
For Ubuntu 18.04:
apt-get -qq install build-essential apt-get -qq install bcc bin86 gawk bridge-utils iproute2 libcurl4 libcurl4-openssl-dev bzip2 module-init-tools transfig tgif apt-get -qq install texinfo texlive-latex-base texlive-latex-recommended texlive-fonts-extra texlive-fonts-recommended pciutils-dev mercurial apt-get -qq install make gcc libc6-dev zlib1g-dev python python-dev python-twisted libncurses5-dev patch libvncserver-dev libsdl-dev libjpeg-dev apt-get -qq install python3-dev apt-get -qq install libnl-3-dev libnl-cli-3-dev libnl-genl-3-dev libnl-route-3-dev libnl-idiag-3-dev libnl-xfrm-3-dev apt-get -qq install iasl libbz2-dev e2fslibs-dev git-core uuid-dev ocaml ocaml-findlib libx11-dev bison flex xz-utils libyajl-dev apt-get -qq install gettext libpixman-1-dev libaio-dev markdown pandoc iasl cmake figlet apt-get -qq install libc6-dev-i386 apt-get -qq install lzma lzma-dev liblzma-dev apt-get -qq install libsystemd-dev apt-get -qq install libzstd1-dev apt-get -qq install ninja-build
For Ubuntu 20.04
apt-get -qq install build-essential apt-get -qq install bcc bin86 gawk bridge-utils iproute2 libcurl4 libcurl4-openssl-dev bzip2 kmod transfig tgif pkg-config apt-get -qq install texinfo texlive-latex-base texlive-latex-recommended texlive-fonts-extra texlive-fonts-recommended libpci-dev mercurial apt-get -qq install make gcc libc6-dev zlib1g-dev python python-dev python3-twisted libncurses5-dev patch libvncserver-dev libsdl-dev libjpeg-dev apt-get -qq install python3-dev libglib2.0-dev apt-get -qq install libnl-3-dev libnl-cli-3-dev libnl-genl-3-dev libnl-route-3-dev libnl-idiag-3-dev libnl-xfrm-3-dev apt-get -qq install iasl libbz2-dev e2fslibs-dev git-core uuid-dev ocaml ocaml-findlib ocamlbuild libx11-dev bison flex xz-utils libyajl-dev apt-get -qq install gettext libpixman-1-dev libaio-dev markdown pandoc iasl cmake figlet apt-get -qq install libc6-dev-i386 apt-get -qq install lzma lzma-dev liblzma-dev apt-get -qq install libsystemd-dev apt-get -qq install libzstd-dev apt-get -qq install ninja-build
Download and prepare and make
We use the latest stable for 4.16
git clone git://xenbits.xen.org/xen.git cd xen git checkout origin/stable-4.16
Configure and make
Ubuntu uses systemd:
./configure --enable-systemd
For first make use:
make dist
For new make use make world (same like make clean && make dist).
Get a coffee now.
Install
The install-files are in /dist/install. And you will find an install-script in dist/install.sh. Dont use this script! It will breaks your /var/run-folder.
You can copy the files via cp -a or rsync in your system. Or you may use make debball and install the package from file (I didnt try).
Post-Install
After copying the files you will do some changes in your system:
Reload dynamic libraries:
/sbin/ldconfig
Grub-Settings:
mkdir -p /etc/default/grub.d
Create /etc/default/grub.d/xen.cfg:
vi /etc/default/grub.d/xen.cfg
GRUB_DISABLE_OS_PROBER=true GRUB_CMDLINE_XEN_DEFAULT="dom0_mem=2560M,max:2560M" GRUB_DEFAULT="Ubuntu GNU/Linux, mit Xen-Hypervisor"
Be careful! The last settings depends on your system-language! For english use: "Ubuntu GNU/Linux, with Xen hypervisor" - Ubuntu 18.04 does not use the german translation!
You have to update grub:
update-grub
Enable systemd-files:
In the current version is a bug and xendomains.service and /etc/init.d/xendomains are created both. To use systemd you have to remove /etc/init.d/xendomains
rm /etc/init.d/xendomains
systemctl enable xen-qemu-dom0-disk-backend.service systemctl enable xen-init-dom0.service systemctl enable xenconsoled.service systemctl enable xenstored.service systemctl enable xendomains.service
Optional you can enable xen-watchdog.service
systemctl enable xen-watchdog.service
Configure xen
Configure xen for your needs.
xen-tools
For creating new VMs you can use xen-tools. Unfortunately you cannot use the ubuntu-package because it requires xen-hypervisor. So we build from source.
Install requirements for build
apt install lvm2 debootstrap libconfig-inifiles-perl libdata-validate-domain-perl libdata-validate-ip-perl libdata-validate-uri-perl libfile-slurp-perl libfile-which-perl libsort-versions-perl libterm-ui-perl libtext-template-perl openssh-client perl debian-archive-keyring rinse libtest-notabs-perl
Download and prepare and make
git clone https://github.com/xen-tools/xen-tools.git cd xen-tools make install
If you want only the install-files (e.g. for build you own package), you can edit the Makefile and manually set the variable DESTDIR before make install.
Configure xen-tools
Configure xen-tools for your needs.
Reboot
After reboot you have your Ubuntu on xen-hypervisor.
Test:
xentop
Settings for PVH
For PVH you have to use Linux 4.11 or newer (e.g. HWE-Kernel) in guest:
apt install linux-virtual-hwe-16.04 linux-tools-virtual-hwe-16.04
Then you can use:
bootloader = '/usr/local/bin/pygrub' type="pvh"
If you have an old kernel in your guest-system, you have to boot from dom0-kernel with this settings:
type="pvh" kernel='/vmlinuz' ramdisk="/initrd.img"