mirror of
https://github.com/systemd/systemd
synced 2024-07-21 18:24:38 +00:00
nspawn: port over to /supervisor/ subcgroup being delegated to nspawn
Let's make use of the new DelegateSubgroup= feature and delegate the /supervisor/ subcgroup already to nspawn, so that moving the supervisor process there is unnecessary.
This commit is contained in:
parent
f8371dbd56
commit
1a3704dcc3
|
@ -141,9 +141,9 @@ finish:
|
||||||
}
|
}
|
||||||
|
|
||||||
int create_subcgroup(pid_t pid, bool keep_unit, CGroupUnified unified_requested) {
|
int create_subcgroup(pid_t pid, bool keep_unit, CGroupUnified unified_requested) {
|
||||||
_cleanup_free_ char *cgroup = NULL;
|
_cleanup_free_ char *cgroup = NULL, *payload = NULL;
|
||||||
CGroupMask supported;
|
CGroupMask supported;
|
||||||
const char *payload;
|
char *e;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(pid > 1);
|
assert(pid > 1);
|
||||||
|
@ -174,15 +174,26 @@ int create_subcgroup(pid_t pid, bool keep_unit, CGroupUnified unified_requested)
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to get our control group: %m");
|
return log_error_errno(r, "Failed to get our control group: %m");
|
||||||
|
|
||||||
payload = strjoina(cgroup, "/payload");
|
/* If the service manager already placed us in the supervisor cgroup, let's handle that. */
|
||||||
|
e = endswith(cgroup, "/supervisor");
|
||||||
|
if (e)
|
||||||
|
*e = 0; /* chop off, we want the main path delegated to us */
|
||||||
|
|
||||||
|
payload = path_join(cgroup, "payload");
|
||||||
|
if (!payload)
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
r = cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, payload, pid);
|
r = cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, payload, pid);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to create %s subcgroup: %m", payload);
|
return log_error_errno(r, "Failed to create %s subcgroup: %m", payload);
|
||||||
|
|
||||||
if (keep_unit) {
|
if (keep_unit) {
|
||||||
const char *supervisor;
|
_cleanup_free_ char *supervisor = NULL;
|
||||||
|
|
||||||
|
supervisor = path_join(cgroup, "supervisor");
|
||||||
|
if (!supervisor)
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
supervisor = strjoina(cgroup, "/supervisor");
|
|
||||||
r = cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, supervisor, 0);
|
r = cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, supervisor, 0);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to create %s subcgroup: %m", supervisor);
|
return log_error_errno(r, "Failed to create %s subcgroup: %m", supervisor);
|
||||||
|
|
|
@ -25,6 +25,7 @@ RestartForceExitStatus=133
|
||||||
SuccessExitStatus=133
|
SuccessExitStatus=133
|
||||||
Slice=machine.slice
|
Slice=machine.slice
|
||||||
Delegate=yes
|
Delegate=yes
|
||||||
|
DelegateSubgroup=supervisor
|
||||||
TasksMax=16384
|
TasksMax=16384
|
||||||
{{SERVICE_WATCHDOG}}
|
{{SERVICE_WATCHDOG}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue