[CRIU] [PATCH v1 10/17] user_ns: Dump parent user_ns id
Kirill Tkhai
ktkhai at virtuozzo.com
Thu Jan 12 09:53:46 PST 2017
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/namespaces.c | 16 ++++++++++++++++
images/userns.proto | 1 +
2 files changed, 17 insertions(+)
diff --git a/criu/namespaces.c b/criu/namespaces.c
index 24dafe84b..949675f9b 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -303,6 +303,8 @@ struct ns_id *rst_new_ns_id(unsigned int id, pid_t pid,
nsid->type = type;
nsid_add(nsid, nd, id, pid);
nsid->ns_populated = false;
+ INIT_LIST_HEAD(&nsid->parent_head);
+ INIT_LIST_HEAD(&nsid->child_node);
}
return nsid;
@@ -1015,6 +1017,11 @@ static int dump_user_ns(struct ns_id *ns)
if (check_user_ns(ns))
return -1;
+ if (ns->type != NS_ROOT) {
+ e->has_parent_ns_id = true;
+ e->parent_ns_id = ns->parent->id;
+ }
+
img = open_image(CR_FD_USERNS, O_DUMP, ns->id);
if (!img)
goto err;
@@ -1577,6 +1584,15 @@ static int do_read_user_ns_img(struct ns_id *ns, void *arg)
if (ns->type == NS_ROOT)
userns_entry = e;
+ if (e->has_parent_ns_id) {
+ ns->parent = lookup_ns_by_id(e->parent_ns_id, &user_ns_desc);
+ if (!ns->parent) {
+ pr_err("Can't find parent %u of ns %u\n", e->parent_ns_id, ns->id);
+ return -1;
+ }
+ list_add(&ns->child_node, &ns->parent->parent_head);
+ }
+
return 0;
}
diff --git a/images/userns.proto b/images/userns.proto
index 16be6b161..9d8aec663 100644
--- a/images/userns.proto
+++ b/images/userns.proto
@@ -9,4 +9,5 @@ message uid_gid_extent {
message userns_entry {
repeated uid_gid_extent uid_map = 1;
repeated uid_gid_extent gid_map = 2;
+ optional uint32 parent_ns_id = 3;
}
More information about the CRIU
mailing list