mirror of
https://github.com/systemd/systemd.git
synced 2024-10-28 03:25:31 +03:00
Merge pull request #12336 from anitazha/disablecontroller
core: support DisableControllers= for transient units
This commit is contained in:
commit
6610200d29
@ -253,6 +253,7 @@ All cgroup/resource control settings are available for transient units
|
|||||||
✓ TasksAccounting=
|
✓ TasksAccounting=
|
||||||
✓ TasksMax=
|
✓ TasksMax=
|
||||||
✓ Delegate=
|
✓ Delegate=
|
||||||
|
✓ DisableControllers=
|
||||||
✓ IPAccounting=
|
✓ IPAccounting=
|
||||||
✓ IPAddressAllow=
|
✓ IPAddressAllow=
|
||||||
✓ IPAddressDeny=
|
✓ IPAddressDeny=
|
||||||
|
@ -202,6 +202,7 @@ void cgroup_context_done(CGroupContext *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
|
void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
|
||||||
|
_cleanup_free_ char *disable_controllers_str = NULL;
|
||||||
CGroupIODeviceLimit *il;
|
CGroupIODeviceLimit *il;
|
||||||
CGroupIODeviceWeight *iw;
|
CGroupIODeviceWeight *iw;
|
||||||
CGroupIODeviceLatency *l;
|
CGroupIODeviceLatency *l;
|
||||||
@ -217,6 +218,8 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
|
|||||||
|
|
||||||
prefix = strempty(prefix);
|
prefix = strempty(prefix);
|
||||||
|
|
||||||
|
(void) cg_mask_to_string(c->disable_controllers, &disable_controllers_str);
|
||||||
|
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"%sCPUAccounting=%s\n"
|
"%sCPUAccounting=%s\n"
|
||||||
"%sIOAccounting=%s\n"
|
"%sIOAccounting=%s\n"
|
||||||
@ -243,6 +246,7 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
|
|||||||
"%sMemoryLimit=%" PRIu64 "\n"
|
"%sMemoryLimit=%" PRIu64 "\n"
|
||||||
"%sTasksMax=%" PRIu64 "\n"
|
"%sTasksMax=%" PRIu64 "\n"
|
||||||
"%sDevicePolicy=%s\n"
|
"%sDevicePolicy=%s\n"
|
||||||
|
"%sDisableControllers=%s\n"
|
||||||
"%sDelegate=%s\n",
|
"%sDelegate=%s\n",
|
||||||
prefix, yes_no(c->cpu_accounting),
|
prefix, yes_no(c->cpu_accounting),
|
||||||
prefix, yes_no(c->io_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->memory_limit,
|
||||||
prefix, c->tasks_max,
|
prefix, c->tasks_max,
|
||||||
prefix, cgroup_device_policy_to_string(c->device_policy),
|
prefix, cgroup_device_policy_to_string(c->device_policy),
|
||||||
|
prefix, strnull(disable_controllers_str),
|
||||||
prefix, yes_no(c->delegate));
|
prefix, yes_no(c->delegate));
|
||||||
|
|
||||||
if (c->delegate) {
|
if (c->delegate) {
|
||||||
|
@ -401,10 +401,10 @@ static int bus_cgroup_set_transient_property(
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
} else if (streq(name, "DelegateControllers")) {
|
} else if (STR_IN_SET(name, "DelegateControllers", "DisableControllers")) {
|
||||||
CGroupMask mask = 0;
|
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");
|
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");
|
r = sd_bus_message_enter_container(message, 'a', "s");
|
||||||
@ -439,13 +439,25 @@ static int bus_cgroup_set_transient_property(
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
c->delegate = true;
|
if (streq(name, "DelegateControllers")) {
|
||||||
if (mask == 0)
|
|
||||||
c->delegate_controllers = 0;
|
|
||||||
else
|
|
||||||
c->delegate_controllers |= mask;
|
|
||||||
|
|
||||||
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;
|
return 1;
|
||||||
@ -1426,7 +1438,7 @@ int bus_cgroup_set_property(
|
|||||||
return 1;
|
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 bus_cgroup_set_transient_property(u, c, name, message, flags, error);
|
||||||
|
|
||||||
return 0;
|
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);
|
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")) {
|
if (streq(field, "Delegate")) {
|
||||||
|
|
||||||
r = parse_boolean(eq);
|
r = parse_boolean(eq);
|
||||||
|
Loading…
Reference in New Issue
Block a user