[systemd-commits] 4 commits - TODO src/core src/shared units/user at .service.m4.in
Lennart Poettering
lennart at kemper.freedesktop.org
Wed Dec 10 13:14:43 PST 2014
TODO | 6 ----
src/core/cgroup.c | 58 ++++++++++++++++++++++++++++++++++------------
src/core/cgroup.h | 1
src/core/execute.c | 2 -
src/core/scope.c | 6 ----
src/shared/cgroup-util.c | 18 +++++++++++---
src/shared/cgroup-util.h | 4 +--
units/user at .service.m4.in | 8 +++---
8 files changed, 66 insertions(+), 37 deletions(-)
New commits:
commit 1f3ba2bb4f65b56ee77b098d8ab34766db55cf0a
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Dec 10 22:10:46 2014 +0100
build-sys: turn off SMACK capabilities stuff for now, since it is incompatible with nspawn
diff --git a/units/user at .service.m4.in b/units/user at .service.m4.in
index 340c02b..0daa43a 100644
--- a/units/user at .service.m4.in
+++ b/units/user at .service.m4.in
@@ -17,7 +17,7 @@ ExecStart=- at rootlibexecdir@/systemd --user
Slice=user-%i.slice
KillMode=mixed
Delegate=yes
-m4_ifdef(`HAVE_SMACK',
-Capabilities=cap_mac_admin=i
-SecureBits=keep-caps
-)
+#m4_ifdef(`HAVE_SMACK',
+#Capabilities=cap_mac_admin=i
+#SecureBits=keep-caps
+#)
commit fbcedaaea4705a0548d50d9702ece04f73847344
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Dec 10 22:08:49 2014 +0100
update TODO
diff --git a/TODO b/TODO
index 124f7d9..af7bdef 100644
--- a/TODO
+++ b/TODO
@@ -1,9 +1,3 @@
-Preparations for 218:
-
-* cgroup delegation issues
-
-* test-bus-kernel-bloom is borked
-
Bugfixes:
* Should systemctl status \* work on all unit types, not just .service?
commit 7b3fd6313c4b07b6f822a9f979d0c22350a401d9
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Dec 10 22:06:44 2014 +0100
scope: make attachment of initial PIDs a bit more robust
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 83678e6..35b862d 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -605,7 +605,6 @@ static const char *migrate_callback(CGroupControllerMask mask, void *userdata) {
}
static int unit_create_cgroups(Unit *u, CGroupControllerMask mask) {
- _cleanup_free_ char *path = NULL;
CGroupContext *c;
int r;
@@ -615,18 +614,22 @@ static int unit_create_cgroups(Unit *u, CGroupControllerMask mask) {
if (!c)
return 0;
- path = unit_default_cgroup_path(u);
- if (!path)
- return log_oom();
+ if (!u->cgroup_path) {
+ _cleanup_free_ char *path = NULL;
- r = hashmap_put(u->manager->cgroup_unit, path, u);
- if (r < 0) {
- log_error(r == -EEXIST ? "cgroup %s exists already: %s" : "hashmap_put failed for %s: %s", path, strerror(-r));
- return r;
- }
- if (r > 0) {
- u->cgroup_path = path;
- path = NULL;
+ path = unit_default_cgroup_path(u);
+ if (!path)
+ return log_oom();
+
+ r = hashmap_put(u->manager->cgroup_unit, path, u);
+ if (r < 0) {
+ log_error(r == -EEXIST ? "cgroup %s exists already: %s" : "hashmap_put failed for %s: %s", path, strerror(-r));
+ return r;
+ }
+ if (r > 0) {
+ u->cgroup_path = path;
+ path = NULL;
+ }
}
/* First, create our own group */
@@ -651,6 +654,21 @@ static int unit_create_cgroups(Unit *u, CGroupControllerMask mask) {
return 0;
}
+int unit_attach_pids_to_cgroup(Unit *u) {
+ int r;
+ assert(u);
+
+ r = unit_realize_cgroup(u);
+ if (r < 0)
+ return r;
+
+ r = cg_attach_many_everywhere(u->manager->cgroup_supported, u->cgroup_path, u->pids, migrate_callback, u);
+ if (r < 0)
+ return r;
+
+ return 0;
+}
+
static bool unit_has_mask_realized(Unit *u, CGroupControllerMask mask) {
assert(u);
diff --git a/src/core/cgroup.h b/src/core/cgroup.h
index 16d6613..7150e5e 100644
--- a/src/core/cgroup.h
+++ b/src/core/cgroup.h
@@ -110,6 +110,7 @@ CGroupControllerMask unit_get_target_mask(Unit *u);
void unit_update_cgroup_members_masks(Unit *u);
int unit_realize_cgroup(Unit *u);
void unit_destroy_cgroup_if_empty(Unit *u);
+int unit_attach_pids_to_cgroup(Unit *u);
int manager_setup_cgroup(Manager *m);
void manager_shutdown_cgroup(Manager *m, bool delete);
diff --git a/src/core/execute.c b/src/core/execute.c
index 955090c..5e4135e 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -1351,7 +1351,7 @@ static int exec_child(ExecCommand *command,
}
if (params->cgroup_path) {
- err = cg_attach_everywhere(params->cgroup_supported, params->cgroup_path, 0);
+ err = cg_attach_everywhere(params->cgroup_supported, params->cgroup_path, 0, NULL, NULL);
if (err < 0) {
*error = EXIT_CGROUP;
return err;
diff --git a/src/core/scope.c b/src/core/scope.c
index f0efec0..e0da6e4 100644
--- a/src/core/scope.c
+++ b/src/core/scope.c
@@ -288,11 +288,7 @@ static int scope_start(Unit *u) {
if (!u->transient && UNIT(s)->manager->n_reloading <= 0)
return -ENOENT;
- r = unit_realize_cgroup(u);
- if (r < 0)
- return log_error_errno(r, "Failed to realize cgroup: %m");
-
- r = cg_attach_many_everywhere(u->manager->cgroup_supported, u->cgroup_path, UNIT(s)->pids);
+ r = unit_attach_pids_to_cgroup(u);
if (r < 0)
return r;
diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c
index e595d89..1bcba01 100644
--- a/src/shared/cgroup-util.c
+++ b/src/shared/cgroup-util.c
@@ -1624,7 +1624,7 @@ int cg_create_everywhere(CGroupControllerMask supported, CGroupControllerMask ma
return 0;
}
-int cg_attach_everywhere(CGroupControllerMask supported, const char *path, pid_t pid) {
+int cg_attach_everywhere(CGroupControllerMask supported, const char *path, pid_t pid, cg_migrate_callback_t path_callback, void *userdata) {
CGroupControllerMask bit = 1;
const char *n;
int r;
@@ -1634,8 +1634,18 @@ int cg_attach_everywhere(CGroupControllerMask supported, const char *path, pid_t
return r;
NULSTR_FOREACH(n, mask_names) {
- if (supported & bit)
+
+ if (supported & bit) {
+ const char *p = NULL;
+
+ if (path_callback)
+ p = path_callback(bit, userdata);
+
+ if (!p)
+ p = path;
+
cg_attach_fallback(n, path, pid);
+ }
bit <<= 1;
}
@@ -1643,7 +1653,7 @@ int cg_attach_everywhere(CGroupControllerMask supported, const char *path, pid_t
return 0;
}
-int cg_attach_many_everywhere(CGroupControllerMask supported, const char *path, Set* pids) {
+int cg_attach_many_everywhere(CGroupControllerMask supported, const char *path, Set* pids, cg_migrate_callback_t path_callback, void *userdata) {
Iterator i;
void *pidp;
int r = 0;
@@ -1652,7 +1662,7 @@ int cg_attach_many_everywhere(CGroupControllerMask supported, const char *path,
pid_t pid = PTR_TO_LONG(pidp);
int q;
- q = cg_attach_everywhere(supported, path, pid);
+ q = cg_attach_everywhere(supported, path, pid, path_callback, userdata);
if (q < 0)
r = q;
}
diff --git a/src/shared/cgroup-util.h b/src/shared/cgroup-util.h
index a65f515..5e1e445 100644
--- a/src/shared/cgroup-util.h
+++ b/src/shared/cgroup-util.h
@@ -126,8 +126,8 @@ int cg_slice_to_path(const char *unit, char **ret);
typedef const char* (*cg_migrate_callback_t)(CGroupControllerMask mask, void *userdata);
int cg_create_everywhere(CGroupControllerMask supported, CGroupControllerMask mask, const char *path);
-int cg_attach_everywhere(CGroupControllerMask supported, const char *path, pid_t pid);
-int cg_attach_many_everywhere(CGroupControllerMask supported, const char *path, Set* pids);
+int cg_attach_everywhere(CGroupControllerMask supported, const char *path, pid_t pid, cg_migrate_callback_t callback, void *userdata);
+int cg_attach_many_everywhere(CGroupControllerMask supported, const char *path, Set* pids, cg_migrate_callback_t callback, void *userdata);
int cg_migrate_everywhere(CGroupControllerMask supported, const char *from, const char *to, cg_migrate_callback_t callback, void *userdata);
int cg_trim_everywhere(CGroupControllerMask supported, const char *path, bool delete_root);
commit 0cd385d31814c8c1bc0c81d11ef321036b8b0921
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Dec 10 20:38:24 2014 +0100
core: don't migrate PIDs for units that may contain subcgroups, do this only for leaf units
Otherwise a slice or delegation unit might move PIDs around ignoring the
fact that it is attached to a subcgroup.
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 6815ca9..83678e6 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -606,10 +606,15 @@ static const char *migrate_callback(CGroupControllerMask mask, void *userdata) {
static int unit_create_cgroups(Unit *u, CGroupControllerMask mask) {
_cleanup_free_ char *path = NULL;
+ CGroupContext *c;
int r;
assert(u);
+ c = unit_get_cgroup_context(u);
+ if (!c)
+ return 0;
+
path = unit_default_cgroup_path(u);
if (!path)
return log_oom();
@@ -633,10 +638,15 @@ static int unit_create_cgroups(Unit *u, CGroupControllerMask mask) {
u->cgroup_realized = true;
u->cgroup_realized_mask = mask;
- /* Then, possibly move things over */
- r = cg_migrate_everywhere(u->manager->cgroup_supported, u->cgroup_path, u->cgroup_path, migrate_callback, u);
- if (r < 0)
- log_warning_errno(r, "Failed to migrate cgroup from to %s: %m", u->cgroup_path);
+ if (u->type != UNIT_SLICE && !c->delegate) {
+
+ /* Then, possibly move things over, but not if
+ * subgroups may contain processes, which is the case
+ * for slice and delegation units. */
+ r = cg_migrate_everywhere(u->manager->cgroup_supported, u->cgroup_path, u->cgroup_path, migrate_callback, u);
+ if (r < 0)
+ log_warning_errno(r, "Failed to migrate cgroup from to %s: %m", u->cgroup_path);
+ }
return 0;
}
More information about the systemd-commits
mailing list