qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* QMP qom-get feels useless for child properties
@ 2020-05-29  6:57 Markus Armbruster
  2020-05-29  8:47 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Armbruster @ 2020-05-29  6:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Daniel P. Berrangé,
	Dr. David Alan Gilbert (git),
	Andreas Färber, clg

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 ;)

Fine print: child properties cannot dangle.  See
object_get_child_property().

To get the actual contents, you need to use another command:

    QMP> {"execute": "qom-list", "arguments": {"path": "/machine/peripheral"}}
    {"return": [{"name": "type", "type": "string"}, {"name": "vga", "type": "child<VGA>"}, {"name": "nic.0", "type": "child<virtio-net-pci>"}, {"name": "ide2", "type": "child<ide-cd>"}, {"name": "vd0", "type": "child<virtio-blk-pci>"}]}

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.
Sadly, -ENOTIME.



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: QMP qom-get feels useless for child properties
  2020-05-29  6:57 QMP qom-get feels useless for child properties Markus Armbruster
@ 2020-05-29  8:47 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2020-05-29  8:47 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel
  Cc: Daniel P. Berrangé, Dr. David Alan Gilbert (git),
	Andreas Färber, clg

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-29  8:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-29  6:57 QMP qom-get feels useless for child properties Markus Armbruster
2020-05-29  8:47 ` Paolo Bonzini

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).