The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/2383

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
On low-memory systems (below 2GB of RAM), limit unsquashfs to a single
CPU and to 10% of the RAM for its fragment size.

Closes #2382

Signed-off-by: Stéphane Graber <[email protected]>
From 5306765c7fe2a4f46ab0019b05a16892fc7e25cb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <[email protected]>
Date: Thu, 15 Sep 2016 16:01:57 -0400
Subject: [PATCH] Tweak squashfs for low-memory systems
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On low-memory systems (below 2GB of RAM), limit unsquashfs to a single
CPU and to 10% of the RAM for its fragment size.

Closes #2382

Signed-off-by: Stéphane Graber <[email protected]>
---
 lxd/images.go | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lxd/images.go b/lxd/images.go
index 842a923..70b33e6 100644
--- a/lxd/images.go
+++ b/lxd/images.go
@@ -99,6 +99,13 @@ func unpack(file string, path string) error {
        } else if strings.HasPrefix(extension, ".squashfs") {
                command = "unsquashfs"
                args = append(args, "-f", "-d", path, "-n")
+
+               mem, err := deviceTotalMemory()
+               mem = mem / 1024 / 1024 / 10
+               if err == nil && mem < 256 {
+                       args = append(args, "-da", fmt.Sprintf("%d", mem), 
"-fr", fmt.Sprintf("%d", mem), "-p", "1")
+               }
+
                args = append(args, file)
        } else {
                return fmt.Errorf("Unsupported image format: %s", extension)
_______________________________________________
lxc-devel mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to