diff options
author | Luke Shumaker <lukeshu@parabola.nu> | 2017-08-07 20:24:01 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@parabola.nu> | 2018-08-16 21:55:17 -0400 |
commit | 117fe403f15a05282679e370b34cdce25c386cc4 (patch) | |
tree | 0606b7f454a69df3782ccacbf63f14c60e0dbdf1 | |
parent | 9a459f8f026943dd780f46a7cd896c4bebd60c8f (diff) |
nspawn: Hoist the decision to sync cgroups from the callee sync_cgroup() to the caller cgroup_setup()
-rw-r--r-- | src/nspawn/nspawn-cgroup.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/nspawn/nspawn-cgroup.c b/src/nspawn/nspawn-cgroup.c index 1c20a3f630..7ef6b4b8f4 100644 --- a/src/nspawn/nspawn-cgroup.c +++ b/src/nspawn/nspawn-cgroup.c @@ -146,9 +146,6 @@ static int sync_cgroup(pid_t pid, CGroupUnified outer_cgver, CGroupUnified inner const char *fn; int r; - if ((outer_cgver >= CGROUP_UNIFIED_SYSTEMD232) == (inner_cgver >= CGROUP_UNIFIED_SYSTEMD232)) - return 0; - /* When the host uses the legacy cgroup setup, but the * container shall use the unified hierarchy, let's make sure * we copy the path from the name=systemd hierarchy into the @@ -201,7 +198,7 @@ finish: return r; } -static int create_subcgroup(pid_t pid, bool keep_unit, CGroupUnified outer_cgver, CGroupUnified inner_cgver) { +static int create_subcgroup(pid_t pid, bool keep_unit) { _cleanup_free_ char *cgroup = NULL; CGroupMask supported; const char *payload; @@ -258,11 +255,14 @@ int cgroup_setup(pid_t pid, CGroupUnified outer_cgver, CGroupUnified inner_cgver int r; - r = sync_cgroup(pid, outer_cgver, inner_cgver, uid_shift); - if (r < 0) - return r; + if ((outer_cgver >= CGROUP_UNIFIED_SYSTEMD232) != (inner_cgver >= CGROUP_UNIFIED_SYSTEMD232)) { + /* sync the name=systemd hierarchy with the unified hierarchy */ + r = sync_cgroup(pid, outer_cgver, inner_cgver, uid_shift); + if (r < 0) + return r; + } - r = create_subcgroup(pid, keep_unit, outer_cgver, inner_cgver); + r = create_subcgroup(pid, keep_unit); if (r < 0) return r; |