[CRIU] [PATCHv0 1/3] cgroups: save freezer state during dump

Eugene Batalov eabatalov89 at gmail.com
Tue Nov 24 05:34:12 PST 2015


From: Evgeniy Akimov <geka666 at gmail.com>

CRIU sets freezer.state to "THAWED" during process tree dumping. That's why
we can't simply save freezer.state file contents to cgroups image. New
special function get_real_freezer_state() returns freezer cgroup state
observed before CRIU dumping start. Patch puts its return value to dump file.

Signed-off-by: Evgeniy Akimov <geka666 at gmail.com>
Signed-off-by: Eugene Batalov <eabatalov89 at gmail.com>
---
 cgroup.c              | 10 ++++++++++
 include/seize.h       |  1 +
 protobuf/cgroup.proto |  1 +
 seize.c               |  5 +++++
 4 files changed, 17 insertions(+)

diff --git a/cgroup.c b/cgroup.c
index 7d8f1be..c6718f9 100644
--- a/cgroup.c
+++ b/cgroup.c
@@ -17,6 +17,7 @@
 #include "imgset.h"
 #include "util-pie.h"
 #include "namespaces.h"
+#include "seize.h"
 #include "protobuf.h"
 #include "protobuf/core.pb-c.h"
 #include "protobuf/cgroup.pb-c.h"
@@ -788,6 +789,14 @@ static int dump_sets(CgroupEntry *cg)
 	return 0;
 }
 
+static void dump_real_freezer_state(CgroupEntry *cg)
+{
+	if (opts.freeze_cgroup) {
+		cg->freezer_state = xstrdup(get_real_freezer_state());
+	}
+}
+
+
 int dump_cgroups(void)
 {
 	CgroupEntry cg = CGROUP_ENTRY__INIT;
@@ -816,6 +825,7 @@ int dump_cgroups(void)
 		return -1;
 	if (dump_controllers(&cg))
 		return -1;
+	dump_real_freezer_state(&cg);
 
 	pr_info("Writing CG image\n");
 	return pb_write_one(img_from_set(glob_imgset, CR_FD_CGROUP), &cg, PB_CGROUP);
diff --git a/include/seize.h b/include/seize.h
index 3c23e24..315fab2 100644
--- a/include/seize.h
+++ b/include/seize.h
@@ -3,5 +3,6 @@
 
 extern int collect_pstree(pid_t pid);
 extern void pstree_switch_state(struct pstree_item *root_item, int st);
+extern const char *get_real_freezer_state(void);
 
 #endif
diff --git a/protobuf/cgroup.proto b/protobuf/cgroup.proto
index 2084388..97b70a1 100644
--- a/protobuf/cgroup.proto
+++ b/protobuf/cgroup.proto
@@ -27,4 +27,5 @@ message cg_set_entry {
 message cgroup_entry {
 	repeated cg_set_entry		sets		= 1;
 	repeated cg_controller_entry	controllers	= 2;
+	optional string			freezer_state	= 3;
 }
diff --git a/seize.c b/seize.c
index 11b5ad8..744e0ea 100644
--- a/seize.c
+++ b/seize.c
@@ -55,6 +55,11 @@ err:
 
 static bool freezer_thawed;
 
+const char *get_real_freezer_state(void)
+{
+	return freezer_thawed ? thawed : frozen;
+}
+
 static int freezer_restore_state(void)
 {
 	int fd;
-- 
1.9.1



More information about the CRIU mailing list