[CRIU] [PATCH] cgroup: Skip unified hier controllers (v2)

Pavel Emelyanov xemul at virtuozzo.com
Thu Jun 29 13:24:55 MSK 2017


The unified hierarchy controller doesn't have any name, so criu hangs
while parsing this sort of strings.

Let's skip those for now, until we implement cgroup2 support.

https://github.com/xemul/criu/issues/252

v2: Code comments

Reported-and-tested-by: Adrian Reber <adrian at lisas.de>
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/proc_parse.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/criu/proc_parse.c b/criu/proc_parse.c
index b8881d2..4609633 100644
--- a/criu/proc_parse.c
+++ b/criu/proc_parse.c
@@ -2335,8 +2335,19 @@ int parse_cgroup_file(FILE *f, struct list_head *retl, unsigned int *n)
 		 * 2:name=systemd:/user.slice/user-1000.slice/session-1.scope
 		 */
 		name = strchr(buf, ':');
-		if (name)
+		if (name) {
 			path = strchr(++name, ':');
+			if (*name == ':') {
+				/*
+				 * It's unified hierarchy. On kernels with legacy
+				 * tree this item is added automatically, so we
+				 * can just skip one. For those with full unified
+				 * support is on ... we need to write new code.
+				 */
+				xfree(ncc);
+				continue;
+			}
+		}
 		if (!name || !path) {
 			pr_err("Failed parsing cgroup %s\n", buf);
 			xfree(ncc);
@@ -2500,6 +2511,13 @@ int collect_controllers(struct list_head *cgroups, unsigned int *n_cgroups)
 		}
 		controllers++;
 
+		if (*controllers == ':')
+			/*
+			 * Unified hier. See comment in parse_cgroup_file
+			 * for more details.
+			 */
+			continue;
+
 		off = strchr(controllers, ':');
 		if (!off) {
 			pr_err("Unable to parse \"%s\"\n", buf);
-- 
2.1.4



More information about the CRIU mailing list