[CRIU] [PATCH v3 18/33] proto: Add ns_hookup_entry description

Kirill Tkhai ktkhai at virtuozzo.com
Thu Feb 16 04:09:14 PST 2017


New image format, generic for all namespaces.
Currently, it's for pid, net and user ns.

v3: Move parent_id to pid and user ext

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/image-desc.c            |    1 +
 criu/include/image-desc.h    |    1 +
 criu/include/magic.h         |    1 +
 criu/include/protobuf-desc.h |    1 +
 criu/protobuf-desc.c         |    1 +
 images/ns.proto              |   19 +++++++++++++++++++
 lib/py/images/images.py      |    1 +
 7 files changed, 25 insertions(+)

diff --git a/criu/image-desc.c b/criu/image-desc.c
index fffaf5a01..336a50e6d 100644
--- a/criu/image-desc.c
+++ b/criu/image-desc.c
@@ -99,6 +99,7 @@ struct cr_fd_desc_tmpl imgset_template[CR_FD_MAX] = {
 	FD_ENTRY(USERNS,	"userns-%d"),
 	FD_ENTRY(NETNF_CT,	"netns-ct-%d"),
 	FD_ENTRY(NETNF_EXP,	"netns-exp-%d"),
+	FD_ENTRY(NS_HOOKUP,	"ns-hookup"),
 
 	[CR_FD_STATS] = {
 		.fmt	= "stats-%s",
diff --git a/criu/include/image-desc.h b/criu/include/image-desc.h
index 09d187d22..16d0183ff 100644
--- a/criu/include/image-desc.h
+++ b/criu/include/image-desc.h
@@ -107,6 +107,7 @@ enum {
 	CR_FD_EVENTPOLL_TFD,
 
 	CR_FD_AUTOFS,
+	CR_FD_NS_HOOKUP,
 
 	CR_FD_MAX
 };
diff --git a/criu/include/magic.h b/criu/include/magic.h
index deb54b1d0..34e766fa3 100644
--- a/criu/include/magic.h
+++ b/criu/include/magic.h
@@ -93,6 +93,7 @@
 #define SECCOMP_MAGIC		0x64413049 /* Kostomuksha */
 #define BINFMT_MISC_MAGIC	0x67343323 /* Apatity */
 #define AUTOFS_MAGIC		0x49353943 /* Sochi */
+#define NS_HOOKUP_MAGIC		0x55523343 /* Dnepropetrovsk */
 
 #define IFADDR_MAGIC		RAW_IMAGE_MAGIC
 #define ROUTE_MAGIC		RAW_IMAGE_MAGIC
diff --git a/criu/include/protobuf-desc.h b/criu/include/protobuf-desc.h
index 6c76b494f..e45700b3d 100644
--- a/criu/include/protobuf-desc.h
+++ b/criu/include/protobuf-desc.h
@@ -70,6 +70,7 @@ enum {
 	PB_SK_QUEUES,
 	PB_IPCNS_MSG,
 	PB_IPCNS_MSG_ENT,
+	PB_NS_HOOKUP,
 
 	PB_MAX,
 };
diff --git a/criu/protobuf-desc.c b/criu/protobuf-desc.c
index 05f3eb386..f3361ff5f 100644
--- a/criu/protobuf-desc.c
+++ b/criu/protobuf-desc.c
@@ -97,6 +97,7 @@ void cr_pb_init(void)
 	CR_PB_DESC(REMAP_FPATH,		RemapFilePath,	remap_file_path);
 	CR_PB_DESC(NETDEV,		NetDevice,	net_device);
 	CR_PB_MDESC_INIT(cr_pb_descs[PB_PAGEMAP_HEAD],	PagemapHead,	pagemap_head);
+	CR_PB_DESC(NS_HOOKUP,		NsHookup,	ns_hookup);
 
 #include "protobuf-desc-gen.h"
 }
diff --git a/images/ns.proto b/images/ns.proto
index 7f7b09094..01cb032bf 100644
--- a/images/ns.proto
+++ b/images/ns.proto
@@ -16,4 +16,23 @@ message uid_gid_extent {
 message userns_entry {
 	repeated uid_gid_extent uid_map		= 1;
 	repeated uid_gid_extent gid_map 	= 2;
+	optional uint32		parent_id	= 3;
+}
+
+message pidns_entry {
+	required uint32	userns_id		= 1;
+	optional uint32		parent_id	= 2;
+}
+
+message netns_entry2 {
+	required uint32	userns_id		= 1;
+}
+
+message ns_hookup_entry {
+	required uint32		id		= 1;
+	required uint32		ns_cflag	= 2;
+
+	optional userns_entry	user_ext	= 3;
+	optional pidns_entry	pid_ext		= 4;
+	optional netns_entry2	net_ext		= 5;
 }
diff --git a/lib/py/images/images.py b/lib/py/images/images.py
index c593a3b85..69f813c40 100644
--- a/lib/py/images/images.py
+++ b/lib/py/images/images.py
@@ -454,6 +454,7 @@ handlers = {
 	'USERNS'		: entry_handler(userns_entry),
 	'SECCOMP'		: entry_handler(seccomp_entry),
 	'AUTOFS'		: entry_handler(autofs_entry),
+	'NS_HOOKUP'	        : entry_handler(ns_hookup_entry),
 	}
 
 def __rhandler(f):



More information about the CRIU mailing list