From: Markus Armbruster <armbru@redhat.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: qemu-devel@nongnu.org, thuth@redhat.com,
alistair@alistair23.me, edgar.iglesias@gmail.com,
peter.maydell@linaro.org, francisco.iglesias@amd.com,
qemu-arm@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
Eduardo Habkost <eduardo@habkost.net>
Subject: Re: [PATCH 0/2] Replace anti-social QOM type names (again)
Date: Tue, 14 Nov 2023 08:41:30 +0100 [thread overview]
Message-ID: <87y1f0hjdh.fsf@pond.sub.org> (raw)
In-Reply-To: <ZVIo3FsmwpfHzsh8@redhat.com> ("Daniel P. Berrangé"'s message of "Mon, 13 Nov 2023 13:47:08 +0000")
Cc: the other QOM maintainers
Daniel P. Berrangé <berrange@redhat.com> writes:
> On Mon, Nov 13, 2023 at 02:43:42PM +0100, Markus Armbruster wrote:
>> We got rid of QOM type names containing ',' in 6.0, but some have
>> crept back in. Replace them just like we did in 6.0.
>
> It is practical to add
>
> assert(strchr(name, ',') == NULL)
>
> to some place in QOM to stop them coming back yet again ?
This adds a naming rule to QOM. Right now, QOM has none whatsoever,
which I've long called out as a mistake.
I'm all for correcting that mistake, but I'd go further than just
outlawing ','.
Discussed in more depth here:
>> Cover letter of 6.0's replacement:
>> https://lore.kernel.org/qemu-devel/20210304140229.575481-1-armbru@redhat.com/
Let me copy the text for convenience.
QAPI has naming rules. docs/devel/qapi-code-gen.txt:
=== Naming rules and reserved names ===
All names must begin with a letter, and contain only ASCII letters,
digits, hyphen, and underscore. There are two exceptions: enum values
may start with a digit, and names that are downstream extensions (see
section Downstream extensions) start with underscore.
[More on reserved names, upper vs. lower case, '-' vs. '_'...]
The generator enforces the rules.
Naming rules help in at least three ways:
1. They help with keeping names in interfaces consistent and
predictable.
2. They make avoiding collisions with the users' names in the
generator simpler.
3. They enable quote-less, evolvable syntax.
For instance, keyval_parse() syntax consists of names, values, and
special characters ',', '=', '.'
Since names cannot contain special characters, there is no need for
quoting[*]. Simple.
Values are unrestricted, but only ',' is special there. We quote
it by doubling.
Together, we get exactly the same quoting as in QemuOpts. This is
a feature.
If we ever decice to extend key syntax, we have plenty of special
characters to choose from. This is also a feature.
Both features rely on naming rules.
QOM has no naming rules whatsoever. Actual names aren't nearly as bad
as they could be. Still, there are plenty of "funny" names. This may
become a problem when we
* Switch from QemuOpts to keyval_parse()
Compared to QemuOpts, keyval_parse() restricts *keys*, but not
*values*.
"Funny" type names occuring as values are no worse than before:
quoting issues, described below.
Type names occuring in keys must be valid QAPI names. Should be
avoidable.
* QAPIfy (the compile-time static parts of) QOM
QOM type names become QAPI enum values. They must conform to QAPI
enum naming rules.
[...]
One more thing on relaxing QAPI naming rules. QAPI names get mapped
to (parts of) C identifiers. These mappings are not injective. The
basic mapping is simple: replace characters other than letters and
digits by '_'.
This means names distinct QAPI names can clash in C. Fairly harmless
when the only "other" characters are '-' and '_'. The more "others" we
permit, the more likely confusing clashes become. Not a show stopper,
"merely" an issue of ergonomics.
next prev parent reply other threads:[~2023-11-14 7:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-13 13:43 [PATCH 0/2] Replace anti-social QOM type names (again) Markus Armbruster
2023-11-13 13:43 ` [PATCH 1/2] docs/system/arm: Fix for rename of type "xlnx.bbram-ctrl" Markus Armbruster
2023-11-13 14:00 ` Francisco Iglesias
2023-11-13 14:50 ` Philippe Mathieu-Daudé
2023-11-13 15:54 ` Thomas Huth
2023-11-13 16:22 ` Markus Armbruster
2023-11-13 13:43 ` [PATCH 2/2] hw: Replace anti-social QOM type names (again) Markus Armbruster
2023-11-13 14:13 ` Francisco Iglesias
2023-11-13 16:06 ` Thomas Huth
2023-11-13 13:47 ` [PATCH 0/2] " Daniel P. Berrangé
2023-11-14 7:41 ` Markus Armbruster [this message]
2023-11-14 8:06 ` Thomas Huth
2023-11-14 9:51 ` 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=87y1f0hjdh.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=alistair@alistair23.me \
--cc=berrange@redhat.com \
--cc=edgar.iglesias@gmail.com \
--cc=eduardo@habkost.net \
--cc=francisco.iglesias@amd.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/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.