[CRIU] [PATCH] zdtm: add a program to umount a test root

Andrei Vagin avagin at openvz.org
Thu Sep 1 14:50:12 PDT 2016


This program doesn't parse /etc/fstab or /etc/mtab,
it just calls the umount2 syscall.

It is another attempt to fix the error:
subprocess.CalledProcessError: Command '['mount', '--make-private', '/tmp/criu-root-C7MZS9']' returned non-zero exit status 1
OSError: [Errno 16] Device or resource busy: '/tmp/criu-root-C7MZS9'

Signed-off-by: Andrei Vagin <avagin at openvz.org>
Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 test/Makefile  |  4 +++-
 test/umount2.c | 16 ++++++++++++++++
 test/zdtm.py   |  5 +++--
 3 files changed, 22 insertions(+), 3 deletions(-)
 create mode 100644 test/umount2.c

diff --git a/test/Makefile b/test/Makefile
index 22fcf71..20336b7 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -21,6 +21,8 @@ other:
 
 zdtm_ct: zdtm_ct.c
 
+umount2: umount2
+
 zdtm:
 	./zdtm.py run -a --parallel 2
 .PHONY: zdtm
@@ -53,7 +55,7 @@ clean_root:
 .PHONY: clean_root
 
 clean: clean_root
-	$(RM) zdtm_ct zdtm-tst-list
+	$(RM) zdtm_ct zdtm-tst-list umount2
 	$(Q) $(RM) *.log
 	$(Q) $(RM) -r ./dump/
 	$(Q) $(MAKE) -C zdtm cleandep clean cleanout
diff --git a/test/umount2.c b/test/umount2.c
new file mode 100644
index 0000000..a150f34
--- /dev/null
+++ b/test/umount2.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <sys/mount.h>
+
+int main(int argc, char *argv[])
+{
+	if (argc < 2) {
+		fprintf(stderr, "umount PATH\n");
+		return 1;
+	}
+	if (umount2(argv[1], MNT_DETACH)) {
+		fprintf(stderr, "umount %s: %m\n", argv[1]);
+		return 1;
+	}
+
+	return 0;
+}
diff --git a/test/zdtm.py b/test/zdtm.py
index facd2d9..d3446fb 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -263,8 +263,7 @@ class ns_flavor:
 
 	def fini(self):
 		if self.root_mounted:
-			subprocess.check_call(["mount", "--make-private", self.root])
-			subprocess.check_call(["umount", "-l", self.root])
+			subprocess.check_call(["./umount2", self.root])
 			self.root_mounted = False
 
 	@staticmethod
@@ -529,6 +528,8 @@ class zdtm_test:
 
 	@staticmethod
 	def available():
+		if not os.access("umount2", os.X_OK):
+			subprocess.check_call(["make", "umount2"])
 		if not os.access("zdtm_ct", os.X_OK):
 			subprocess.check_call(["make", "zdtm_ct"])
 		if not os.access("zdtm/lib/libzdtmtst.a", os.F_OK):
-- 
2.7.4



More information about the CRIU mailing list