qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: crosa@redhat.com, ehabkost@redhat.com, eblake@redhat.com,
	armbru@redhat.com, kwolf@redhat.com, den@openvz.org
Subject: Re: [Qemu-devel] [PATCH v4 1/3] qapi: add x-debug-query-block-graph
Date: Sat, 13 Oct 2018 15:55:34 +0200	[thread overview]
Message-ID: <25ab8194-078c-aee7-a9fa-ea1e5310621d@redhat.com> (raw)
In-Reply-To: <20181009150006.10712-2-vsementsov@virtuozzo.com>

[-- Attachment #1: Type: text/plain, Size: 1932 bytes --]

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 <vsementsov@virtuozzo.com>
> ---
>  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));
> +        }
> +    }


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2018-10-13 13:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-09 15:00 [Qemu-devel] [PATCH v4 0/3] block nodes graph visualization Vladimir Sementsov-Ogievskiy
2018-10-09 15:00 ` [Qemu-devel] [PATCH v4 1/3] qapi: add x-debug-query-block-graph Vladimir Sementsov-Ogievskiy
2018-10-13 13:55   ` Max Reitz [this message]
2018-10-09 15:00 ` [Qemu-devel] [PATCH v4 2/3] scripts: add render_block_graph function for QEMUMachine Vladimir Sementsov-Ogievskiy
2018-10-09 15:00 ` [Qemu-devel] [PATCH v4 3/3] not-for-commit: example of new command usage for debugging Vladimir Sementsov-Ogievskiy

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=25ab8194-078c-aee7-a9fa-ea1e5310621d@redhat.com \
    --to=mreitz@redhat.com \
    --cc=armbru@redhat.com \
    --cc=crosa@redhat.com \
    --cc=den@openvz.org \
    --cc=eblake@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.com \
    /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).