[CRIU] [PATCH] crit: Show CLONE_ flags in ns image

Cyrill Gorcunov gorcunov at openvz.org
Sat Aug 5 18:22:14 MSK 2017


For better readability

 | {
 |     "magic": "NS",
 |     "entries": [
 |         {
 |             "id": 10,
 |             "ns_cflag": "CLONE_NEWPID"
 |         },
 |         {
 |             "id": 8,
 |             "ns_cflag": "CLONE_NEWNET"
 |         }
 |     ]
 | }

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 images/ns.proto          |  4 +++-
 lib/py/images/pb2dict.py | 27 +++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/images/ns.proto b/images/ns.proto
index f40a6d651da2..dfab45e12ab8 100644
--- a/images/ns.proto
+++ b/images/ns.proto
@@ -1,5 +1,7 @@
 syntax = "proto2";
 
+import "opts.proto";
+
 message ns_file_entry {
 	required uint32		id		= 1;
 	required uint32		ns_id		= 2;
@@ -20,7 +22,7 @@ message userns_entry {
 
 message ns_entry {
 	required uint32		id		= 1;
-	required uint32		ns_cflag	= 2;
+	required uint32		ns_cflag	= 2 [(criu).flags = "ns.ns_cflags"];
 	optional uint32		parent_id	= 3;
 	optional uint32		userns_id	= 4;
 	optional userns_entry	user_ext	= 5;
diff --git a/lib/py/images/pb2dict.py b/lib/py/images/pb2dict.py
index bf05278ffad7..d653905cd1b3 100644
--- a/lib/py/images/pb2dict.py
+++ b/lib/py/images/pb2dict.py
@@ -111,12 +111,39 @@ pmap_flags_map = [
 	('PE_PRESENT',	1 << 2),
 ];
 
+ns_cflags_map = [
+	('CLONE_VM',	        0x00000100),
+	('CLONE_FS',	        0x00000200),
+	('CLONE_FILES',	        0x00000400),
+	('CLONE_SIGHAND',	0x00000800),
+	('CLONE_PTRACE',	0x00002000),
+	('CLONE_VFORK',	        0x00004000),
+	('CLONE_PARENT',	0x00008000),
+	('CLONE_THREAD',	0x00010000),
+	('CLONE_NEWNS',	        0x00020000),
+	('CLONE_SYSVSEM',	0x00040000),
+	('CLONE_SETTLS',	0x00080000),
+	('CLONE_PARENT_SETTID',	0x00100000),
+	('CLONE_CHILD_CLEARTID',0x00200000),
+	('CLONE_DETACHED',	0x00400000),
+	('CLONE_UNTRACED',	0x00800000),
+	('CLONE_CHILD_SETTID',	0x01000000),
+	('CLONE_NEWCGROUP',	0x02000000),
+	('CLONE_NEWUTS',	0x04000000),
+	('CLONE_NEWIPC',	0x08000000),
+	('CLONE_NEWUSER',	0x10000000),
+	('CLONE_NEWPID',	0x20000000),
+	('CLONE_NEWNET',	0x40000000),
+	('CLONE_IO',	        0x80000000),
+];
+
 flags_maps = {
 	'mmap.prot' : mmap_prot_map,
 	'mmap.flags' : mmap_flags_map,
 	'mmap.status' : mmap_status_map,
 	'rfile.flags' : rfile_flags_map,
 	'pmap.flags' : pmap_flags_map,
+        'ns.ns_cflags': ns_cflags_map,
 }
 
 gen_maps = {
-- 
2.7.5



More information about the CRIU mailing list