mirror of https://github.com/proxmox/mirror_qemu
block/qapi: Factor out bdrv_query_blk_stats()
The new functions handles the data that is taken from the BlockBackend. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>master
parent
396374caea
commit
2b77e60ab8
43
block/qapi.c
43
block/qapi.c
|
@ -355,26 +355,9 @@ static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info,
|
||||||
qapi_free_BlockInfo(info);
|
qapi_free_BlockInfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BlockStats *bdrv_query_stats(const BlockDriverState *bs,
|
static void bdrv_query_blk_stats(BlockStats *s, BlockBackend *blk)
|
||||||
bool query_backing)
|
|
||||||
{
|
{
|
||||||
BlockStats *s;
|
BlockAcctStats *stats = blk_get_stats(blk);
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bdrv_get_node_name(bs)[0]) {
|
|
||||||
s->has_node_name = true;
|
|
||||||
s->node_name = g_strdup(bdrv_get_node_name(bs));
|
|
||||||
}
|
|
||||||
|
|
||||||
s->stats = g_malloc0(sizeof(*s->stats));
|
|
||||||
if (bs->blk) {
|
|
||||||
BlockAcctStats *stats = blk_get_stats(bs->blk);
|
|
||||||
BlockAcctTimedStats *ts = NULL;
|
BlockAcctTimedStats *ts = NULL;
|
||||||
|
|
||||||
s->stats->rd_bytes = stats->nr_bytes[BLOCK_ACCT_READ];
|
s->stats->rd_bytes = stats->nr_bytes[BLOCK_ACCT_READ];
|
||||||
|
@ -437,6 +420,28 @@ static BlockStats *bdrv_query_stats(const BlockDriverState *bs,
|
||||||
dev_stats->avg_wr_queue_depth =
|
dev_stats->avg_wr_queue_depth =
|
||||||
block_acct_queue_depth(ts, BLOCK_ACCT_WRITE);
|
block_acct_queue_depth(ts, BLOCK_ACCT_WRITE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static BlockStats *bdrv_query_stats(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));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bdrv_get_node_name(bs)[0]) {
|
||||||
|
s->has_node_name = true;
|
||||||
|
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;
|
s->stats->wr_highest_offset = bs->wr_highest_offset;
|
||||||
|
|
Loading…
Reference in New Issue