Skip to content

Commit f187609

Browse files
Fabiano RosasstefanhaRH
authored andcommitted
block-migration: Ensure we don't crash during migration cleanup
We can fail the blk_insert_bs() at init_blk_migration(), leaving the BlkMigDevState without a dirty_bitmap and BlockDriverState. Account for the possibly missing elements when doing cleanup. Fix the following crashes: Thread 1 "qemu-system-x86" received signal SIGSEGV, Segmentation fault. 0x0000555555ec83ef in bdrv_release_dirty_bitmap (bitmap=0x0) at ../block/dirty-bitmap.c:359 359 BlockDriverState *bs = bitmap->bs; #0 0x0000555555ec83ef in bdrv_release_dirty_bitmap (bitmap=0x0) at ../block/dirty-bitmap.c:359 #1 0x0000555555bba331 in unset_dirty_tracking () at ../migration/block.c:371 qemu#2 0x0000555555bbad98 in block_migration_cleanup_bmds () at ../migration/block.c:681 Thread 1 "qemu-system-x86" received signal SIGSEGV, Segmentation fault. 0x0000555555e971ff in bdrv_op_unblock (bs=0x0, op=BLOCK_OP_TYPE_BACKUP_SOURCE, reason=0x0) at ../block.c:7073 7073 QLIST_FOREACH_SAFE(blocker, &bs->op_blockers[op], list, next) { #0 0x0000555555e971ff in bdrv_op_unblock (bs=0x0, op=BLOCK_OP_TYPE_BACKUP_SOURCE, reason=0x0) at ../block.c:7073 #1 0x0000555555e9734a in bdrv_op_unblock_all (bs=0x0, reason=0x0) at ../block.c:7095 qemu#2 0x0000555555bbae13 in block_migration_cleanup_bmds () at ../migration/block.c:690 Signed-off-by: Fabiano Rosas <[email protected]> Message-id: [email protected] Signed-off-by: Stefan Hajnoczi <[email protected]>
1 parent 813bac3 commit f187609

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

migration/block.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,9 @@ static void unset_dirty_tracking(void)
368368
BlkMigDevState *bmds;
369369

370370
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
371-
bdrv_release_dirty_bitmap(bmds->dirty_bitmap);
371+
if (bmds->dirty_bitmap) {
372+
bdrv_release_dirty_bitmap(bmds->dirty_bitmap);
373+
}
372374
}
373375
}
374376

@@ -676,13 +678,18 @@ static int64_t get_remaining_dirty(void)
676678
static void block_migration_cleanup_bmds(void)
677679
{
678680
BlkMigDevState *bmds;
681+
BlockDriverState *bs;
679682
AioContext *ctx;
680683

681684
unset_dirty_tracking();
682685

683686
while ((bmds = QSIMPLEQ_FIRST(&block_mig_state.bmds_list)) != NULL) {
684687
QSIMPLEQ_REMOVE_HEAD(&block_mig_state.bmds_list, entry);
685-
bdrv_op_unblock_all(blk_bs(bmds->blk), bmds->blocker);
688+
689+
bs = blk_bs(bmds->blk);
690+
if (bs) {
691+
bdrv_op_unblock_all(bs, bmds->blocker);
692+
}
686693
error_free(bmds->blocker);
687694

688695
/* Save ctx, because bmds->blk can disappear during blk_unref. */

0 commit comments

Comments
 (0)