mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-22 22:03:43 +03:00
core: support DisableControllers= for transient units
This commit is contained in:
parent
ac9b17271f
commit
25cc30c4c8
@ -253,6 +253,7 @@ All cgroup/resource control settings are available for transient units
|
||||
✓ TasksAccounting=
|
||||
✓ TasksMax=
|
||||
✓ Delegate=
|
||||
✓ DisableControllers=
|
||||
✓ IPAccounting=
|
||||
✓ IPAddressAllow=
|
||||
✓ IPAddressDeny=
|
||||
|
@ -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) {
|
||||
|
@ -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")) {
|
||||
|
||||
unit_write_settingf(u, flags, name, "Delegate=%s", strempty(t));
|
||||
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));
|
||||
|
||||
} 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;
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user