[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH v4 1/3] qapi: add x-debug-query-block-graph
From: |
Max Reitz |
Subject: |
Re: [Qemu-block] [PATCH v4 1/3] qapi: add x-debug-query-block-graph |
Date: |
Sat, 13 Oct 2018 15:55:34 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 |
On 09.10.18 17:00, Vladimir Sementsov-Ogievskiy wrote:
> Add a new command, returning block nodes (and their users) graph.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
> ---
> qapi/block-core.json | 108 ++++++++++++++++++++++++
> include/block/block.h | 1 +
> include/sysemu/block-backend.h | 2 +
> block.c | 146 +++++++++++++++++++++++++++++++++
> block/block-backend.c | 5 ++
> blockdev.c | 5 ++
> 6 files changed, 267 insertions(+)
[...]
> diff --git a/block.c b/block.c
> index 7710b399a3..90825f427f 100644
> --- a/block.c
> +++ b/block.c
> @@ -4047,6 +4047,152 @@ BlockDeviceInfoList *bdrv_named_nodes_list(Error
> **errp)
[...]
> +BlockGraph *bdrv_get_block_graph(Error **errp)
> +{
> + BlockBackend *blk;
> + BlockJob *job;
> + BlockDriverState *bs;
> + BdrvChild *child;
> + BlockGraphConstructor *gr = dbg_graph_new();
> +
> + for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) {
> + char *allocated_name = NULL;
> + const char *name = blk_name(blk);
> +
> + if (!name) {
blk_name() never returns NULL, so you need to check for !*name here.
The rest looks OK, although I realized that maybe we want to use the
QAPI type name "BlockGraph" for a non-debug command in the future. But
I think that as long as it's only this command providing that structure,
we should be free to rename it should the need arise.
(And introspection doesn't care about structure names, I think.)
Max
> + name = allocated_name = blk_get_attached_dev_id(blk);
> + }
> + dbg_graph_add_node(gr, blk, BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKEND,
> name);
> + g_free(allocated_name);
> + if (blk_root(blk)) {
> + dbg_graph_add_edge(gr, blk, blk_root(blk));
> + }
> + }
signature.asc
Description: OpenPGP digital signature