Skip to content

Commit

Permalink
block: fix wrong order in live block migration setup
Browse files Browse the repository at this point in the history
The function init_blk_migration is better to be called before
set_dirty_tracking as the reasons below.

If we want to track dirty blocks via dirty_maps on a BlockDriverState
when doing live block-migration, its correspoding 'BlkMigDevState' should be
added to block_mig_state.bmds_list first for subsequent processing.
Otherwise set_dirty_tracking will do nothing on an empty list than allocating
dirty_bitmaps for them. And bdrv_get_dirty_count will access the
bmds->dirty_maps directly, then there would be a segfault triggered.

If the set_dirty_tracking fails, qemu_savevm_state_cancel will handle
the cleanup of init_blk_migration automatically.

Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: chai wen <chaiw.fnst@cn.fujitsu.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
chai wen authored and stefanhaRH committed Jun 4, 2014
1 parent b15446f commit 1ac362c
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions block-migration.c
Expand Up @@ -629,6 +629,7 @@ static int block_save_setup(QEMUFile *f, void *opaque)
block_mig_state.submitted, block_mig_state.transferred);

qemu_mutex_lock_iothread();
init_blk_migration(f);

/* start track dirty blocks */
ret = set_dirty_tracking();
Expand All @@ -638,8 +639,6 @@ static int block_save_setup(QEMUFile *f, void *opaque)
return ret;
}

init_blk_migration(f);

qemu_mutex_unlock_iothread();

ret = flush_blks(f);
Expand Down

0 comments on commit 1ac362c

Please sign in to comment.