[lxc-devel] [lxd/master] lxd/rsync: Don't pass --bwlimit when no limits set

stgraber on Github lxc-bot at linuxcontainers.org
Wed Aug 5 23:00:27 UTC 2020


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/20200805/76020135/attachment.bin>
-------------- next part --------------
From c978a20c2432314bed0caedac2680432aa17ffd5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 5 Aug 2020 18:59:32 -0400
Subject: [PATCH] lxd/rsync: Don't pass --bwlimit when no limits set
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>
---
 lxd/rsync/rsync.go | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/lxd/rsync/rsync.go b/lxd/rsync/rsync.go
index db22f123ef..13a37eeca6 100644
--- a/lxd/rsync/rsync.go
+++ b/lxd/rsync/rsync.go
@@ -33,10 +33,6 @@ func LocalCopy(source string, dest string, bwlimit string, xattrs bool, rsyncArg
 		rsyncVerbosity = "-vi"
 	}
 
-	if bwlimit == "" {
-		bwlimit = "0"
-	}
-
 	args := []string{
 		"-a",
 		"-HA",
@@ -123,9 +119,6 @@ func sendSetup(name string, path string, bwlimit string, execPath string, featur
 	 * hardcoding that at the other end, so we can just ignore it.
 	 */
 	rsyncCmd := fmt.Sprintf("sh -c \"%s netcat %s %s\"", execPath, auds, name)
-	if bwlimit == "" {
-		bwlimit = "0"
-	}
 
 	args := []string{
 		"-ar",
@@ -135,6 +128,10 @@ func sendSetup(name string, path string, bwlimit string, execPath string, featur
 		"--sparse",
 	}
 
+	if bwlimit != "" {
+		args = append(args, "--bwlimit", bwlimit)
+	}
+
 	if features != nil && len(features) > 0 {
 		args = append(args, rsyncFeatureArgs(features)...)
 	}
@@ -147,9 +144,7 @@ func sendSetup(name string, path string, bwlimit string, execPath string, featur
 		path,
 		"localhost:/tmp/foo",
 		"-e",
-		rsyncCmd,
-		"--bwlimit",
-		bwlimit}...)
+		rsyncCmd}...)
 
 	cmd := exec.Command("rsync", args...)
 


More information about the lxc-devel mailing list