[CRIU] [PATCH 01/10] cgroup: allow restoring from multi-headed freezer cgroups

Tycho Andersen tycho.andersen at canonical.com
Wed Mar 2 11:28:50 PST 2016


b428a3a2fb01eed34e01112b6ba1f60b25b25196 allows dumping containers with
multi-headed freezer cgroups, but we can't restore these containers without
some help at restore time too.

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 criu/cgroup.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/criu/cgroup.c b/criu/cgroup.c
index 7742fda..218a6e4 100644
--- a/criu/cgroup.c
+++ b/criu/cgroup.c
@@ -1209,9 +1209,27 @@ int restore_freezer_state(void)
 
 static void add_freezer_state_for_restore(CgroupPropEntry *entry, char *path, size_t path_len)
 {
-	BUG_ON(freezer_state_entry);
 	BUG_ON(path_len >= sizeof(freezer_path));
 
+	if (freezer_state_entry) {
+		int max_len, i;
+
+		max_len = strlen(freezer_path);
+		if (max_len > path_len)
+			max_len = path_len;
+
+		/* If there are multiple freezer.state properties, that means they had
+		 * one common path prefix with no tasks in it. Let's find that common
+		 * prefix.
+		 */
+		for (i = 0; i < max_len; i++) {
+			if (freezer_path[i] != path[i]) {
+				freezer_path[i] = 0;
+				return;
+			}
+		}
+	}
+
 	freezer_state_entry = entry;
 	/* Path is not null terminated at path_len */
 	strncpy(freezer_path, path, path_len);
-- 
2.7.0



More information about the CRIU mailing list