Merge pull request #67356 from alexbakker/libvirt-onboot

libvirtd: add onBoot option
This commit is contained in:
Marek Mahut 2019-08-24 11:59:07 +02:00 committed by GitHub
commit b8b35816c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -104,6 +104,18 @@ in {
'';
};
onBoot = mkOption {
type = types.enum ["start" "ignore" ];
default = "start";
description = ''
Specifies the action to be done to / on the guests when the host boots.
The "start" option starts all guests that were running prior to shutdown
regardless of their autostart settings. The "ignore" option will not
start the formally running guest on boot. However, any guest marked as
autostart will still be automatically started by libvirtd.
'';
};
onShutdown = mkOption {
type = types.enum ["shutdown" "suspend" ];
default = "suspend";
@ -221,6 +233,7 @@ in {
path = with pkgs; [ coreutils libvirt gawk ];
restartIfChanged = false;
environment.ON_BOOT = "${cfg.onBoot}";
environment.ON_SHUTDOWN = "${cfg.onShutdown}";
};

View file

@ -129,6 +129,7 @@ in stdenv.mkDerivation rec {
binPath = [ iptables iproute pmutils numad numactl bridge-utils dmidecode dnsmasq ebtables ] ++ optionals enableIscsi [ openiscsi ];
in ''
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 "$out/bin" '${gettext}/bin' \
--replace 'lock/subsys' 'lock' \