nspawn: rename UNIFIED_CGROUP_HIERARCHY to SYSTEMD_NSPAWN_UNIFIED_HIERARCHY

We should never have used an unprefixed environment variable name.
All other systemd-nspawn variables have the "SYSTEMD_NSPAWN_" prefix,
and all other systemd variables have the "SYSTEMD_" prefix.

The new variable name takes precedence, but we fall back to checking the
old one. If only the old one is found, a warning is emitted.

In addition, SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="" is accepted as an override
to avoid looking for the old variable name.

We have a variable with the same name ($UNIFIED_CGROUP_HIERARCHY) in tests,
which governs both systemd-nspawn and qemu behaviour. It is not renamed.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2019-10-01 10:21:13 -07:00
committed by Filipe Brandenburger
parent 490486842b
commit c78c095b1e
4 changed files with 34 additions and 22 deletions
+16 -4
View File
@@ -412,15 +412,27 @@ static int custom_mount_check_all(void) {
}
static int detect_unified_cgroup_hierarchy_from_environment(void) {
const char *e;
const char *e, *var = "SYSTEMD_NSPAWN_UNIFIED_HIERARCHY";
int r;
/* Allow the user to control whether the unified hierarchy is used */
e = getenv("UNIFIED_CGROUP_HIERARCHY");
if (e) {
e = getenv(var);
if (!e) {
static bool warned = false;
var = "UNIFIED_CGROUP_HIERARCHY";
e = getenv(var);
if (e && !warned) {
log_info("$UNIFIED_CGROUP_HIERARCHY has been renamed to $SYSTEMD_NSPAWN_UNIFIED_HIERARCHY.");
warned = true;
}
}
if (!isempty(e)) {
r = parse_boolean(e);
if (r < 0)
return log_error_errno(r, "Failed to parse $UNIFIED_CGROUP_HIERARCHY.");
return log_error_errno(r, "Failed to parse $%s: %m", var);
if (r > 0)
arg_unified_cgroup_hierarchy = CGROUP_UNIFIED_ALL;
else