[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 03/40] block/qapi: Factor out bdrv_query_bds_stats()
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 03/40] block/qapi: Factor out bdrv_query_bds_stats() |
Date: |
Mon, 14 Mar 2016 18:37:04 +0100 |
The new functions handles the data that is taken from the
BlockDriverState.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
block/qapi.c | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/block/qapi.c b/block/qapi.c
index c04f1d8..31ae879 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -355,6 +355,9 @@ static void bdrv_query_info(BlockBackend *blk, BlockInfo
**p_info,
qapi_free_BlockInfo(info);
}
+static BlockStats *bdrv_query_stats(const BlockDriverState *bs,
+ bool query_backing);
+
static void bdrv_query_blk_stats(BlockStats *s, BlockBackend *blk)
{
BlockAcctStats *stats = blk_get_stats(blk);
@@ -422,13 +425,9 @@ static void bdrv_query_blk_stats(BlockStats *s,
BlockBackend *blk)
}
}
-static BlockStats *bdrv_query_stats(const BlockDriverState *bs,
- bool query_backing)
+static void bdrv_query_bds_stats(BlockStats *s, const BlockDriverState *bs,
+ bool query_backing)
{
- BlockStats *s;
-
- s = g_malloc0(sizeof(*s));
-
if (bdrv_get_device_name(bs)[0]) {
s->has_device = true;
s->device = g_strdup(bdrv_get_device_name(bs));
@@ -439,11 +438,6 @@ static BlockStats *bdrv_query_stats(const BlockDriverState
*bs,
s->node_name = g_strdup(bdrv_get_node_name(bs));
}
- s->stats = g_malloc0(sizeof(*s->stats));
- if (bs->blk) {
- bdrv_query_blk_stats(s, bs->blk);
- }
-
s->stats->wr_highest_offset = bs->wr_highest_offset;
if (bs->file) {
@@ -456,6 +450,21 @@ static BlockStats *bdrv_query_stats(const BlockDriverState
*bs,
s->backing = bdrv_query_stats(bs->backing->bs, query_backing);
}
+}
+
+static BlockStats *bdrv_query_stats(const BlockDriverState *bs,
+ bool query_backing)
+{
+ BlockStats *s;
+
+ s = g_malloc0(sizeof(*s));
+ s->stats = g_malloc0(sizeof(*s->stats));
+
+ if (bs->blk) {
+ bdrv_query_blk_stats(s, bs->blk);
+ }
+ bdrv_query_bds_stats(s, bs, query_backing);
+
return s;
}
--
1.8.3.1
- [Qemu-devel] [PULL 00/40] Block patches, Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 03/40] block/qapi: Factor out bdrv_query_bds_stats(),
Kevin Wolf <=
- [Qemu-devel] [PULL 01/40] qemu-img: eliminate memory leak, Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 02/40] block/qapi: Factor out bdrv_query_blk_stats(), Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 04/40] block/qapi: Include empty drives in query-blockstats, Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 05/40] block/vpc: choose size calculation method based on creator_app field, Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 09/40] docs: fix invalid node name in qmp event, Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 11/40] quorum: modify vote rules for flush operation, Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 06/40] block/vpc: tests for auto-detecting VPC and Hyper-V VHD images, Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 10/40] qmp event: Refactor QUORUM_REPORT_BAD, Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 08/40] block/vpc: add tests for image creation force_size parameter, Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 07/40] block/vpc: give option to force the current_size field in .bdrv_create, Kevin Wolf, 2016/03/14