[v4,16/31] proto: Add ns_entry description

Submitted by Kirill Tkhai on Feb. 22, 2017, 11:32 a.m.

Details

Message ID 148776317492.17334.7947969950766905527.stgit@localhost.localdomain
State New
Series "Nested user namespaces support"
Headers show

Commit Message

Kirill Tkhai Feb. 22, 2017, 11:32 a.m.
New image format, generic for all namespaces.
Currently, it's for pid, net and user ns.

v4: Rename ns-hookup to ns.
    Make user_ns and parent generic.
v3: Move parent_id to pid and user ext

Signed-off-by: Kirill Tkhai <ktkhai@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              |    8 ++++++++
 lib/py/images/images.py      |    1 +
 7 files changed, 14 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/image-desc.c b/criu/image-desc.c
index fffaf5a01..71fae9ebc 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,		"ns"),
 
 	[CR_FD_STATS] = {
 		.fmt	= "stats-%s",
diff --git a/criu/include/image-desc.h b/criu/include/image-desc.h
index 09d187d22..3fad408a7 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,
 
 	CR_FD_MAX
 };
diff --git a/criu/include/magic.h b/criu/include/magic.h
index deb54b1d0..059d0053c 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_MAGIC		0x44293409 /* Yalta */
 
 #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 43ac534a2..1fd095f3f 100644
--- a/criu/include/protobuf-desc.h
+++ b/criu/include/protobuf-desc.h
@@ -74,6 +74,7 @@  enum {
 	PB_SK_QUEUES,
 	PB_IPCNS_MSG,
 	PB_IPCNS_MSG_ENT,
+	PB_NS,
 
 	PB_MAX,
 };
diff --git a/criu/protobuf-desc.c b/criu/protobuf-desc.c
index 4676929b1..5ea84bf61 100644
--- a/criu/protobuf-desc.c
+++ b/criu/protobuf-desc.c
@@ -98,6 +98,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,			Ns,		ns);
 
 #include "protobuf-desc-gen.h"
 }
diff --git a/images/ns.proto b/images/ns.proto
index 7f7b09094..f40a6d651 100644
--- a/images/ns.proto
+++ b/images/ns.proto
@@ -17,3 +17,11 @@  message userns_entry {
 	repeated uid_gid_extent uid_map		= 1;
 	repeated uid_gid_extent gid_map 	= 2;
 }
+
+message ns_entry {
+	required uint32		id		= 1;
+	required uint32		ns_cflag	= 2;
+	optional uint32		parent_id	= 3;
+	optional uint32		userns_id	= 4;
+	optional userns_entry	user_ext	= 5;
+}
diff --git a/lib/py/images/images.py b/lib/py/images/images.py
index c593a3b85..4d8fc10c2 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'                    : entry_handler(ns_entry),
 	}
 
 def __rhandler(f):