Skip to content

Commit

Permalink
nixos/xen: init Domain 0 xl configuration module
Browse files Browse the repository at this point in the history
Signed-off-by: Fernando Rodrigues <[email protected]>
  • Loading branch information
SigmaSquadron committed Dec 9, 2024
1 parent 0dfe7ef commit fc8e8b2
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/manpage-urls.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@
"30-systemd-environment-d-generator(8)": "https://www.freedesktop.org/software/systemd/man/30-systemd-environment-d-generator.html",
"halt(8)": "https://www.freedesktop.org/software/systemd/man/halt.html",
"kernel-install(8)": "https://www.freedesktop.org/software/systemd/man/kernel-install.html",
"xl.cfg(5)": "https://xenbits.xen.org/docs/unstable/man/xl.cfg.5.html",
"xl.conf(5)": "https://xenbits.xen.org/docs/unstable/man/xl.conf.5.html",
"libnss_myhostname.so.2(8)": "https://www.freedesktop.org/software/systemd/man/libnss_myhostname.so.2.html",
"libnss_mymachines.so.2(8)": "https://www.freedesktop.org/software/systemd/man/libnss_mymachines.so.2.html",
"libnss_resolve.so.2(8)": "https://www.freedesktop.org/software/systemd/man/libnss_resolve.so.2.html",
Expand Down
Empty file.
Empty file.
Empty file.
55 changes: 55 additions & 0 deletions nixos/modules/virtualisation/xen/xl.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Xen Project Hypervisor Domain 0 libxenlight configuration
{
config,
lib,
pkgs,
...
}:

let
inherit (lib) mkIf mkOption;

cfg = config.virtualisation.xen;

settingsFormat = pkgs.formats.xenLight { type = "conf"; };
in
{
## Interface ##

options.virtualisation.xen = {
settings = mkOption {
inherit (settingsFormat) type;
default = { };
example = {
autoballoon = "off";
bootloader_restrict = false;
lockfile = "/run/lock/xen/xl";
max_grant_version = 256;
"vif.default.bridge" = "xenbr0";
"vm.hvm.cpumask" = [
"2"
"3-8,^5"
];
};
description = ''
The contents of the `/etc/xen/xl.conf` file.
See {manpage}`xl.conf(5)` for available configuration options.
'';
};
};

## Implementation ##

config = mkIf cfg.enable {
assertions = [
{
assertion = cfg.dom0Resources.memory != 0 -> !cfg.settings.autoballoon == "on";
message = ''
Upstream Xen strongly recommends that autoballoon be set to "off" or "auto" if
virtualisation.xen.dom0Resources.memory is limiting the total Domain 0 memory.
'';
}
];
environment.etc."xen/xl.conf".source = settingsFormat.generate "xl.conf" cfg.settings;
};
}

0 comments on commit fc8e8b2

Please sign in to comment.