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

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) ===
Closes #4962

Signed-off-by: Stéphane Graber <[email protected]>
From 7dfc2939ac278d8436ff4b892599c795c5482007 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <[email protected]>
Date: Thu, 23 Aug 2018 19:27:31 -0400
Subject: [PATCH] global: Advertise rsync features
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #4962

Signed-off-by: Stéphane Graber <[email protected]>
---
 lxc-to-lxd/utils.go            |   4 +-
 lxd-p2c/utils.go               |   4 +-
 lxd/migrate.go                 |   4 +
 lxd/migrate_container.go       |  31 +++++--
 lxd/migrate_storage_volumes.go |  16 +++-
 lxd/migration/migrate.pb.go    | 161 +++++++++++++++++++--------------
 lxd/migration/migrate.proto    |   5 +
 lxd/rsync.go                   |  16 +++-
 lxd/storage.go                 |   5 +-
 lxd/storage_btrfs.go           |   8 +-
 lxd/storage_ceph.go            |   4 +-
 lxd/storage_ceph_migration.go  |   2 +-
 lxd/storage_dir.go             |   8 +-
 lxd/storage_lvm.go             |   8 +-
 lxd/storage_migration.go       |  36 ++++----
 lxd/storage_mock.go            |   4 +-
 lxd/storage_zfs.go             |   6 +-
 17 files changed, 196 insertions(+), 126 deletions(-)

