[CRIU] [PATCH v3 29/55] pid_ns: Implement pid_ns_root_off()
Kirill Tkhai
ktkhai at virtuozzo.com
Mon Apr 10 01:19:50 PDT 2017
Implement a helper receiving number of levels between
pid namespace level NS_CRIU and NS_ROOT.
v2: Pre-dump tasks pid_ns in predump_task_ns_ids()
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/include/namespaces.h | 7 +++++++
criu/namespaces.c | 6 +++++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/criu/include/namespaces.h b/criu/include/namespaces.h
index 551d18aa3..3f57924c2 100644
--- a/criu/include/namespaces.h
+++ b/criu/include/namespaces.h
@@ -257,5 +257,12 @@ extern int add_ns_shared_cb(int (*actor)(void *data), void *data);
extern struct ns_id *get_socket_ns(int lfd);
extern struct ns_id *lookup_ns_by_kid(unsigned int kid, struct ns_desc *nd);
+/* Number of levels of pid_ns between NS_CRIU and NS_ROOT */
+static inline int pid_ns_root_off(void)
+{
+ if (root_ns_mask & CLONE_NEWPID)
+ return 1;
+ return 0;
+}
#endif /* __CR_NS_H__ */
diff --git a/criu/namespaces.c b/criu/namespaces.c
index e5e2ef9d4..115ed1217 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -673,10 +673,11 @@ struct collect_image_info nsfile_cinfo = {
/*
* Same as dump_task_ns_ids(), but
* a) doesn't keep IDs (don't need them)
- * b) generates them for mount and netns only
+ * b) generates them for mount, netns and pid_ns only
* mnt ones are needed for open_mount() in
* inotify pred-dump
* net ones are needed for parasite socket
+ * pid is need for pid_ns_root_off()
*/
int predump_task_ns_ids(struct pstree_item *item)
@@ -689,6 +690,9 @@ int predump_task_ns_ids(struct pstree_item *item)
if (!get_ns_id(pid, &mnt_ns_desc, NULL))
return -1;
+ if (!get_ns_id(pid, &pid_ns_desc, NULL))
+ return -1;
+
return 0;
}
More information about the CRIU
mailing list