[lxc-devel] [lxd/master] exec: create config file before referencing it

tych0 on Github lxc-bot at linuxcontainers.org
Wed Apr 13 17:29:31 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 574 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160413/5176f4dd/attachment.bin>
-------------- next part --------------
From 7b7c4a5d74a571472d814fc57ae849e9f8b0eb48 Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.andersen at canonical.com>
Date: Wed, 13 Apr 2016 11:26:17 -0600
Subject: [PATCH] exec: create config file before referencing it

This config file is created when starting a container, but not migrating it
or resuming it or probably some other cases. Instead, let's just always
create it so that we don't have to worry about it existing.

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 lxd/container_lxc.go | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 68b25e1..140d301 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -2987,7 +2987,13 @@ func (c *containerLXC) Exec(command []string, env map[string]string, stdin *os.F
 		envSlice = append(envSlice, fmt.Sprintf("%s=%s", k, v))
 	}
 
-	args := []string{c.daemon.execPath, "forkexec", c.name, c.daemon.lxcpath, filepath.Join(c.LogPath(), "lxc.conf")}
+	configPath := filepath.Join(c.LogPath(), "lxc.conf")
+	err := c.c.SaveConfigFile(configPath)
+	if err != nil {
+		return -1, err
+	}
+
+	args := []string{c.daemon.execPath, "forkexec", c.name, c.daemon.lxcpath, configPath}
 
 	args = append(args, "--")
 	args = append(args, "env")


More information about the lxc-devel mailing list