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 v10 01/25] tests/qapi-schema: Test for reserved names, empty struct
Date: Fri, 23 Oct 2015 06:39:59 -0600 [thread overview]
Message-ID: <562A2A9F.60004@redhat.com> (raw)
In-Reply-To: <87twphhih6.fsf@blackfin.pond.sub.org>
[-- Attachment #1: Type: text/plain, Size: 4644 bytes --]
On 10/23/2015 06:33 AM, Markus Armbruster wrote:
> Eric Blake <eblake@redhat.com> writes:
>
>> We are failing to detect a collision between a QMP member and
>> the implicit 'has_*' flag for another optional QMP member. The
>> easiest fix would be for a future patch to reserve the entire
>> "has[-_]" namespace for member names (the collision is also
>> possible for branch names within flat unions, but only as long
>> as branch names can collide with QMP names; since future
>> patches are about to remove that, it is not worth testing here).
>
> This is args-has-clash.json.
>
>> A similar collision exists between a QMP member where c_name()
>> munges what might otherwise be a reserved name to start with
>> 'q_', and another member explicitly starts with "q[-_]". Again,
>> the easiest task for a future patch will be reserving the entire
>
> s/task/solution/ ?
>
Sounds better.
>> namespace, but here for commands as well as members.
>
> This is reserved-member.json.
And reserve-commands.json
>
>> Our current representation of qapi arrays is done by appending
>> 'List' to the element name; but we are not preventing the
>> creation of a non-array type with the same name.
>
> This is struct-name-list.json.
>
>> Finally, our testsuite does not have any compilation coverage
>> of struct inheritance with empty qapi structs.
>
> This is qapi-schema-test.json.
>
> Left undescribed: reserved-commands.json :)
No, the 'q_' paragraph covered both. But yes, mentioning the actual
test names in the commit body can't hurt.
>
>> Add tests to cover these issues.
>>
>> On the other hand, there is currently no technical reason to
>> forbid type name patterns from member names, or member name
>> patterns from types, since the two are not in the same namespace
>> in C and won't collide (but it's not worth adding positive tests
>> of these corner cases, especially while there is other churn
>> pending in patches that rearrange which collisions actually
>> happen).
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>>
>> ---
>> +++ b/tests/qapi-schema/reserved-command.json
>> @@ -0,0 +1,7 @@
>> +# C entity name collision
>> +# FIXME - This parses, but fails to compile, because it attempts to declare
>> +# two 'qmp_q_unix' functions (one for 'q-unix', the other because c_name()
>> +# munges 'unix' to 'q_unix' to avoid reserved word collisions). We should
>> +# reject attempts to explicitly use 'q_' names, to reserve it for qapi.
>> +{ 'command': 'unix' }
>> +{ 'command': 'q-unix' }
>
> Note that mangling 'unix' to 'q-unix' is pretty pointless for command
> names, because their C name occurs only in identifiers qmp_CNAME() and
> qmp_marshal_CNAME().
>
Probably true, but it is the current implementation, and we DO have a
compile time collision until (unless?) we bother to fix it.
>> +++ b/tests/qapi-schema/reserved-member.json
>> @@ -0,0 +1,6 @@
>> +# C member name collision
>> +# FIXME - This parses, but fails to compile, because it attempts to declare
>> +# two 'q_unix' members (one for 'q-unix', the other because c_name()
>> +# munges 'unix' to 'q_unix' to avoid reserved word collisions). We should
>> +# reject attempts to explicitly use 'q_' names, to reserve it for qapi.
>> +{ 'struct': 'Foo', 'data': { 'unix':'int', 'q-unix':'bool' } }
>
> Unlike command names, member names actually occur by themselves, so some
> name mangling is required.
>
> A less ham-fisted approach would mangle *complete* identifiers, i.e.
> c_name('qmp_' + name) instead of 'qmp_' + c_name(name).
>
> Please feel free to stick to ham-fisted for now. We need to make
> progress flushing the queue.
Indeed - cleaning up command name mangling can come at a later date, and
maybe at that point we can decide 'q_' reservations for command names
doesn't add any power, and relax it at that point.
>> +++ b/tests/qapi-schema/struct-name-list.json
>> @@ -0,0 +1,5 @@
>> +# Potential C name collision
>> +# FIXME - This parses and compiles on its own, but prevents the user from
>> +# creating a type named 'Foo' and using ['Foo'] for an array. We should
>> +# reject the use of any non-array type names ending in 'List'.
>> +{ 'struct': 'FooList', 'data': { 's': 'str' } }
>
> "Non-array type name" makes no sense when talking about the QAPI schema,
> because arrays don't have names there.
Suggestions? Maybe s/non-array//? The wording changes in 2/25 when the
test starts working.
--
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:[~2015-10-23 12:40 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-23 5:09 [Qemu-devel] [PATCH v10 00/25] qapi collision reduction (post-introspection subset B') Eric Blake
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 01/25] tests/qapi-schema: Test for reserved names, empty struct Eric Blake
2015-10-23 12:33 ` Markus Armbruster
2015-10-23 12:39 ` Eric Blake [this message]
2015-10-23 14:17 ` Markus Armbruster
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 02/25] qapi: More idiomatic string operations Eric Blake
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 03/25] qapi: More robust conditions for when labels are needed Eric Blake
2015-10-23 12:44 ` Markus Armbruster
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 04/25] qapi: Reserve '*List' type names for list types Eric Blake
2015-10-23 12:53 ` Markus Armbruster
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 05/25] qapi: Reserve 'q_*' and 'has_*' member names Eric Blake
2015-10-23 13:05 ` Markus Armbruster
2015-10-23 14:14 ` Eric Blake
2015-10-23 14:47 ` Markus Armbruster
2015-10-23 14:52 ` Eric Blake
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 06/25] vnc: Hoist allocation of VncBasicInfo to callers Eric Blake
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 07/25] qapi-visit: Split off visit_type_FOO_fields forward decl Eric Blake
2015-10-23 13:46 ` Markus Armbruster
2015-10-23 14:35 ` Eric Blake
2015-10-23 18:05 ` Markus Armbruster
2015-10-23 19:44 ` Eric Blake
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 08/25] qapi-types: Refactor base fields output Eric Blake
2015-10-23 15:06 ` Markus Armbruster
2015-10-23 15:16 ` Eric Blake
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 09/25] qapi: Prefer typesafe upcasts to qapi base classes Eric Blake
2015-10-23 15:30 ` Markus Armbruster
2015-10-23 20:44 ` Eric Blake
2015-10-26 7:33 ` Markus Armbruster
2015-10-26 16:24 ` Eric Blake
2015-10-26 17:54 ` Markus Armbruster
2015-10-26 20:53 ` Eric Blake
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 10/25] qapi: Unbox base members Eric Blake
2015-10-23 19:14 ` Markus Armbruster
2015-10-23 19:19 ` Eric Blake
2015-10-23 20:45 ` Eric Blake
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 11/25] qapi-visit: Remove redundant functions for flat union base Eric Blake
2015-10-23 19:35 ` Markus Armbruster
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 12/25] qapi: Start converting to new qapi union layout Eric Blake
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 13/25] qapi-visit: Convert " Eric Blake
2015-10-26 17:07 ` Markus Armbruster
2015-10-26 20:39 ` Eric Blake
2015-10-27 7:08 ` Markus Armbruster
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 14/25] tests: " Eric Blake
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 15/25] block: " Eric Blake
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 16/25] sockets: " Eric Blake
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 17/25] net: " Eric Blake
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 18/25] char: " Eric Blake
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 19/25] input: " Eric Blake
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 20/25] memory: " Eric Blake
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 21/25] tpm: " Eric Blake
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 22/25] qapi: Finish converting " Eric Blake
2015-10-27 8:33 ` Markus Armbruster
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 23/25] qapi: Reserve 'u' member name Eric Blake
2015-10-26 17:27 ` Markus Armbruster
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 24/25] qapi: Remove outdated tests related to QMP/branch collisions Eric Blake
2015-10-23 23:27 ` Eric Blake
2015-10-23 5:09 ` [Qemu-devel] [PATCH v10 25/25] qapi: Simplify gen_struct_field() Eric Blake
2015-10-26 17:55 ` [Qemu-devel] [PATCH v10 00/25] qapi collision reduction (post-introspection subset B') 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=562A2A9F.60004@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 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).