[CRIU] [PATCH] restore: Show human readable namespace filags used

Cyrill Gorcunov gorcunov at openvz.org
Tue Oct 29 02:31:07 PDT 2013


For debug purpose

 | (00.007001) Will restore in 64020000 namespaces (uts,pid,net,)

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 include/namespaces.h |  2 ++
 namespaces.c         | 23 +++++++++++++++++++++++
 pstree.c             |  3 ++-
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/include/namespaces.h b/include/namespaces.h
index 4b427f8..3675aea 100644
--- a/include/namespaces.h
+++ b/include/namespaces.h
@@ -36,4 +36,6 @@ int restore_ns(int rst, struct ns_desc *nd);
 
 int dump_task_ns_ids(struct pstree_item *);
 
+extern char *nsflags_to_str(unsigned long flags);
+
 #endif /* __CR_NS_H__ */
diff --git a/namespaces.c b/namespaces.c
index c6e9b3f..32f3b82 100644
--- a/namespaces.c
+++ b/namespaces.c
@@ -449,6 +449,29 @@ int dump_namespaces(struct pstree_item *item, unsigned int ns_flags)
 	return 0;
 }
 
+char *nsflags_to_str(unsigned long flags)
+{
+	static char s[32];
+
+	if (flags & (CLONE_NEWUTS | CLONE_NEWIPC |
+		     CLONE_NEWUSER | CLONE_NEWPID |
+		     CLONE_NEWNET)) {
+		if (flags & CLONE_NEWUTS)
+			strcat(s, "uts,");
+		if (flags & CLONE_NEWIPC)
+			strcat(s, "ipc,");
+		if (flags & CLONE_NEWUSER)
+			strcat(s, "user,");
+		if (flags & CLONE_NEWPID)
+			strcat(s, "pid,");
+		if (flags & CLONE_NEWNET)
+			strcat(s, "net,");
+	} else
+		strcat(s, "none");
+
+	return s;
+}
+
 int prepare_namespace(struct pstree_item *item, unsigned long clone_flags)
 {
 	pid_t pid = item->pid.virt;
diff --git a/pstree.c b/pstree.c
index fbd69ff..75eebf9 100644
--- a/pstree.c
+++ b/pstree.c
@@ -636,7 +636,8 @@ set_mask:
 		 * criu or is created for the init task (only)
 		 */
 		if (item == root_item) {
-			pr_info("Will restore in %lx namespaces\n", cflags);
+			pr_info("Will restore in %lx namespaces (%s)\n",
+				cflags, nsflags_to_str(cflags));
 			current_ns_mask = cflags & CLONE_ALLNS;
 		} else if (cflags & CLONE_ALLNS) {
 			pr_err("Can't restore sub-task in NS\n");
-- 
1.8.3.1



More information about the CRIU mailing list