[lxc-devel] [lxd/master] lxd/cgroup: Fix swap limits

stgraber on Github lxc-bot at linuxcontainers.org
Wed Nov 11 03:26:35 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/20201110/8e40c0a0/attachment.bin>
-------------- next part --------------
From c16f6407d64b126ba97e8f3676476c29869bf5e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 10 Nov 2020 22:26:14 -0500
Subject: [PATCH] lxd/cgroup: Fix swap limits
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/abstraction.go | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lxd/cgroup/abstraction.go b/lxd/cgroup/abstraction.go
index 4727021032..f78da3ab95 100644
--- a/lxd/cgroup/abstraction.go
+++ b/lxd/cgroup/abstraction.go
@@ -172,6 +172,10 @@ func (cg *CGroup) SetMemorySwapLimit(limit int64) error {
 	case Unavailable:
 		return ErrControllerMissing
 	case V1:
+		if limit == -1 {
+			return cg.rw.Set(version, "memory", "memory.memsw.limit_in_bytes", "-1")
+		}
+
 		val, err := cg.rw.Get(version, "memory", "memory.limit_in_bytes")
 		if err != nil {
 			return err


More information about the lxc-devel mailing list