aboutsummaryrefslogtreecommitdiff
path: root/migration
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2017-06-05 14:39:05 +0200
committerFam Zheng <famz@redhat.com>2017-06-16 07:55:00 +0800
commitb64bd51efa9bbf30df1b2f91477d2805678d0b93 (patch)
tree99267190671c4f0e72db020993ae16f3797120d3 /migration
parentc0bad49946287ef218e871608b753b9991f6e54c (diff)
block: protect modification of dirty bitmaps with a mutex
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20170605123908.18777-17-pbonzini@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com>
Diffstat (limited to 'migration')
-rw-r--r--migration/block.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/migration/block.c b/migration/block.c
index 423877bb40..7674ae1078 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -525,14 +525,15 @@ static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds,
} else {
blk_mig_unlock();
}
- if (bdrv_get_dirty(bs, bmds->dirty_bitmap, sector)) {
-
+ bdrv_dirty_bitmap_lock(bmds->dirty_bitmap);
+ if (bdrv_get_dirty_locked(bs, bmds->dirty_bitmap, sector)) {
if (total_sectors - sector < BDRV_SECTORS_PER_DIRTY_CHUNK) {
nr_sectors = total_sectors - sector;
} else {
nr_sectors = BDRV_SECTORS_PER_DIRTY_CHUNK;
}
- bdrv_reset_dirty_bitmap(bmds->dirty_bitmap, sector, nr_sectors);
+ bdrv_reset_dirty_bitmap_locked(bmds->dirty_bitmap, sector, nr_sectors);
+ bdrv_dirty_bitmap_unlock(bmds->dirty_bitmap);
blk = g_new(BlkMigBlock, 1);
blk->buf = g_malloc(BLOCK_SIZE);
@@ -568,9 +569,10 @@ static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds,
sector += nr_sectors;
bmds->cur_dirty = sector;
-
break;
}
+
+ bdrv_dirty_bitmap_unlock(bmds->dirty_bitmap);
sector += BDRV_SECTORS_PER_DIRTY_CHUNK;
bmds->cur_dirty = sector;
}