[CRIU] [PATCH 1/4] zdtm: check --ext-mount-map auto
Tycho Andersen
tycho.andersen at canonical.com
Wed May 6 07:07:51 PDT 2015
From: Andrey Vagin <avagin at openvz.org>
Cc: Tycho Andersen <tycho.andersen at canonical.com>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
test/zdtm.sh | 4 ++
test/zdtm/lib/ns.c | 7 +++-
test/zdtm/live/static/Makefile | 1 +
test/zdtm/live/static/mnt_ext_auto.c | 71 +++++++++++++++++++++++++++++++++
test/zdtm/live/static/mnt_ext_auto.opts | 1 +
5 files changed, 83 insertions(+), 1 deletion(-)
create mode 100644 test/zdtm/live/static/mnt_ext_auto.c
create mode 100644 test/zdtm/live/static/mnt_ext_auto.opts
diff --git a/test/zdtm.sh b/test/zdtm.sh
index 2fa51c2..d55a92c 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -559,6 +559,10 @@ start_test()
echo "Test failed to start"
return 1
fi
+
+ mount --make-private "$ZDTM_ROOT"
+ umount -l "$ZDTM_ROOT"
+ mount --make-private --bind . $ZDTM_ROOT || return 1
}
stop_test()
diff --git a/test/zdtm/lib/ns.c b/test/zdtm/lib/ns.c
index 6b8e6f6..4b4ef6b 100644
--- a/test/zdtm/lib/ns.c
+++ b/test/zdtm/lib/ns.c
@@ -36,7 +36,7 @@ static int prepare_mntns()
* under them. So we need to create another mount for the
* new root.
*/
- if (mount("/", "/", NULL, MS_PRIVATE | MS_REC, NULL)) {
+ if (mount(root, root, NULL, MS_SLAVE , NULL)) {
fprintf(stderr, "Can't bind-mount root: %m\n");
return -1;
}
@@ -72,6 +72,11 @@ static int prepare_mntns()
return -1;
}
+ if (mount("./old", "./old", NULL, MS_PRIVATE | MS_REC , NULL)) {
+ fprintf(stderr, "Can't bind-mount root: %m\n");
+ return -1;
+ }
+
if (mkdir("proc", 0777) && errno != EEXIST) {
fprintf(stderr, "mkdir(proc) failed: %m\n");
return -1;
diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index 33a91f1..eb3567d 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -187,6 +187,7 @@ TST_DIR = \
mntns_shared_bind \
mntns_shared_bind02 \
mntns_root_bind \
+ mnt_ext_auto \
TST_DIR_FILE = \
chroot \
diff --git a/test/zdtm/live/static/mnt_ext_auto.c b/test/zdtm/live/static/mnt_ext_auto.c
new file mode 100644
index 0000000..d780a61
--- /dev/null
+++ b/test/zdtm/live/static/mnt_ext_auto.c
@@ -0,0 +1,71 @@
+#include <sys/mount.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <linux/limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc = "Run busy loop while migrating";
+const char *test_author = "Roman Kagan <rkagan at parallels.com>";
+
+char *dirname = "mnt_ext_auto.test";
+TEST_OPTION(dirname, string, "directory name", 1);
+
+int main(int argc, char ** argv)
+{
+ char src[PATH_MAX], dst[PATH_MAX], *root;
+ char *dname = "/tmp/zdtm_ext_auto.XXXXXX";
+ int status;
+ pid_t pid;
+
+ root = getenv("ZDTM_ROOT");
+ if (root == NULL) {
+ err("root");
+ return 1;
+ }
+
+ sprintf(dst, "%s/ext_mounts", getenv("ZDTM_ROOT"));
+
+ if (strcmp(getenv("ZDTM_NEWNS"), "1"))
+ goto test;
+
+ pid = fork();
+ if (pid < 0)
+ return 1;
+ if (pid == 0) {
+ test_ext_init(argc, argv);
+
+ mkdir(dname, 755);
+ sprintf(src, "%s/test", dname);
+ if (mount("zdtm_auto_ext_mnt", dname, "tmpfs", 0, NULL)) {
+ err("mount");
+ return 1;
+ }
+ mkdir(src, 755);
+ mkdir(dst, 755);
+ if (mount(src, dst, NULL, MS_BIND, NULL)) {
+ err("bind");
+ return 1;
+ }
+ return 0;
+ }
+
+ wait(&status);
+ if (status != 0)
+ return 1;
+
+test:
+ test_init(argc, argv);
+
+ test_daemon();
+ test_waitsig();
+
+
+ pass();
+
+ return 0;
+}
diff --git a/test/zdtm/live/static/mnt_ext_auto.opts b/test/zdtm/live/static/mnt_ext_auto.opts
new file mode 100644
index 0000000..aab0bcd
--- /dev/null
+++ b/test/zdtm/live/static/mnt_ext_auto.opts
@@ -0,0 +1 @@
+--ext-mount-map auto --enable-external-sharing
--
2.1.4
More information about the CRIU
mailing list