]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: also fall back to legacy cgroup hierarchy for old containers 4310/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 8 Oct 2016 23:03:53 +0000 (19:03 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 8 Oct 2016 23:03:53 +0000 (19:03 -0400)
Current systemd version detection routine cannot detect systemd 230,
only systmed >= 231. This means that we'll still use the legacy hierarchy
in some cases where we wouldn't have too. If somebody figures out a nice
way to detect systemd 230 this can be later improved.

src/nspawn/nspawn.c

index a775d1ac4f3c08d65e99679a32df07acb038125c..dbf94b48c30f3bc6a451be6f9c479509c09a9492 100644 (file)
@@ -342,10 +342,18 @@ static int detect_unified_cgroup_hierarchy(const char *directory) {
                                        "Failed to determine whether the unified cgroups hierarchy is used: %m");
 
         /* Otherwise inherit the default from the host system */
-        if (all_unified > 0)
-                arg_unified_cgroup_hierarchy = CGROUP_UNIFIED_ALL;
-        else if (systemd_unified > 0) {
-                /* mixed cgroup hierarchy support was added in 232 */
+        if (all_unified > 0) {
+                /* Unified cgroup hierarchy support was added in 230. Unfortunately the detection
+                 * routine only detects 231, so we'll have a false negative here for 230. */
+                r = systemd_installation_has_version(directory, 230);
+                if (r < 0)
+                        return log_error_errno(r, "Failed to determine systemd version in container: %m");
+                if (r > 0)
+                        arg_unified_cgroup_hierarchy = CGROUP_UNIFIED_ALL;
+                else
+                        arg_unified_cgroup_hierarchy = CGROUP_UNIFIED_NONE;
+        } else if (systemd_unified > 0) {
+                /* Mixed cgroup hierarchy support was added in 232 */
                 r = systemd_installation_has_version(directory, 232);
                 if (r < 0)
                         return log_error_errno(r, "Failed to determine systemd version in container: %m");