mirror of https://github.com/xemu-project/xemu.git
qapi: Change BlockDirtyInfo to list
We have multiple dirty bitmaps in BDS now, switch QAPI to allow query it (BlockInfo.dirty_bitmaps), and also drop old BlockInfo.dirty. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
e4654d2d94
commit
21b5683508
20
block.c
20
block.c
|
@ -4522,6 +4522,26 @@ void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs)
|
||||||
|
{
|
||||||
|
BdrvDirtyBitmap *bm;
|
||||||
|
BlockDirtyInfoList *list = NULL;
|
||||||
|
BlockDirtyInfoList **plist = &list;
|
||||||
|
|
||||||
|
QLIST_FOREACH(bm, &bs->dirty_bitmaps, list) {
|
||||||
|
BlockDirtyInfo *info = g_malloc0(sizeof(BlockDirtyInfo));
|
||||||
|
BlockDirtyInfoList *entry = g_malloc0(sizeof(BlockDirtyInfoList));
|
||||||
|
info->count = bdrv_get_dirty_count(bs, bm);
|
||||||
|
info->granularity =
|
||||||
|
((int64_t) BDRV_SECTOR_SIZE << hbitmap_granularity(bm->bitmap));
|
||||||
|
entry->value = info;
|
||||||
|
*plist = entry;
|
||||||
|
plist = &entry->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
int bdrv_get_dirty(BlockDriverState *bs, BdrvDirtyBitmap *bitmap, int64_t sector)
|
int bdrv_get_dirty(BlockDriverState *bs, BdrvDirtyBitmap *bitmap, int64_t sector)
|
||||||
{
|
{
|
||||||
if (bitmap) {
|
if (bitmap) {
|
||||||
|
|
|
@ -204,6 +204,11 @@ void bdrv_query_info(BlockDriverState *bs,
|
||||||
info->io_status = bs->iostatus;
|
info->io_status = bs->iostatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!QLIST_EMPTY(&bs->dirty_bitmaps)) {
|
||||||
|
info->has_dirty_bitmaps = true;
|
||||||
|
info->dirty_bitmaps = bdrv_query_dirty_bitmaps(bs);
|
||||||
|
}
|
||||||
|
|
||||||
if (bs->drv) {
|
if (bs->drv) {
|
||||||
info->has_inserted = true;
|
info->has_inserted = true;
|
||||||
info->inserted = g_malloc0(sizeof(*info->inserted));
|
info->inserted = g_malloc0(sizeof(*info->inserted));
|
||||||
|
|
|
@ -422,6 +422,7 @@ struct HBitmapIter;
|
||||||
typedef struct BdrvDirtyBitmap BdrvDirtyBitmap;
|
typedef struct BdrvDirtyBitmap BdrvDirtyBitmap;
|
||||||
BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, int granularity);
|
BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, int granularity);
|
||||||
void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap);
|
void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap);
|
||||||
|
BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs);
|
||||||
int bdrv_get_dirty(BlockDriverState *bs, BdrvDirtyBitmap *bitmap, int64_t sector);
|
int bdrv_get_dirty(BlockDriverState *bs, BdrvDirtyBitmap *bitmap, int64_t sector);
|
||||||
void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector, int nr_sectors);
|
void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector, int nr_sectors);
|
||||||
void bdrv_reset_dirty(BlockDriverState *bs, int64_t cur_sector, int nr_sectors);
|
void bdrv_reset_dirty(BlockDriverState *bs, int64_t cur_sector, int nr_sectors);
|
||||||
|
|
|
@ -948,8 +948,8 @@
|
||||||
# @tray_open: #optional True if the device has a tray and it is open
|
# @tray_open: #optional True if the device has a tray and it is open
|
||||||
# (only present if removable is true)
|
# (only present if removable is true)
|
||||||
#
|
#
|
||||||
# @dirty: #optional dirty bitmap information (only present if the dirty
|
# @dirty-bitmaps: #optional dirty bitmaps information (only present if the
|
||||||
# bitmap is enabled)
|
# driver has one or more dirty bitmaps) (Since 1.8)
|
||||||
#
|
#
|
||||||
# @io-status: #optional @BlockDeviceIoStatus. Only present if the device
|
# @io-status: #optional @BlockDeviceIoStatus. Only present if the device
|
||||||
# supports it and the VM is configured to stop on errors
|
# supports it and the VM is configured to stop on errors
|
||||||
|
@ -963,7 +963,7 @@
|
||||||
'data': {'device': 'str', 'type': 'str', 'removable': 'bool',
|
'data': {'device': 'str', 'type': 'str', 'removable': 'bool',
|
||||||
'locked': 'bool', '*inserted': 'BlockDeviceInfo',
|
'locked': 'bool', '*inserted': 'BlockDeviceInfo',
|
||||||
'*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
|
'*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
|
||||||
'*dirty': 'BlockDirtyInfo' } }
|
'*dirty-bitmaps': ['BlockDirtyInfo'] } }
|
||||||
|
|
||||||
##
|
##
|
||||||
# @query-block:
|
# @query-block:
|
||||||
|
|
Loading…
Reference in New Issue