summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-06-13 22:27:40 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-06-16 17:06:56 -0400
commit9edf1c8ee349c85b1f95a9c3d4369ffda1410259 (patch)
tree901dbed13cb915b7f9273c048e8fc2156bc56637
parentcf68314dd14e23459d04cf7a185fb4697866791a (diff)
nspawn: Parse UNIFIED_CGROUP_HIERARCHY similarly to any other arg
-rw-r--r--src/nspawn/nspawn.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 570b170b16..c0b4c3142d 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -320,25 +320,10 @@ static int custom_mounts_prepare(void) {
return 0;
}
-static int detect_unified_cgroup_hierarchy(const char *directory) {
- const char *e;
+static int pick_cgroup_version(const char *directory) {
int r;
CGroupUnified outer;
- /* Allow the user to control whether the unified hierarchy is used */
- e = getenv("UNIFIED_CGROUP_HIERARCHY");
- if (e) {
- r = parse_boolean(e);
- if (r < 0)
- return log_error_errno(r, "Failed to parse $UNIFIED_CGROUP_HIERARCHY.");
- if (r > 0)
- arg_unified_cgroup_hierarchy = CGROUP_UNIFIED_ALL;
- else
- arg_unified_cgroup_hierarchy = CGROUP_UNIFIED_NONE;
-
- return 0;
- }
-
r = cg_version(&outer);
if (r < 0)
return log_error_errno(r, "Failed to determine whether the unified cgroups hierarchy is used: %m");
@@ -1172,6 +1157,17 @@ static int parse_argv(int argc, char *argv[]) {
else
arg_use_cgns = r && cg_ns_supported();
+ e = getenv("UNIFIED_CGROUP_HIERARCHY");
+ if (e) {
+ r = parse_boolean(e);
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse $UNIFIED_CGROUP_HIERARCHY.");
+ if (r > 0)
+ arg_unified_cgroup_hierarchy = CGROUP_UNIFIED_ALL;
+ else
+ arg_unified_cgroup_hierarchy = CGROUP_UNIFIED_NONE;
+ }
+
return 1;
}
@@ -4209,9 +4205,11 @@ int main(int argc, char *argv[]) {
if (r < 0)
goto finish;
- r = detect_unified_cgroup_hierarchy(arg_directory);
- if (r < 0)
- goto finish;
+ if (arg_unified_cgroup_hierarchy == CGROUP_UNIFIED_UNKNOWN) {
+ r = pick_cgroup_version(arg_directory);
+ if (r < 0)
+ goto finish;
+ }
interactive =
isatty(STDIN_FILENO) > 0 &&