[CRIU] [PATCH 3/7] image: Add bits and pieces for cgroups image

Pavel Emelyanov xemul at parallels.com
Thu May 8 06:07:58 PDT 2014


The exact structure of the image will be revealed in the
next patch(es). What is important here, is that cgroup
image is somewhat new.

It will likely contain arrays of objects of different types,
so I introduce the "header" object, that will link these
arrays using pb repeated fields. This will help us to avoid
many image files for different cgroup objects and will make
the amount of write()-s required be 1.

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 cr-show.c                |  1 +
 image-desc.c             |  1 +
 include/image-desc.h     |  1 +
 include/magic.h          |  1 +
 include/protobuf-desc.h  |  1 +
 protobuf-desc.c          |  1 +
 protobuf/Makefile        |  1 +
 protobuf/cgroup.proto    | 13 +++++++++++++
 protobuf/core.proto      |  2 ++
 protobuf/inventory.proto |  1 +
 10 files changed, 23 insertions(+)
 create mode 100644 protobuf/cgroup.proto

diff --git a/cr-show.c b/cr-show.c
index 191cc63..1d762c4 100644
--- a/cr-show.c
+++ b/cr-show.c
@@ -296,6 +296,7 @@ static struct show_image_info show_infos[] = {
 	SHOW_VERT(FS),
 	SHOW_VERT(GHOST_FILE),
 	SHOW_VERT(MM),
+	SHOW_VERT(CGROUP),
 
 	SHOW_PLAINS(REG_FILE),
 	SHOW_PLAINS(NS_FILE),
diff --git a/image-desc.c b/image-desc.c
index 5a48d4b..8145f15 100644
--- a/image-desc.c
+++ b/image-desc.c
@@ -76,6 +76,7 @@ struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX] = {
 	FD_ENTRY(SIGNAL,	"signal-s-%d"),
 	FD_ENTRY(PSIGNAL,	"signal-p-%d"),
 	FD_ENTRY(TUNFILE,	"tunfile"),
+	FD_ENTRY(CGROUP,	"cgroup"),
 
 	[CR_FD_STATS] = {
 		.fmt	= "stats-%s",
diff --git a/include/image-desc.h b/include/image-desc.h
index b92394f..76644c8 100644
--- a/include/image-desc.h
+++ b/include/image-desc.h
@@ -74,6 +74,7 @@ enum {
 	CR_FD_FANOTIFY_FILE,
 	CR_FD_FANOTIFY_MARK,
 	CR_FD_TUNFILE,
+	CR_FD_CGROUP,
 	_CR_FD_GLOB_TO,
 
 	CR_FD_TMPFS_IMG,
diff --git a/include/magic.h b/include/magic.h
index 6b111f5..09fa85d 100644
--- a/include/magic.h
+++ b/include/magic.h
@@ -72,6 +72,7 @@
 #define NETLINK_SK_MAGIC	0x58005614 /* Perm */
 #define NS_FILES_MAGIC		0x61394011 /* Nyandoma */
 #define TUNFILE_MAGIC		0x57143751 /* Kalyazin */
+#define CGROUP_MAGIC		0x59383330 /* Tikhvin */
 
 #define IFADDR_MAGIC		RAW_IMAGE_MAGIC
 #define ROUTE_MAGIC		RAW_IMAGE_MAGIC
diff --git a/include/protobuf-desc.h b/include/protobuf-desc.h
index 4ad0aa5..42f837d 100644
--- a/include/protobuf-desc.h
+++ b/include/protobuf-desc.h
@@ -50,6 +50,7 @@ enum {
 	PB_SIGINFO,
 	PB_TUNFILE,
 	PB_IRMAP_CACHE,
+	PB_CGROUP,
 
 	/* PB_AUTOGEN_STOP */
 
diff --git a/protobuf-desc.c b/protobuf-desc.c
index a86ec38..86c3acb 100644
--- a/protobuf-desc.c
+++ b/protobuf-desc.c
@@ -57,6 +57,7 @@
 #include "protobuf/sk-netlink.pb-c.h"
 #include "protobuf/vma.pb-c.h"
 #include "protobuf/tun.pb-c.h"
+#include "protobuf/cgroup.pb-c.h"
 
 struct cr_pb_message_desc cr_pb_descs[PB_MAX];
 
diff --git a/protobuf/Makefile b/protobuf/Makefile
index db42368..e23d9c9 100644
--- a/protobuf/Makefile
+++ b/protobuf/Makefile
@@ -59,6 +59,7 @@ proto-obj-y	+= pagemap.o
 proto-obj-y	+= siginfo.o
 proto-obj-y	+= rpc.o
 proto-obj-y	+= ext-file.o
+proto-obj-y	+= cgroup.o
 
 proto		:= $(proto-obj-y:.o=)
 proto-c		:= $(proto-obj-y:.o=.pb-c.c)
diff --git a/protobuf/cgroup.proto b/protobuf/cgroup.proto
new file mode 100644
index 0000000..a497c70
--- /dev/null
+++ b/protobuf/cgroup.proto
@@ -0,0 +1,13 @@
+message controller_entry {
+	required string name	= 1;
+	required string path	= 2;
+}
+
+message cg_set_entry {
+	required uint32			id	= 1;
+	repeated controller_entry	ctls	= 2;
+}
+
+message cgroup_entry {
+	repeated cg_set_entry	sets	= 1;
+}
diff --git a/protobuf/core.proto b/protobuf/core.proto
index fea7621..21218ec 100644
--- a/protobuf/core.proto
+++ b/protobuf/core.proto
@@ -17,6 +17,8 @@ message task_core_entry {
 
 	optional task_timers_entry	timers		= 7;
 	optional task_rlimits_entry	rlimits		= 8;
+
+	optional uint32			cg_set		= 9;
 }
 
 message task_kobj_ids_entry {
diff --git a/protobuf/inventory.proto b/protobuf/inventory.proto
index 1a329e6..97f572f 100644
--- a/protobuf/inventory.proto
+++ b/protobuf/inventory.proto
@@ -5,4 +5,5 @@ message inventory_entry {
 	optional bool			fdinfo_per_id	= 2;
 	optional task_kobj_ids_entry	root_ids	= 3;
 	optional bool			ns_per_id	= 4;
+	optional uint32			root_cg_set	= 5;
 }
-- 
1.8.4.2


More information about the CRIU mailing list