aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-07-03 12:50:11 +0200
committerLennart Poettering <lennart@poettering.net>2014-07-03 12:51:07 +0200
commitce38dbc84b40148026801dd29fd0ad1f1b25d3fb (patch)
tree244cdf17483e5f1b1edae8e1014ac0fcd76ccad6
parentmachined: don't force terminate registered machines (diff)
downloadsystemd-ce38dbc84b40148026801dd29fd0ad1f1b25d3fb.tar.gz
systemd-ce38dbc84b40148026801dd29fd0ad1f1b25d3fb.tar.bz2
systemd-ce38dbc84b40148026801dd29fd0ad1f1b25d3fb.zip
nspawn: when running in a service unit, use systemd for restarts
THis way we can remove cgroup priviliges after setup, but get them back for the next restart, as we need it.
-rw-r--r--src/nspawn/nspawn.c15
-rw-r--r--units/systemd-nspawn@.service.in2
2 files changed, 17 insertions, 0 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 656c1bf9f..0d538c254 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -3342,6 +3342,21 @@ int main(int argc, char *argv[]) {
break;
/* CONTAINER_REBOOTED, loop again */
+
+ if (arg_keep_unit) {
+ /* Special handling if we are running as a
+ * service: instead of simply restarting the
+ * machine we want to restart the entire
+ * service, so let's inform systemd about this
+ * with the special exit code 133. The service
+ * file uses RestartForceExitStatus=133 so
+ * that this results in a full nspawn
+ * restart. This is necessary since we might
+ * have cgroup parameters set we want to have
+ * flushed out. */
+ r = 133;
+ break;
+ }
}
finish:
diff --git a/units/systemd-nspawn@.service.in b/units/systemd-nspawn@.service.in
index e37362847..574d0deaf 100644
--- a/units/systemd-nspawn@.service.in
+++ b/units/systemd-nspawn@.service.in
@@ -13,6 +13,8 @@ Documentation=man:systemd-nspawn(1)
ExecStart=@bindir@/systemd-nspawn --quiet --keep-unit --boot --link-journal=guest --directory=/var/lib/container/%i
KillMode=mixed
Type=notify
+RestartForceExitStatus=133
+SuccessExitStatus=133
[Install]
WantedBy=multi-user.target