From 330fadb7060074bd5c38e5dcefc394abaf8d6a09 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 13 Aug 2014 00:45:36 +0200 Subject: Containers: Use systemd-nspawn startup notification This prevents the container unit startup from hanging until timeout if systemd-nspawn fails. --- nixos/modules/virtualisation/containers.nix | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'nixos') diff --git a/nixos/modules/virtualisation/containers.nix b/nixos/modules/virtualisation/containers.nix index a7256148f088..6933fbaa9eec 100644 --- a/nixos/modules/virtualisation/containers.nix +++ b/nixos/modules/virtualisation/containers.nix @@ -228,12 +228,6 @@ in postStart = '' - # This blocks until the container-startup-done service - # writes something to this pipe. FIXME: it also hangs - # until the start timeout expires if systemd-nspawn exits. - read x < $root/var/lib/startup-done - rm -f $root/var/lib/startup-done - if [ "$PRIVATE_NETWORK" = 1 ]; then ifaceHost=ve-$INSTANCE ip link set dev $ifaceHost up @@ -244,6 +238,12 @@ in ip route add $LOCAL_ADDRESS dev $ifaceHost fi fi + + # This blocks until the container-startup-done service + # writes something to this pipe. FIXME: it also hangs + # until the start timeout expires if systemd-nspawn exits. + read x < $root/var/lib/startup-done + rm -f $root/var/lib/startup-done ''; preStop = @@ -267,6 +267,8 @@ in EnvironmentFile = "-/etc/containers/%i.conf"; + Type = "notify"; + # Note that on reboot, systemd-nspawn returns 10, so this # unit will be restarted. On poweroff, it returns 0, so the # unit won't be restarted. -- cgit 1.4.1