The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/3931

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Prefix local paths with `/var/lib/snapd/hostfs` when running in the snap.
From 32cc148ce1a35a51929caad2544c315867b2e00a Mon Sep 17 00:00:00 2001
From: Alberto Donato <[email protected]>
Date: Tue, 10 Oct 2017 09:29:53 +0200
Subject: [PATCH 1/2] lxc/file: use shared.HostPath for push/pull

Signed-off-by: Alberto Donato <[email protected]>
---
 lxc/file.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lxc/file.go b/lxc/file.go
index 8373ca7e6..1d1a3e893 100644
--- a/lxc/file.go
+++ b/lxc/file.go
@@ -77,7 +77,7 @@ func (c *fileCmd) recursivePullFile(d lxd.ContainerServer, 
container string, p s
                return err
        }
 
-       target := filepath.Join(targetDir, filepath.Base(p))
+       target := filepath.Join(shared.HostPath(targetDir), filepath.Base(p))
        if resp.Type == "directory" {
                err := os.Mkdir(target, os.FileMode(resp.Mode))
                if err != nil {
@@ -116,7 +116,7 @@ func (c *fileCmd) recursivePullFile(d lxd.ContainerServer, 
container string, p s
 }
 
 func (c *fileCmd) recursivePushFile(d lxd.ContainerServer, container string, 
source string, target string) error {
-       source = filepath.Clean(source)
+       source = shared.HostPath(filepath.Clean(source))
        sourceDir, _ := filepath.Split(source)
        sourceLen := len(sourceDir)
 

From bad4777d875bb9406fc1e4ba74c7a4f2c9be6092 Mon Sep 17 00:00:00 2001
From: Alberto Donato <[email protected]>
Date: Tue, 10 Oct 2017 09:37:50 +0200
Subject: [PATCH 2/2] lxc/image: use shared.HostPath for import/export

Signed-off-by: Alberto Donato <[email protected]>
---
 lxc/image.go | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lxc/image.go b/lxc/image.go
index 286bb4681..4a629083b 100644
--- a/lxc/image.go
+++ b/lxc/image.go
@@ -630,7 +630,7 @@ func (c *imageCmd) run(conf *config.Config, args []string) 
error {
 
                for _, arg := range args[1:] {
                        split := strings.Split(arg, "=")
-                       if len(split) == 1 || shared.PathExists(arg) {
+                       if len(split) == 1 || 
shared.PathExists(shared.HostPath(arg)) {
                                if strings.HasSuffix(arg, ":") {
                                        var err error
                                        remote, _, err = conf.ParseRemote(arg)
@@ -657,6 +657,7 @@ func (c *imageCmd) run(conf *config.Config, args []string) 
error {
                        imageFile = args[1]
                        properties = properties[1:]
                }
+               imageFile = shared.HostPath(imageFile)
 
                d, err := conf.GetContainerServer(remote)
                if err != nil {
@@ -881,7 +882,8 @@ func (c *imageCmd) run(conf *config.Config, args []string) 
error {
                                targetMeta = args[2]
                        }
                }
-               targetRootfs := targetMeta + ".root"
+               targetMeta = shared.HostPath(targetMeta)
+               targetRootfs := shared.HostPath(targetMeta + ".root")
 
                // Prepare the files
                dest, err := os.Create(targetMeta)
@@ -927,7 +929,7 @@ func (c *imageCmd) run(conf *config.Config, args []string) 
error {
                // Rename files
                if shared.IsDir(target) {
                        if resp.MetaName != "" {
-                               err := os.Rename(targetMeta, 
filepath.Join(target, resp.MetaName))
+                               err := os.Rename(targetMeta, 
shared.HostPath(filepath.Join(target, resp.MetaName)))
                                if err != nil {
                                        os.Remove(targetMeta)
                                        os.Remove(targetRootfs)
@@ -937,7 +939,7 @@ func (c *imageCmd) run(conf *config.Config, args []string) 
error {
                        }
 
                        if resp.RootfsSize > 0 && resp.RootfsName != "" {
-                               err := os.Rename(targetRootfs, 
filepath.Join(target, resp.RootfsName))
+                               err := os.Rename(targetRootfs, 
shared.HostPath(filepath.Join(target, resp.RootfsName)))
                                if err != nil {
                                        os.Remove(targetMeta)
                                        os.Remove(targetRootfs)
_______________________________________________
lxc-devel mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to