From c039e286b9116bcc4c5f4ac9e3fd64a8f667bcc6 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 27 Mar 2013 17:20:41 +0100 Subject: [PATCH] Set the kernel.poweroff_cmd sysctl This allows Xen (and EC2) to power off an instance properly. We had this before (see aeb89fc753c6f95c9d143e6f5346f92e4a02fa67), but it got lost in the systemd migration. --- modules/system/boot/shutdown.nix | 2 ++ tests/misc.nix | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/modules/system/boot/shutdown.nix b/modules/system/boot/shutdown.nix index 23ddf6d0202..ad71a2e816e 100644 --- a/modules/system/boot/shutdown.nix +++ b/modules/system/boot/shutdown.nix @@ -22,4 +22,6 @@ with pkgs.lib; ''; }; + boot.kernel.sysctl."kernel.poweroff_cmd" = "${config.systemd.package}/sbin/poweroff"; + } diff --git a/tests/misc.nix b/tests/misc.nix index 9f85877e8bb..118ed8f45cb 100644 --- a/tests/misc.nix +++ b/tests/misc.nix @@ -33,6 +33,11 @@ $machine->waitForUnit("root-swapfile.swap"); $machine->succeed("ls -l /root/swapfile | grep 134217728"); }; + + # Test whether kernel.poweroff_cmd is set. + subtest "poweroff_cmd", sub { + $machine->succeed("[ -x \"\$(cat /proc/sys/kernel/poweroff_cmd)\" ]") + }; ''; }