diff --git a/lxc-to-lxd/utils.go b/lxc-to-lxd/utils.go
index bcad65d8b1..2d3aea2381 100644
--- a/lxc-to-lxd/utils.go
+++ b/lxc-to-lxd/utils.go
@@ -31,8 +31,10 @@ func transferRootfs(dst lxd.ContainerServer, op 
lxd.Operation, rootfs string, rs
 
        // Setup control struct
        fs := migration.MigrationFSType_RSYNC
+       rsyncXattrs := true
        header := migration.MigrationHeader{
-               Fs: &fs,
+               Fs:            &fs,
+               RsyncFeatures: &migration.RsyncFeatures{Xattrs: &rsyncXattrs},
        }
 
        err = migration.ProtoSend(wsControl, &header)
diff --git a/lxd-p2c/utils.go b/lxd-p2c/utils.go
index 0b5b388ecd..de82041c79 100644
--- a/lxd-p2c/utils.go
+++ b/lxd-p2c/utils.go
@@ -32,8 +32,10 @@ func transferRootfs(dst lxd.ContainerServer, op 
lxd.Operation, rootfs string, rs
 
        // Setup control struct
        fs := migration.MigrationFSType_RSYNC
+       rsyncXattrs := true
        header := migration.MigrationHeader{
-               Fs: &fs,
+               RsyncFeatures: &migration.RsyncFeatures{Xattrs: &rsyncXattrs},
+               Fs:            &fs,
        }
 
        err = migration.ProtoSend(wsControl, &header)
diff --git a/lxd/migrate.go b/lxd/migrate.go
index febc73d1e9..4d94fa5115 100644
--- a/lxd/migrate.go
+++ b/lxd/migrate.go
@@ -249,6 +249,7 @@ type migrationSink struct {
        dialer       websocket.Dialer
        allConnected chan bool
        push         bool
+       rsyncArgs    []string
 }
 
 type MigrationSinkArgs struct {
@@ -264,6 +265,9 @@ type MigrationSinkArgs struct {
 
        // storage specific fields
        Storage storage
+
+       // transport specific fields
+       RsyncArgs []string
 }
 
 func (c *migrationSink) connectWithSecret(secret string) (*websocket.Conn, 
error) {
diff --git a/lxd/migrate_container.go b/lxd/migrate_container.go
index 9cd8c6dcba..74f82f262c 100644
--- a/lxd/migrate_container.go
+++ b/lxd/migrate_container.go
@@ -379,6 +379,7 @@ func (s *migrationSourceWs) Do(migrateOp *operation) error {
        // The protocol says we have to send a header no matter what, so let's
        // do that, but then immediately send an error.
        myType := s.container.Storage().MigrationType()
+       rsyncXattrs := true
        header := migration.MigrationHeader{
                Fs:            &myType,
                Criu:          criuType,
@@ -386,6 +387,7 @@ func (s *migrationSourceWs) Do(migrateOp *operation) error {
                SnapshotNames: snapshotNames,
                Snapshots:     snapshots,
                Predump:       proto.Bool(use_pre_dumps),
+               RsyncFeatures: &migration.RsyncFeatures{Xattrs: &rsyncXattrs},
        }
 
        err = s.send(&header)
@@ -659,11 +661,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,
+               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,
        }
 
        if sink.push {
@@ -788,9 +791,11 @@ func (c *migrationSink) Do(migrateOp *operation) error {
 
        mySink := c.src.container.Storage().MigrationSink
        myType := c.src.container.Storage().MigrationType()
+       rsyncXattrs := true
        resp := migration.MigrationHeader{
-               Fs:   &myType,
-               Criu: criuType,
+               Fs:            &myType,
+               Criu:          criuType,
+               RsyncFeatures: &migration.RsyncFeatures{Xattrs: &rsyncXattrs},
        }
 
        // If the storage type the source has doesn't match what we have, then
@@ -870,9 +875,15 @@ func (c *migrationSink) Do(migrateOp *operation) error {
                                sendFinalFsDelta = true
                        }
 
+                       args := MigrationSinkArgs{}
+                       rsyncFeatures := header.GetRsyncFeatures()
+                       if rsyncFeatures.GetXattrs() {
+                               args.RsyncArgs = []string{"--xattrs"}
+                       }
+
                        err = mySink(sendFinalFsDelta, c.src.container,
                                snapshots, fsConn, srcIdmap, migrateOp,
-                               c.src.containerOnly)
+                               c.src.containerOnly, args)
                        if err != nil {
                                fsTransfer <- err
                                return
@@ -912,7 +923,7 @@ func (c *migrationSink) Do(migrateOp *operation) error {
                                for !sync.GetFinalPreDump() {
                                        logger.Debugf("About to receive rsync")
                                        // Transfer a CRIU pre-dump
-                                       err = 
RsyncRecv(shared.AddSlash(imagesDir), criuConn, nil)
+                                       err = 
RsyncRecv(shared.AddSlash(imagesDir), criuConn, nil, c.rsyncArgs)
                                        if err != nil {
                                                restore <- err
                                                return
@@ -940,7 +951,7 @@ func (c *migrationSink) Do(migrateOp *operation) error {
                        }
 
                        // Final CRIU dump
-                       err = RsyncRecv(shared.AddSlash(imagesDir), criuConn, 
nil)
+                       err = RsyncRecv(shared.AddSlash(imagesDir), criuConn, 
nil, c.rsyncArgs)
                        if err != nil {
                                restore <- err
                                return
diff --git a/lxd/migrate_storage_volumes.go b/lxd/migrate_storage_volumes.go
index 1055f9b315..b92cb3d7b5 100644
--- a/lxd/migrate_storage_volumes.go
+++ b/lxd/migrate_storage_volumes.go
@@ -47,8 +47,10 @@ func (s *migrationSourceWs) DoStorage(migrateOp *operation) 
error {
        // The protocol says we have to send a header no matter what, so let's
        // do that, but then immediately send an error.
        myType := s.storage.MigrationType()
+       rsyncXattrs := true
        header := migration.MigrationHeader{
-               Fs: &myType,
+               Fs:            &myType,
+               RsyncFeatures: &migration.RsyncFeatures{Xattrs: &rsyncXattrs},
        }
 
        err = s.send(&header)
@@ -213,8 +215,10 @@ func (c *migrationSink) DoStorage(migrateOp *operation) 
error {
 
        mySink := c.src.storage.StorageMigrationSink
        myType := c.src.storage.MigrationType()
+       rsyncXattrs := true
        resp := migration.MigrationHeader{
-               Fs: &myType,
+               Fs:            &myType,
+               RsyncFeatures: &migration.RsyncFeatures{Xattrs: &rsyncXattrs},
        }
 
        // If the storage type the source has doesn't match what we have, then
@@ -225,6 +229,12 @@ func (c *migrationSink) DoStorage(migrateOp *operation) 
error {
                resp.Fs = &myType
        }
 
+       args := MigrationSinkArgs{}
+       rsyncFeatures := header.GetRsyncFeatures()
+       if rsyncFeatures.GetXattrs() {
+               args.RsyncArgs = []string{"--xattrs"}
+       }
+
        err = sender(&resp)
        if err != nil {
                logger.Errorf("Failed to send storage volume migration header")
@@ -239,7 +249,7 @@ func (c *migrationSink) DoStorage(migrateOp *operation) 
error {
                fsConn = c.src.fsConn
        }
 
-       err = mySink(fsConn, migrateOp, c.dest.storage)
+       err = mySink(fsConn, migrateOp, c.dest.storage, args)
        if err != nil {
                logger.Errorf("Failed to start storage volume migration sink")
                controller(err)
diff --git a/lxd/migration/migrate.pb.go b/lxd/migration/migrate.pb.go
index 13e68f3067..456ffd16e3 100644
--- a/lxd/migration/migrate.pb.go
+++ b/lxd/migration/migrate.pb.go
@@ -12,6 +12,7 @@ It has these top-level messages:
        Config
        Device
        Snapshot
+       RsyncFeatures
        MigrationHeader
        MigrationControl
        MigrationSync
@@ -293,6 +294,23 @@ func (m *Snapshot) GetLastUsedDate() int64 {
        return 0
 }
 
+type RsyncFeatures struct {
+       Xattrs           *bool  `protobuf:"varint,1,opt,name=xattrs" 
json:"xattrs,omitempty"`
+       XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *RsyncFeatures) Reset()                    { *m = RsyncFeatures{} }
+func (m *RsyncFeatures) String() string            { return 
proto.CompactTextString(m) }
+func (*RsyncFeatures) ProtoMessage()               {}
+func (*RsyncFeatures) Descriptor() ([]byte, []int) { return fileDescriptor0, 
[]int{4} }
+
+func (m *RsyncFeatures) GetXattrs() bool {
+       if m != nil && m.Xattrs != nil {
+               return *m.Xattrs
+       }
+       return false
+}
+
 type MigrationHeader struct {
        Fs               *MigrationFSType 
`protobuf:"varint,1,req,name=fs,enum=migration.MigrationFSType" 
json:"fs,omitempty"`
        Criu             *CRIUType        
`protobuf:"varint,2,opt,name=criu,enum=migration.CRIUType" 
json:"criu,omitempty"`
@@ -300,13 +318,14 @@ type MigrationHeader struct {
        SnapshotNames    []string         
`protobuf:"bytes,4,rep,name=snapshotNames" json:"snapshotNames,omitempty"`
        Snapshots        []*Snapshot      
`protobuf:"bytes,5,rep,name=snapshots" json:"snapshots,omitempty"`
        Predump          *bool            `protobuf:"varint,7,opt,name=predump" 
json:"predump,omitempty"`
+       RsyncFeatures    *RsyncFeatures   
`protobuf:"bytes,8,opt,name=rsyncFeatures" json:"rsyncFeatures,omitempty"`
        XXX_unrecognized []byte           `json:"-"`
 }
 
 func (m *MigrationHeader) Reset()                    { *m = MigrationHeader{} }
 func (m *MigrationHeader) String() string            { return 
proto.CompactTextString(m) }
 func (*MigrationHeader) ProtoMessage()               {}
-func (*MigrationHeader) Descriptor() ([]byte, []int) { return fileDescriptor0, 
[]int{4} }
+func (*MigrationHeader) Descriptor() ([]byte, []int) { return fileDescriptor0, 
[]int{5} }
 
 func (m *MigrationHeader) GetFs() MigrationFSType {
        if m != nil && m.Fs != nil {
@@ -350,6 +369,13 @@ func (m *MigrationHeader) GetPredump() bool {
        return false
 }
 
+func (m *MigrationHeader) GetRsyncFeatures() *RsyncFeatures {
+       if m != nil {
+               return m.RsyncFeatures
+       }
+       return nil
+}
+
 type MigrationControl struct {
        Success *bool `protobuf:"varint,1,req,name=success" 
json:"success,omitempty"`
        // optional failure message if sending a failure
@@ -360,7 +386,7 @@ type MigrationControl struct {
 func (m *MigrationControl) Reset()                    { *m = 
MigrationControl{} }
 func (m *MigrationControl) String() string            { return 
proto.CompactTextString(m) }
 func (*MigrationControl) ProtoMessage()               {}
-func (*MigrationControl) Descriptor() ([]byte, []int) { return 
fileDescriptor0, []int{5} }
+func (*MigrationControl) Descriptor() ([]byte, []int) { return 
fileDescriptor0, []int{6} }
 
 func (m *MigrationControl) GetSuccess() bool {
        if m != nil && m.Success != nil {
@@ -384,7 +410,7 @@ type MigrationSync struct {
 func (m *MigrationSync) Reset()                    { *m = MigrationSync{} }
 func (m *MigrationSync) String() string            { return 
proto.CompactTextString(m) }
 func (*MigrationSync) ProtoMessage()               {}
-func (*MigrationSync) Descriptor() ([]byte, []int) { return fileDescriptor0, 
[]int{6} }
+func (*MigrationSync) Descriptor() ([]byte, []int) { return fileDescriptor0, 
[]int{7} }
 
 func (m *MigrationSync) GetFinalPreDump() bool {
        if m != nil && m.FinalPreDump != nil {
@@ -412,7 +438,7 @@ type DumpStatsEntry struct {
 func (m *DumpStatsEntry) Reset()                    { *m = DumpStatsEntry{} }
 func (m *DumpStatsEntry) String() string            { return 
proto.CompactTextString(m) }
 func (*DumpStatsEntry) ProtoMessage()               {}
-func (*DumpStatsEntry) Descriptor() ([]byte, []int) { return fileDescriptor0, 
[]int{7} }
+func (*DumpStatsEntry) Descriptor() ([]byte, []int) { return fileDescriptor0, 
[]int{8} }
 
 func (m *DumpStatsEntry) GetFreezingTime() uint32 {
        if m != nil && m.FreezingTime != nil {
@@ -503,7 +529,7 @@ type RestoreStatsEntry struct {
 func (m *RestoreStatsEntry) Reset()                    { *m = 
RestoreStatsEntry{} }
 func (m *RestoreStatsEntry) String() string            { return 
proto.CompactTextString(m) }
 func (*RestoreStatsEntry) ProtoMessage()               {}
-func (*RestoreStatsEntry) Descriptor() ([]byte, []int) { return 
fileDescriptor0, []int{8} }
+func (*RestoreStatsEntry) Descriptor() ([]byte, []int) { return 
fileDescriptor0, []int{9} }
 
 func (m *RestoreStatsEntry) GetPagesCompared() uint64 {
        if m != nil && m.PagesCompared != nil {
@@ -549,7 +575,7 @@ type StatsEntry struct {
 func (m *StatsEntry) Reset()                    { *m = StatsEntry{} }
 func (m *StatsEntry) String() string            { return 
proto.CompactTextString(m) }
 func (*StatsEntry) ProtoMessage()               {}
-func (*StatsEntry) Descriptor() ([]byte, []int) { return fileDescriptor0, 
[]int{9} }
+func (*StatsEntry) Descriptor() ([]byte, []int) { return fileDescriptor0, 
[]int{10} }
 
 func (m *StatsEntry) GetDump() *DumpStatsEntry {
        if m != nil {
@@ -570,6 +596,7 @@ func init() {
        proto.RegisterType((*Config)(nil), "migration.Config")
        proto.RegisterType((*Device)(nil), "migration.Device")
        proto.RegisterType((*Snapshot)(nil), "migration.Snapshot")
+       proto.RegisterType((*RsyncFeatures)(nil), "migration.rsyncFeatures")
        proto.RegisterType((*MigrationHeader)(nil), "migration.MigrationHeader")
        proto.RegisterType((*MigrationControl)(nil), 
"migration.MigrationControl")
        proto.RegisterType((*MigrationSync)(nil), "migration.MigrationSync")
@@ -583,64 +610,66 @@ func init() {
 func init() { proto.RegisterFile("lxd/migration/migrate.proto", 
fileDescriptor0) }
 
 var fileDescriptor0 = []byte{
-       // 934 bytes of a gzipped FileDescriptorProto
-       0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x94, 
0x4d, 0x6f, 0xdb, 0x46,
-       0x13, 0xc7, 0x1f, 0x51, 0x94, 0x2d, 0x8e, 0x24, 0x47, 0xd9, 0x18, 0x0f, 
0x88, 0xa4, 0x2f, 0x2a,
-       0x93, 0xa2, 0xaa, 0x0f, 0x76, 0xaa, 0xa0, 0x40, 0x7b, 0xac, 0xa5, 0xba, 
0x09, 0x90, 0xb8, 0xc6,
-       0xca, 0x46, 0xd1, 0x5e, 0x88, 0x2d, 0x39, 0x94, 0x17, 0xe6, 0x1b, 0x76, 
0x49, 0x3b, 0xf2, 0xa5,
-       0xa7, 0x7e, 0x94, 0x7e, 0x9e, 0x9e, 0xfa, 0x7d, 0x8a, 0xdd, 0xe5, 0xd2, 
0x54, 0x1b, 0xa0, 0xb7,
-       0x9d, 0xff, 0xfc, 0x38, 0xb3, 0xf3, 0xc2, 0x85, 0x67, 0xe9, 0xfb, 0xf8, 
0x24, 0xe3, 0x1b, 0xc1,
-       0x2a, 0x5e, 0xe4, 0xcd, 0x09, 0x8f, 0x4b, 0x51, 0x54, 0x05, 0xf1, 0x5a, 
0x47, 0xf0, 0x1b, 0x78,
-       0x6f, 0x56, 0xef, 0x58, 0x79, 0xb9, 0x2d, 0x91, 0x1c, 0xc2, 0x80, 0xcb, 
0x9a, 0xc7, 0x7e, 0x6f,
-       0xe6, 0xcc, 0x87, 0xd4, 0x18, 0x46, 0xdd, 0xf0, 0xd8, 0x77, 0xac, 0xba, 
0xe1, 0x31, 0xf9, 0x3f,
-       0xec, 0x5d, 0x17, 0xb2, 0xe2, 0xb1, 0xdf, 0x9f, 0x39, 0xf3, 0x01, 0x6d, 
0x2c, 0x42, 0xc0, 0xcd,
-       0x25, 0x8f, 0x7d, 0x57, 0xab, 0xfa, 0x4c, 0x9e, 0xc2, 0x30, 0x63, 0xa5, 
0x60, 0xf9, 0x06, 0xfd,
-       0x81, 0xd6, 0x5b, 0x3b, 0x78, 0x09, 0x7b, 0xcb, 0x22, 0x4f, 0xf8, 0x86, 
0x4c, 0xa1, 0x7f, 0x83,
-       0x5b, 0x9d, 0xdb, 0xa3, 0xea, 0xa8, 0x32, 0xdf, 0xb2, 0xb4, 0x46, 0x9d, 
0xd9, 0xa3, 0xc6, 0x08,
-       0x7e, 0x80, 0xbd, 0x15, 0xde, 0xf2, 0x08, 0x75, 0x2e, 0x96, 0x61, 0xf3, 
0x89, 0x3e, 0x93, 0x2f,
-       0x61, 0x2f, 0xd2, 0xf1, 0x7c, 0x67, 0xd6, 0x9f, 0x8f, 0x16, 0x8f, 0x8f, 
0xdb, 0x62, 0x8f, 0x4d,
-       0x22, 0xda, 0x00, 0xc1, 0x9f, 0x0e, 0x0c, 0xd7, 0x39, 0x2b, 0xe5, 0x75, 
0x51, 0x7d, 0x30, 0xd6,
-       0x2b, 0x18, 0xa5, 0x45, 0xc4, 0xd2, 0xe5, 0x7f, 0x04, 0xec, 0x52, 0xaa, 
0xd8, 0x52, 0x14, 0x09,
-       0x4f, 0x51, 0xfa, 0xfd, 0x59, 0x7f, 0xee, 0xd1, 0xd6, 0x26, 0x1f, 0x81, 
0x87, 0xe5, 0x35, 0x66,
-       0x28, 0x58, 0xaa, 0x3b, 0x34, 0xa4, 0x0f, 0x02, 0xf9, 0x1a, 0xc6, 0x3a, 
0x90, 0xa9, 0x4e, 0xfa,
-       0x83, 0x7f, 0xe5, 0x33, 0x1e, 0xba, 0x83, 0x91, 0x00, 0xc6, 0x4c, 0x44, 
0xd7, 0xbc, 0xc2, 0xa8,
-       0xaa, 0x05, 0xfa, 0x7b, 0xba, 0xc3, 0x3b, 0x9a, 0xba, 0x94, 0xac, 0x58, 
0x85, 0x49, 0x9d, 0xfa,
-       0xfb, 0x3a, 0x6f, 0x6b, 0x93, 0xe7, 0x30, 0x89, 0x04, 0xea, 0x04, 0x61, 
0xcc, 0x2a, 0xf4, 0x87,
-       0xb3, 0xde, 0xbc, 0x4f, 0xc7, 0x56, 0x5c, 0xb1, 0x0a, 0xc9, 0x0b, 0x38, 
0x48, 0x99, 0xac, 0xc2,
-       0x5a, 0x62, 0x6c, 0x28, 0xcf, 0x50, 0x4a, 0xbd, 0x92, 0x18, 0x2b, 0x2a, 
0xf8, 0xdd, 0x81, 0x47,
-       0xef, 0xec, 0x6d, 0x5f, 0x23, 0x8b, 0x51, 0x90, 0x23, 0x70, 0x12, 0xa9, 
0xdb, 0x7a, 0xb0, 0x78,
-       0xda, 0xa9, 0xa5, 0xe5, 0xce, 0xd6, 0x6a, 0xf9, 0xa8, 0x93, 0x48, 0xf2, 
0x05, 0xb8, 0x91, 0xe0,
-       0xb5, 0xef, 0xcc, 0x7a, 0xf3, 0x83, 0xc5, 0x93, 0x6e, 0xa7, 0xe9, 0x9b, 
0x2b, 0x8d, 0x69, 0x80,
-       0x1c, 0xc1, 0x80, 0xc7, 0x19, 0x2b, 0x75, 0x87, 0x47, 0x8b, 0xc3, 0x0e, 
0xd9, 0xae, 0x33, 0x35,
-       0x08, 0x79, 0x01, 0x13, 0xd9, 0x4c, 0xf9, 0x9c, 0x65, 0x28, 0x7d, 0x57, 
0x4f, 0x65, 0x57, 0x24,
-       0x5f, 0x81, 0x67, 0x05, 0xdb, 0xf9, 0x6e, 0x7e, 0xbb, 0x27, 0xf4, 0x81, 
0x22, 0x3e, 0xec, 0x97,
-       0x02, 0xe3, 0x3a, 0x2b, 0xfd, 0xfd, 0x59, 0x6f, 0x3e, 0xa4, 0xd6, 0x0c, 
0xce, 0x60, 0xda, 0x96,
-       0xb7, 0x2c, 0xf2, 0x4a, 0x14, 0xa9, 0xa2, 0x65, 0x1d, 0x45, 0x28, 0x65, 
0xf3, 0x7b, 0x59, 0x53,
-       0x79, 0x32, 0x94, 0x92, 0x6d, 0x50, 0x17, 0xee, 0x51, 0x6b, 0x06, 0xaf, 
0x60, 0xd2, 0xc6, 0x59,
-       0x6f, 0xf3, 0x48, 0xcd, 0x3a, 0xe1, 0x39, 0x4b, 0x2f, 0x04, 0xae, 0x54, 
0x5e, 0x13, 0x69, 0x47,
-       0x0b, 0xfe, 0xe8, 0xc3, 0x54, 0xdd, 0x22, 0x54, 0x13, 0x96, 0x21, 0xe6, 
0x95, 0xd8, 0xaa, 0x21,
-       0x27, 0x02, 0xf1, 0x9e, 0xe7, 0x9b, 0xb0, 0xe2, 0xcd, 0x9e, 0x4f, 0xe8, 
0xd8, 0x8a, 0x97, 0x3c,
-       0x43, 0xf2, 0x29, 0x8c, 0x12, 0x51, 0xdc, 0x63, 0x6e, 0x10, 0x47, 0x23, 
0x60, 0x24, 0x0d, 0x7c,
-       0x06, 0xe3, 0x0c, 0x33, 0x1d, 0x5c, 0x13, 0x7d, 0x4d, 0x8c, 0x1a, 0x4d, 
0x23, 0xcf, 0x61, 0x92,
-       0x61, 0x76, 0x27, 0x78, 0x85, 0x86, 0x71, 0x4d, 0x22, 0x2b, 0x5a, 0xa8, 
0x64, 0x1b, 0x94, 0xa1,
-       0x8c, 0x58, 0x9e, 0x63, 0xac, 0x5f, 0x05, 0x97, 0x8e, 0xb5, 0xb8, 0x36, 
0x1a, 0x79, 0x09, 0x87,
-       0x0d, 0x74, 0xc3, 0xcb, 0x12, 0xe3, 0xb0, 0x64, 0x02, 0xf3, 0x4a, 0xef, 
0xb7, 0x4b, 0x89, 0x61,
-       0x8d, 0xeb, 0x42, 0x7b, 0x1e, 0xc2, 0xaa, 0x4c, 0x15, 0xe6, 0x7a, 0xd5, 
0x6d, 0xd8, 0x9f, 0x8c,
-       0xa6, 0x20, 0x2e, 0x32, 0x56, 0x86, 0x02, 0x65, 0x91, 0xde, 0x9a, 0x75, 
0x9f, 0xd0, 0xb1, 0x16,
-       0xa9, 0xd1, 0xc8, 0xc7, 0x00, 0x26, 0x52, 0xca, 0xee, 0xb7, 0xbe, 0xa7, 
0xc3, 0x78, 0x5a, 0x79,
-       0xcb, 0xee, 0xb7, 0xd6, 0x1d, 0x96, 0xbc, 0x44, 0xe9, 0xc3, 0xac, 0x67, 
0xdd, 0x17, 0x4a, 0x50,
-       0x3f, 0x4b, 0xeb, 0x0e, 0x7f, 0xad, 0x13, 0xe9, 0x8f, 0x34, 0x32, 0xb6, 
0xc8, 0x69, 0x9d, 0xc8,
-       0xe0, 0xaf, 0x1e, 0x3c, 0x11, 0x28, 0xab, 0x42, 0xe0, 0xce, 0xa8, 0x3e, 
0x37, 0x5f, 0xcb, 0x30,
-       0x2a, 0x32, 0x55, 0xb2, 0x79, 0x8e, 0x5d, 0x6a, 0x6a, 0x5b, 0x36, 0x22, 
0x39, 0x82, 0xc7, 0xbb,
-       0xed, 0x89, 0x8a, 0x3b, 0x3d, 0x32, 0x97, 0x3e, 0xea, 0xf6, 0x66, 0x59, 
0xdc, 0xa9, 0xb9, 0x25,
-       0x85, 0xb8, 0x69, 0x87, 0xdf, 0xcc, 0xad, 0xd1, 0xec, 0x68, 0xed, 0x65, 
0x3a, 0x63, 0x1b, 0x35,
-       0x9a, 0x46, 0xda, 0x8b, 0x35, 0xa2, 0x1a, 0x5b, 0xaf, 0xbd, 0x18, 0x6d, 
0xc4, 0xe0, 0x3d, 0x8c,
-       0xba, 0xe5, 0x9c, 0x80, 0x1b, 0x9b, 0x55, 0xed, 0xcd, 0x47, 0x8b, 0x67, 
0x9d, 0x7f, 0xea, 0x9f,
-       0x4b, 0x4a, 0x35, 0x48, 0xbe, 0x81, 0xfd, 0x26, 0x81, 0xfe, 0x1d, 0x46, 
0x8b, 0x4f, 0x3a, 0xdf,
-       0x7c, 0xa0, 0x61, 0xd4, 0xe2, 0x47, 0xdf, 0x76, 0x5e, 0x1f, 0xf3, 0xaa, 
0x10, 0x0f, 0x06, 0x74,
-       0xfd, 0xf3, 0xf9, 0x72, 0xfa, 0x3f, 0x75, 0x3c, 0xbd, 0xa4, 0x67, 0xeb, 
0x69, 0x8f, 0xec, 0x43,
-       0xff, 0x97, 0xb3, 0xf5, 0xd4, 0x51, 0x07, 0x7a, 0xba, 0x9a, 0xf6, 0x8f, 
0x4e, 0x60, 0x68, 0x9f,
-       0x18, 0x72, 0x00, 0xa0, 0xce, 0x61, 0xe7, 0xc3, 0x8b, 0xd7, 0xdf, 0x5d, 
0xbd, 0x9d, 0xf6, 0xc8,
-       0x10, 0xdc, 0xf3, 0x1f, 0xcf, 0xbf, 0x9f, 0x3a, 0x7f, 0x07, 0x00, 0x00, 
0xff, 0xff, 0x45, 0x27,
-       0x31, 0x3a, 0x61, 0x07, 0x00, 0x00,
+       // 972 bytes of a gzipped FileDescriptorProto
+       0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 
0xdd, 0x6e, 0xdb, 0x36,
+       0x14, 0x9e, 0x65, 0x39, 0xb1, 0x8e, 0xed, 0xd4, 0x65, 0x8b, 0x41, 0x68, 
0xf7, 0xe3, 0xa9, 0x1d,
+       0xea, 0xe5, 0x22, 0xe9, 0x5c, 0x0c, 0xd8, 0x6e, 0x06, 0x2c, 0xce, 0xb2, 
0x16, 0x68, 0xb3, 0x80,
+       0x4e, 0x30, 0x6c, 0x37, 0x02, 0x27, 0x1d, 0x39, 0x44, 0xf4, 0x07, 0x52, 
0x4a, 0xe2, 0xdc, 0xec,
+       0x69, 0xf6, 0x28, 0xbb, 0xde, 0xd5, 0xde, 0x67, 0x20, 0x29, 0x2a, 0x72, 
0x3b, 0x60, 0x77, 0x3c,
+       0xdf, 0xf9, 0x78, 0x3e, 0x9e, 0x3f, 0xc2, 0xd3, 0xf4, 0x36, 0x3e, 0xcc, 
0xf8, 0x5a, 0xb0, 0x8a,
+       0x17, 0x79, 0x73, 0xc2, 0x83, 0x52, 0x14, 0x55, 0x41, 0xbc, 0xd6, 0x11, 
0xfc, 0x01, 0xde, 0x9b,
+       0xe3, 0x77, 0xac, 0x3c, 0xdf, 0x94, 0x48, 0x1e, 0xc3, 0x80, 0xcb, 0x9a, 
0xc7, 0x7e, 0x6f, 0xe6,
+       0xcc, 0x87, 0xd4, 0x18, 0x06, 0x5d, 0xf3, 0xd8, 0x77, 0x2c, 0xba, 0xe6, 
0x31, 0xf9, 0x18, 0x76,
+       0x2e, 0x0b, 0x59, 0xf1, 0xd8, 0xef, 0xcf, 0x9c, 0xf9, 0x80, 0x36, 0x16, 
0x21, 0xe0, 0xe6, 0x92,
+       0xc7, 0xbe, 0xab, 0x51, 0x7d, 0x26, 0x4f, 0x60, 0x98, 0xb1, 0x52, 0xb0, 
0x7c, 0x8d, 0xfe, 0x40,
+       0xe3, 0xad, 0x1d, 0xbc, 0x84, 0x9d, 0x65, 0x91, 0x27, 0x7c, 0x4d, 0xa6, 
0xd0, 0xbf, 0xc2, 0x8d,
+       0xd6, 0xf6, 0xa8, 0x3a, 0x2a, 0xe5, 0x6b, 0x96, 0xd6, 0xa8, 0x95, 0x3d, 
0x6a, 0x8c, 0xe0, 0x27,
+       0xd8, 0x39, 0xc6, 0x6b, 0x1e, 0xa1, 0xd6, 0x62, 0x19, 0x36, 0x57, 0xf4, 
0x99, 0x7c, 0x05, 0x3b,
+       0x91, 0x8e, 0xe7, 0x3b, 0xb3, 0xfe, 0x7c, 0xb4, 0x78, 0x78, 0xd0, 0x26, 
0x7b, 0x60, 0x84, 0x68,
+       0x43, 0x08, 0xfe, 0x76, 0x60, 0xb8, 0xca, 0x59, 0x29, 0x2f, 0x8b, 0xea, 
0x3f, 0x63, 0xbd, 0x82,
+       0x51, 0x5a, 0x44, 0x2c, 0x5d, 0xfe, 0x4f, 0xc0, 0x2e, 0x4b, 0x25, 0x5b, 
0x8a, 0x22, 0xe1, 0x29,
+       0x4a, 0xbf, 0x3f, 0xeb, 0xcf, 0x3d, 0xda, 0xda, 0xe4, 0x13, 0xf0, 0xb0, 
0xbc, 0xc4, 0x0c, 0x05,
+       0x4b, 0x75, 0x85, 0x86, 0xf4, 0x1e, 0x20, 0xdf, 0xc0, 0x58, 0x07, 0x32, 
0xd9, 0x49, 0x7f, 0xf0,
+       0x81, 0x9e, 0xf1, 0xd0, 0x2d, 0x1a, 0x09, 0x60, 0xcc, 0x44, 0x74, 0xc9, 
0x2b, 0x8c, 0xaa, 0x5a,
+       0xa0, 0xbf, 0xa3, 0x2b, 0xbc, 0x85, 0xa9, 0x47, 0xc9, 0x8a, 0x55, 0x98, 
0xd4, 0xa9, 0xbf, 0xab,
+       0x75, 0x5b, 0x9b, 0x3c, 0x83, 0x49, 0x24, 0x50, 0x0b, 0x84, 0x31, 0xab, 
0xd0, 0x1f, 0xce, 0x7a,
+       0xf3, 0x3e, 0x1d, 0x5b, 0xf0, 0x98, 0x55, 0x48, 0x9e, 0xc3, 0x5e, 0xca, 
0x64, 0x15, 0xd6, 0x12,
+       0x63, 0xc3, 0xf2, 0x0c, 0x4b, 0xa1, 0x17, 0x12, 0x63, 0xc5, 0x0a, 0x5e, 
0xc0, 0x44, 0xc8, 0x4d,
+       0x1e, 0x9d, 0x20, 0x53, 0xb2, 0x52, 0x4d, 0xc9, 0x2d, 0xab, 0x2a, 0x21, 
0xfd, 0xde, 0xac, 0x37,
+       0x1f, 0xd2, 0xc6, 0x0a, 0xfe, 0x72, 0xe0, 0xc1, 0x3b, 0x9b, 0xd6, 0x6b, 
0x64, 0x31, 0x0a, 0xb2,
+       0x0f, 0x4e, 0x22, 0x75, 0xfd, 0xf7, 0x16, 0x4f, 0x3a, 0x49, 0xb7, 0xbc, 
0x93, 0x95, 0x9a, 0x52,
+       0xea, 0x24, 0x92, 0xbc, 0x00, 0x37, 0x12, 0xbc, 0xf6, 0x9d, 0x59, 0x6f, 
0xbe, 0xb7, 0x78, 0xd4,
+       0x6d, 0x09, 0x7d, 0x73, 0xa1, 0x69, 0x9a, 0x40, 0xf6, 0x61, 0xc0, 0xe3, 
0x8c, 0x95, 0xba, 0x15,
+       0xa3, 0xc5, 0xe3, 0x0e, 0xb3, 0x9d, 0x7b, 0x6a, 0x28, 0xe4, 0x39, 0x4c, 
0x64, 0x33, 0x0e, 0xa7,
+       0x2c, 0x43, 0xe9, 0xbb, 0xba, 0x7d, 0xdb, 0x20, 0xf9, 0x1a, 0x3c, 0x0b, 
0xd8, 0x16, 0x75, 0xf5,
+       0xed, 0x40, 0xd1, 0x7b, 0x16, 0xf1, 0x61, 0xb7, 0x14, 0x18, 0xd7, 0x59, 
0xe9, 0xef, 0xea, 0x32,
+       0x58, 0x93, 0x7c, 0xff, 0x5e, 0xc1, 0x74, 0xed, 0x47, 0x0b, 0xbf, 0x13, 
0x70, 0xcb, 0x4f, 0xb7,
+       0xe9, 0xc1, 0x09, 0x4c, 0xdb, 0xf2, 0x2c, 0x8b, 0xbc, 0x12, 0x45, 0xaa, 
0xd4, 0x64, 0x1d, 0x45,
+       0x28, 0x65, 0xb3, 0xc7, 0xd6, 0x54, 0x9e, 0x0c, 0xa5, 0x64, 0x6b, 0xd4, 
0x85, 0xf3, 0xa8, 0x35,
+       0x83, 0x57, 0x30, 0x69, 0xe3, 0xac, 0x36, 0x79, 0xa4, 0x86, 0x2a, 0xe1, 
0x39, 0x4b, 0xcf, 0x04,
+       0x1e, 0xab, 0x77, 0x9b, 0x48, 0x5b, 0x58, 0xf0, 0x67, 0x1f, 0xa6, 0x2a, 
0x8b, 0x50, 0x8d, 0x92,
+       0x0c, 0x31, 0xaf, 0xc4, 0x46, 0x4d, 0x53, 0x22, 0x10, 0xef, 0x78, 0xbe, 
0x0e, 0x2b, 0xde, 0x2c,
+       0xd4, 0x84, 0x8e, 0x2d, 0x78, 0xce, 0x33, 0x24, 0x9f, 0xc3, 0x28, 0x11, 
0xc5, 0x1d, 0xe6, 0x86,
+       0xe2, 0x68, 0x0a, 0x18, 0x48, 0x13, 0xbe, 0x80, 0x71, 0x86, 0x99, 0x0e, 
0xae, 0x19, 0x7d, 0xcd,
+       0x18, 0x35, 0x98, 0xa6, 0x3c, 0x83, 0x49, 0x86, 0xd9, 0x8d, 0xe0, 0x15, 
0x1a, 0x8e, 0x6b, 0x84,
+       0x2c, 0x68, 0x49, 0x25, 0x5b, 0xa3, 0x0c, 0x65, 0xc4, 0xf2, 0x1c, 0x63, 
0xfd, 0xfd, 0xb8, 0x74,
+       0xac, 0xc1, 0x95, 0xc1, 0xc8, 0x4b, 0x78, 0xdc, 0x90, 0xae, 0x78, 0x59, 
0x62, 0x1c, 0x96, 0x4c,
+       0x60, 0x5e, 0xe9, 0x45, 0x72, 0x29, 0x31, 0x5c, 0xe3, 0x3a, 0xd3, 0x9e, 
0xfb, 0xb0, 0x4a, 0xa9,
+       0xc2, 0x5c, 0xef, 0x94, 0x0d, 0xfb, 0x8b, 0xc1, 0x14, 0x89, 0x8b, 0x8c, 
0x95, 0xa1, 0x40, 0x59,
+       0xa4, 0xd7, 0x66, 0xaf, 0x26, 0x74, 0xac, 0x41, 0x6a, 0x30, 0xf2, 0x29, 
0x80, 0x89, 0x94, 0xb2,
+       0xbb, 0x8d, 0xef, 0xe9, 0x30, 0x9e, 0x46, 0xde, 0xb2, 0xbb, 0x8d, 0x75, 
0x87, 0x25, 0x2f, 0x51,
+       0xfa, 0x30, 0xeb, 0x59, 0xf7, 0x99, 0x02, 0xd4, 0x56, 0xb6, 0xee, 0xf0, 
0xf7, 0x3a, 0x91, 0xfe,
+       0x48, 0x53, 0xc6, 0x96, 0x72, 0x54, 0x27, 0x32, 0xf8, 0xa7, 0x07, 0x8f, 
0x04, 0xca, 0xaa, 0x10,
+       0xb8, 0xd5, 0xaa, 0x2f, 0xcd, 0x6d, 0x19, 0x46, 0x45, 0xa6, 0x52, 0x36, 
0xff, 0xbe, 0x4b, 0x4d,
+       0x6e, 0xcb, 0x06, 0x24, 0xfb, 0xf0, 0x70, 0xbb, 0x3c, 0x51, 0x71, 0xa3, 
0x5b, 0xe6, 0xd2, 0x07,
+       0xdd, 0xda, 0x2c, 0x8b, 0x1b, 0xd5, 0xb7, 0xa4, 0x10, 0x57, 0x6d, 0xf3, 
0x9b, 0xbe, 0x35, 0x98,
+       0x6d, 0xad, 0x7d, 0x4c, 0xa7, 0x6d, 0xa3, 0x06, 0xd3, 0x94, 0xf6, 0x61, 
0x0d, 0xa8, 0xda, 0xd6,
+       0x6b, 0x1f, 0x46, 0x1b, 0x30, 0xb8, 0x85, 0x51, 0x37, 0x9d, 0x43, 0x70, 
0x63, 0x33, 0xaa, 0x6a,
+       0x85, 0x9e, 0x76, 0x56, 0xe8, 0xfd, 0x21, 0xa5, 0x9a, 0x48, 0xbe, 0x85, 
0xdd, 0x46, 0x40, 0xaf,
+       0xc3, 0x68, 0xf1, 0x59, 0x77, 0xed, 0x3e, 0x2c, 0x18, 0xb5, 0xf4, 0xfd, 
0xef, 0x3a, 0xbf, 0x97,
+       0xf9, 0x95, 0x88, 0x07, 0x03, 0xba, 0xfa, 0xf5, 0x74, 0x39, 0xfd, 0x48, 
0x1d, 0x8f, 0xce, 0xe9,
+       0xc9, 0x6a, 0xda, 0x23, 0xbb, 0xd0, 0xff, 0xed, 0x64, 0x35, 0x75, 0xd4, 
0x81, 0x1e, 0x1d, 0x4f,
+       0xfb, 0xfb, 0x87, 0x30, 0xb4, 0x5f, 0x14, 0xd9, 0x03, 0x50, 0xe7, 0xb0, 
0x73, 0xf1, 0xec, 0xf5,
+       0x0f, 0x17, 0x6f, 0xa7, 0x3d, 0x32, 0x04, 0xf7, 0xf4, 0xe7, 0xd3, 0x1f, 
0xa7, 0xce, 0xbf, 0x01,
+       0x00, 0x00, 0xff, 0xff, 0x2b, 0x3f, 0x34, 0xa3, 0xca, 0x07, 0x00, 0x00,
 }
diff --git a/lxd/migration/migrate.proto b/lxd/migration/migrate.proto
index 6f04db560e..7ae4591d52 100644
--- a/lxd/migration/migrate.proto
+++ b/lxd/migration/migrate.proto
@@ -46,6 +46,10 @@ message Snapshot {
        optional int64                  last_used_date  = 9;
 }
 
+message rsyncFeatures {
+       optional bool           xattrs = 1;
+}
+
 message MigrationHeader {
        required MigrationFSType                fs              = 1;
        optional CRIUType                       criu            = 2;
@@ -53,6 +57,7 @@ message MigrationHeader {
        repeated string                         snapshotNames   = 4;
        repeated Snapshot                       snapshots       = 5;
        optional bool                           predump         = 7;
+       optional rsyncFeatures          rsyncFeatures = 8;
 }
 
 message MigrationControl {
diff --git a/lxd/rsync.go b/lxd/rsync.go
index 5f300312e5..cb1b7f4e38 100644
--- a/lxd/rsync.go
+++ b/lxd/rsync.go
@@ -178,17 +178,23 @@ func RsyncSend(name string, path string, conn 
*websocket.Conn, readWrapper func(
 // RsyncRecv sets up the receiving half of the websocket to rsync (the other
 // half set up by RsyncSend), putting the contents in the directory specified
 // by path.
-func RsyncRecv(path string, conn *websocket.Conn, writeWrapper 
func(io.WriteCloser) io.WriteCloser) error {
-       cmd := exec.Command("rsync",
+func RsyncRecv(path string, conn *websocket.Conn, writeWrapper 
func(io.WriteCloser) io.WriteCloser, extraArgs []string) error {
+       args := []string{
                "--server",
                "-vlogDtpre.iLsfx",
                "--numeric-ids",
                "--devices",
                "--partial",
                "--sparse",
-               "--xattrs",
-               ".",
-               path)
+       }
+
+       if extraArgs != nil && len(extraArgs) > 0 {
+               args = append(args, extraArgs...)
+       }
+
+       args = append(args, []string{".", path}...)
+
+       cmd := exec.Command("rsync", args...)
 
        stdin, err := cmd.StdinPipe()
        if err != nil {
diff --git a/lxd/storage.go b/lxd/storage.go
index 6d6b98baac..a53207b74a 100644
--- a/lxd/storage.go
+++ b/lxd/storage.go
@@ -233,10 +233,11 @@ type storage interface {
                conn *websocket.Conn,
                srcIdmap *idmap.IdmapSet,
                op *operation,
-               containerOnly bool) error
+               containerOnly bool,
+               args MigrationSinkArgs) error
 
        StorageMigrationSource() (MigrationStorageSourceDriver, error)
-       StorageMigrationSink(conn *websocket.Conn, op *operation, storage 
storage) error
+       StorageMigrationSink(conn *websocket.Conn, op *operation, storage 
storage, args MigrationSinkArgs) error
 }
 
 func storageCoreInit(driver string) (storage, error) {
diff --git a/lxd/storage_btrfs.go b/lxd/storage_btrfs.go
index a39b4cb21f..6ecdce2b55 100644
--- a/lxd/storage_btrfs.go
+++ b/lxd/storage_btrfs.go
@@ -2495,9 +2495,9 @@ func (s *storageBtrfs) MigrationSource(c container, 
containerOnly bool) (Migrati
        return driver, nil
 }
 
-func (s *storageBtrfs) MigrationSink(live bool, container container, snapshots 
[]*migration.Snapshot, conn *websocket.Conn, srcIdmap *idmap.IdmapSet, op 
*operation, containerOnly bool) error {
+func (s *storageBtrfs) MigrationSink(live bool, container container, snapshots 
[]*migration.Snapshot, conn *websocket.Conn, srcIdmap *idmap.IdmapSet, op 
*operation, containerOnly bool, args MigrationSinkArgs) error {
        if s.s.OS.RunningInUserNS {
-               return rsyncMigrationSink(live, container, snapshots, conn, 
srcIdmap, op, containerOnly)
+               return rsyncMigrationSink(live, container, snapshots, conn, 
srcIdmap, op, containerOnly, args)
        }
 
        btrfsRecv := func(snapName string, btrfsPath string, targetPath string, 
isSnapshot bool, writeWrapper func(io.WriteCloser) io.WriteCloser) error {
@@ -2840,8 +2840,8 @@ func (s *storageBtrfs) StorageMigrationSource() 
(MigrationStorageSourceDriver, e
        return rsyncStorageMigrationSource()
 }
 
-func (s *storageBtrfs) StorageMigrationSink(conn *websocket.Conn, op 
*operation, storage storage) error {
-       return rsyncStorageMigrationSink(conn, op, storage)
+func (s *storageBtrfs) StorageMigrationSink(conn *websocket.Conn, op 
*operation, storage storage, args MigrationSinkArgs) error {
+       return rsyncStorageMigrationSink(conn, op, storage, args)
 }
 
 func (s *storageBtrfs) GetStoragePool() *api.StoragePool {
diff --git a/lxd/storage_ceph.go b/lxd/storage_ceph.go
index 2dd3ccd0af..a18e9cd6b9 100644
--- a/lxd/storage_ceph.go
+++ b/lxd/storage_ceph.go
@@ -2618,8 +2618,8 @@ func (s *storageCeph) StorageMigrationSource() 
(MigrationStorageSourceDriver, er
        return rsyncStorageMigrationSource()
 }
 
-func (s *storageCeph) StorageMigrationSink(conn *websocket.Conn, op 
*operation, storage storage) error {
-       return rsyncStorageMigrationSink(conn, op, storage)
+func (s *storageCeph) StorageMigrationSink(conn *websocket.Conn, op 
*operation, storage storage, args MigrationSinkArgs) error {
+       return rsyncStorageMigrationSink(conn, op, storage, args)
 }
 
 func (s *storageCeph) GetStoragePool() *api.StoragePool {
diff --git a/lxd/storage_ceph_migration.go b/lxd/storage_ceph_migration.go
index dfab3dafe7..984a5facf0 100644
--- a/lxd/storage_ceph_migration.go
+++ b/lxd/storage_ceph_migration.go
@@ -221,7 +221,7 @@ func (s *storageCeph) MigrationSource(c container, 
containerOnly bool) (Migratio
 
 func (s *storageCeph) MigrationSink(live bool, c container,
        snapshots []*migration.Snapshot, conn *websocket.Conn, srcIdmap 
*idmap.IdmapSet,
-       op *operation, containerOnly bool) error {
+       op *operation, containerOnly bool, args MigrationSinkArgs) error {
        // Check that we received a valid root disk device with a pool property
        // set.
        parentStoragePool := ""
diff --git a/lxd/storage_dir.go b/lxd/storage_dir.go
index ba63a7597d..4d9eb6dd0e 100644
--- a/lxd/storage_dir.go
+++ b/lxd/storage_dir.go
@@ -1205,8 +1205,8 @@ func (s *storageDir) MigrationSource(container container, 
containerOnly bool) (M
        return rsyncMigrationSource(container, containerOnly)
 }
 
-func (s *storageDir) MigrationSink(live bool, container container, snapshots 
[]*migration.Snapshot, conn *websocket.Conn, srcIdmap *idmap.IdmapSet, op 
*operation, containerOnly bool) error {
-       return rsyncMigrationSink(live, container, snapshots, conn, srcIdmap, 
op, containerOnly)
+func (s *storageDir) MigrationSink(live bool, container container, snapshots 
[]*migration.Snapshot, conn *websocket.Conn, srcIdmap *idmap.IdmapSet, op 
*operation, containerOnly bool, args MigrationSinkArgs) error {
+       return rsyncMigrationSink(live, container, snapshots, conn, srcIdmap, 
op, containerOnly, args)
 }
 
 func (s *storageDir) StorageEntitySetQuota(volumeType int, size int64, data 
interface{}) error {
@@ -1270,8 +1270,8 @@ func (s *storageDir) StorageMigrationSource() 
(MigrationStorageSourceDriver, err
        return rsyncStorageMigrationSource()
 }
 
-func (s *storageDir) StorageMigrationSink(conn *websocket.Conn, op *operation, 
storage storage) error {
-       return rsyncStorageMigrationSink(conn, op, storage)
+func (s *storageDir) StorageMigrationSink(conn *websocket.Conn, op *operation, 
storage storage, args MigrationSinkArgs) error {
+       return rsyncStorageMigrationSink(conn, op, storage, args)
 }
 
 func (s *storageDir) GetStoragePool() *api.StoragePool {
diff --git a/lxd/storage_lvm.go b/lxd/storage_lvm.go
index 036761210e..291bd0c932 100644
--- a/lxd/storage_lvm.go
+++ b/lxd/storage_lvm.go
@@ -1971,8 +1971,8 @@ func (s *storageLvm) MigrationSource(container container, 
containerOnly bool) (M
        return rsyncMigrationSource(container, containerOnly)
 }
 
-func (s *storageLvm) MigrationSink(live bool, container container, snapshots 
[]*migration.Snapshot, conn *websocket.Conn, srcIdmap *idmap.IdmapSet, op 
*operation, containerOnly bool) error {
-       return rsyncMigrationSink(live, container, snapshots, conn, srcIdmap, 
op, containerOnly)
+func (s *storageLvm) MigrationSink(live bool, container container, snapshots 
[]*migration.Snapshot, conn *websocket.Conn, srcIdmap *idmap.IdmapSet, op 
*operation, containerOnly bool, args MigrationSinkArgs) error {
+       return rsyncMigrationSink(live, container, snapshots, conn, srcIdmap, 
op, containerOnly, args)
 }
 
 func (s *storageLvm) StorageEntitySetQuota(volumeType int, size int64, data 
interface{}) error {
@@ -2169,8 +2169,8 @@ func (s *storageLvm) StorageMigrationSource() 
(MigrationStorageSourceDriver, err
        return rsyncStorageMigrationSource()
 }
 
-func (s *storageLvm) StorageMigrationSink(conn *websocket.Conn, op *operation, 
storage storage) error {
-       return rsyncStorageMigrationSink(conn, op, storage)
+func (s *storageLvm) StorageMigrationSink(conn *websocket.Conn, op *operation, 
storage storage, args MigrationSinkArgs) error {
+       return rsyncStorageMigrationSink(conn, op, storage, args)
 }
 
 func (s *storageLvm) GetStoragePool() *api.StoragePool {
diff --git a/lxd/storage_migration.go b/lxd/storage_migration.go
index 9fcc5ed6af..b3bde2cabc 100644
--- a/lxd/storage_migration.go
+++ b/lxd/storage_migration.go
@@ -165,7 +165,7 @@ func snapshotProtobufToContainerArgs(containerName string, 
snap *migration.Snaps
        return args
 }
 
-func rsyncStorageMigrationSink(conn *websocket.Conn, op *operation, storage 
storage) error {
+func rsyncStorageMigrationSink(conn *websocket.Conn, op *operation, storage 
storage, args MigrationSinkArgs) error {
        err := storage.StoragePoolVolumeCreate()
        if err != nil {
                return err
@@ -186,10 +186,10 @@ func rsyncStorageMigrationSink(conn *websocket.Conn, op 
*operation, storage stor
        path := getStoragePoolVolumeMountPoint(pool.Name, volume.Name)
        path = shared.AddSlash(path)
        logger.Debugf("Starting to receive storage volume %s on storage pool %s 
into %s", volume.Name, pool.Name, path)
-       return RsyncRecv(path, conn, wrapper)
+       return RsyncRecv(path, conn, wrapper, args.RsyncArgs)
 }
 
-func rsyncMigrationSink(live bool, container container, snapshots 
[]*migration.Snapshot, conn *websocket.Conn, srcIdmap *idmap.IdmapSet, op 
*operation, containerOnly bool) error {
+func rsyncMigrationSink(live bool, container container, snapshots 
[]*migration.Snapshot, conn *websocket.Conn, srcIdmap *idmap.IdmapSet, op 
*operation, containerOnly bool, args MigrationSinkArgs) error {
        ourStart, err := container.StorageStart()
        if err != nil {
                return err
@@ -216,27 +216,27 @@ func rsyncMigrationSink(live bool, container container, 
snapshots []*migration.S
        if isDirBackend {
                if !containerOnly {
                        for _, snap := range snapshots {
-                               args := 
snapshotProtobufToContainerArgs(container.Name(), snap)
+                               snapArgs := 
snapshotProtobufToContainerArgs(container.Name(), snap)
 
                                // Ensure that snapshot and parent container 
have the
                                // same storage pool in their local root disk 
device.
                                // If the root disk device for the snapshot 
comes from a
                                // profile on the new instance as well we don't 
need to
                                // do anything.
-                               if args.Devices != nil {
-                                       snapLocalRootDiskDeviceKey, _, _ := 
shared.GetRootDiskDevice(args.Devices)
+                               if snapArgs.Devices != nil {
+                                       snapLocalRootDiskDeviceKey, _, _ := 
shared.GetRootDiskDevice(snapArgs.Devices)
                                        if snapLocalRootDiskDeviceKey != "" {
-                                               
args.Devices[snapLocalRootDiskDeviceKey]["pool"] = parentStoragePool
+                                               
snapArgs.Devices[snapLocalRootDiskDeviceKey]["pool"] = parentStoragePool
                                        }
                                }
 
-                               s, err := 
containerCreateEmptySnapshot(container.DaemonState(), args)
+                               s, err := 
containerCreateEmptySnapshot(container.DaemonState(), snapArgs)
                                if err != nil {
                                        return err
                                }
 
                                wrapper := StorageProgressWriter(op, 
"fs_progress", s.Name())
-                               if err := RsyncRecv(shared.AddSlash(s.Path()), 
conn, wrapper); err != nil {
+                               if err := RsyncRecv(shared.AddSlash(s.Path()), 
conn, wrapper, args.RsyncArgs); err != nil {
                                        return err
                                }
 
@@ -248,29 +248,29 @@ func rsyncMigrationSink(live bool, container container, 
snapshots []*migration.S
                }
 
                wrapper := StorageProgressWriter(op, "fs_progress", 
container.Name())
-               err = RsyncRecv(shared.AddSlash(container.Path()), conn, 
wrapper)
+               err = RsyncRecv(shared.AddSlash(container.Path()), conn, 
wrapper, args.RsyncArgs)
                if err != nil {
                        return err
                }
        } else {
                if !containerOnly {
                        for _, snap := range snapshots {
-                               args := 
snapshotProtobufToContainerArgs(container.Name(), snap)
+                               snapArgs := 
snapshotProtobufToContainerArgs(container.Name(), snap)
 
                                // Ensure that snapshot and parent container 
have the
                                // same storage pool in their local root disk 
device.
                                // If the root disk device for the snapshot 
comes from a
                                // profile on the new instance as well we don't 
need to
                                // do anything.
-                               if args.Devices != nil {
-                                       snapLocalRootDiskDeviceKey, _, _ := 
shared.GetRootDiskDevice(args.Devices)
+                               if snapArgs.Devices != nil {
+                                       snapLocalRootDiskDeviceKey, _, _ := 
shared.GetRootDiskDevice(snapArgs.Devices)
                                        if snapLocalRootDiskDeviceKey != "" {
-                                               
args.Devices[snapLocalRootDiskDeviceKey]["pool"] = parentStoragePool
+                                               
snapArgs.Devices[snapLocalRootDiskDeviceKey]["pool"] = parentStoragePool
                                        }
                                }
 
                                wrapper := StorageProgressWriter(op, 
"fs_progress", snap.GetName())
-                               err := 
RsyncRecv(shared.AddSlash(container.Path()), conn, wrapper)
+                               err := 
RsyncRecv(shared.AddSlash(container.Path()), conn, wrapper, args.RsyncArgs)
                                if err != nil {
                                        return err
                                }
@@ -280,7 +280,7 @@ func rsyncMigrationSink(live bool, container container, 
snapshots []*migration.S
                                        return err
                                }
 
-                               _, err = 
containerCreateAsSnapshot(container.DaemonState(), args, container)
+                               _, err = 
containerCreateAsSnapshot(container.DaemonState(), snapArgs, container)
                                if err != nil {
                                        return err
                                }
@@ -288,7 +288,7 @@ func rsyncMigrationSink(live bool, container container, 
snapshots []*migration.S
                }
 
                wrapper := StorageProgressWriter(op, "fs_progress", 
container.Name())
-               err = RsyncRecv(shared.AddSlash(container.Path()), conn, 
wrapper)
+               err = RsyncRecv(shared.AddSlash(container.Path()), conn, 
wrapper, args.RsyncArgs)
                if err != nil {
                        return err
                }
@@ -297,7 +297,7 @@ func rsyncMigrationSink(live bool, container container, 
snapshots []*migration.S
        if live {
                /* now receive the final sync */
                wrapper := StorageProgressWriter(op, "fs_progress", 
container.Name())
-               err := RsyncRecv(shared.AddSlash(container.Path()), conn, 
wrapper)
+               err := RsyncRecv(shared.AddSlash(container.Path()), conn, 
wrapper, args.RsyncArgs)
                if err != nil {
                        return err
                }
diff --git a/lxd/storage_mock.go b/lxd/storage_mock.go
index 201ea1d065..e2713e3fcb 100644
--- a/lxd/storage_mock.go
+++ b/lxd/storage_mock.go
@@ -226,7 +226,7 @@ func (s *storageMock) MigrationSource(container container, 
containerOnly bool) (
        return nil, fmt.Errorf("not implemented")
 }
 
-func (s *storageMock) MigrationSink(live bool, container container, snapshots 
[]*migration.Snapshot, conn *websocket.Conn, srcIdmap *idmap.IdmapSet, op 
*operation, containerOnly bool) error {
+func (s *storageMock) MigrationSink(live bool, container container, snapshots 
[]*migration.Snapshot, conn *websocket.Conn, srcIdmap *idmap.IdmapSet, op 
*operation, containerOnly bool, args MigrationSinkArgs) error {
        return nil
 }
 
@@ -246,7 +246,7 @@ func (s *storageMock) StorageMigrationSource() 
(MigrationStorageSourceDriver, er
        return nil, nil
 }
 
-func (s *storageMock) StorageMigrationSink(conn *websocket.Conn, op 
*operation, storage storage) error {
+func (s *storageMock) StorageMigrationSink(conn *websocket.Conn, op 
*operation, storage storage, args MigrationSinkArgs) error {
        return nil
 }
 
diff --git a/lxd/storage_zfs.go b/lxd/storage_zfs.go
index d96eaae42e..49e2cdca9f 100644
--- a/lxd/storage_zfs.go
+++ b/lxd/storage_zfs.go
@@ -2583,7 +2583,7 @@ func (s *storageZfs) MigrationSource(ct container, 
containerOnly bool) (Migratio
        return &driver, nil
 }
 
-func (s *storageZfs) MigrationSink(live bool, container container, snapshots 
[]*migration.Snapshot, conn *websocket.Conn, srcIdmap *idmap.IdmapSet, op 
*operation, containerOnly bool) error {
+func (s *storageZfs) MigrationSink(live bool, container container, snapshots 
[]*migration.Snapshot, conn *websocket.Conn, srcIdmap *idmap.IdmapSet, op 
*operation, containerOnly bool, args MigrationSinkArgs) error {
        poolName := s.getOnDiskPoolName()
        zfsRecv := func(zfsName string, writeWrapper func(io.WriteCloser) 
io.WriteCloser) error {
                zfsFsName := fmt.Sprintf("%s/%s", poolName, zfsName)
@@ -2933,8 +2933,8 @@ func (s *storageZfs) StorageMigrationSource() 
(MigrationStorageSourceDriver, err
        return rsyncStorageMigrationSource()
 }
 
-func (s *storageZfs) StorageMigrationSink(conn *websocket.Conn, op *operation, 
storage storage) error {
-       return rsyncStorageMigrationSink(conn, op, storage)
+func (s *storageZfs) StorageMigrationSink(conn *websocket.Conn, op *operation, 
storage storage, args MigrationSinkArgs) error {
+       return rsyncStorageMigrationSink(conn, op, storage, args)
 }
 
 func (s *storageZfs) GetStoragePool() *api.StoragePool {
_______________________________________________
lxc-devel mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to