chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sd-daemon: fix sd_is_mq for non-mq fds
[elogind.git]
/
src
/
core
/
cgroup.c
diff --git
a/src/core/cgroup.c
b/src/core/cgroup.c
index 1733521cd9aa01600aef820129a765e9f4d8fe1a..54da47182f29ad4f8736b5019b35d668e11a1065 100644
(file)
--- a/
src/core/cgroup.c
+++ b/
src/core/cgroup.c
@@
-762,7
+762,7
@@
int unit_watch_cgroup(Unit *u) {
if (r < 0)
return log_oom();
if (r < 0)
return log_oom();
- r = cg_get_path(
ELOGIN
D_CGROUP_CONTROLLER, u->cgroup_path, "cgroup.populated", &populated);
+ r = cg_get_path(
SYSTEM
D_CGROUP_CONTROLLER, u->cgroup_path, "cgroup.populated", &populated);
if (r < 0)
return log_oom();
if (r < 0)
return log_oom();
@@
-1053,7
+1053,7
@@
int unit_search_main_pid(Unit *u, pid_t *ret) {
if (!u->cgroup_path)
return -ENXIO;
if (!u->cgroup_path)
return -ENXIO;
- r = cg_enumerate_processes(
ELOGIN
D_CGROUP_CONTROLLER, u->cgroup_path, &f);
+ r = cg_enumerate_processes(
SYSTEM
D_CGROUP_CONTROLLER, u->cgroup_path, &f);
if (r < 0)
return r;
if (r < 0)
return r;
@@
-1090,7
+1090,7
@@
static int unit_watch_pids_in_path(Unit *u, const char *path) {
assert(u);
assert(path);
assert(u);
assert(path);
- r = cg_enumerate_processes(
ELOGIN
D_CGROUP_CONTROLLER, path, &f);
+ r = cg_enumerate_processes(
SYSTEM
D_CGROUP_CONTROLLER, path, &f);
if (r < 0)
ret = r;
else {
if (r < 0)
ret = r;
else {
@@
-1106,7
+1106,7
@@
static int unit_watch_pids_in_path(Unit *u, const char *path) {
ret = r;
}
ret = r;
}
- r = cg_enumerate_subgroups(
ELOGIN
D_CGROUP_CONTROLLER, path, &d);
+ r = cg_enumerate_subgroups(
SYSTEM
D_CGROUP_CONTROLLER, path, &d);
if (r < 0) {
if (ret >= 0)
ret = r;
if (r < 0) {
if (ret >= 0)
ret = r;
@@
-1159,7
+1159,7
@@
int unit_notify_cgroup_empty(Unit *u) {
if (!u->cgroup_path)
return 0;
if (!u->cgroup_path)
return 0;
- r = cg_is_empty_recursive(
ELOGIN
D_CGROUP_CONTROLLER, u->cgroup_path);
+ r = cg_is_empty_recursive(
SYSTEM
D_CGROUP_CONTROLLER, u->cgroup_path);
if (r <= 0)
return r;
if (r <= 0)
return r;
@@
-1226,9
+1226,10
@@
int manager_setup_cgroup(Manager *m) {
/* 1. Determine hierarchy */
m->cgroup_root = mfree(m->cgroup_root);
/* 1. Determine hierarchy */
m->cgroup_root = mfree(m->cgroup_root);
- r = cg_pid_get_path(
ELOGIN
D_CGROUP_CONTROLLER, 0, &m->cgroup_root);
+ r = cg_pid_get_path(
SYSTEM
D_CGROUP_CONTROLLER, 0, &m->cgroup_root);
if (r < 0)
return log_error_errno(r, "Cannot determine cgroup we are running in: %m");
if (r < 0)
return log_error_errno(r, "Cannot determine cgroup we are running in: %m");
+
/// elogind does not support systemd scopes and slices
#if 0
/* Chop off the init scope, if we are already located in it */
/// elogind does not support systemd scopes and slices
#if 0
/* Chop off the init scope, if we are already located in it */
@@
-1253,10
+1254,10
@@
int manager_setup_cgroup(Manager *m) {
while ((e = endswith(m->cgroup_root, "/")))
*e = 0;
log_debug_elogind("Cgroup Controller \"%s\" -> root \"%s\"",
while ((e = endswith(m->cgroup_root, "/")))
*e = 0;
log_debug_elogind("Cgroup Controller \"%s\" -> root \"%s\"",
-
ELOGIN
D_CGROUP_CONTROLLER, m->cgroup_root);
+
SYSTEM
D_CGROUP_CONTROLLER, m->cgroup_root);
/* 2. Show data */
/* 2. Show data */
- r = cg_get_path(
ELOGIN
D_CGROUP_CONTROLLER, m->cgroup_root, NULL, &path);
+ r = cg_get_path(
SYSTEM
D_CGROUP_CONTROLLER, m->cgroup_root, NULL, &path);
if (r < 0)
return log_error_errno(r, "Cannot find cgroup mount point: %m");
if (r < 0)
return log_error_errno(r, "Cannot find cgroup mount point: %m");
@@
-1266,7
+1267,7
@@
int manager_setup_cgroup(Manager *m) {
if (unified > 0)
log_debug("Unified cgroup hierarchy is located at %s.", path);
else
if (unified > 0)
log_debug("Unified cgroup hierarchy is located at %s.", path);
else
- log_debug("Using cgroup controller "
ELOGIN
D_CGROUP_CONTROLLER ". File system hierarchy is at %s.", path);
+ log_debug("Using cgroup controller "
SYSTEM
D_CGROUP_CONTROLLER ". File system hierarchy is at %s.", path);
if (!m->test_run) {
const char *scope_path;
if (!m->test_run) {
const char *scope_path;
@@
-1297,7
+1298,7
@@
int manager_setup_cgroup(Manager *m) {
#else
return log_error_errno(EOPNOTSUPP, "Unified cgroup hierarchy not supported: %m");
#else
return log_error_errno(EOPNOTSUPP, "Unified cgroup hierarchy not supported: %m");
-#endif //
elogind
+#endif //
0
} else if (m->running_as == MANAGER_SYSTEM) {
/* On the legacy hierarchy we only get
* notifications via cgroup agents. (Which
} else if (m->running_as == MANAGER_SYSTEM) {
/* On the legacy hierarchy we only get
* notifications via cgroup agents. (Which
@@
-1305,7
+1306,7
@@
int manager_setup_cgroup(Manager *m) {
* generate events when control groups with
* children run empty. */
* generate events when control groups with
* children run empty. */
- r = cg_install_release_agent(
ELOGIN
D_CGROUP_CONTROLLER, ELOGIND_CGROUP_AGENT_PATH);
+ r = cg_install_release_agent(
SYSTEM
D_CGROUP_CONTROLLER, ELOGIND_CGROUP_AGENT_PATH);
if (r < 0)
log_warning_errno(r, "Failed to install release agent, ignoring: %m");
else if (r > 0)
if (r < 0)
log_warning_errno(r, "Failed to install release agent, ignoring: %m");
else if (r > 0)
@@
-1318,15
+1319,18
@@
int manager_setup_cgroup(Manager *m) {
#if 0
/* 4. Make sure we are in the special "init.scope" unit in the root slice. */
scope_path = strjoina(m->cgroup_root, "/" SPECIAL_INIT_SCOPE);
#if 0
/* 4. 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(
ELOGIN
D_CGROUP_CONTROLLER, scope_path, 0);
+ r = cg_create_and_attach(
SYSTEM
D_CGROUP_CONTROLLER, scope_path, 0);
#else
#else
- if (streq(m->cgroup_root, "/elogind"))
+ if (streq(SYSTEMD_CGROUP_CONTROLLER, "name=elogind"))
+ // we are our own cgroup controller
+ scope_path = strjoina("");
+ else if (streq(m->cgroup_root, "/elogind"))
// root already is our cgroup
scope_path = strjoina(m->cgroup_root);
else
// we have to create our own group
scope_path = strjoina(m->cgroup_root, "/elogind");
// root already is our cgroup
scope_path = strjoina(m->cgroup_root);
else
// we have to create our own group
scope_path = strjoina(m->cgroup_root, "/elogind");
- r = cg_create_and_attach(
ELOGIN
D_CGROUP_CONTROLLER, scope_path, 0);
+ r = cg_create_and_attach(
SYSTEM
D_CGROUP_CONTROLLER, scope_path, 0);
#endif // 0
if (r < 0)
return log_error_errno(r, "Failed to create %s control group: %m", scope_path);
#endif // 0
if (r < 0)
return log_error_errno(r, "Failed to create %s control group: %m", scope_path);
@@
-1335,7
+1339,7
@@
int manager_setup_cgroup(Manager *m) {
/* also, move all other userspace processes remaining
* in the root cgroup into that scope. */
if (!streq(m->cgroup_root, scope_path)) {
/* also, move all other userspace processes remaining
* in the root cgroup into that scope. */
if (!streq(m->cgroup_root, scope_path)) {
- r = cg_migrate(
ELOGIND_CGROUP_CONTROLLER, m->cgroup_root, ELOGIN
D_CGROUP_CONTROLLER, scope_path, false);
+ r = cg_migrate(
SYSTEMD_CGROUP_CONTROLLER, m->cgroup_root, SYSTEM
D_CGROUP_CONTROLLER, scope_path, false);
if (r < 0)
log_warning_errno(r, "Couldn't move remaining userspace processes, ignoring: %m");
}
if (r < 0)
log_warning_errno(r, "Couldn't move remaining userspace processes, ignoring: %m");
}
@@
-1368,7
+1372,7
@@
void manager_shutdown_cgroup(Manager *m, bool delete) {
/* We can't really delete the group, since we are in it. But
* let's trim it. */
if (delete && m->cgroup_root)
/* We can't really delete the group, since we are in it. But
* let's trim it. */
if (delete && m->cgroup_root)
- (void) cg_trim(
ELOGIN
D_CGROUP_CONTROLLER, m->cgroup_root, false);
+ (void) cg_trim(
SYSTEM
D_CGROUP_CONTROLLER, m->cgroup_root, false);
/// elogind does not support the unified hierarchy, yet.
#if 0
/// elogind does not support the unified hierarchy, yet.
#if 0
@@
-1421,7
+1425,7
@@
Unit *manager_get_unit_by_pid_cgroup(Manager *m, pid_t pid) {
if (pid <= 0)
return NULL;
if (pid <= 0)
return NULL;
- r = cg_pid_get_path(
ELOGIN
D_CGROUP_CONTROLLER, pid, &cgroup);
+ r = cg_pid_get_path(
SYSTEM
D_CGROUP_CONTROLLER, pid, &cgroup);
if (r < 0)
return NULL;
if (r < 0)
return NULL;