[CRIU] [PATCH] check/zdtm: Check userns feature in criu

Pavel Emelyanov xemul at parallels.com
Tue Jan 13 11:23:40 PST 2015


This is the continuation -- check relevant userns features in criu check.

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 cr-check.c   | 22 ++++++++++++++++++++++
 test/zdtm.sh | 10 ++--------
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/cr-check.c b/cr-check.c
index 51d25ae..9afc9e8 100644
--- a/cr-check.c
+++ b/cr-check.c
@@ -748,6 +748,26 @@ static int check_tun(void)
 	return check_tun_cr(-1);
 }
 
+static int check_userns(void)
+{
+	int ret;
+	unsigned long size = 0;
+
+	ret = access("/proc/self/ns/user", F_OK);
+	if (ret) {
+		pr_perror("No userns proc file");
+		return -1;
+	}
+
+	ret = sys_prctl(PR_SET_MM, PR_SET_MM_MAP_SIZE, (unsigned long)&size, 0, 0);
+	if (ret) {
+		pr_perror("No new prctl API");
+		return -1;
+	}
+
+	return 0;
+}
+
 int check_add_feature(char *feat)
 {
 	if (!strcmp(feat, "mnt_id"))
@@ -758,6 +778,8 @@ int check_add_feature(char *feat)
 		chk_feature = check_timerfd;
 	else if (!strcmp(feat, "tun"))
 		chk_feature = check_tun;
+	else if (!strcmp(feat, "userns"))
+		chk_feature = check_userns;
 	else {
 		pr_err("Unknown feature %s\n", feat);
 		return -1;
diff --git a/test/zdtm.sh b/test/zdtm.sh
index d8933b6..01bcbec 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -284,15 +284,9 @@ ns/static/mntns_shared_bind02
 ns/static/mntns_root_bind
 "
 
-can_cr_userns() {
-	[ ! -f /proc/self/ns/user ] && return 1
-	$CRIU check | fgrep -q 'PR_SET_MM_MAP is not supported' && return 1
-
-	return 0 # this means TRUE in bash :\
-}
-
 # Add tests which can be executed in an user namespace
-if can_cr_userns ; then
+$CRIU check --feature "userns"
+if [ $? -eq 0 ]; then
 	blist=`mktemp /tmp/zdtm.black.XXXXXX`
 	echo "$BLACKLIST_FOR_USERNS" | sort > $blist
 
-- 
1.8.4.2




More information about the CRIU mailing list