[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 04/73] qmp: Add optional switch "query-nodes" in quer
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 04/73] qmp: Add optional switch "query-nodes" in query-blockstats |
Date: |
Wed, 10 Dec 2014 11:33:30 +0100 |
From: Fam Zheng <address@hidden>
This bool option will allow query all the node names. It iterates all
the BDSes that are assigned a name, also in this case don't query up the
backing chain.
Signed-off-by: Fam Zheng <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qapi.c | 20 +++++++++++++-------
hmp.c | 2 +-
qapi/block-core.json | 11 ++++++++++-
qmp-commands.hx | 2 +-
4 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/block/qapi.c b/block/qapi.c
index d70336a..3a14559 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -300,7 +300,8 @@ static void bdrv_query_info(BlockBackend *blk, BlockInfo
**p_info,
qapi_free_BlockInfo(info);
}
-static BlockStats *bdrv_query_stats(const BlockDriverState *bs)
+static BlockStats *bdrv_query_stats(const BlockDriverState *bs,
+ bool query_backing)
{
BlockStats *s;
@@ -330,12 +331,12 @@ static BlockStats *bdrv_query_stats(const
BlockDriverState *bs)
if (bs->file) {
s->has_parent = true;
- s->parent = bdrv_query_stats(bs->file);
+ s->parent = bdrv_query_stats(bs->file, query_backing);
}
- if (bs->backing_hd) {
+ if (query_backing && bs->backing_hd) {
s->has_backing = true;
- s->backing = bdrv_query_stats(bs->backing_hd);
+ s->backing = bdrv_query_stats(bs->backing_hd, query_backing);
}
return s;
@@ -366,17 +367,22 @@ BlockInfoList *qmp_query_block(Error **errp)
return NULL;
}
-BlockStatsList *qmp_query_blockstats(Error **errp)
+BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
+ bool query_nodes,
+ Error **errp)
{
BlockStatsList *head = NULL, **p_next = &head;
BlockDriverState *bs = NULL;
- while ((bs = bdrv_next(bs))) {
+ /* Just to be safe if query_nodes is not always initialized */
+ query_nodes = has_query_nodes && query_nodes;
+
+ while ((bs = query_nodes ? bdrv_next_node(bs) : bdrv_next(bs))) {
BlockStatsList *info = g_malloc0(sizeof(*info));
AioContext *ctx = bdrv_get_aio_context(bs);
aio_context_acquire(ctx);
- info->value = bdrv_query_stats(bs);
+ info->value = bdrv_query_stats(bs, !query_nodes);
aio_context_release(ctx);
*p_next = info;
diff --git a/hmp.c b/hmp.c
index 63d7686..94b27df 100644
--- a/hmp.c
+++ b/hmp.c
@@ -403,7 +403,7 @@ void hmp_info_blockstats(Monitor *mon, const QDict *qdict)
{
BlockStatsList *stats_list, *stats;
- stats_list = qmp_query_blockstats(NULL);
+ stats_list = qmp_query_blockstats(false, false, NULL);
for (stats = stats_list; stats; stats = stats->next) {
if (!stats->value->has_device) {
diff --git a/qapi/block-core.json b/qapi/block-core.json
index de1bd45..8e51e78 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -427,11 +427,20 @@
#
# Query the @BlockStats for all virtual block devices.
#
+# @query-nodes: #optional If true, the command will query all the block nodes
+# that have a node name, in a list which will include "parent"
+# information, but not "backing".
+# If false or omitted, the behavior is as before - query all the
+# device backends, recursively including their "parent" and
+# "backing". (Since 2.3)
+#
# Returns: A list of @BlockStats for each virtual block devices.
#
# Since: 0.14.0
##
-{ 'command': 'query-blockstats', 'returns': ['BlockStats'] }
+{ 'command': 'query-blockstats',
+ 'data': { '*query-nodes': 'bool' },
+ 'returns': ['BlockStats'] }
##
# @BlockdevOnError:
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 718dd92..d4b0010 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2347,7 +2347,7 @@ EQMP
{
.name = "query-blockstats",
- .args_type = "",
+ .args_type = "query-nodes:b?",
.mhandler.cmd_new = qmp_marshal_input_query_blockstats,
},
--
1.8.3.1
- [Qemu-devel] [PULL 71/73] vmdk: Check descriptor file length when reading it, (continued)
- [Qemu-devel] [PULL 71/73] vmdk: Check descriptor file length when reading it, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 70/73] vmdk: Clean up descriptor file reading, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 67/73] block: Use g_new0() for a bit of extra type checking, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 73/73] vmdk: Set errp on failures in vmdk_open_vmdk4, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 72/73] vmdk: Remove unnecessary initialization, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 64/73] qemu-iotests: Skip 099 for VMDK subformats with desc file, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 43/73] qcow2.py: Add required padding for header extensions, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 05/73] qjson: Drop trailing space for pretty formatting, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 59/73] iotests: Add test for unsupported image creation, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 12/73] blockdev: acquire AioContext in change-backing-file, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 04/73] qmp: Add optional switch "query-nodes" in query-blockstats,
Kevin Wolf <=
- [Qemu-devel] [PULL 18/73] blkdebug: Simplify and improve filename generation, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 33/73] block: Factor bdrv_probe_all() out of find_image_format(), Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 08/73] iotests: Use -qmp-pretty in 067, Kevin Wolf, 2014/12/10
- Re: [Qemu-devel] [PULL 00/73] Merging block-next for 2.3, Peter Maydell, 2014/12/11