From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com
Subject: [Qemu-devel] [PATCH 2/3] block/qapi: Factor out bdrv_query_bds_stats()
Date: Fri, 26 Feb 2016 21:22:21 +0100 [thread overview]
Message-ID: <1456518142-9849-3-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1456518142-9849-1-git-send-email-kwolf@redhat.com>
The new functions handles the data that is taken from the
BlockDriverState.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
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
next prev parent reply other threads:[~2016-02-26 20:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-26 20:22 [Qemu-devel] [PATCH 0/3] block/qapi: Include empty drives in query-blockstats Kevin Wolf
2016-02-26 20:22 ` [Qemu-devel] [PATCH 1/3] block/qapi: Factor out bdrv_query_blk_stats() Kevin Wolf
2016-03-02 16:42 ` Max Reitz
2016-02-26 20:22 ` Kevin Wolf [this message]
2016-03-02 16:47 ` [Qemu-devel] [PATCH 2/3] block/qapi: Factor out bdrv_query_bds_stats() Max Reitz
2016-03-02 16:52 ` Kevin Wolf
2016-03-02 16:55 ` Max Reitz
2016-02-26 20:22 ` [Qemu-devel] [PATCH 3/3] block/qapi: Include empty drives in query-blockstats Kevin Wolf
2016-03-02 17:10 ` Max Reitz
2016-03-02 17:27 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456518142-9849-3-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).