summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/cgroup.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index dd173e2a3..313801544 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -2285,6 +2285,11 @@ int manager_setup_cgroup(Manager *m) {
/* 5. Make sure we are in the special "init.scope" unit in the root slice. */
scope_path = strjoina(m->cgroup_root, "/" SPECIAL_INIT_SCOPE);
r = cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, scope_path, 0);
+ if (r >= 0) {
+ /* Also, move all other userspace processes remaining in the root cgroup into that scope. */
+ r = cg_migrate(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_root, SYSTEMD_CGROUP_CONTROLLER, scope_path, 0);
+ if (r < 0)
+ log_warning_errno(r, "Couldn't move remaining userspace processes, ignoring: %m");
#else
/* Note:
* This method is in core, and normally called by systemd
@@ -2303,22 +2308,18 @@ int manager_setup_cgroup(Manager *m) {
scope_path = strjoina(m->cgroup_root, "/elogind");
r = cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, scope_path, 0);
#endif // 0
- if (r < 0)
- return log_error_errno(r, "Failed to create %s control group: %m", scope_path);
log_debug_elogind("Created control group \"%s\"", scope_path);
#if 0 /// elogind is not a "sub-controller" like systemd, so migration is not needed.
- /* Also, move all other userspace processes remaining in the root cgroup into that scope. */
- r = cg_migrate(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_root, SYSTEMD_CGROUP_CONTROLLER, scope_path, 0);
- if (r < 0)
- log_warning_errno(r, "Couldn't move remaining userspace processes, ignoring: %m");
#endif // 0
+ /* 6. And pin it, so that it cannot be unmounted */
+ safe_close(m->pin_cgroupfs_fd);
+ m->pin_cgroupfs_fd = open(path, O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY|O_NONBLOCK);
+ if (m->pin_cgroupfs_fd < 0)
+ return log_error_errno(errno, "Failed to open pin file: %m");
- /* 6. And pin it, so that it cannot be unmounted */
- safe_close(m->pin_cgroupfs_fd);
- m->pin_cgroupfs_fd = open(path, O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY|O_NONBLOCK);
- if (m->pin_cgroupfs_fd < 0)
- return log_error_errno(errno, "Failed to open pin file: %m");
+ } else if (r < 0 && !m->test_run_flags)
+ return log_error_errno(r, "Failed to create %s control group: %m", scope_path);
/* 7. Always enable hierarchical support if it exists... */
if (!all_unified && m->test_run_flags == 0)