[CRIU] [PATCH 1/2] restore: don't pass cgroup nsroot= option to mount()

Tycho Andersen tycho.andersen at canonical.com
Wed Mar 23 14:41:18 PDT 2016


https://lkml.org/lkml/2016/3/21/777 introduces a new cgroup mount option
called nsroot, but doesn't allow you to pass it to mount() to actually
mount it. Let's chop this option off so that we don't get errors from
mount().

There may be better places to chop this off (e.g. perhaps on dump),
although I think it is useful to have it in there for debugging purposes,
and only costs us a few extra bytes to keep it in the images since we're
going to have other cgroup options anyways.

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 criu/mount.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/criu/mount.c b/criu/mount.c
index a425828..be79999 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -2866,6 +2866,18 @@ static int collect_mnt_from_image(struct mount_info **pms, struct ns_id *nsid)
 		/* FIXME: abort unsupported early */
 		pm->fstype = decode_fstype(me->fstype, me->fsname);
 
+		if (pm->fstype->code == FSTYPE__CGROUP) {
+			char *pos;
+
+			pos = strstr(pm->options, "nsroot=");
+			if (pos > pm->options && *(pos-1) == ',')
+				pos--;
+			if (pos) {
+				pr_info("trimming nsroot option %s from cgroup mount\n", pos);
+				*pos = 0;
+			}
+		}
+
 		if (get_mp_root(me, pm))
 			goto err;
 
-- 
2.7.3



More information about the CRIU mailing list