[CRIU] [PATCH 08/10] cgroup: only set up the cgns prefix once
Tycho Andersen
tycho.andersen at canonical.com
Wed Mar 2 11:28:57 PST 2016
Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
criu/cgroup.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/criu/cgroup.c b/criu/cgroup.c
index 0ad70bf..5b4dcf2 100644
--- a/criu/cgroup.c
+++ b/criu/cgroup.c
@@ -993,7 +993,7 @@ static int userns_move(void *arg, int fd, pid_t pid)
return 0;
}
-static int move_in_cgroup(CgSetEntry *se)
+static int move_in_cgroup(CgSetEntry *se, bool setup_cgns)
{
int i;
@@ -1034,7 +1034,7 @@ static int move_in_cgroup(CgSetEntry *se)
* namespace boundary at /unsprefix" without first entering that, doing
* 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];
ce->path[ce->cgns_prefix] = '\0';
@@ -1074,6 +1074,7 @@ int prepare_task_cgroup(struct pstree_item *me)
{
CgSetEntry *se;
u32 current_cgset;
+ bool needs_cgns_setup = false;
if (!rsti(me)->cg_set)
return 0;
@@ -1094,7 +1095,14 @@ int prepare_task_cgroup(struct pstree_item *me)
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)
--
2.7.0
More information about the CRIU
mailing list