[lxc-devel] [lxd/master] container: use lxcSetConfigItem() for lxc.log.file

brauner on Github lxc-bot at linuxcontainers.org
Mon Jul 2 13:01:20 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 953 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180702/1e3797bb/attachment.bin>
-------------- next part --------------
From 0011d2b5d05797b91df6d302c53f3a80f82364f0 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Mon, 2 Jul 2018 14:55:51 +0200
Subject: [PATCH] container: use lxcSetConfigItem() for lxc.log.file

So far we've been using the go-lxc SetLogFile() function. The problem is that
the go-lxc shared library might have been linked against an older liblxc than
LXD. In that case SetLogFile() will check:

if VersionAtLeast(2, 1, 0) {
        err = c.setConfigItem("lxc.log.file", filename)
} else {
        err = c.setConfigItem("lxc.logfile", filename)
}

but VersionAtLeast() will not check the runtime but the linked liblxc version
and thus set the wrong config item.
Fix this by using lxcSetConfigItem() which will check against the runtime
liblxc version.

Closes #4713.

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

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index f5c4db983..77b53cb36 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -909,8 +909,7 @@ func (c *containerLXC) initLXC(config bool) error {
 
 	// Setup logging
 	logfile := c.LogFilePath()
-
-	err = cc.SetLogFile(logfile)
+	err = lxcSetConfigItem(cc, "lxc.log.file", logfile)
 	if err != nil {
 		return err
 	}


More information about the lxc-devel mailing list