[CRIU] [PATCH] zdtm: mount test cgroup controllers before executing tests

Andrey Vagin avagin at openvz.org
Wed Sep 3 03:26:28 PDT 2014


If a controller is mounted during dumping processes, criu may fail with error:
Error (cgroup.c:768): cg: Set 3 is not subset of 2

so lets create all test controllers before executing tests.

Reported-by: Mr Jenkins
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/zdtm.sh                     | 18 ++++++++++++++++++
 test/zdtm/live/static/cgroup02.c |  2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/test/zdtm.sh b/test/zdtm.sh
index 78b4701..4108d37 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -315,6 +315,23 @@ exit_callback()
 }
 trap exit_callback EXIT
 
+# If a controller is mounted during dumping processes, criu may fail with error:
+# Error (cgroup.c:768): cg: Set 3 is not subset of 2
+# so lets mount all test controllers before executing tests.
+mount_cgroups()
+{
+	cat /proc/self/cgroup | grep zdtmtst.defaultroot && return
+	local tdir
+	tdir=`mktemp -d zdtm.XXXXXX`
+	for i in "zdtmtst" "zdtmtst.defaultroot"; do
+		mount -t cgroup -o none,name=$i zdtm $tdir &&
+		# a fake group prevents destroying of a controller
+		mkdir $tdir/holder &&
+		umount $tdir || return 1
+	done
+	rmdir $tdir
+}
+
 construct_root()
 {
 	local root=$1
@@ -904,6 +921,7 @@ while :; do
 			# mntns is used to mount /proc
 			# net is used to avoid conflicts of parasite sockets
 			make zdtm_ct &&
+			mount_cgroups &&
 			./zdtm_ct ./zdtm.sh "$@"
 			exit
 		}
diff --git a/test/zdtm/live/static/cgroup02.c b/test/zdtm/live/static/cgroup02.c
index b6f2b51..6bc0e54 100644
--- a/test/zdtm/live/static/cgroup02.c
+++ b/test/zdtm/live/static/cgroup02.c
@@ -15,7 +15,7 @@ char *dirname;
 TEST_OPTION(dirname, string, "cgroup directory name", 1);
 static const char *cgname = "zdtmtst";
 static const char *subname = "oldroot";
-static const char *cgname2 = "defaultroot";
+static const char *cgname2 = "zdtmtst.defaultroot";
 
 int mount_and_add(const char *controller, const char *path)
 {
-- 
1.9.3



More information about the CRIU mailing list