qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, berto@igalia.com, mdroth@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH RFC v3 30/32] qapi: New QMP command query-schema for QMP schema introspection
Date: Wed, 5 Aug 2015 14:54:21 -0600	[thread overview]
Message-ID: <55C277FD.1020105@redhat.com> (raw)
In-Reply-To: <1438703896-12553-31-git-send-email-armbru@redhat.com>

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

On 08/04/2015 09:58 AM, Markus Armbruster wrote:
> * All type references are by name.
> 

>   Dictionary argument/result or list result is an implicit type
>   definition.
> 

> 
> * Clients should *not* look up types by name, because type names are
>   not ABI.  Look up the command or event you're interested in, then
>   follow the references.
> 
>   TODO Should we hide the type names to eliminate the temptation?

[not sure this conversation belongs better on 32 than here]

I was just experimenting with things, and noticed that our choice of
array names might not be ideal for clients.  We already discussed
earlier in the series that the name 'intList' might collide (the parser
currently rejects collisions with '*Kind', but not '*List').  But in
addition to that, look at what happens here in this patch:

    "{ \"element-type\": \"str\", \"meta-type\": \"array\", \"name\":
\"strList\" }, "

    "{ \"element-type\": \"BlockStats\", \"meta-type\": \"array\",
\"name\": \"BlockStatsList\" }, "

    "{ \"members\": [{ \"name\": \"values\", \"type\": \"strList\" } ],
\"meta-type\": \"object\", \"name\": \"SchemaInfoEnum\" }, "

    "{ \"arg-type\": \":obj-query-blockstats-arg\", \"meta-type\":
\"command\", \"name\": \"query-blockstats\", \"ret-type\":
\"BlockStatsList\" }, "


and particularly what happens to it after patch 32 is applied:

    "{ \"element-type\": \"str\", \"meta-type\": \"array\", \"name\":
\"270\" }, "

    "{ \"element-type\": \"179\", \"meta-type\": \"array\", \"name\":
\"96\" }, "

    "{ \"members\": [{ \"name\": \"values\", \"type\": \"270\" } ],
\"meta-type\": \"object\", \"name\": \"273\" }, "

    "{ \"arg-type\": \"95\", \"meta-type\": \"command\", \"name\":
\"query-blockstats\", \"ret-type\": \"96\" }, "

In order to learn the return type of query-blockstats (to see if a new
member was added to the struct), I now have to query what type 96 is,
see that it is an array, and then query what members type 179 has.  And
when dealing with type 273, I don't know whether to expect an array or
an object for the "type" member until I look up type 270 (but I _do_
know not to expect an int, number, boolean, or null).

What if we instead munged the name of array types in introspection
output to be "[int]" or "[BlockStats]"; or, with type masking in place,
"[int]" or "[179]"?  As in the following for the above examples:

 "{ \"element-type\": \"str\", \"meta-type\": \"array\", \"name\":
\"[str]\" }, "

"{ \"element-type\": \"179\", \"meta-type\": \"array\", \"name\":
\"[179]\" }, "

"{ \"members\": [{ \"name\": \"values\", \"type\": \"[str]\" } ],
\"meta-type\": \"object\", \"name\": \"273\" }, "

"{ \"arg-type\": \"95\", \"meta-type\": \"command\", \"name\":
\"query-blockstats\", \"ret-type\": \"[179]\" }, "

This way, libvirt or other clients could take shortcuts: I know that the
return of query-blockstats will be an array, and I only have to look up
the single type 179 to learn what members will be in the struct of that
array; likewise, when inspecting struct 273, I know that "type" is an
array of builtin strings and not an array of dicts, without needing to
do another type lookup.

