[lxc-devel] [lxd/master] client: Fix copying between two unix sockets

stgraber on Github lxc-bot at linuxcontainers.org
Thu Apr 18 19:32:31 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190418/6e6bf8f0/attachment.bin>
-------------- next part --------------
From 1f1e557df60d454afa984f0ff47d22e1c3717dad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 18 Apr 2019 13:49:47 -0400
Subject: [PATCH] client: Fix copying between two unix sockets
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 client/connection.go     | 1 +
 client/interfaces.go     | 1 +
 client/lxd.go            | 2 ++
 client/lxd_containers.go | 2 +-
 4 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/client/connection.go b/client/connection.go
index 90875debd6..40932b3aa5 100644
--- a/client/connection.go
+++ b/client/connection.go
@@ -83,6 +83,7 @@ func ConnectLXDUnix(path string, args *ConnectionArgs) (ContainerServer, error)
 	// Initialize the client struct
 	server := ProtocolLXD{
 		httpHost:      "http://unix.socket",
+		httpUnixPath: path,
 		httpProtocol:  "unix",
 		httpUserAgent: args.UserAgent,
 	}
diff --git a/client/interfaces.go b/client/interfaces.go
index 29d0f40c3b..6e8cc7df3e 100644
--- a/client/interfaces.go
+++ b/client/interfaces.go
@@ -239,6 +239,7 @@ type ConnectionInfo struct {
 	Certificate string
 	Protocol    string
 	URL         string
+	SocketPath  string
 	Project     string
 }
 
diff --git a/client/lxd.go b/client/lxd.go
index a77f081890..06feece85f 100644
--- a/client/lxd.go
+++ b/client/lxd.go
@@ -30,6 +30,7 @@ type ProtocolLXD struct {
 	http            *http.Client
 	httpCertificate string
 	httpHost        string
+	httpUnixPath    string
 	httpProtocol    string
 	httpUserAgent   string
 
@@ -47,6 +48,7 @@ func (r *ProtocolLXD) GetConnectionInfo() (*ConnectionInfo, error) {
 	info.Certificate = r.httpCertificate
 	info.Protocol = "lxd"
 	info.URL = r.httpHost
+	info.SocketPath = r.httpUnixPath
 	info.Project = r.project
 	if info.Project == "" {
 		info.Project = "default"
diff --git a/client/lxd_containers.go b/client/lxd_containers.go
index 9d8dbfd957..17210f01b5 100644
--- a/client/lxd_containers.go
+++ b/client/lxd_containers.go
@@ -355,7 +355,7 @@ func (r *ProtocolLXD) CopyContainer(source ContainerServer, container api.Contai
 	}
 
 	// Optimization for the local copy case
-	if destInfo.URL == sourceInfo.URL && (!r.IsClustered() || container.Location == r.clusterTarget) {
+	if destInfo.URL == sourceInfo.URL && destInfo.SocketPath == sourceInfo.SocketPath && (!r.IsClustered() || container.Location == r.clusterTarget) {
 		// Project handling
 		if destInfo.Project != sourceInfo.Project {
 			if !r.HasExtension("container_copy_project") {


More information about the lxc-devel mailing list