[lxc-devel] [lxd/master] zfs: Fix cross-backend copies
stgraber on Github
lxc-bot at linuxcontainers.org
Wed Feb 3 21:59:22 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 581 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160203/24d7698d/attachment.bin>
-------------- next part --------------
From 3bea9bb6f10d2b54eb168b13a92a0f21c3b9e5b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 3 Feb 2016 22:42:02 +0100
Subject: [PATCH] zfs: Fix cross-backend copies
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Without this change, copying a non-zfs container to a new container
that's backed by zfs was failing due to ContainerCreate already creating
the symlink and setting the permissions on the new path.
Reported-by: Brad Figg
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/storage_zfs.go | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/lxd/storage_zfs.go b/lxd/storage_zfs.go
index 9f50082..61a92ed 100644
--- a/lxd/storage_zfs.go
+++ b/lxd/storage_zfs.go
@@ -286,6 +286,24 @@ func (s *storageZfs) ContainerCopy(container container, sourceContainer containe
if err != nil {
return err
}
+
+ cPath := container.Path()
+ err = os.Symlink(cPath+".zfs", cPath)
+ if err != nil {
+ return err
+ }
+
+ var mode os.FileMode
+ if container.IsPrivileged() {
+ mode = 0700
+ } else {
+ mode = 0755
+ }
+
+ err = os.Chmod(cPath, mode)
+ if err != nil {
+ return err
+ }
} else {
err := s.ContainerCreate(container)
if err != nil {
@@ -298,24 +316,6 @@ func (s *storageZfs) ContainerCopy(container container, sourceContainer containe
}
}
- cPath := container.Path()
- err := os.Symlink(cPath+".zfs", cPath)
- if err != nil {
- return err
- }
-
- var mode os.FileMode
- if container.IsPrivileged() {
- mode = 0700
- } else {
- mode = 0755
- }
-
- err = os.Chmod(cPath, mode)
- if err != nil {
- return err
- }
-
return container.TemplateApply("copy")
}
More information about the lxc-devel
mailing list