From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49896) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wswnp-0005gs-0e for qemu-devel@nongnu.org; Fri, 06 Jun 2014 12:15:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wswnk-0004sg-9z for qemu-devel@nongnu.org; Fri, 06 Jun 2014 12:15:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48610) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wswnk-0004sJ-2J for qemu-devel@nongnu.org; Fri, 06 Jun 2014 12:15:32 -0400 From: Stefan Hajnoczi Date: Fri, 6 Jun 2014 18:13:55 +0200 Message-Id: <1402071243-16702-35-git-send-email-stefanha@redhat.com> In-Reply-To: <1402071243-16702-1-git-send-email-stefanha@redhat.com> References: <1402071243-16702-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 34/42] block: fix wrong order in live block migration setup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefan Hajnoczi , chai wen From: chai wen 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 Signed-off-by: chai wen Signed-off-by: Stefan Hajnoczi --- block-migration.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/block-migration.c b/block-migration.c index 1656270..25a0388 100644 --- a/block-migration.c +++ b/block-migration.c @@ -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(); @@ -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); -- 1.9.3