[lxc-devel] [lxd/master] {container_lxc, test}: runtime liblxc fixes

brauner on Github lxc-bot at linuxcontainers.org
Wed Nov 15 16:15:52 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20171115/fe325697/attachment.bin>
-------------- next part --------------
From 6eafeef2fe1329dad3d166a4882c3cb9f1d0b8a5 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Wed, 15 Nov 2017 17:08:09 +0100
Subject: [PATCH 1/2] container_lxc: check runtime version for new keys

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 lxd/container_lxc.go | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index b3bb3238b..dc042da91 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -160,6 +160,24 @@ func lxcSetConfigItem(c *lxc.Container, key string, value string) error {
 		}
 	}
 
+	if key == "lxc.console.logsize" {
+		if !util.RuntimeLiblxcVersionAtLeast(3, 0, 0) {
+			return fmt.Errorf(`The console ringbuffer options require libxc >= 3.0`)
+		}
+	}
+
+	if key == "lxc.console.rotate" {
+		if !util.RuntimeLiblxcVersionAtLeast(3, 0, 0) {
+			return fmt.Errorf(`Rotating the console logfile requires libxc >= 3.0`)
+		}
+	}
+
+	if strings.HasPrefix(key, "lxc.console.buffer.") {
+		if !util.RuntimeLiblxcVersionAtLeast(3, 0, 0) {
+			return fmt.Errorf(`The console ringbuffer options require libxc >= 3.0`)
+		}
+	}
+
 	err := c.SetConfigItem(key, value)
 	if err != nil {
 		return fmt.Errorf("Failed to set LXC config: %s=%s", key, value)

From 9810ec209a145f2af8ab689329e6ce82ff63b454 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Wed, 15 Nov 2017 17:12:27 +0100
Subject: [PATCH 2/2] test: skip console tests on lower versions

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 test/suites/console.sh | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/test/suites/console.sh b/test/suites/console.sh
index 5b49247e4..8c1733940 100644
--- a/test/suites/console.sh
+++ b/test/suites/console.sh
@@ -1,4 +1,14 @@
 test_console() {
+  lxc_version=$(lxc info | grep "driver_version: " | cut -d' ' -f4)
+  lxc_major=$(echo "${lxc_version}" | cut -d. -f1)
+
+  if [ "${lxc_major}" -lt 3 ]; then
+    echo "==> SKIP: The console ringbuffer require liblxc 3.0 or higher"
+    return
+  fi
+
+  echo "==> API extension console"
+
   ensure_import_testimage
 
   lxc init testimage cons1


More information about the lxc-devel mailing list