From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, mst@redhat.com,
mark.cave-ayland@ilande.co.uk, frederic.konrad@adacore.com,
kraxel@redhat.com, edgar.iglesias@gmail.com, jcd@tribudubois.net,
qemu-block@nongnu.org, quintela@redhat.com,
andrew.smirnov@gmail.com, marcandre.lureau@redhat.com,
atar4qemu@gmail.com, ehabkost@redhat.com, alistair@alistair23.me,
dgilbert@redhat.com, chouteau@adacore.com, qemu-arm@nongnu.org,
peter.chubb@nicta.com.au, jsnow@redhat.com, kwolf@redhat.com,
berrange@redhat.com, mreitz@redhat.com, pbonzini@redhat.com
Subject: Re: [PATCH RFC 0/1] QOM type names and QAPI
Date: Fri, 29 Jan 2021 12:54:52 +0100 [thread overview]
Message-ID: <875z3g2c1f.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20210129081519.3848145-1-armbru@redhat.com> (Markus Armbruster's message of "Fri, 29 Jan 2021 09:15:18 +0100")
Markus Armbruster <armbru@redhat.com> writes:
> 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
> will become a problem when we
>
> * Switch from QemuOpts to keyval_parse()
>
> QOM type names must not contain special characters, unless we
> introduce more quoting. Which we shouldn't, because the value of
> special characters in names is negligible compared to the hassle of
> having to quote them.
>
> * QAPIfy (the compile-time static parts of) QOM
>
> QOM type names become QAPI enum values. They must conform to QAPI
> naming rules.
>
> Adopting QAPI naming rules for QOM type names takes care of both.
>
> Let's review the existing offenders.
>
> 1. We have a few type names containing ',', and one containing ' '.
> The former require QemuOpts / keyval quoting (double the comma),
> the latter requires shell quoting. There is no excuse for making
> our users remember and do such crap. PATCH 1 eliminates it.
>
> 2. We have some 550 type names containing '.'. QAPI's naming rules
> could be relaxed to accept '.', but keyval_parse()'s can't.
Thinko: keyval_parse() copes. QOM type names occur as *value*, not as
key.
One more thing on 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.
> Aside: I wish keyval_parse() would use '/' instead of '.', but it's
> designed to be compatible to the block layer's existing use of
> dotted keys (shoehorned into QemuOpts).
>
> 3. We have six type names containing '+'. Four of them also contain
> '.'. Naming rules could be relaxed to accept '+'. I'm not sure
> it's worthwhile.
>
> 4. We have 19 names starting with a digit. Three of them also contain
> '.'. Leading digit is okay as QAPI enum, not okay as
> keyval_parse() key fragment. We can either rename these types, or
> make keyval_parse() a bit less strict.
>
> Of the type names containing '.' or '+'[**], 293 are CPUs, 107 are
> machines, and 150 are something else. 48 of them can be plugged with
> -device, all s390x or spapr CPUs.
>
> Can we get rid of '.'?
>
> I figure we could keep old names as deprecated aliases if we care.
> Perhaps just the ones that can be plugged with -device.
>
>
> [*] Paolo's "[PATCH 04/25] keyval: accept escaped commas in implied
> option" provides for comma-quoting. I'm ignoring it here for brevity.
> I assure you it doesn't weaken my argument.
>
> [**] They are:
> 603e_v1.1-powerpc-cpu
[...]
next prev parent reply other threads:[~2021-01-29 11:58 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-29 8:15 [PATCH RFC 0/1] QOM type names and QAPI Markus Armbruster
2021-01-29 8:15 ` Markus Armbruster
2021-01-29 8:15 ` [PATCH RFC 1/1] hw: Replace anti-social QOM type names Markus Armbruster
2021-01-29 8:15 ` Markus Armbruster
2021-01-29 9:06 ` Paolo Bonzini
2021-01-29 9:06 ` Paolo Bonzini
2021-01-29 9:18 ` Markus Armbruster
2021-02-01 20:45 ` Mark Cave-Ayland
2021-02-02 9:21 ` Markus Armbruster
2021-02-02 9:21 ` Markus Armbruster
2021-01-29 9:17 ` [PATCH RFC 0/1] QOM type names and QAPI Markus Armbruster
2021-01-29 11:54 ` Markus Armbruster [this message]
2021-01-29 12:01 ` Peter Maydell
2021-01-29 12:01 ` Peter Maydell
2021-01-29 12:17 ` Daniel P. Berrangé
2021-01-29 13:25 ` Paolo Bonzini
2021-01-29 13:25 ` Paolo Bonzini
2021-02-01 21:31 ` Eduardo Habkost
2021-02-02 9:28 ` 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=875z3g2c1f.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=alistair@alistair23.me \
--cc=andrew.smirnov@gmail.com \
--cc=atar4qemu@gmail.com \
--cc=berrange@redhat.com \
--cc=chouteau@adacore.com \
--cc=dgilbert@redhat.com \
--cc=edgar.iglesias@gmail.com \
--cc=ehabkost@redhat.com \
--cc=frederic.konrad@adacore.com \
--cc=jcd@tribudubois.net \
--cc=jsnow@redhat.com \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mreitz@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.chubb@nicta.com.au \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@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.