From: Paolo Bonzini <pbonzini@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>,
"Andreas Färber" <afaerber@suse.de>,
clg@kaod.org
Subject: Re: QMP qom-get feels useless for child properties
Date: Fri, 29 May 2020 10:47:42 +0200 [thread overview]
Message-ID: <037647cc-d7e4-65a6-19d3-977fc6e4f2c7@redhat.com> (raw)
In-Reply-To: <87lflbns8o.fsf@dusky.pond.sub.org>
On 29/05/20 08:57, Markus Armbruster wrote:
> QMP qom-get for a link property returns the canonical path of the link's
> target:
>
> $ socat "READLINE,history=$HOME/.qmp_history,prompt=QMP> " UNIX-CONNECT:$HOME/work/images/test-qmp
> [...]
> QMP> {"execute": "qom-get", "arguments": {"path": "/machine", "property": "acpi-device"}}
> {"return": "/machine/unattached/device[23]"}
>
> This makes sense.
>
> Fine print: it returns "" for dangling links, I think. See
> object_get_link_property().
>
> qom-get behaves the same for child properties:
>
> QMP> {"execute": "qom-get", "arguments": {"path": "/machine", "property": "peripheral"}}
> {"return": "/machine/peripheral"}
>
> This surprised me. I'm writing to the list in the hope of saving
> somebody else the surprise and the time to figure out what's going on
> here.
>
> Returning the canonical path feels useless here. The only explanation
> that comes to my mind is we have to return something, the canonical path
> is something, therefore we have to return it ;)
It is useful in that the caller need not care whether a property is a
child or a link. If a property has object type, it consistently returns
a canonical path.
> You either just know that /machine/peripheral is a child property, or
> you recognize the pattern "type": "child<T>" in output of qom-list one
> level up:
>
> QMP>{"execute":"qom-list","arguments":{"path":"/machine"}}
> {"return": [... {"name": "peripheral", "type": "child<container>"}, ...]}
>
> I believe ad hoc matching of type strings is necessary in other cases to
> make sense of qom-get output.
>
> I wish QOM introspection described types like QAPI introspection does.
At least in theory all QOM property types should be one of child<>,
link<> or a QAPI type. Perhaps it should have been just the QOM type
without the child<> and link<> annotations? Can we change that
retroactively? (We probably can).
Paolo
prev parent reply other threads:[~2020-05-29 8:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-29 6:57 QMP qom-get feels useless for child properties Markus Armbruster
2020-05-29 8:47 ` Paolo Bonzini [this message]
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=037647cc-d7e4-65a6-19d3-977fc6e4f2c7@redhat.com \
--to=pbonzini@redhat.com \
--cc=afaerber@suse.de \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=clg@kaod.org \
--cc=dgilbert@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).