From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXmk7-0006br-K2 for qemu-devel@nongnu.org; Mon, 22 Feb 2016 04:25:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aXmk6-0008GI-G7 for qemu-devel@nongnu.org; Mon, 22 Feb 2016 04:25:23 -0500 From: Kevin Wolf Date: Mon, 22 Feb 2016 10:25:13 +0100 Message-Id: <1456133113-15298-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH] block migration: Activate image on destination before writing to it List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org 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 Signed-off-by: Kevin Wolf --- migration/block.c | 7 +++++++ 1 file changed, 7 insertions(+) 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) { -- 1.8.3.1