[CRIU] [PATCH] zdtm/mnt_tracefs: mount tracefs and don't affect an external mount namepace

Andrey Vagin avagin at openvz.org
Mon May 23 14:07:54 PDT 2016


From: Andrew Vagin <avagin at virtuozzo.com>

====================== Run zdtm/static/mnt_tracefs in uns ======================
Start test
./mnt_tracefs --pidfile=mnt_tracefs.pid --outfile=mnt_tracefs.out --dirname=mnt_tracefs.test
Run criu dump
Wait for zdtm/static/mnt_tracefs to die for 0.100000
Run criu restore
Run criu dump
Run criu restore
Run criu dump
Run criu restore
1: Old mounts lost: set([])
1: New mounts appeared: set([('/', '/debugfs/tracing')])
Wait for zdtm/static/mnt_tracefs to die for 0.100000

Cc: Tycho Andersen <tycho.andersen at canonical.com>
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 test/zdtm/static/mnt_tracefs.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/test/zdtm/static/mnt_tracefs.c b/test/zdtm/static/mnt_tracefs.c
index 55a7d64..91d4585 100644
--- a/test/zdtm/static/mnt_tracefs.c
+++ b/test/zdtm/static/mnt_tracefs.c
@@ -1,3 +1,5 @@
+#define _GNU_SOURCE
+#include <sched.h>
 #include <sys/mount.h>
 #include <unistd.h>
 #include <sys/stat.h>
@@ -18,8 +20,6 @@ TEST_OPTION(dirname, string, "directory name", 1);
 int main(int argc, char ** argv)
 {
 	char dst[PATH_MAX], *root;
-	int status;
-	pid_t pid;
 
 	root = getenv("ZDTM_ROOT");
 	if (root == NULL) {
@@ -32,23 +32,16 @@ int main(int argc, char ** argv)
 	if (strcmp(getenv("ZDTM_NEWNS"), "1"))
 		goto test;
 
-	pid = fork();
-	if (pid < 0)
+	if (unshare(CLONE_NEWNS)) {
+		pr_perror("unshare");
 		return 1;
-	if (pid == 0) {
-		test_ext_init(argc, argv);
-
-		mkdir(dst, 755);
-		if (mount("/sys/kernel/debug", dst, NULL, MS_BIND, NULL)) {
-			pr_perror("mount");
-			return 1;
-		}
-		return 0;
 	}
 
-	wait(&status);
-	if (status != 0)
+	mkdir(dst, 755);
+	if (mount("/sys/kernel/debug", dst, NULL, MS_BIND | MS_REC, NULL)) {
+		pr_perror("mount");
 		return 1;
+	}
 
 test:
 	test_init(argc, argv);
-- 
2.7.4



More information about the CRIU mailing list