[CRIU] [PATCH v3 14/33] ns: Provide the case when root_item has !NS_ROOT user_ns in rst_add_ns_id()

Kirill Tkhai ktkhai at virtuozzo.com
Thu Feb 16 04:08:39 PST 2017


root_item may have NS_OTHER user_ns, so do not set it directly.
This will be used in next patches.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/namespaces.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/criu/namespaces.c b/criu/namespaces.c
index 3f1190e5e..b3b79de24 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -313,6 +313,7 @@ struct ns_id *rst_new_ns_id(unsigned int id, pid_t pid,
 int rst_add_ns_id(unsigned int id, struct pstree_item *i, struct ns_desc *nd)
 {
 	pid_t pid = i->pid->ns[0].virt;
+	int type = NS_OTHER;
 	struct ns_id *nsid;
 
 	nsid = lookup_ns_by_id(id, nd);
@@ -322,8 +323,9 @@ int rst_add_ns_id(unsigned int id, struct pstree_item *i, struct ns_desc *nd)
 		return 0;
 	}
 
-	nsid = rst_new_ns_id(id, pid, nd,
-			i == root_item ? NS_ROOT : NS_OTHER);
+	if (i == root_item && nd != &user_ns_desc)
+		type = NS_ROOT;
+	nsid = rst_new_ns_id(id, pid, nd, type);
 	if (nsid == NULL)
 		return -1;
 
@@ -1666,6 +1668,7 @@ static int do_read_old_user_ns_img(struct ns_id *ns, void *arg)
 		return -1;
 	ns->user.e = e;
 	userns_entry = e;
+	ns->type = NS_ROOT;
 	root_user_ns = ns;
 	return 0;
 }



More information about the CRIU mailing list