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 11, 2024
1 parent 74bbd20 commit a901dca
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
4 changes: 3 additions & 1 deletion doc/manpage-urls.json
Original file line number Diff line number Diff line change
Expand Up @@ -321,5 +321,7 @@
"[email protected](5)": "https://www.freedesktop.org/software/systemd/man/[email protected]",
"userdbctl(1)": "https://www.freedesktop.org/software/systemd/man/userdbctl.html",
"vconsole.conf(5)": "https://www.freedesktop.org/software/systemd/man/vconsole.conf.html",
"veritytab(5)": "https://www.freedesktop.org/software/systemd/man/veritytab.html"
"veritytab(5)": "https://www.freedesktop.org/software/systemd/man/veritytab.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"
}
56 changes: 56 additions & 0 deletions nixos/modules/virtualisation/xen/xl.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Xen Project Hypervisor Domain 0 libxenlight configuration
{
config,
lib,
pkgs,
...
}:

let
inherit (lib) mkIf mkOption attrByPath;

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) -> ((attrByPath [ "autoballoon" ] "auto" cfg.settings) != "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 a901dca

Please sign in to comment.