[lxc-devel] [lxd/master] lxd/cgroup: Fix V2 detection/handling

stgraber on Github lxc-bot at linuxcontainers.org
Fri Nov 6 22:34:01 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20201106/76ec5e9a/attachment.bin>
-------------- next part --------------
From 79aca195c917f1ba851c9a4ae0b490e4d6e6de11 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 6 Nov 2020 17:33:45 -0500
Subject: [PATCH] lxd/cgroup: Fix V2 detection/handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/cgroup/init.go | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lxd/cgroup/init.go b/lxd/cgroup/init.go
index 8fa085a06f..732d4afa40 100644
--- a/lxd/cgroup/init.go
+++ b/lxd/cgroup/init.go
@@ -358,8 +358,10 @@ func init() {
 
 			scanControllers := bufio.NewScanner(controllers)
 			for scanControllers.Scan() {
-				line := strings.TrimSpace(scanSelfCg.Text())
-				unifiedControllers[line] = V2
+				line := strings.TrimSpace(scanControllers.Text())
+				for _, entry := range strings.Split(line, " ") {
+					unifiedControllers[entry] = V2
+				}
 			}
 			hasV2 = true
 
@@ -411,11 +413,11 @@ func init() {
 
 	val, ok = cgControllers["memory"]
 	if ok && val == V2 {
-		if shared.PathExists("/sys/fs/cgroup/memory/memory.swap.max") {
+		if shared.PathExists("/sys/fs/cgroup/memory.swap.max") {
 			cgControllers["memory.swap.max"] = V2
 		}
 
-		if shared.PathExists("/sys/fs/cgroup/memory/memory.swap.current") {
+		if shared.PathExists("/sys/fs/cgroup/memory.swap.current") {
 			cgControllers["memory.swap.current"] = V2
 		}
 	}


More information about the lxc-devel mailing list