[lxc-devel] [lxd/master] lxc/{import, export}: Deal with snap paths

stgraber on Github lxc-bot at linuxcontainers.org
Wed Jun 13 11:45:50 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180613/59977882/attachment.bin>
-------------- next part --------------
From dfd7906636f1b1ce52076acfad247fa78994e621 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 13 Jun 2018 07:43:38 -0400
Subject: [PATCH] lxc/{import,export}: Deal with snap paths
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #4643

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxc/export.go | 3 ++-
 lxc/import.go | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lxc/export.go b/lxc/export.go
index 8afbac8e8..1a38c2130 100644
--- a/lxc/export.go
+++ b/lxc/export.go
@@ -10,6 +10,7 @@ import (
 
 	"github.com/lxc/lxd/client"
 	"github.com/lxc/lxd/lxc/utils"
+	"github.com/lxc/lxd/shared"
 	"github.com/lxc/lxd/shared/api"
 	cli "github.com/lxc/lxd/shared/cmd"
 	"github.com/lxc/lxd/shared/i18n"
@@ -96,7 +97,7 @@ func (c *cmdExport) Run(cmd *cobra.Command, args []string) error {
 		targetName = "backup.tar.xz"
 	}
 
-	target, err := os.Create(targetName)
+	target, err := os.Create(shared.HostPath(targetName))
 	if err != nil {
 		return err
 	}
diff --git a/lxc/import.go b/lxc/import.go
index 4d527afc8..b532a6a7d 100644
--- a/lxc/import.go
+++ b/lxc/import.go
@@ -6,6 +6,7 @@ import (
 	"github.com/spf13/cobra"
 
 	"github.com/lxc/lxd/client"
+	"github.com/lxc/lxd/shared"
 	cli "github.com/lxc/lxd/shared/cmd"
 	"github.com/lxc/lxd/shared/i18n"
 )
@@ -49,7 +50,7 @@ func (c *cmdImport) Run(cmd *cobra.Command, args []string) error {
 
 	resource := resources[0]
 
-	file, err := os.Open(args[len(args)-1])
+	file, err := os.Open(shared.HostPath(args[len(args)-1]))
 	if err != nil {
 		return nil
 	}


More information about the lxc-devel mailing list