aboutsummaryrefslogtreecommitdiff
path: root/nbd.c
diff options
context:
space:
mode:
authorAlexey Kardashevskiy <aik@ozlabs.ru>2014-10-09 13:50:46 +1100
committerJuan Quintela <quintela@trasno.org>2014-10-14 09:35:21 +0200
commit7ea2d269cb84ca7a2f4b7c3735634176f7c1dc35 (patch)
tree7db382cb3a25419bfafdfa8bfa8f8f248debe1bd /nbd.c
parent9935baca9b3573dfdb19aff03b3cbe1116350400 (diff)
block/migration: Disable cache invalidate for incoming migration
When migrated using libvirt with "--copy-storage-all", at the end of migration there is race between NBD mirroring task trying to do flush and migration completion, both end up invalidating cache. Since qcow2 driver does not handle this situation very well, random crashes happen. This disables the BDRV_O_INCOMING flag for the block device being migrated once the cache has been invalidated. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> -- fixed parens by hand Signed-off-by: Juan Quintela <quintela@redhat.com>
Diffstat (limited to 'nbd.c')
-rw-r--r--nbd.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/nbd.c b/nbd.c
index e9b539be58..a7bce45117 100644
--- a/nbd.c
+++ b/nbd.c
@@ -972,6 +972,12 @@ NBDExport *nbd_export_new(BlockDriverState *bs, off_t dev_offset,
exp->ctx = bdrv_get_aio_context(bs);
bdrv_ref(bs);
bdrv_add_aio_context_notifier(bs, bs_aio_attached, bs_aio_detach, exp);
+ /*
+ * NBD exports are used for non-shared storage migration. Make sure
+ * that BDRV_O_INCOMING is cleared and the image is ready for write
+ * access since the export could be available before migration handover.
+ */
+ bdrv_invalidate_cache(bs, NULL);
return exp;
}