[CRIU] [PATCH v3 5/5] zdtm/mnt_ext_auto: add different bind-mounts of external mount
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Mon Mar 20 02:45:44 PDT 2017
Before dump:
438 437 0:51 /mtest /zdtm/static/mnt_ext_manual.test rw,relatime - tmpfs zdtm_auto_ext_mnt rw
439 437 0:51 /mtest /zdtm/static/mnt_ext_manual_private_shared_bind.test rw,relatime shared:144 - tmpfs zdtm_auto_ext_mnt rw
440 437 0:51 /mtest /zdtm/static/mnt_ext_manual_bind.test rw,relatime shared:144 - tmpfs zdtm_auto_ext_mnt rw
441 437 0:51 /mtest /zdtm/static/mnt_ext_manual_slave_shared_bind.test rw,relatime shared:145 master:144 - tmpfs zdtm_auto_ext_mnt rw
442 437 0:51 /mtest /zdtm/static/mnt_ext_manual_slave_bind.test rw,relatime master:145 - tmpfs zdtm_auto_ext_mnt rw
Criu log:
(00.187324) 1: mnt: Bind /tmp/zdtm_ext_auto.XXXXXX/mtest to /tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual.test
(00.187334) 1: mnt: 438:/tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual.test private 1 shared 0 slave 0
(00.187338) 1: mnt: Bind private /tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_bind.test
(00.187340) 1: mnt: Bind private /tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_private_shared_bind.test
(00.187342) 1: mnt: Postpone slave /tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_slave_bind.test
(00.187344) 1: mnt: Postpone slave /tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_slave_shared_bind.test
(00.187345) 1: mnt: Mounting tmpfs @/tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_bind.test (0)
(00.187348) 1: mnt: Bind /tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual.test/ to /tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_bind.test
(00.187354) 1: mnt: 440:/tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_bind.test private 1 shared 1 slave 0
(00.187360) 1: mnt: Bind share /tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_private_shared_bind.test
(00.187362) 1: mnt: Mounting tmpfs @/tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_private_shared_bind.test (0)
(00.187363) 1: mnt: Bind /tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_bind.test/ to /tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_private_shared_bind.test
(00.187369) 1: mnt: 439:/tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_private_shared_bind.test private 0 shared 0 slave 0
(00.187372) 1: mnt: Bind slave /tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_slave_shared_bind.test
(00.187374) 1: mnt: Postpone slave /tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_slave_bind.test
(00.187376) 1: mnt: Mounting tmpfs @/tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_slave_shared_bind.test (0)
(00.187378) 1: mnt: Bind /tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_private_shared_bind.test/ to /tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_slave_shared_bind.test
(00.187384) 1: mnt: 441:/tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_slave_shared_bind.test private 0 shared 1 slave 1
(00.187390) 1: mnt: Bind slave /tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_slave_bind.test
(00.187391) 1: mnt: Mounting tmpfs @/tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_slave_bind.test (0)
(00.187394) 1: mnt: Bind /tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_slave_shared_bind.test/ to /tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_slave_bind.test
(00.187399) 1: mnt: 442:/tmp/.criu.mntns.BSmvjH/12-0000000000/zdtm/static/mnt_ext_manual_slave_bind.test private 0 shared 0 slave 1
>From log: mount mnt_ext_manual_slave_bind is restored as slave of
mnt_ext_manual_slave_shared_bind, which is restored as slave of
mnt_ext_manual_private_shared_bind, which is restored as shared of
mnt_ext_manual_bind, which is restored as private bind of external,
that is exactly the same way mnt_is_external() looks for external.
v3: fix test to cover all cases in mnt_is_external()
https://jira.sw.ru/browse/PSBM-46753
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
test/zdtm/static/mnt_ext_auto.c | 114 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 113 insertions(+), 1 deletion(-)
diff --git a/test/zdtm/static/mnt_ext_auto.c b/test/zdtm/static/mnt_ext_auto.c
index 44d774b..69d8149 100644
--- a/test/zdtm/static/mnt_ext_auto.c
+++ b/test/zdtm/static/mnt_ext_auto.c
@@ -16,9 +16,17 @@ const char *test_author = "Andrew Vagin <avagin at gmail.com>";
#ifdef ZDTM_EXTMAP_MANUAL
char *dirname = "mnt_ext_manual.test";
+char *dirname_private_shared_bind = "mnt_ext_manual_private_shared_bind.test";
+char *dirname_bind = "mnt_ext_manual_bind.test";
+char *dirname_slave_shared_bind = "mnt_ext_manual_slave_shared_bind.test";
+char *dirname_slave_bind = "mnt_ext_manual_slave_bind.test";
#define DDIR "mtest"
#else
char *dirname = "mnt_ext_auto.test";
+char *dirname_private_shared_bind = "mnt_ext_auto_private_shared_bind.test";
+char *dirname_bind = "mnt_ext_auto_bind.test";
+char *dirname_slave_shared_bind = "mnt_ext_auto_slave_shared_bind.test";
+char *dirname_slave_bind = "mnt_ext_auto_slave_bind.test";
#define DDIR "atest"
#endif
TEST_OPTION(dirname, string, "directory name", 1);
@@ -26,8 +34,10 @@ TEST_OPTION(dirname, string, "directory name", 1);
int main(int argc, char ** argv)
{
char src[PATH_MAX], dst[PATH_MAX], *root;
+ char dst_bind[PATH_MAX], dst_private_shared_bind[PATH_MAX],
+ dst_slave_shared_bind[PATH_MAX], dst_slave_bind[PATH_MAX];
char *dname = "/tmp/zdtm_ext_auto.XXXXXX";
- struct stat sta, stb;
+ struct stat sta, stb, bsta, bstb, ssbsta, sbsta, ssbstb, sbstb, psbsta, psbstb;
char* zdtm_newns = getenv("ZDTM_NEWNS");
root = getenv("ZDTM_ROOT");
@@ -37,6 +47,10 @@ int main(int argc, char ** argv)
}
sprintf(dst, "%s/%s", get_current_dir_name(), dirname);
+ sprintf(dst_private_shared_bind, "%s/%s", get_current_dir_name(), dirname_private_shared_bind);
+ sprintf(dst_bind, "%s/%s", get_current_dir_name(), dirname_bind);
+ sprintf(dst_slave_shared_bind, "%s/%s", get_current_dir_name(), dirname_slave_shared_bind);
+ sprintf(dst_slave_bind, "%s/%s", get_current_dir_name(), dirname_slave_bind);
if (!zdtm_newns) {
pr_perror("ZDTM_NEWNS is not set");
@@ -59,6 +73,46 @@ int main(int argc, char ** argv)
pr_perror("bind");
return 1;
}
+ mkdir(dst_private_shared_bind, 755);
+ if (mount(dst, dst_private_shared_bind, NULL, MS_BIND, NULL)) {
+ pr_perror("bind");
+ return 1;
+ }
+ if (mount("none", dst_private_shared_bind, NULL, MS_PRIVATE, NULL)) {
+ pr_perror("bind");
+ return 1;
+ }
+ if (mount("none", dst_private_shared_bind, NULL, MS_SHARED, NULL)) {
+ pr_perror("bind");
+ return 1;
+ }
+ mkdir(dst_bind, 755);
+ if (mount(dst_private_shared_bind, dst_bind, NULL, MS_BIND, NULL)) {
+ pr_perror("bind");
+ return 1;
+ }
+ mkdir(dst_slave_shared_bind, 755);
+ if (mount(dst_bind, dst_slave_shared_bind, NULL, MS_BIND, NULL)) {
+ pr_perror("bind");
+ return 1;
+ }
+ if (mount("none", dst_slave_shared_bind, NULL, MS_SLAVE, NULL)) {
+ pr_perror("bind");
+ return 1;
+ }
+ if (mount("none", dst_slave_shared_bind, NULL, MS_SHARED, NULL)) {
+ pr_perror("bind");
+ return 1;
+ }
+ mkdir(dst_slave_bind, 755);
+ if (mount(dst_slave_shared_bind, dst_slave_bind, NULL, MS_BIND, NULL)) {
+ pr_perror("bind");
+ return 1;
+ }
+ if (mount("none", dst_slave_bind, NULL, MS_SLAVE, NULL)) {
+ pr_perror("bind");
+ return 1;
+ }
test:
test_init(argc, argv);
@@ -67,18 +121,76 @@ int main(int argc, char ** argv)
sleep(100);
return 1;
}
+ if (stat(dirname_private_shared_bind, &psbstb)) {
+ pr_perror("stat");
+ sleep(100);
+ return 1;
+ }
+ if (stat(dirname_bind, &bstb)) {
+ pr_perror("stat");
+ sleep(100);
+ return 1;
+ }
+ if (stat(dirname_slave_shared_bind, &ssbstb)) {
+ pr_perror("stat");
+ sleep(100);
+ return 1;
+ }
+ if (stat(dirname_slave_bind, &sbstb)) {
+ pr_perror("stat");
+ sleep(100);
+ return 1;
+ }
test_daemon();
test_waitsig();
if (stat(dirname, &sta)) {
pr_perror("stat");
+ sleep(100);
+ return 1;
+ }
+ if (stat(dirname_private_shared_bind, &psbsta)) {
+ pr_perror("stat");
+ sleep(100);
+ return 1;
+ }
+ if (stat(dirname_bind, &bsta)) {
+ pr_perror("stat");
+ sleep(100);
+ return 1;
+ }
+ if (stat(dirname_slave_shared_bind, &ssbsta)) {
+ pr_perror("stat");
+ sleep(100);
+ return 1;
+ }
+ if (stat(dirname_slave_bind, &sbsta)) {
+ pr_perror("stat");
+ sleep(100);
return 1;
}
+
if (sta.st_dev != stb.st_dev) {
fail();
return 1;
}
+ if (psbsta.st_dev != psbstb.st_dev) {
+ fail();
+ return 1;
+ }
+ if (bsta.st_dev != bstb.st_dev) {
+ fail();
+ return 1;
+ }
+ if (ssbsta.st_dev != ssbstb.st_dev) {
+ fail();
+ return 1;
+ }
+ if (sbsta.st_dev != sbstb.st_dev) {
+ fail();
+ return 1;
+ }
pass();
--
2.9.3
More information about the CRIU
mailing list