naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
84b277
From 4d554c7c1b5373f854cdfd3b8c7d6804225c752e Mon Sep 17 00:00:00 2001
cc2231
From: Lennart Poettering <lennart@poettering.net>
cc2231
Date: Wed, 10 Dec 2014 20:38:24 +0100
cc2231
Subject: [PATCH] core: don't migrate PIDs for units that may contain
cc2231
 subcgroups, do this only for leaf units
cc2231
cc2231
Otherwise a slice or delegation unit might move PIDs around ignoring the
cc2231
fact that it is attached to a subcgroup.
cc2231
cc2231
(cherry picked from commit 0cd385d31814c8c1bc0c81d11ef321036b8b0921)
cc2231
84b277
Resolves: #1139223
cc2231
---
cc2231
 src/core/cgroup.c | 11 +++++++++--
cc2231
 1 file changed, 9 insertions(+), 2 deletions(-)
cc2231
cc2231
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
84b277
index 443937b..5163ee4 100644
cc2231
--- a/src/core/cgroup.c
cc2231
+++ b/src/core/cgroup.c
cc2231
@@ -392,11 +392,16 @@ static CGroupControllerMask unit_get_siblings_mask(Unit *u) {
cc2231
 
cc2231
 static int unit_create_cgroups(Unit *u, CGroupControllerMask mask) {
cc2231
         _cleanup_free_ char *path;
cc2231
+        CGroupContext *c;
cc2231
         int r;
cc2231
         bool was_in_hash = false;
cc2231
 
cc2231
         assert(u);
cc2231
 
cc2231
+        c = unit_get_cgroup_context(u);
cc2231
+        if (!c)
cc2231
+                return 0;
cc2231
+
cc2231
         path = unit_default_cgroup_path(u);
cc2231
         if (!path)
cc2231
                 return log_oom();
cc2231
@@ -416,8 +421,10 @@ static int unit_create_cgroups(Unit *u, CGroupControllerMask mask) {
cc2231
         if (r < 0)
cc2231
                 log_error("Failed to create cgroup %s: %s", path, strerror(-r));
cc2231
 
cc2231
-        /* Then, possibly move things over */
cc2231
-        if (u->cgroup_path) {
cc2231
+        /* Then, possibly move things over, but not if
cc2231
+         * subgroups may contain processes, which is the case
cc2231
+         * for slice and delegation units. */
cc2231
+        if (u->cgroup_path && u->type != UNIT_SLICE && !c->delegate) {
cc2231
                 r = cg_migrate_everywhere(u->manager->cgroup_supported, u->cgroup_path, path);
cc2231
                 if (r < 0)
cc2231
                         log_error("Failed to migrate cgroup from %s to %s: %s",