diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2018-07-05 13:33:52 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2018-07-05 13:33:52 +0100 |
commit | 6cf495be0b445789eeb7e88a6015c8cf74d4c1cf (patch) | |
tree | cc515b3f7f99f69d7acc26310d4f62a91df73aba | |
parent | 4fd1cbaf146d4ab35f465bba0fe23115c33cd5a7 (diff) | |
parent | 58f72b965e9e1820d246329461216c4d13140122 (diff) |
Merge remote-tracking branch 'remotes/jnsnow/tags/bitmaps-pull-request' into staging
Pull request
# gpg: Signature made Wed 04 Jul 2018 07:33:42 BST
# gpg: using RSA key 7DEF8106AAFC390E
# gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>"
# Primary key fingerprint: FAEB 9711 A12C F475 812F 18F2 88A9 064D 1835 61EB
# Subkey fingerprint: F9B7 ABDB BCAC DF95 BE76 CBD0 7DEF 8106 AAFC 390E
* remotes/jnsnow/tags/bitmaps-pull-request:
dirty-bitmap: fix double lock on bitmap enabling
block/dirty-bitmap: add bdrv_enable_dirty_bitmap_locked
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r-- | block/dirty-bitmap.c | 12 | ||||
-rw-r--r-- | include/block/dirty-bitmap.h | 1 | ||||
-rw-r--r-- | migration/block-dirty-bitmap.c | 4 |
3 files changed, 12 insertions, 5 deletions
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index db1782ec1f..c9b8a6fd52 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -241,11 +241,18 @@ int bdrv_dirty_bitmap_create_successor(BlockDriverState *bs, return 0; } +void bdrv_enable_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap) +{ + assert(!bdrv_dirty_bitmap_frozen(bitmap)); + bitmap->disabled = false; +} + /* Called with BQL taken. */ void bdrv_dirty_bitmap_enable_successor(BdrvDirtyBitmap *bitmap) { + assert(bitmap->mutex == bitmap->successor->mutex); qemu_mutex_lock(bitmap->mutex); - bdrv_enable_dirty_bitmap(bitmap->successor); + bdrv_enable_dirty_bitmap_locked(bitmap->successor); qemu_mutex_unlock(bitmap->mutex); } @@ -424,8 +431,7 @@ void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap) void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap) { bdrv_dirty_bitmap_lock(bitmap); - assert(!bdrv_dirty_bitmap_frozen(bitmap)); - bitmap->disabled = false; + bdrv_enable_dirty_bitmap_locked(bitmap); bdrv_dirty_bitmap_unlock(bitmap); } diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h index 288dc6adb6..259bd27c40 100644 --- a/include/block/dirty-bitmap.h +++ b/include/block/dirty-bitmap.h @@ -32,6 +32,7 @@ void bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs, Error **errp); void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap); void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap); +void bdrv_enable_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap); BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs); uint32_t bdrv_get_default_bitmap_granularity(BlockDriverState *bs); uint32_t bdrv_dirty_bitmap_granularity(const BdrvDirtyBitmap *bitmap); diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 3bafbbdc4c..477826330c 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -511,7 +511,7 @@ void dirty_bitmap_mig_before_vm_start(void) DirtyBitmapLoadBitmapState *b = item->data; if (b->migrated) { - bdrv_enable_dirty_bitmap(b->bitmap); + bdrv_enable_dirty_bitmap_locked(b->bitmap); } else { bdrv_dirty_bitmap_enable_successor(b->bitmap); } @@ -547,7 +547,7 @@ static void dirty_bitmap_load_complete(QEMUFile *f, DirtyBitmapLoadState *s) if (enabled_bitmaps == NULL) { /* in postcopy */ bdrv_reclaim_dirty_bitmap_locked(s->bs, s->bitmap, &error_abort); - bdrv_enable_dirty_bitmap(s->bitmap); + bdrv_enable_dirty_bitmap_locked(s->bitmap); } else { /* target not started, successor must be empty */ int64_t count = bdrv_get_dirty_count(s->bitmap); |