[lxc-devel] [lxd/master] write the container's config file on start to the log path directly

tych0 on Github lxc-bot at linuxcontainers.org
Thu Apr 14 21:12:00 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 460 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160414/326a9f05/attachment.bin>
-------------- next part --------------
From 068313ad07d8971cd148a345463310227fcdad39 Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.andersen at canonical.com>
Date: Thu, 14 Apr 2016 15:10:54 -0600
Subject: [PATCH] write the container's config file on start to the log path
 directly

Now that we're dending on this file to exist in all cases when execing,
let's always write it.

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 lxd/container_lxc.go | 14 +-------------
 lxd/containers.go    |  3 ---
 2 files changed, 1 insertion(+), 16 deletions(-)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index e5adcfc..4cd1524 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -1084,19 +1084,7 @@ func (c *containerLXC) startCommon() (string, error) {
 	}
 
 	// Generate the LXC config
-	f, err := ioutil.TempFile("", "lxd_lxc_startconfig_")
-	if err != nil {
-		return "", err
-	}
-
-	configPath := f.Name()
-	if err = f.Chmod(0600); err != nil {
-		f.Close()
-		os.Remove(configPath)
-		return "", err
-	}
-	f.Close()
-
+	configPath := filepath.Join(c.LogPath(), "lxc.conf")
 	err = c.c.SaveConfigFile(configPath)
 	if err != nil {
 		os.Remove(configPath)
diff --git a/lxd/containers.go b/lxd/containers.go
index 4231399..b125768 100644
--- a/lxd/containers.go
+++ b/lxd/containers.go
@@ -240,9 +240,6 @@ func startContainer(args []string) error {
 		syscall.Dup3(int(logFile.Fd()), 2, 0)
 	}
 
-	// Move the config so we can inspect it on failure
-	shared.FileMove(configPath, shared.LogPath(name, "lxc.conf"))
-
 	return c.Start()
 }
 


More information about the lxc-devel mailing list