This very basic documentation page contains a small introduction to Xen taken from my previous writeup at the NixOS Wiki, and some instructions on how to import the domU profile and enable Dom0. Signed-off-by: Fernando Rodrigues <alpha@sigmasquadron.net>
2.7 KiB
Xen Project Hypervisor
Introduction
The Xen Project Hypervisor is an open-source
type-1 virtual machine manager which allows multiple virtual machines, known as
domains, to run concurrently with the host on the physical machine. This is
unlike a typical type-2 hypervisor, such as QEMU, where the virtual machines run
as applications on top of the host. NixOS runs as the privileged Domain 0, and
can paravirtualise (PV Mode) or fully virtualise (HVM Mode) unprivileged domains
(domUs).
Xen is security-supported in NixOS. All Xen Security Advisories are patched within hours of release, and generally reach the binary cache channels within a couple of days.
Domain 0 Installation
Xen may be used as a Domain 0 since
NixOS 24.11, using the
{option}virtualisation.xen.enable option. There are various hardware and
software requirements to running a Xen Domain 0; the module is configured to
prevent running Xen on a NixOS system that does not meet the software
requirements. (i.e. a NixOS system that uses the legacy, scripted initial
ramdisk.) The module does not yet check if the hardware requirements are met:
please manually ensure that the target machine supports
SLAT and
IOMMU,
the latter being required only for non-PV domains to be virtualised.
The boot menu on a Xen-enabled NixOS system will show duplicate entries for each
generation: one boots a normal NixOS system, and the other boots into the Xen
Project Hypervisor. The systemd-boot
and Limine bootloaders are the only supported
boot methods at this time.
Xen may be managed through various frontend configuration systems. libxenlight
is one such configuration system, and is built into all Xen systems. The xl
command is the primary command-line interface to libxenlight, and is capable
of managing a NixOS Domain 0.
Unprivileged Domain Installation
Known generically as guests, unprivileged domains running NixOS may import the
xen-domU.nix
profile in their configurations to automatically enable various recommended
optimisations which are relevant for unprivileged domains.
:::{.example}
Import the Xen Unprivileged Domain profile into a NixOS configuration
{
imports = [
<nixpkgs/nixos/modules/virtualisation/xen-domU.nix>
];
}
:::