All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: Max Reitz <mreitz@redhat.com>, Eric Blake <eblake@redhat.com>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: crosa@redhat.com, ehabkost@redhat.com, armbru@redhat.com,
	kwolf@redhat.com, famz@redhat.com, jsnow@redhat.com,
	den@openvz.org, stefanha@redhat.com, pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 1/3] qapi: add x-query-block-graph
Date: Mon, 20 Aug 2018 20:35:50 +0300	[thread overview]
Message-ID: <ca86b264-0694-973f-59aa-9d10a756bdda@virtuozzo.com> (raw)
In-Reply-To: <1c1b2056-19d6-843d-619d-0208b837970b@redhat.com>

20.08.2018 20:13, Max Reitz wrote:
> On 2018-08-20 19:04, Vladimir Sementsov-Ogievskiy wrote:
>> 20.08.2018 19:35, Max Reitz wrote:
>>> On 2018-08-20 17:13, Vladimir Sementsov-Ogievskiy wrote:
>>>> 20.08.2018 16:44, Max Reitz wrote:
>>>>> On 2018-08-20 12:20, Vladimir Sementsov-Ogievskiy wrote:
>>> [...]
>>>
>>>>>> My goal is to get graphviz representation of block graph with all the
>>>>>> parents for debugging. And I'm absolutely ok to do it with x-debug-.
>>>>>> Then we shouldn't care about enum for role type now. So, it the
>>>>>> patch ok
>>>>>> for you with x-debug- prefix?
>>>>> Actually, no, because I'm not sure whether using points for the IDs
>>>>> is a
>>>>> good idea.  That may defeat ASLR, and that would be a problem even with
>>>>> x-debug-.
>>>> Good point, agree.
>>>>
>>>>> So I'd prefer using e.g. a hash map to map pointers to freshly
>>>>> generated
>>>>> IDs (just incrementing integers).
>>> (By the way, that would also improve the speed of checking whether a
>>> certain node needs to be added to the @nodes list still.)
>>>
>>>>> In any case, I'll take a further look at the patch later, but another
>>>>> thing that I've just seen is that using the opaque pointers to identify
>>>>> a parent is something that doesn't look like it's guaranteed to work.
>>>> Hm, isn't it a bug? Can you point to an example?
>>> Ah, no, it's OK.  Well, kind of.  It's OK in the sense that it is unique
>>> when set.  I didn't notice that you only use it for the non-node
>>> parents, sorry.
>> hm, no, I use opaque for all. So, it can be zero? In what case? In this
>> case, I cant get its parent?
> As far as I can see, you only use it for BLOCK_GRAPH_NODE_TYPE_OTHER,
> and you only do it when the parent is indeed not a BDS (because BDS are
> always children of some sort, so they'll be automatically accounted for
> anyway).
>
> Ah, but you set edge->parent = (uint64_t)child->opaque.  I see, because
> you assume it's always going to point to the BDS.

... or to some non-bds parent

>
> Yeah, generally, you can't get the parent.  That's the whole point.  I
> suppose in practice your code works, but that's not how it's supposed to
> be.  You generally cannot go from child to parent, only through the
> interface defined through BdrvChildRole (which uses the opaque pointer).
>
> As I said, a safe way to do this would be to enumerate all possible
> block graph roots; those being (as far as I know) all BlockBackends and
> all monitor-owned BDSs (see bdrv_close_all(), which handles exactly
> those two cases).  Then you can walk down from the roots through the trees.

hmm, what about block jobs here?

>
>>> Still, it probably would be better to just use the BdrvChild object, as
>>> that should be unique as well, and it is obviously non-NULL.
>>> (BdrvChild.opaque may be NULL, even though it isn't in practice.)
>> but BdrvChild corresponds to edge in a graph, not to the node. I need
>> identificators for nodes..
> But an edge identifies two nodes.  All edges have at least one BDS on
> one end.
>
> Since you can identify all BDS through the BDS itself, if you have a
> non-BDS node, you can use the edge to identify it (because the other end
> of the edge is going to be a BDS which you can identify by itself).

But non-bds node may have several children, therefore several 
BdrvChild's with different pointers.. And only opque point should be the 
same for them.

>
> Or, well, if you take my suggestion and walk down the trees starting at
> the roots, you'll see that the only non-BDS nodes in the block graph are
> BlockBackends.  And you can just use their addresses to identify them
> (just internally, of course; externally you'll still want to generate a
> new ID).

As I understand, I'll not see block jobs in this way to be non-bds nodes..

>
> Max
>


-- 
Best regards,
Vladimir

  reply	other threads:[~2018-08-20 17:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-17 18:00 [Qemu-devel] [PATCH v2 0/3] block nodes graph visualization Vladimir Sementsov-Ogievskiy
2018-08-17 18:04 ` [Qemu-devel] [PATCH v2 1/3] qapi: add x-query-block-graph Vladimir Sementsov-Ogievskiy
2018-08-17 18:04   ` [Qemu-devel] [PATCH v2 2/3] scripts: add render_block_graph function for QEMUMachine Vladimir Sementsov-Ogievskiy
2018-08-17 18:25     ` Eduardo Habkost
2018-08-17 18:59       ` Vladimir Sementsov-Ogievskiy
2018-08-17 19:09         ` Eduardo Habkost
2018-08-17 18:04   ` [Qemu-devel] [PATCH v2 3/3] not-for-commit: example of new command usage for debugging Vladimir Sementsov-Ogievskiy
2018-08-17 20:32   ` [Qemu-devel] [PATCH v2 1/3] qapi: add x-query-block-graph Eric Blake
2018-08-17 21:03     ` Max Reitz
2018-08-20 10:20       ` Vladimir Sementsov-Ogievskiy
2018-08-20 13:44         ` Max Reitz
2018-08-20 15:13           ` Vladimir Sementsov-Ogievskiy
2018-08-20 16:35             ` Max Reitz
2018-08-20 17:04               ` Vladimir Sementsov-Ogievskiy
2018-08-20 17:13                 ` Max Reitz
2018-08-20 17:35                   ` Vladimir Sementsov-Ogievskiy [this message]
2018-08-22 15:19                     ` Vladimir Sementsov-Ogievskiy
2018-08-20 18:38           ` Vladimir Sementsov-Ogievskiy
2018-08-22  8:33             ` Max Reitz
2018-08-20 10:03     ` 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=ca86b264-0694-973f-59aa-9d10a756bdda@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=armbru@redhat.com \
    --cc=crosa@redhat.com \
    --cc=den@openvz.org \
    --cc=eblake@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=famz@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.