libvirtd: add parallelShutdown option

This adds a new ``parallelShutdown`` option that allows users to control
how many guests can be shut down concurrently. Allowing multiple virtual
machines to be shut down at the same time reduces the amount of time it
takes to reboot the host.

Upstream documentation: https://www.libvirt.org/manpages/libvirt-guests.html#files
This commit is contained in:
Alexander Bakker 2022-12-24 18:45:04 +01:00 committed by Bjørn Forsman
parent b6d94e3962
commit 89f4a5ab26
2 changed files with 13 additions and 0 deletions

View File

@ -220,6 +220,17 @@ in
'';
};
parallelShutdown = mkOption {
type = types.ints.unsigned;
default = 0;
description = lib.mdDoc ''
Number of guests that will be shutdown concurrently, taking effect when onShutdown
is set to "shutdown". If set to 0, guests will be shutdown one after another.
Number of guests on shutdown at any time will not exceed number set in this
variable.
'';
};
allowedBridges = mkOption {
type = types.listOf types.str;
default = [ "virbr0" ];
@ -373,6 +384,7 @@ in
environment.ON_BOOT = "${cfg.onBoot}";
environment.ON_SHUTDOWN = "${cfg.onShutdown}";
environment.PARALLEL_SHUTDOWN = "${toString cfg.parallelShutdown}";
};
systemd.sockets.virtlogd = {

View File

@ -341,6 +341,7 @@ stdenv.mkDerivation rec {
substituteInPlace $out/libexec/libvirt-guests.sh \
--replace 'ON_BOOT="start"' 'ON_BOOT=''${ON_BOOT:-start}' \
--replace 'ON_SHUTDOWN="suspend"' 'ON_SHUTDOWN=''${ON_SHUTDOWN:-suspend}' \
--replace 'PARALLEL_SHUTDOWN=0' 'PARALLEL_SHUTDOWN=''${PARALLEL_SHUTDOWN:-0}' \
--replace "$out/bin" '${gettext}/bin' \
--replace 'lock/subsys' 'lock' \
--replace 'gettext.sh' 'gettext.sh