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

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 #4475.

Signed-off-by: Christian Brauner <[email protected]>
From 795d74cafced1b4c39c6623d197754ef9d42a83c Mon Sep 17 00:00:00 2001
From: Christian Brauner <[email protected]>
Date: Wed, 25 Apr 2018 16:09:42 +0200
Subject: [PATCH] migration: fix btrfs live migration

Closes #4475.

Signed-off-by: Christian Brauner <[email protected]>
---
 lxd/container_lxc.go     |  5 +++++
 lxd/migrate_container.go |  4 ++++
 lxd/storage_btrfs.go     | 10 ++++++++--
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 63e137031..640dbc552 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -5104,6 +5104,11 @@ func (c *containerLXC) Migrate(args *CriuMigrationArgs) 
error {
                        opts.PredumpDir = fmt.Sprintf("../%s", args.preDumpDir)
                }
 
+               if !c.IsRunning() {
+                       // otherwise the migration will needlessly fail
+                       args.stop = false
+               }
+
                migrateErr = c.c.Migrate(args.cmd, opts)
        }
 
diff --git a/lxd/migrate_container.go b/lxd/migrate_container.go
index 9e1bd8aca..2d583fc28 100644
--- a/lxd/migrate_container.go
+++ b/lxd/migrate_container.go
@@ -993,6 +993,10 @@ func (c *migrationSink) Do(migrateOp *operation) error {
        for {
                select {
                case err = <-restore:
+                       if err != nil {
+                               disconnector()
+                               return err
+                       }
                        controller(err)
                        return err
                case msg, ok := <-source:
diff --git a/lxd/storage_btrfs.go b/lxd/storage_btrfs.go
index 6c2e02f4f..67ef92d95 100644
--- a/lxd/storage_btrfs.go
+++ b/lxd/storage_btrfs.go
@@ -2097,8 +2097,6 @@ func (s *storageBtrfs) MigrationSink(live bool, container 
container, snapshots [
                        return err
                }
 
-               defer os.RemoveAll(btrfsPath)
-
                err = btrfsSubVolumesDelete(receivedSnapshot)
                if err != nil {
                        logger.Errorf("Failed to delete BTRFS subvolume \"%s\": 
%s.", btrfsPath, err)
@@ -2184,6 +2182,7 @@ func (s *storageBtrfs) MigrationSink(live bool, container 
container, snapshots [
 
                        wrapper := StorageProgressWriter(op, "fs_progress", 
*snap.Name)
                        err = btrfsRecv(*(snap.Name), tmpSnapshotMntPoint, 
snapshotMntPoint, true, wrapper)
+                       os.RemoveAll(tmpSnapshotMntPoint)
                        if err != nil {
                                return err
                        }
@@ -2215,6 +2214,13 @@ func (s *storageBtrfs) MigrationSink(live bool, 
container container, snapshots [
                return err
        }
 
+       if live {
+               err = btrfsRecv("", tmpContainerMntPoint, containerMntPoint, 
false, wrapper)
+               if err != nil {
+                       return err
+               }
+       }
+
        return nil
 }
 
_______________________________________________
lxc-devel mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to