From 23dcdb0fd1be55f1f19861c124ef931f6b571797 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 9 Mar 2018 19:34:50 +0900 Subject: [PATCH] core/cgroup: accepts MemorySwapMax=0 (#8366) Also, this moves two macros from dbus-util.h to dbus-cgroup.c, as they are only used in dbus-cgroup.c. Fixes #8363. (cherry picked from commit 906bdbf5e79870f6997fc0925348f9412f3c5f3e) [mkoutny: simplify range condition, we don't have 681ae88e06 ("dbus-cgroup: simplify bus_cgroup_set_property()") v237~157^2] --- src/core/dbus-cgroup.c | 4 ++-- src/core/load-fragment.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c index 6d05c337a1591..a90887c8a00a1 100644 --- a/src/core/dbus-cgroup.c +++ b/src/core/dbus-cgroup.c @@ -939,7 +939,7 @@ int bus_cgroup_set_property( r = sd_bus_message_read(message, "t", &v); if (r < 0) return r; - if (v <= 0) + if (v <= 0 && !streq(name, "MemorySwapMax")) return sd_bus_error_set_errnof(error, EINVAL, "%s= is too small", name); if (mode != UNIT_CHECK) { @@ -971,7 +971,7 @@ int bus_cgroup_set_property( return r; v = physical_memory_scale(raw, UINT32_MAX); - if (v <= 0 || v == UINT64_MAX) + if ((v <= 0 && !streq(name, "MemorySwapMaxScale")) || v == UINT64_MAX) return sd_bus_error_set_errnof(error, EINVAL, "%s= is out of range", name); if (mode != UNIT_CHECK) { diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index b115027222f8a..1844c5c3d790e 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -3055,7 +3055,8 @@ int config_parse_memory_limit( } else bytes = physical_memory_scale(r, 100U); - if (bytes <= 0 || bytes >= UINT64_MAX) { + if (bytes >= UINT64_MAX || + (bytes <= 0 && !streq(lvalue, "MemorySwapMax"))) { log_syntax(unit, LOG_ERR, filename, line, 0, "Memory limit '%s' out of range. Ignoring.", rvalue); return 0; }