diff --git a/block.c b/block.c index b26817495bba015a386520f8eedeacda09c334c7..b8df11d647caeb50964c3babe77d4ab3df1fe306 100644 --- a/block.c +++ b/block.c @@ -5575,8 +5575,7 @@ BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs) BlockDirtyInfo *info = g_new0(BlockDirtyInfo, 1); BlockDirtyInfoList *entry = g_new0(BlockDirtyInfoList, 1); info->count = bdrv_get_dirty_count(bs, bm); - info->granularity = - ((uint32_t) BDRV_SECTOR_SIZE << hbitmap_granularity(bm->bitmap)); + info->granularity = bdrv_dirty_bitmap_granularity(bm); info->has_name = !!bm->name; info->name = g_strdup(bm->name); entry->value = info; @@ -5616,6 +5615,11 @@ uint32_t bdrv_get_default_bitmap_granularity(BlockDriverState *bs) return granularity; } +uint32_t bdrv_dirty_bitmap_granularity(BdrvDirtyBitmap *bitmap) +{ + return BDRV_SECTOR_SIZE << hbitmap_granularity(bitmap->bitmap); +} + void bdrv_dirty_iter_init(BlockDriverState *bs, BdrvDirtyBitmap *bitmap, HBitmapIter *hbi) { diff --git a/include/block/block.h b/include/block/block.h index 283117ff89744c53ddeadac61f7ff5ef87b0e846..0c0dd6d8b77c4c214e198b0d7210103b3ea62d76 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -460,6 +460,7 @@ void bdrv_dirty_bitmap_make_anon(BlockDriverState *bs, BdrvDirtyBitmap *bitmap); void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap); BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs); uint32_t bdrv_get_default_bitmap_granularity(BlockDriverState *bs); +uint32_t bdrv_dirty_bitmap_granularity(BdrvDirtyBitmap *bitmap); int bdrv_get_dirty(BlockDriverState *bs, BdrvDirtyBitmap *bitmap, int64_t sector); void bdrv_set_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap, int64_t cur_sector, int nr_sectors);