Skip to content

Commit

Permalink
core/cgroup: accepts MemorySwapMax=0 (systemd#8366)
Browse files Browse the repository at this point in the history
Also, this moves two macros from dbus-util.h to dbus-cgroup.c,
as they are only used in dbus-cgroup.c.

Fixes systemd#8363.

(cherry picked from commit 906bdbf)

[mkoutny: simplify range condition, we don't have 681ae88 ("dbus-cgroup: simplify bus_cgroup_set_property()") v237~157^2]
  • Loading branch information
yuwata authored and Werkov committed Jul 9, 2020
1 parent f480087 commit 23dcdb0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/core/dbus-cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/core/load-fragment.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 23dcdb0

Please sign in to comment.