[lxc-devel] [lxc/master] cgroups: skip v2 hierarchy entry

brauner on Github lxc-bot at linuxcontainers.org
Thu Nov 10 23:31:45 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 367 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20161110/4726641d/attachment.bin>
-------------- next part --------------
From ff8d6ee93625f3cb3399522f7c69ed0efe1cf357 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Fri, 11 Nov 2016 00:29:15 +0100
Subject: [PATCH] cgroups: skip v2 hierarchy entry

Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
 src/lxc/cgroups/cgfsng.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
index ec94099..992096a 100644
--- a/src/lxc/cgroups/cgfsng.c
+++ b/src/lxc/cgroups/cgfsng.c
@@ -686,6 +686,18 @@ static void get_existing_subsystems(char ***klist, char ***nlist)
 		if (!p2)
 			continue;
 		*p2 = '\0';
+
+		/* If we have a mixture between cgroup v1 and cgroup v2
+		 * hierarchies, then /proc/self/cgroup contains entries of the
+		 * form:
+		 *
+		 *	0::/some/path
+		 *
+		 * We need to skip those.
+		 */
+		if ((p2 - p) == 0)
+			continue;
+
 		for (tok = strtok_r(p, ",", &saveptr); tok;
 				tok = strtok_r(NULL, ",", &saveptr)) {
 			if (strncmp(tok, "name=", 5) == 0)


More information about the lxc-devel mailing list