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

Submitted by Pavel Tikhomirov on Feb. 7, 2019, 12:17 p.m.

Details

Message ID 20190207121754.19667-4-ptikhomirov@virtuozzo.com
State New
Series "mount: check mounts after restoring"
Headers show

Commit Message

Pavel Tikhomirov Feb. 7, 2019, 12:17 p.m.
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@virtuozzo.com>
---
 criu/mount.c | 5 +++++
 criu/net.c   | 3 +++
 2 files changed, 8 insertions(+)

Patch hide | download patch | download mbox

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;