Skip to content

Commit

Permalink
migration/block: Clean up BBs in block_save_complete()
Browse files Browse the repository at this point in the history
We need to release any block migrations BlockBackends on the source
before successfully completing the migration because otherwise
inactivating the images will fail (inactivation only tolerates device
BBs).

Signed-off-by: Kevin Wolf <[email protected]>
Reviewed-by: Fam Zheng <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Reviewed-by: Jeff Cody <[email protected]>
  • Loading branch information
kevmw committed Jun 9, 2017
1 parent f07fa4c commit 362fdf1
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions migration/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,16 +674,14 @@ static int64_t get_remaining_dirty(void)
return dirty << BDRV_SECTOR_BITS;
}

/* Called with iothread lock taken. */

static void block_migration_cleanup(void *opaque)

/* Called with iothread lock taken. */
static void block_migration_cleanup_bmds(void)
{
BlkMigDevState *bmds;
BlkMigBlock *blk;
AioContext *ctx;

bdrv_drain_all();

unset_dirty_tracking();

while ((bmds = QSIMPLEQ_FIRST(&block_mig_state.bmds_list)) != NULL) {
Expand All @@ -701,6 +699,16 @@ static void block_migration_cleanup(void *opaque)
g_free(bmds->aio_bitmap);
g_free(bmds);
}
}

/* Called with iothread lock taken. */
static void block_migration_cleanup(void *opaque)
{
BlkMigBlock *blk;

bdrv_drain_all();

block_migration_cleanup_bmds();

blk_mig_lock();
while ((blk = QSIMPLEQ_FIRST(&block_mig_state.blk_list)) != NULL) {
Expand Down Expand Up @@ -844,6 +852,10 @@ static int block_save_complete(QEMUFile *f, void *opaque)

qemu_put_be64(f, BLK_MIG_FLAG_EOS);

/* Make sure that our BlockBackends are gone, so that the block driver
* nodes can be inactivated. */
block_migration_cleanup_bmds();

return 0;
}

Expand Down

0 comments on commit 362fdf1

Please sign in to comment.