[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 23/41] qapi: Change BlockDirtyInfo to list
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 23/41] qapi: Change BlockDirtyInfo to list |
Date: |
Fri, 29 Nov 2013 17:45:38 +0100 |
From: Fam Zheng <address@hidden>
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 <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 20 ++++++++++++++++++++
block/qapi.c | 5 +++++
include/block/block.h | 1 +
qapi-schema.json | 6 +++---
4 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/block.c b/block.c
index d792d53..765bbae 100644
--- a/block.c
+++ b/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)
{
if (bitmap) {
diff --git a/block/qapi.c b/block/qapi.c
index 6b0cdcf..a32cb79 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -204,6 +204,11 @@ void bdrv_query_info(BlockDriverState *bs,
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) {
info->has_inserted = true;
info->inserted = g_malloc0(sizeof(*info->inserted));
diff --git a/include/block/block.h b/include/block/block.h
index 33ae9a9..b6bdae8 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -422,6 +422,7 @@ struct HBitmapIter;
typedef struct BdrvDirtyBitmap BdrvDirtyBitmap;
BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, int
granularity);
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);
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);
diff --git a/qapi-schema.json b/qapi-schema.json
index 83fa485..8630eb5 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -948,8 +948,8 @@
# @tray_open: #optional True if the device has a tray and it is open
# (only present if removable is true)
#
-# @dirty: #optional dirty bitmap information (only present if the dirty
-# bitmap is enabled)
+# @dirty-bitmaps: #optional dirty bitmaps information (only present if the
+# driver has one or more dirty bitmaps) (Since 1.8)
#
# @io-status: #optional @BlockDeviceIoStatus. Only present if the device
# supports it and the VM is configured to stop on errors
@@ -963,7 +963,7 @@
'data': {'device': 'str', 'type': 'str', 'removable': 'bool',
'locked': 'bool', '*inserted': 'BlockDeviceInfo',
'*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
- '*dirty': 'BlockDirtyInfo' } }
+ '*dirty-bitmaps': ['BlockDirtyInfo'] } }
##
# @query-block:
--
1.8.1.4
- [Qemu-devel] [PULL 16/41] qemu-img: add support for fully allocated images, (continued)
- [Qemu-devel] [PULL 16/41] qemu-img: add support for fully allocated images, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 17/41] qemu-img: conditionally zero out target on convert, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 18/41] util/error: Save errno from clobbering, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 19/41] Test coroutine execution order, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 20/41] sheepdog: implement .bdrv_get_allocated_file_size, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 21/41] block/stream: Don't stream unbacked devices, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 22/41] block: per caller dirty bitmap, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 24/41] COW: Speed up writes, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 25/41] COW: Extend checking allocated bits to beyond one sector, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 26/41] MAINTAINERS: add sheepdog development mailing list, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 23/41] qapi: Change BlockDirtyInfo to list,
Kevin Wolf <=
- [Qemu-devel] [PULL 27/41] qdict: Fix memory leak in qdict_do_flatten(), Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 28/41] qdict: Optimise qdict_do_flatten(), Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 29/41] sheepdog: refactor do_sd_create(), Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 31/41] qemu-iotests: Drop local version of cancel_and_wait from 040, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 30/41] sheepdog: support user-defined redundancy option, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 32/41] blkdebug: add "remove_break" command, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 33/41] qemu-iotest: Add pause_drive and resume_drive methods, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 34/41] qemu-iotests: Make test case 030, 040 and 055 deterministic, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 35/41] block: Enable BDRV_O_SNAPSHOT with driver-specific options, Kevin Wolf, 2013/11/29