Commit 89c7475c authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

cgroup: only set up the cgns prefix once

Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 9f814087
...@@ -1015,7 +1015,7 @@ static int userns_move(void *arg, int fd, pid_t pid) ...@@ -1015,7 +1015,7 @@ static int userns_move(void *arg, int fd, pid_t pid)
return 0; return 0;
} }
static int move_in_cgroup(CgSetEntry *se) static int move_in_cgroup(CgSetEntry *se, bool setup_cgns)
{ {
int i; int i;
...@@ -1056,7 +1056,7 @@ static int move_in_cgroup(CgSetEntry *se) ...@@ -1056,7 +1056,7 @@ static int move_in_cgroup(CgSetEntry *se)
* namespace boundary at /unsprefix" without first entering that, doing * namespace boundary at /unsprefix" without first entering that, doing
* the unshare, and then entering the rest of the path. * the unshare, and then entering the rest of the path.
*/ */
if (ce->has_cgns_prefix) { if (setup_cgns && ce->has_cgns_prefix) {
char tmp = ce->path[ce->cgns_prefix]; char tmp = ce->path[ce->cgns_prefix];
ce->path[ce->cgns_prefix] = '\0'; ce->path[ce->cgns_prefix] = '\0';
...@@ -1096,6 +1096,7 @@ int prepare_task_cgroup(struct pstree_item *me) ...@@ -1096,6 +1096,7 @@ int prepare_task_cgroup(struct pstree_item *me)
{ {
CgSetEntry *se; CgSetEntry *se;
u32 current_cgset; u32 current_cgset;
bool needs_cgns_setup = false;
if (!rsti(me)->cg_set) if (!rsti(me)->cg_set)
return 0; return 0;
...@@ -1116,7 +1117,14 @@ int prepare_task_cgroup(struct pstree_item *me) ...@@ -1116,7 +1117,14 @@ int prepare_task_cgroup(struct pstree_item *me)
return -1; return -1;
} }
return move_in_cgroup(se); /* Since don't support nesting of cgroup namespaces, let's only set up
* the cgns (if it exists) in the init task. In the future, we should
* just check that the cgns prefix string matches for all the entries
* in the cgset, and only unshare if that's true.
*/
needs_cgns_setup = !me->parent;
return move_in_cgroup(se, needs_cgns_setup);
} }
void fini_cgroup(void) void fini_cgroup(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment