From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH v14 02/19] qapi-visit: Add visitor.type classification
Date: Wed, 13 Apr 2016 10:23:22 -0600 [thread overview]
Message-ID: <570E727A.7000908@redhat.com> (raw)
In-Reply-To: <87vb3llitc.fsf@dusky.pond.sub.org>
[-- Attachment #1: Type: text/plain, Size: 3901 bytes --]
On 04/13/2016 07:49 AM, Markus Armbruster wrote:
> Eric Blake <eblake@redhat.com> writes:
>
>> We have three classes of QAPI visitors: input, output, and dealloc.
>> Currently, all implementations of these visitors have one thing in
>> common based on their visitor type: the implementation used for the
>> visit_type_enum() callback. But since we plan to add more such
>> common behavior, in relation to documenting and further refining
>> the semantics, it makes more sense to have the visitor
>> implementations advertise which class they belong to, so the common
>> qapi-visit-core code can use that information in multiple places.
>>
>> For this patch, knowing the class of a visitor implementation lets
>> us make input_type_enum() and output_type_enum() become static
>> functions, by replacing the callback function Visitor.type_enum()
>> with the simpler enum member Visitor.type. Share a common
>> assertion in qapi-visit-core as part of the refactoring.
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>>
>> +/* There are three classes of visitors; setting the class determines
>> + * how QAPI enums are visited, as well as what additional restrictions
>> + * can be asserted. */
>> +typedef enum VisitorType {
>> + VISITOR_INPUT,
>> + VISITOR_OUTPUT,
>> + VISITOR_DEALLOC,
>> +} VisitorType;
>> +
>> struct Visitor
>> {
>> /* Must be set */
>
> I think we should explain what makes a visitor an input/output/dealloc
> visitor. Not necessarily in this patch, and not necessarily in this
> place, just somewhere. Right now, the information is scattered.
8/19 might be the patch that does just that. We'll see what you think
when you get further through the review.
>> @@ -514,16 +516,6 @@ opts_visitor_new(const QemuOpts *opts)
>> ov->visitor.next_list = &opts_next_list;
>> ov->visitor.end_list = &opts_end_list;
>>
>> - /* input_type_enum() covers both "normal" enums and union discriminators.
>> - * The union discriminator field is always generated as "type"; it should
>> - * match the "type" QemuOpt child of any QemuOpts.
>> - *
>> - * input_type_enum() will remove the looked-up key from the
>> - * "unprocessed_opts" hash even if the lookup fails, because the removal is
>> - * done earlier in opts_type_str(). This should be harmless.
>> - */
>> - ov->visitor.type_enum = &input_type_enum;
>> -
>
> Hmm, this comment doesn't look worthless. With its statement gone, I
> guess it should move somewhere else. What do you think?
The first half of the comment is fluff. The second half, about a
looked-up key being removed from unprocessed_opts even if lookup fails,
might be something I can move, but where? Maybe to the visit_type_enum()
in qapi-visit-core.c, stating that an input visitor will visit the
string even if conversion to enum fails? It really only affects what
happens for an input visitor that has a visit_check_struct() (commit
14/19 of the series), but even then, we really only report an input
visit failure regarding unvisited options if there was no earlier error
- but the mere fact that visiting an enum type fails whether the string
was present but not a valid enum value, or whether the string was not
even present, means that we won't be reaching the visit_check_struct()
to even care about errors about unvisited members.
Maybe that means I just move the documentation into the commit message,
and explain why the comment disappears (because a later patch will
guarantee the semantics that we only care about reporting unvisited
members in an input visitor only if all other visits are successful, so
it doesn't matter on earlier failure whether we consumed or did not
consume input).
--
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 --]
next prev parent reply other threads:[~2016-04-13 16:23 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-08 16:12 [Qemu-devel] [PATCH v14 00/19] qapi visitor cleanups (post-introspection cleanups subset E) Eric Blake
2016-04-08 16:12 ` [Qemu-devel] [PATCH v14 01/19] qapi: Consolidate object visitors Eric Blake
2016-04-13 12:48 ` Markus Armbruster
2016-04-13 16:13 ` Eric Blake
2016-04-15 15:05 ` Markus Armbruster
2016-04-08 16:12 ` [Qemu-devel] [PATCH v14 02/19] qapi-visit: Add visitor.type classification Eric Blake
2016-04-13 13:49 ` Markus Armbruster
2016-04-13 16:23 ` Eric Blake [this message]
2016-04-15 15:24 ` Markus Armbruster
2016-04-08 16:12 ` [Qemu-devel] [PATCH v14 03/19] qapi: Guarantee NULL obj on input visitor callback error Eric Blake
2016-04-13 14:04 ` Markus Armbruster
2016-04-08 16:12 ` [Qemu-devel] [PATCH v14 04/19] qmp: Drop dead command->type Eric Blake
2016-04-08 16:12 ` [Qemu-devel] [PATCH v14 05/19] qmp-input: Clean up stack handling Eric Blake
2016-04-13 15:53 ` Markus Armbruster
2016-04-13 16:36 ` Eric Blake
2016-04-13 16:40 ` Eric Blake
2016-04-15 15:27 ` Markus Armbruster
2016-04-08 16:12 ` [Qemu-devel] [PATCH v14 06/19] qmp-input: Don't consume input when checking has_member Eric Blake
2016-04-13 16:06 ` Markus Armbruster
2016-04-13 16:43 ` Eric Blake
2016-04-15 15:28 ` Markus Armbruster
2016-04-08 16:13 ` [Qemu-devel] [PATCH v14 07/19] qmp-input: Refactor when list is advanced Eric Blake
2016-04-13 17:38 ` Markus Armbruster
2016-04-13 19:58 ` Eric Blake
2016-04-08 16:13 ` [Qemu-devel] [PATCH v14 08/19] qapi: Document visitor interfaces, add assertions Eric Blake
2016-04-14 15:22 ` Markus Armbruster
2016-04-26 21:50 ` Eric Blake
2016-04-28 16:33 ` Markus Armbruster
2016-04-08 16:13 ` [Qemu-devel] [PATCH v14 09/19] tests: Add check-qnull Eric Blake
2016-04-14 16:13 ` Markus Armbruster
2016-04-14 17:37 ` Markus Armbruster
2016-04-14 18:54 ` Eric Blake
2016-04-08 16:13 ` [Qemu-devel] [PATCH v14 10/19] qapi: Add visit_type_null() visitor Eric Blake
2016-04-14 17:09 ` Markus Armbruster
2016-04-08 16:13 ` [Qemu-devel] [PATCH v14 11/19] qmp: Support explicit null during visits Eric Blake
2016-04-15 8:29 ` Markus Armbruster
2016-04-08 16:13 ` [Qemu-devel] [PATCH v14 12/19] spapr_drc: Expose 'null' in qom-get when there is no fdt Eric Blake
2016-04-08 16:13 ` [Qemu-devel] [PATCH v14 13/19] qmp: Tighten output visitor rules Eric Blake
2016-04-15 9:02 ` Markus Armbruster
2016-04-27 1:29 ` Eric Blake
2016-04-27 6:29 ` Markus Armbruster
2016-04-27 12:22 ` Eric Blake
2016-04-08 16:13 ` [Qemu-devel] [PATCH v14 14/19] qapi: Split visit_end_struct() into pieces Eric Blake
2016-04-15 11:03 ` Markus Armbruster
2016-04-08 16:13 ` [Qemu-devel] [PATCH v14 15/19] qapi-commands: Wrap argument visit in visit_start_struct Eric Blake
2016-04-15 11:42 ` Markus Armbruster
2016-04-26 12:56 ` Eric Blake
2016-04-08 16:13 ` [Qemu-devel] [PATCH v14 16/19] qom: Wrap prop " Eric Blake
2016-04-15 11:52 ` Markus Armbruster
2016-04-08 16:13 ` [Qemu-devel] [PATCH v14 17/19] qmp-input: Require struct push to visit members of top dict Eric Blake
2016-04-15 12:53 ` Markus Armbruster
2016-04-08 16:13 ` [Qemu-devel] [PATCH v14 18/19] qapi: Simplify semantics of visit_next_list() Eric Blake
2016-04-15 14:09 ` Markus Armbruster
2016-04-22 8:46 ` Markus Armbruster
2016-04-22 11:35 ` Markus Armbruster
2016-04-22 11:37 ` [Qemu-devel] [PATCH] tests/string-input-visitor: Add negative integer tests Markus Armbruster
2016-04-27 20:22 ` [Qemu-devel] [PATCH v14 18/19] qapi: Simplify semantics of visit_next_list() Eric Blake
2016-04-08 16:13 ` [Qemu-devel] [PATCH v14 19/19] qapi: Change visit_type_FOO() to no longer return partial objects Eric Blake
2016-04-15 14:49 ` Markus Armbruster
2016-04-27 21:51 ` Eric Blake
2016-04-15 15:41 ` [Qemu-devel] [PATCH v14 00/19] qapi visitor cleanups (post-introspection cleanups subset E) 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=570E727A.7000908@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@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 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.