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 v8 11/16] qapi-event: Reduce chance of collision with event data
Date: Wed, 13 Jul 2016 15:05:10 -0600 [thread overview]
Message-ID: <5786AD06.8070602@redhat.com> (raw)
In-Reply-To: <871t35ptl7.fsf@dusky.pond.sub.org>
[-- Attachment #1: Type: text/plain, Size: 3020 bytes --]
On 07/07/2016 05:37 AM, Markus Armbruster wrote:
> Eric Blake <eblake@redhat.com> writes:
>
>> When an unboxed event has accompanying data, we are exposing all
>> of its members alongside our local variables in the generated
>> qapi_event_send_FOO() function. So far, we haven't hit a
>> collision, but it may be a matter of time before someone wants
>> to name a QMP data element 'err' or similar. We can separate
>> the names by making the public function (qapi_event_send_FOO())
>> a shell that boxes things up without having to worry about
>> collisions, then calls into a new worker function
>> (do_qapi_event_send_FOO()) that gets generated to look like what
>> we already output for boxed events.
>>
>> +++ b/scripts/qapi.py
>> @@ -1019,7 +1019,6 @@ class QAPISchemaObjectType(QAPISchemaType):
> def c_name(self):
>> return QAPISchemaType.c_name(self)
>
> Aside: this method became pointless in commit 7ce106a.
>
Sounds like an easy separate cleanup.
>>
>> def c_type(self):
>> - assert not self.is_implicit()
>> return c_name(self.name) + pointer_suffix
>
> Correct if we emit a C type with this name for *any* object type. I
> don't think we do for the empty object type. Any others?
>
> The assertion should be relaxed to reject exactly the object types for
> which we don't emit a C type.
Will fix.
>
>>
>> def c_unboxed_type(self):
>> diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py
>> index 2cab588..b2da0a9 100644
>> --- a/scripts/qapi-event.py
>> +++ b/scripts/qapi-event.py
>> @@ -14,8 +14,13 @@
>> from qapi import *
>>
>>
>> -def gen_event_send_proto(name, arg_type, box):
>> - return 'void qapi_event_send_%(c_name)s(%(param)s)' % {
>> +def gen_event_send_proto(name, arg_type, box, impl=False):
>
> The function has changed from one that does just one thing to one that
> can do many things depending on arg_type, box and impl. It's not even
> obvious which combinations are valid. Either split it into simple,
> self-documenting functions, or explain this complex one with a function
> comment.
At this point, this cleanup is separate from the main work to get
'boxed' commands working, so I'll focus on getting the important first
half of the series posted today, and leave this particular patch for
when I have more time to get the refactoring done right.
>
> This function spans 95 lines, and you have to read to the end to see
> that it first emits a function that can either be the
> qapi_event_send_FOO() function or a helper, and if it's the latter, then
> emits the former. Either split it up into parts that can be more easily
> understood, or add suitable comments to the complex function.
Indeed. The changes were all made piecemeal with minimal churn, but the
end result is messier than if we step back and do it right.
--
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-07-13 21:05 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-03 2:58 [Qemu-devel] [PATCH for-2.7 v8 00/16] qapi netdev_add introspection (post-introspection cleanups subset F) Eric Blake
2016-07-03 2:58 ` [Qemu-devel] [PATCH v8 01/16] net: use Netdev instead of NetClientOptions in client init Eric Blake
2016-07-03 2:58 ` [Qemu-devel] [PATCH v8 02/16] qapi: Require all branches of flat union enum to be covered Eric Blake
2016-07-03 2:58 ` [Qemu-devel] [PATCH v8 03/16] qapi: Hide tag_name data member of variants Eric Blake
2016-07-03 2:58 ` [Qemu-devel] [PATCH v8 04/16] qapi: Add type.is_empty() helper Eric Blake
2016-07-03 2:58 ` [Qemu-devel] [PATCH v8 05/16] qapi: Drop useless gen_err_check() Eric Blake
2016-07-03 2:58 ` [Qemu-devel] [PATCH v8 06/16] qapi-event: Simplify visit of non-implicit data Eric Blake
2016-07-03 2:58 ` [Qemu-devel] [PATCH v8 07/16] qapi: Plumb in 'box' to qapi generator lower levels Eric Blake
2016-07-03 2:58 ` [Qemu-devel] [PATCH v8 08/16] qapi: Implement boxed types for commands/events Eric Blake
2016-07-07 10:52 ` Markus Armbruster
2016-07-07 16:02 ` Eric Blake
2016-07-08 7:06 ` Markus Armbruster
2016-07-03 2:58 ` [Qemu-devel] [PATCH v8 09/16] block: Simplify block_set_io_throttle Eric Blake
2016-07-03 2:58 ` [Qemu-devel] [PATCH v8 10/16] block: Simplify drive-mirror Eric Blake
2016-07-05 20:27 ` [Qemu-devel] [Qemu-block] " John Snow
2016-07-05 22:16 ` Eric Blake
2016-07-05 22:17 ` John Snow
2016-07-03 2:58 ` [Qemu-devel] [PATCH v8 11/16] qapi-event: Reduce chance of collision with event data Eric Blake
2016-07-07 11:37 ` Markus Armbruster
2016-07-13 21:05 ` Eric Blake [this message]
2016-07-03 2:58 ` [Qemu-arm] [PATCH v8 12/16] qapi: Change Netdev into a flat union Eric Blake
2016-07-03 2:58 ` Eric Blake
2016-07-03 2:58 ` [Qemu-devel] " Eric Blake
2016-07-03 2:58 ` [Qemu-devel] [PATCH v8 13/16] net: Use correct type for bool flag Eric Blake
2016-07-03 2:58 ` [Qemu-devel] [PATCH v8 14/16] net: Complete qapi-fication of netdev_add Eric Blake
2016-07-07 12:57 ` Markus Armbruster
2016-07-03 2:58 ` [Qemu-devel] [PATCH v8 15/16] qapi: Allow anonymous branch types in flat union Eric Blake
2016-07-03 2:58 ` [Qemu-devel] [PATCH v8 16/16] schema: Drop pointless empty type CpuInfoOther Eric Blake
2016-07-07 13:40 ` [Qemu-devel] [PATCH for-2.7 v8 00/16] qapi netdev_add introspection (post-introspection cleanups subset F) 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=5786AD06.8070602@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.