I've always mentioned that I'm not a fan of packing multiple pieces of
information into a single JSON member (often a sign that the schema is
not specific enough), but in this particular case, the names would still
resolve without paying attention to the contents of the name.  That is,
we'd be providing extra information (whether a name starts with leading
'[') that clients can optionally use to be more efficient, but which
will not penalize clients that stick with the tried-and-true approach of
finding the array member with the matching name (that is, if I chase
"[179]", I will still learn that I need to look up "179").  And it gives
us the nice property that the first character of a type specifies its
JSON properties (letter=>builtin, [=>array, digit=>object), other than
the magic "any".

I still think we need to munge to '*List' internally (as in our
qapi_free_*() functions, for example), but what I'm trying to propose is
that we don't expose the '*List' naming convention through
introspection.  We'd also have to consider what this means for the
technical possibility of any 2D array types.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


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

  parent reply	other threads:[~2015-08-05 20:54 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-04 15:57 [Qemu-devel] [PATCH RFC v3 00/32] qapi: QMP introspection Markus Armbruster
2015-08-04 15:57 ` [Qemu-devel] [PATCH RFC v3 01/32] qapi: Rename class QAPISchema to QAPISchemaParser Markus Armbruster
2015-08-04 15:57 ` [Qemu-devel] [PATCH RFC v3 02/32] qapi: New QAPISchema intermediate reperesentation Markus Armbruster
2015-08-04 21:53   ` Eric Blake
2015-08-05  6:23     ` Markus Armbruster
2015-08-05 14:27       ` Eric Blake
2015-08-06  5:46         ` Markus Armbruster
2015-08-31 18:09           ` Markus Armbruster
2015-09-03 14:52             ` Eric Blake
2015-09-03 16:13               ` Markus Armbruster
2015-08-04 15:57 ` [Qemu-devel] [PATCH RFC v3 03/32] qapi: QAPISchema code generation helper methods Markus Armbruster
2015-08-04 22:18   ` Eric Blake
2015-08-04 15:57 ` [Qemu-devel] [PATCH RFC v3 04/32] qapi: New QAPISchemaVisitor Markus Armbruster
2015-08-04 22:26   ` Eric Blake
2015-08-05  6:24     ` Markus Armbruster
2015-08-04 15:57 ` [Qemu-devel] [PATCH RFC v3 05/32] tests/qapi-schema: Convert test harness to QAPISchemaVisitor Markus Armbruster
2015-08-04 22:35   ` Eric Blake
2015-08-05  6:26     ` Markus Armbruster
2015-08-04 15:57 ` [Qemu-devel] [PATCH RFC v3 06/32] qapi: Split up some typedefs to ease review Markus Armbruster
2015-08-04 22:37   ` Eric Blake
2015-08-04 15:57 ` [Qemu-devel] [PATCH RFC v3 07/32] qapi: Generate comments to simplify splitting for review Markus Armbruster
2015-08-04 22:54   ` Eric Blake
2015-08-04 15:57 ` [Qemu-devel] [PATCH RFC v3 08/32] Revert "qapi: Generate comments to simplify splitting for review" Markus Armbruster
2015-08-04 15:57 ` [Qemu-devel] [PATCH RFC v3 09/32] Revert "qapi: Split up some typedefs to ease review" Markus Armbruster
2015-08-04 15:57 ` [Qemu-devel] [PATCH RFC v3 10/32] qapi-types: Convert to QAPISchemaVisitor, fixing flat unions Markus Armbruster
2015-08-05 15:15   ` Eric Blake
2015-08-06  5:50     ` Markus Armbruster
2015-08-04 15:57 ` [Qemu-devel] [PATCH RFC v3 11/32] qapi-visit: Convert to QAPISchemaVisitor, fixing bugs Markus Armbruster
2015-08-05 16:03   ` Eric Blake
2015-08-06 22:53   ` Eric Blake
2015-08-08  6:07     ` Markus Armbruster
2015-08-04 15:57 ` [Qemu-devel] [PATCH RFC v3 12/32] qapi-commands: Convert to QAPISchemaVisitor Markus Armbruster
2015-08-04 15:57 ` [Qemu-devel] [PATCH RFC v3 13/32] qapi: De-duplicate enum code generation Markus Armbruster
2015-08-04 15:57 ` [Qemu-devel] [PATCH RFC v3 14/32] qapi-event: Eliminate global variable event_enum_value Markus Armbruster
2015-08-04 15:57 ` [Qemu-devel] [PATCH RFC v3 15/32] qapi-event: Convert to QAPISchemaVisitor, fixing data with base Markus Armbruster
2015-08-04 15:58 ` [Qemu-devel] [PATCH RFC v3 16/32] qapi: Generate comments to simplify splitting for review Markus Armbruster
2015-08-04 23:02   ` Eric Blake
2015-08-04 15:58 ` [Qemu-devel] [PATCH RFC v3 17/32] Revert "qapi: Generate comments to simplify splitting for review" Markus Armbruster
2015-08-04 15:58 ` [Qemu-devel] [PATCH RFC v3 18/32] qapi: Replace dirty is_c_ptr() by method c_null() Markus Armbruster
2015-08-05 16:13   ` Eric Blake
2015-08-06  5:52     ` Markus Armbruster
2015-08-04 15:58 ` [Qemu-devel] [PATCH RFC v3 19/32] qapi: Clean up after recent conversions to QAPISchemaVisitor Markus Armbruster
2015-08-05 16:29   ` Eric Blake
2015-08-04 15:58 ` [Qemu-devel] [PATCH RFC v3 20/32] qapi-visit: Rearrange code a bit Markus Armbruster
2015-08-04 15:58 ` [Qemu-devel] [PATCH RFC v3 21/32] qapi-commands: Rearrange code Markus Armbruster
2015-08-04 15:58 ` [Qemu-devel] [PATCH RFC v3 22/32] qapi: Rename qmp_marshal_input_FOO() to qmp_marshal_FOO() Markus Armbruster
2015-08-04 15:58 ` [Qemu-devel] [PATCH RFC v3 23/32] qapi: De-duplicate parameter list generation Markus Armbruster
2015-08-05 17:00   ` Eric Blake
2015-08-04 15:58 ` [Qemu-devel] [PATCH RFC v3 24/32] qapi-commands: De-duplicate output marshaling functions Markus Armbruster
2015-08-04 15:58 ` [Qemu-devel] [PATCH RFC v3 25/32] qapi: Improve built-in type documentation Markus Armbruster
2015-08-04 15:58 ` [Qemu-devel] [PATCH RFC v3 26/32] qapi: Introduce a first class 'any' type Markus Armbruster
2015-08-07 19:30   ` Eric Blake
2015-08-08  6:24     ` Markus Armbruster
2015-08-31  9:07       ` Markus Armbruster
2015-08-04 15:58 ` [Qemu-devel] [PATCH RFC v3 27/32] qom: Don't use 'gen': false for qom-get, qom-set, object-add Markus Armbruster
2015-08-04 15:58 ` [Qemu-devel] [PATCH RFC v3 28/32] qapi-schema: Fix up misleading specification of netdev_add Markus Armbruster
2015-08-04 15:58 ` [Qemu-devel] [PATCH RFC v3 29/32] qapi: Pseudo-type '**' is now unused, drop it Markus Armbruster
2015-08-05 17:13   ` Eric Blake
2015-08-04 15:58 ` [Qemu-devel] [PATCH RFC v3 30/32] qapi: New QMP command query-schema for QMP schema introspection Markus Armbruster
2015-08-05 20:20   ` Eric Blake
2015-08-06  6:23     ` Markus Armbruster
2015-09-01 13:09       ` Markus Armbruster
2015-09-01 15:48         ` Eric Blake
2015-08-05 20:54   ` Eric Blake [this message]
2015-08-06  6:47     ` Markus Armbruster
2015-08-23  4:17   ` Eric Blake
2015-08-24 11:30     ` Markus Armbruster
2015-08-24 13:07       ` Eric Blake
2015-08-24 16:51         ` Eric Blake
2015-08-24 16:55         ` Markus Armbruster
2015-08-24 17:14           ` Eric Blake
2015-08-25  8:33             ` Markus Armbruster
2015-09-01 18:40   ` Michael Roth
2015-09-01 19:12     ` Eric Blake
2015-09-01 20:23       ` Michael Roth
2015-09-02  8:56         ` Markus Armbruster
2015-09-02 16:21           ` Michael Roth
2015-09-03  9:26             ` Markus Armbruster
2015-09-03 14:31               ` Eric Blake
2015-09-03 15:59                 ` Michael Roth
2015-09-03 17:01                   ` Markus Armbruster
2015-09-03 19:59                     ` Michael Roth
2015-09-04  6:39                       ` Markus Armbruster
2015-08-04 15:58 ` [Qemu-devel] [PATCH RFC v3 31/32] qapi-introspect: Map all integer types to 'int' Markus Armbruster
2015-08-04 15:58 ` [Qemu-devel] [PATCH RFC v3 32/32] qapi-introspect: Hide type names Markus Armbruster
2015-08-05 21:06   ` Eric Blake
2015-08-05 21:50     ` Eric Blake
2015-08-06  6:49     ` Markus Armbruster

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=55C277FD.1020105@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berto@igalia.com \
    --cc=kwolf@redhat.com \
    --cc=mdroth@linux.vnet.ibm.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).