[CRIU] [PATCH 3/7] ns/restore/image: do not read namespace images for non-namespaced case

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Thu Feb 7 15:17:50 MSK 2019


Images for mount and net namespaces are empty if ns does not belong to
us, thus we don't need to collect on restore.

By adding these checks we will eliminate suspicious messages in logs
about lack of images:

./test/zdtm.py run -k always -f h -t zdtm/static/env00

env00/54/2/restore.log:(00.000332) No mountpoints-5.img image
env00/54/2/restore.log:(00.000342) No netns-2.img image

Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 criu/mount.c | 5 +++++
 criu/net.c   | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/criu/mount.c b/criu/mount.c
index 7e2db60a9..88a30b4fd 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -2990,6 +2990,11 @@ int read_mnt_ns_img(void)
 	struct mount_info *pms = NULL;
 	struct ns_id *nsid;
 
+	if (!(root_ns_mask & CLONE_NEWNS)) {
+		mntinfo = 0;
+		return 0;
+	}
+
 	for (nsid = ns_ids; nsid != NULL; nsid = nsid->next) {
 		if (nsid->nd != &mnt_ns_desc)
 			continue;
diff --git a/criu/net.c b/criu/net.c
index c1a6e3094..8bc1d25cd 100644
--- a/criu/net.c
+++ b/criu/net.c
@@ -2079,6 +2079,9 @@ int read_net_ns_img(void)
 {
 	struct ns_id *ns;
 
+	if (!(root_ns_mask & CLONE_NEWNET))
+		return 0;
+
 	for (ns = ns_ids; ns != NULL; ns = ns->next) {
 		struct cr_img *img;
 		int ret;
-- 
2.20.1



More information about the CRIU mailing list