Blob Blame History Raw
From 80a918b3fad70613e7257c22d4c1ad585908440d Mon Sep 17 00:00:00 2001
From: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Date: Mon, 30 Dec 2019 16:17:54 +0300
Subject: [PATCH 156/245] zdtm: fix mnt_ext_master test to correspond to it's
 name

Before these change the on-host-"zdtm_auto_ext_mnt" mount with
mountpoint "/tmp/zdtm_ext_auto.XXXXXX" was private/shared depending on
it's parent mount "/tmp". And e.g. on my setup the parent mount on
"/tmp" is private and our "host" mount becomes private too. So
in-container-"zdtm_auto_ext_mnt" external mount is also private but test
name hints it should be slave.

E.g. If I ran mnt_ext_master before this patch, in mnt_ext_master
process mntns we see that our "external" mount is private but not slave:

[root@fedora criu]# grep zdtm_auto_ext_mnt /proc/167077/mountinfo
1239 1238 0:138 /test /ext_mounts rw,relatime - tmpfs zdtm_auto_ext_mnt rw,seclabel,inode64

After this patch:

[root@fedora criu]# grep zdtm_auto_ext_mnt /proc/166385/mountinfo
1239 1238 0:138 /test /ext_mounts rw,relatime master:413 - tmpfs zdtm_auto_ext_mnt rw,seclabel,inode64
                                              ^^^^^^^^^^

So we just explicitly make on-host-"zdtm_auto_ext_mnt" shared, and this
makes in-container-"zdtm_auto_ext_mnt" external mount slave.

Cherry-picked from Virtuozzo criu:
https://src.openvz.org/projects/OVZ/repos/criu/commits/a1a221fe9

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
---
 test/zdtm/static/mnt_ext_master.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/test/zdtm/static/mnt_ext_master.c b/test/zdtm/static/mnt_ext_master.c
index 5fd8fa8b2..dbadef0b8 100644
--- a/test/zdtm/static/mnt_ext_master.c
+++ b/test/zdtm/static/mnt_ext_master.c
@@ -39,6 +39,10 @@ int main(int argc, char **argv)
 		pr_perror("mount");
 		return 1;
 	}
+	if (mount(NULL, dname, NULL, MS_SHARED, NULL)) {
+		pr_perror("shared");
+		return 1;
+	}
 
 	mkdir(src, 755);
 	mkdir(dst, 755);
-- 
2.35.1