diff mbox

block migration: Activate image on destination before writing to it

Message ID 1456133113-15298-1-git-send-email-kwolf@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kevin Wolf Feb. 22, 2016, 9:25 a.m. UTC
When using 'migrate -b', we must make sure to take ownership of the
image before writing to it. Otherwise metadata would be thrown away on
migration completion; this was caught by the assertions introduced in
commit 09e0c771.

Reported-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 migration/block.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Stefan Hajnoczi Feb. 22, 2016, 7:18 p.m. UTC | #1
On Mon, Feb 22, 2016 at 10:25:13AM +0100, Kevin Wolf wrote:
> When using 'migrate -b', we must make sure to take ownership of the
> image before writing to it. Otherwise metadata would be thrown away on
> migration completion; this was caught by the assertions introduced in
> commit 09e0c771.
> 
> Reported-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  migration/block.c | 7 +++++++
>  1 file changed, 7 insertions(+)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
diff mbox

Patch

diff --git a/migration/block.c b/migration/block.c
index a444058..3a8330a 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -786,6 +786,7 @@  static int block_load(QEMUFile *f, void *opaque, int version_id)
     int64_t addr;
     BlockDriverState *bs, *bs_prev = NULL;
     BlockBackend *blk;
+    Error *local_err = NULL;
     uint8_t *buf;
     int64_t total_sectors = 0;
     int nr_sectors;
@@ -824,6 +825,12 @@  static int block_load(QEMUFile *f, void *opaque, int version_id)
                                  device_name);
                     return -EINVAL;
                 }
+
+                bdrv_invalidate_cache(bs, &local_err);
+                if (local_err) {
+                    error_report_err(local_err);
+                    return -EINVAL;
+                }
             }
 
             if (total_sectors - addr < BDRV_SECTORS_PER_DIRTY_CHUNK) {