[CRIU] [PATCH 5/7] protobuf: Introduce ns_file_entry

Cyrill Gorcunov gorcunov at openvz.org
Wed May 8 09:00:39 EDT 2013


We need this entries for checkpoint/restore of procfs ns entries
tracking. In particular new image ns-files.img will keep the
triplets which would allow us to recognize the ns references
need to be opened.

This commit mostly prepares the ground for the following up ones.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 cr-show.c             | 6 ++++++
 image.c               | 1 +
 include/crtools.h     | 2 ++
 include/magic.h       | 1 +
 include/protobuf.h    | 1 +
 protobuf.c            | 2 ++
 protobuf/Makefile     | 1 +
 protobuf/fdinfo.proto | 1 +
 protobuf/nsfile.proto | 5 +++++
 9 files changed, 20 insertions(+)
 create mode 100644 protobuf/nsfile.proto

diff --git a/cr-show.c b/cr-show.c
index f7d7006..687ab36 100644
--- a/cr-show.c
+++ b/cr-show.c
@@ -27,6 +27,7 @@
 #include "protobuf.h"
 #include "protobuf/fdinfo.pb-c.h"
 #include "protobuf/regfile.pb-c.h"
+#include "protobuf/nsfile.pb-c.h"
 #include "protobuf/ghost-file.pb-c.h"
 #include "protobuf/fifo.pb-c.h"
 #include "protobuf/remap-file-path.pb-c.h"
@@ -65,6 +66,11 @@ void show_fown_cont(void *p)
 	       fown->uid, fown->euid, fown->signum, fown->pid_type, fown->pid);
 }
 
+void show_ns_files(int fd)
+{
+	pb_show_plain(fd, PB_NS_FILES);
+}
+
 void show_reg_files(int fd_reg_files)
 {
 	pb_show_plain(fd_reg_files, PB_REG_FILES);
diff --git a/image.c b/image.c
index d9c624a..ef80bce 100644
--- a/image.c
+++ b/image.c
@@ -119,6 +119,7 @@ struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX] = {
 	FD_ENTRY(PAGEMAP,	"pagemap-%ld",	 show_pagemap),
 	FD_ENTRY(SHMEM_PAGEMAP,	"pagemap-shmem-%ld", show_pagemap),
 	FD_ENTRY(REG_FILES,	"reg-files",	 show_reg_files),
+	FD_ENTRY(NS_FILES,	"ns-files",	 show_ns_files),
 	FD_ENTRY(EVENTFD,	"eventfd",	 show_eventfds),
 	FD_ENTRY(EVENTPOLL,	"eventpoll",	 show_eventpoll),
 	FD_ENTRY(EVENTPOLL_TFD,	"eventpoll-tfd", show_eventpoll_tfd),
diff --git a/include/crtools.h b/include/crtools.h
index d66c042..9da4d85 100644
--- a/include/crtools.h
+++ b/include/crtools.h
@@ -61,6 +61,7 @@ enum {
 	_CR_FD_GLOB_FROM,
 	CR_FD_SK_QUEUES,
 	CR_FD_REG_FILES,
+	CR_FD_NS_FILES,
 	CR_FD_INETSK,
 	CR_FD_UNIXSK,
 	CR_FD_PACKETSK,
@@ -160,6 +161,7 @@ struct cr_fd_desc_tmpl {
 void show_files(int fd);
 void show_pagemap(int fd);
 void show_reg_files(int fd);
+void show_ns_files(int fd);
 void show_core(int fd);
 void show_ids(int fd);
 void show_mm(int fd);
diff --git a/include/magic.h b/include/magic.h
index 66a4b1c..f933881 100644
--- a/include/magic.h
+++ b/include/magic.h
@@ -67,6 +67,7 @@
 #define SIGNAL_MAGIC		0x59255647 /* Berezniki */
 #define PSIGNAL_MAGIC		SIGNAL_MAGIC
 #define NETLINKSK_MAGIC		0x58005614 /* Perm */
+#define NS_FILES_MAGIC		0x61394011 /* Nyandoma */
 
 #define IFADDR_MAGIC		RAW_IMAGE_MAGIC
 #define ROUTE_MAGIC		RAW_IMAGE_MAGIC
diff --git a/include/protobuf.h b/include/protobuf.h
index 9bd6662..74a7cdf 100644
--- a/include/protobuf.h
+++ b/include/protobuf.h
@@ -28,6 +28,7 @@ enum {
 	PB_TCP_STREAM,
 	PB_SK_QUEUES,
 	PB_REG_FILES,
+	PB_NS_FILES,
 	PB_INETSK,
 	PB_UNIXSK,
 	PB_PACKETSK,
diff --git a/protobuf.c b/protobuf.c
index fba0953..caf8fb1 100644
--- a/protobuf.c
+++ b/protobuf.c
@@ -19,6 +19,7 @@
 #include "protobuf.h"
 #include "protobuf/inventory.pb-c.h"
 #include "protobuf/regfile.pb-c.h"
+#include "protobuf/nsfile.pb-c.h"
 #include "protobuf/eventfd.pb-c.h"
 #include "protobuf/eventpoll.pb-c.h"
 #include "protobuf/signalfd.pb-c.h"
@@ -95,6 +96,7 @@ void cr_pb_init(void)
 	CR_PB_DESC(INVENTORY,		Inventory,	inventory);
 	CR_PB_DESC(FDINFO,		Fdinfo,		fdinfo);
 	CR_PB_DESC(REG_FILES,		RegFile,	reg_file);
+	CR_PB_DESC(NS_FILES,		NsFile,		ns_file);
 	CR_PB_DESC(EVENTFD,		EventfdFile,	eventfd_file);
 	CR_PB_DESC(EVENTPOLL,		EventpollFile,	eventpoll_file);
 	CR_PB_DESC(EVENTPOLL_TFD,	EventpollTfd,	eventpoll_tfd);
diff --git a/protobuf/Makefile b/protobuf/Makefile
index d9e578c..f61ce69 100644
--- a/protobuf/Makefile
+++ b/protobuf/Makefile
@@ -16,6 +16,7 @@ proto-obj-y	+= inventory.o
 proto-obj-y	+= fdinfo.o
 proto-obj-y	+= fown.o
 proto-obj-y	+= regfile.o
+proto-obj-y	+= nsfile.o
 proto-obj-y	+= ghost-file.o
 proto-obj-y	+= fifo.o
 proto-obj-y	+= remap-file-path.o
diff --git a/protobuf/fdinfo.proto b/protobuf/fdinfo.proto
index e74488b..9b62883 100644
--- a/protobuf/fdinfo.proto
+++ b/protobuf/fdinfo.proto
@@ -13,6 +13,7 @@ enum fd_types {
 	TTY		= 11;
 	FANOTIFY	= 12;
 	NETLINKSK	= 13;
+	NS		= 14;
 }
 
 message fdinfo_entry {
diff --git a/protobuf/nsfile.proto b/protobuf/nsfile.proto
new file mode 100644
index 0000000..5659ff2
--- /dev/null
+++ b/protobuf/nsfile.proto
@@ -0,0 +1,5 @@
+message ns_file_entry {
+	required uint32		id	= 1;
+	required uint32		ns_id	= 2;
+	required uint32		flags	= 3;
+}
-- 
1.8.1.4



More information about the CRIU mailing list