[lxc-devel] [lxd/master] state: fix state dir

tych0 on Github lxc-bot at linuxcontainers.org
Wed May 4 21:29:19 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 509 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160504/cc259edd/attachment.bin>
-------------- next part --------------
From 301191d557e688870c4d16480e8aa8a323bc21ff Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.andersen at canonical.com>
Date: Wed, 4 May 2016 21:24:40 +0000
Subject: [PATCH] state: fix state dir

We were using /containers/$container/rootfs/state as the directory to save
CRIU state in; instead, let's just use /containers/$container/state.

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

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 2d8e22e..0e4c622 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -4494,5 +4494,13 @@ func (c *containerLXC) TemplatesPath() string {
 }
 
 func (c *containerLXC) StatePath() string {
-	return filepath.Join(c.RootfsPath(), "state")
+	/* FIXME: backwards compatibility: we used to use Join(RootfsPath(),
+	 * "state"), which was bad. Let's just check to see if that directory
+	 * exists.
+	 */
+	oldStatePath := filepath.Join(c.RootfsPath(), "state")
+	if shared.IsDir(oldStatePath) {
+		return oldStatePath
+	}
+	return filepath.Join(c.Path(), "state")
 }


More information about the lxc-devel mailing list