[CRIU] [PATCH] cgroup: actually detect cgroupns bind mounts correctly
Tycho Andersen
tycho.andersen at canonical.com
Fri Aug 12 07:31:50 PDT 2016
Initially, the cgroupns patchset that went into the Ubuntu kernels had the
nsroot= argument in mountopts, which allowed us to distinguish between
cgroupfs mounts. The upstream kernel doesn't have this (the reasoning was
that it showed up in the root field of mountinfo), so all cgroup mounts
look idential if we don't consider the root mount, and we wrongly detect
the mounts as bind mounts. Instead, let's remember the root path and
compare this when considering when a mount is a bind mount.
This patch is a little ugly because it intorduces cgroup specific behavior
into the generic code, which we've thus far been able to avoid. One way to
deal with this might be able to add a ->sb_equal hook to the fstype struct
that could compare mountinfos' superblocks, and then fall back to
mounts_sb_equal if that isn't present. Or we can leave this specific code
in the generic bits until more of these appear. Either way is fine with me.
v2: move the cgroup specific code to mounts_sb_equal()
Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
criu/mount.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/criu/mount.c b/criu/mount.c
index f90ec69..d32aabc 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -297,6 +297,9 @@ static bool mounts_sb_equal(struct mount_info *a, struct mount_info *b)
return false;
}
+ if (a->fstype->code == FSTYPE__CGROUP && strcmp(a->private, b->private))
+ return false;
+
return a->s_dev == b->s_dev && !strcmp(a->source, b->source);
}
@@ -1602,7 +1605,7 @@ static int cgroup_parse(struct mount_info *pm)
/* cgroup namespaced mounts don't look rooted to CRIU, so let's fake it
* here.
*/
- xfree(pm->root);
+ pm->private = pm->root;
pm->root = xstrdup("/");
if (!pm->root)
return -1;
--
2.7.4
More information about the CRIU
mailing list