diff options
author | Michal Koutný <mkoutny@suse.com> | 2020-02-04 16:58:36 +0100 |
---|---|---|
committer | Michal Koutný <mkoutny@suse.com> | 2020-06-02 18:59:47 +0200 |
commit | 53aa85af24cda4470b6750f88e181b775385e228 (patch) | |
tree | bfa5106a4b2453a4843486187ded51ea0cd09717 /src/core/load-fragment.c | |
parent | db2b8d2e2895010f3443a589c9c1f1dfb25256a6 (diff) | |
download | systemd-53aa85af24cda4470b6750f88e181b775385e228.tar.gz |
cgroup: Allow empty assignments of Memory{Low,Min}=
Currently, an empty assignment of Memory{Low,Min}= directives would be
interpretted as setting it to global default, i.e. zero. However, if we
set a runtime protection value on a unit that inherits parent's
DefaultMemory{Low,Min}=, it is not possible to revert it back to the
state where the DefaultMemory{Low,Min}= is propagated from parent
slice(s).
This patch changes the semantics of the empty assignments to explicitly
nullify any value set by the user previously. Since DBus API uses
uint64_t where 0 is a valid configuration, the patch modifies DBus API
by exploiting the variant type of property value to pass the NULL value.
Diffstat (limited to 'src/core/load-fragment.c')
-rw-r--r-- | src/core/load-fragment.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 781fe66f5e..266bd68cb6 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -3396,6 +3396,8 @@ int config_parse_memory_limit( } } + /* Keep Memory{Low,Min} unset with empty assignment so that we fall back to DefaultMemory* which in + * contrast means zeroing the property. */ if (streq(lvalue, "DefaultMemoryLow")) { c->default_memory_low = bytes; c->default_memory_low_set = true; @@ -3404,10 +3406,10 @@ int config_parse_memory_limit( c->default_memory_min_set = true; } else if (streq(lvalue, "MemoryMin")) { c->memory_min = bytes; - c->memory_min_set = true; + c->memory_min_set = !isempty(rvalue); } else if (streq(lvalue, "MemoryLow")) { c->memory_low = bytes; - c->memory_low_set = true; + c->memory_low_set = !isempty(rvalue); } else if (streq(lvalue, "MemoryHigh")) c->memory_high = bytes; else if (streq(lvalue, "MemoryMax")) |