[lxc-devel] [lxd/master] lxd/migration: Fix CRIU rsync option negotiation

stgraber on Github lxc-bot at linuxcontainers.org
Fri Nov 9 22:26:41 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 597 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181109/7d1b8ee9/attachment.bin>
-------------- next part --------------
From ef371a7f1d48842978474558ca92ff3ead0548f6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 9 Nov 2018 17:23:50 -0500
Subject: [PATCH] lxd/migration: Fix CRIU rsync option negotiation
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The source advertises what it will use, then the sink has to adapt and
receive it. We were doing pointless feature advertisement on the sink
side and then not passing the needed options for the CRIU part of the
transfer.

Closes #5243

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/migrate_container.go | 54 ++++++++++++++++++----------------------
 1 file changed, 24 insertions(+), 30 deletions(-)

diff --git a/lxd/migrate_container.go b/lxd/migrate_container.go
index fe64fbbf18..bbc22fabcd 100644
--- a/lxd/migrate_container.go
+++ b/lxd/migrate_container.go
@@ -670,13 +670,12 @@ func (s *migrationSourceWs) Do(migrateOp *operation) error {
 
 func NewMigrationSink(args *MigrationSinkArgs) (*migrationSink, error) {
 	sink := migrationSink{
-		src:       migrationFields{container: args.Container, containerOnly: args.ContainerOnly},
-		dest:      migrationFields{containerOnly: args.ContainerOnly},
-		url:       args.Url,
-		dialer:    args.Dialer,
-		push:      args.Push,
-		rsyncArgs: args.RsyncArgs,
-		refresh:   args.Refresh,
+		src:     migrationFields{container: args.Container, containerOnly: args.ContainerOnly},
+		dest:    migrationFields{containerOnly: args.ContainerOnly},
+		url:     args.Url,
+		dialer:  args.Dialer,
+		push:    args.Push,
+		refresh: args.Refresh,
 	}
 
 	if sink.push {
@@ -785,6 +784,20 @@ func (c *migrationSink) Do(migrateOp *operation) error {
 		return err
 	}
 
+	// Handle rsync options
+	c.rsyncArgs = []string{}
+	rsyncFeatures := header.GetRsyncFeatures()
+	if rsyncFeatures.GetXattrs() {
+		c.rsyncArgs = append(c.rsyncArgs, "--xattrs")
+	}
+	if rsyncFeatures.GetDelete() {
+		c.rsyncArgs = append(c.rsyncArgs, "--delete")
+	}
+	if rsyncFeatures.GetCompress() {
+		c.rsyncArgs = append(c.rsyncArgs, "--compress")
+		c.rsyncArgs = append(c.rsyncArgs, "--compress-level=2")
+	}
+
 	live := c.src.live
 	if c.push {
 		live = c.dest.live
@@ -805,15 +818,9 @@ func (c *migrationSink) Do(migrateOp *operation) error {
 	}
 
 	myType := c.src.container.Storage().MigrationType()
-	rsyncHasFeature := true
 	resp := migration.MigrationHeader{
-		Fs:   &myType,
-		Criu: criuType,
-		RsyncFeatures: &migration.RsyncFeatures{
-			Xattrs:   &rsyncHasFeature,
-			Delete:   &rsyncHasFeature,
-			Compress: &rsyncHasFeature,
-		},
+		Fs:            &myType,
+		Criu:          criuType,
 		Snapshots:     header.Snapshots,
 		SnapshotNames: header.SnapshotNames,
 		Refresh:       &c.refresh,
@@ -931,21 +938,8 @@ func (c *migrationSink) Do(migrateOp *operation) error {
 			}
 
 			args := MigrationSinkArgs{
-				Refresh: c.refresh,
-			}
-			rsyncFeatures := header.GetRsyncFeatures()
-
-			// Handle rsync options
-			args.RsyncArgs = []string{}
-			if rsyncFeatures.GetXattrs() {
-				args.RsyncArgs = append(args.RsyncArgs, "--xattrs")
-			}
-			if rsyncFeatures.GetDelete() {
-				args.RsyncArgs = append(args.RsyncArgs, "--delete")
-			}
-			if rsyncFeatures.GetCompress() {
-				args.RsyncArgs = append(args.RsyncArgs, "--compress")
-				args.RsyncArgs = append(args.RsyncArgs, "--compress-level=2")
+				Refresh:   c.refresh,
+				RsyncArgs: c.rsyncArgs,
 			}
 
 			err = mySink(sendFinalFsDelta, c.src.container,


More information about the lxc-devel mailing list