summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Down <chris@chrisdown.name>2019-04-23 10:42:37 +0200
committerGitHub <noreply@github.com>2019-04-23 10:42:37 +0200
commit6610200d296ad6d5c2c832501fb6d5cff34dfd28 (patch)
tree621b5279fefb031e7b6b6e248bc3f8e01ab049f6 /src
parent528fcf8d1d06f18aed6fd8c90a1ab0530b4f4ba3 (diff)
parent25cc30c4c8747e11410b9780df22e967f665b2c1 (diff)
downloadsystemd-6610200d296ad6d5c2c832501fb6d5cff34dfd28.tar.gz
Merge pull request #12336 from anitazha/disablecontroller
core: support DisableControllers= for transient units
Diffstat (limited to 'src')
-rw-r--r--src/core/cgroup.c5
-rw-r--r--src/core/dbus-cgroup.c30
-rw-r--r--src/shared/bus-unit-util.c4
3 files changed, 30 insertions, 9 deletions
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index ceb7ee2189..a288c07bc9 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -202,6 +202,7 @@ void cgroup_context_done(CGroupContext *c) {
}
void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
+ _cleanup_free_ char *disable_controllers_str = NULL;
CGroupIODeviceLimit *il;
CGroupIODeviceWeight *iw;
CGroupIODeviceLatency *l;
@@ -217,6 +218,8 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
prefix = strempty(prefix);
+ (void) cg_mask_to_string(c->disable_controllers, &disable_controllers_str);
+
fprintf(f,
"%sCPUAccounting=%s\n"
"%sIOAccounting=%s\n"
@@ -243,6 +246,7 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
"%sMemoryLimit=%" PRIu64 "\n"
"%sTasksMax=%" PRIu64 "\n"
"%sDevicePolicy=%s\n"
+ "%sDisableControllers=%s\n"
"%sDelegate=%s\n",
prefix, yes_no(c->cpu_accounting),
prefix, yes_no(c->io_accounting),
@@ -269,6 +273,7 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
prefix, c->memory_limit,
prefix, c->tasks_max,
prefix, cgroup_device_policy_to_string(c->device_policy),
+ prefix, strnull(disable_controllers_str),
prefix, yes_no(c->delegate));
if (c->delegate) {
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
index 5327bfb17d..74a583d81b 100644
--- a/src/core/dbus-cgroup.c
+++ b/src/core/dbus-cgroup.c
@@ -401,10 +401,10 @@ static int bus_cgroup_set_transient_property(
return 1;
- } else if (streq(name, "DelegateControllers")) {
+ } else if (STR_IN_SET(name, "DelegateControllers", "DisableControllers")) {
CGroupMask mask = 0;
- if (!UNIT_VTABLE(u)->can_delegate)
+ if (streq(name, "DelegateControllers") && !UNIT_VTABLE(u)->can_delegate)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Delegation not available for unit type");
r = sd_bus_message_enter_container(message, 'a', "s");
@@ -439,13 +439,25 @@ static int bus_cgroup_set_transient_property(
if (r < 0)
return r;
- c->delegate = true;
- if (mask == 0)
- c->delegate_controllers = 0;
- else
- c->delegate_controllers |= mask;
+ if (streq(name, "DelegateControllers")) {
+
+ c->delegate = true;
+ if (mask == 0)
+ c->delegate_controllers = 0;
+ else
+ c->delegate_controllers |= mask;
+
+ unit_write_settingf(u, flags, name, "Delegate=%s", strempty(t));
- unit_write_settingf(u, flags, name, "Delegate=%s", strempty(t));
+ } else if (streq(name, "DisableControllers")) {
+
+ if (mask == 0)
+ c->disable_controllers = 0;
+ else
+ c->disable_controllers |= mask;
+
+ unit_write_settingf(u, flags, name, "%s=%s", name, strempty(t));
+ }
}
return 1;
@@ -1426,7 +1438,7 @@ int bus_cgroup_set_property(
return 1;
}
- if (u->transient && u->load_state == UNIT_STUB)
+ if (streq(name, "DisableControllers") || (u->transient && u->load_state == UNIT_STUB))
return bus_cgroup_set_transient_property(u, c, name, message, flags, error);
return 0;
diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c
index cae526ba40..c6cbc9828c 100644
--- a/src/shared/bus-unit-util.c
+++ b/src/shared/bus-unit-util.c
@@ -396,6 +396,10 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
return bus_append_cg_blkio_weight_parse(m, field, eq);
+ if (streq(field, "DisableControllers"))
+
+ return bus_append_strv(m, "DisableControllers", eq, EXTRACT_QUOTES);
+
if (streq(field, "Delegate")) {
r = parse_boolean(eq);