diff options
author | Kevin Wolf <kwolf@redhat.com> | 2016-02-26 21:03:01 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2016-03-14 16:46:42 +0100 |
commit | b07363a1a38695e12fc888b490b6215358752e85 (patch) | |
tree | 58bd00cd11298b49c91c30678313eb92209950a7 /block/qapi.c | |
parent | 2b77e60ab86e240a06f1ef117ecd488e85d6226e (diff) | |
download | qemu-b07363a1a38695e12fc888b490b6215358752e85.tar.gz qemu-b07363a1a38695e12fc888b490b6215358752e85.tar.bz2 qemu-b07363a1a38695e12fc888b490b6215358752e85.zip |
block/qapi: Factor out bdrv_query_bds_stats()
The new functions handles the data that is taken from the
BlockDriverState.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block/qapi.c')
-rw-r--r-- | block/qapi.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/block/qapi.c b/block/qapi.c index c04f1d8042..31ae87941f 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; } |