From: Markus Armbruster <armbru@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
"QEMU Developers" <qemu-devel@nongnu.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Eduardo Habkost" <eduardo@habkost.net>
Subject: Re: [RFC PATCH] qom/object: Disallow comma in type names
Date: Tue, 14 Nov 2023 14:22:22 +0100 [thread overview]
Message-ID: <87wmuk8o6p.fsf@pond.sub.org> (raw)
In-Reply-To: <c023a3a5-4435-4381-860f-edb5da227c76@redhat.com> (Thomas Huth's message of "Tue, 14 Nov 2023 10:56:05 +0100")
Thomas Huth <thuth@redhat.com> writes:
> Forgot to CC: qemu-devel (sorry) - thanks to Markus for the hint.
> So let's repeat it here:
>
> On 14/11/2023 10.31, Daniel P. Berrangé wrote:
>> On Tue, Nov 14, 2023 at 10:05:37AM +0100, Thomas Huth wrote:
>>> QOM names currently don't have any enforced naming rules. This can
>>> be problematic, e.g. when they are used on the command line for
>>> the "-device" option (where the comma is used to separate properties).
>>> To avoid that such problematic type names come in again, let's
>>> disallow them now by adding an g_assert() during the type registration.
>>>
>>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>>> ---
>>> Based-on: <20231113134344.1195478-1-armbru@redhat.com>
>>> (without Markus' patches, the g_assert() triggers with the current
>>> code base)
>>>
>>> See discussion here:
>>> https://lore.kernel.org/qemu-devel/87y1f0hjdh.fsf@pond.sub.org/
>>>
>>> Questions: Should we disallow other characters, too? Slash and
>>> backslash maybe (since they can cause trouble with module names)?
>>> Dot and colon would maybe be good candidates, too, but they seem
>>> to be in wide use already, so these don't really seem to be
>>> feasible...
>>
>> There's two questions.
>>
>> * What should we enforce today
>> * What should we ideally enforce in future
>>
>> Ideally the answers would be the same, but getting there will
>> almost certainly require some cleanup first.
>>
>> Given that we can now define QOM types using QAPI, I feel we
>> preserve everyone's sanity by enforcing the same rules for
>> QOM and QAPI type naming. IOW
Agree!
>> All QOM type names must begin with a letter, and contain
>> only ASCII letters, digits, hyphen, and underscore.
>>
>> is the answer for the second question.
As long as type names only occur as *values*, the next sentence's first
exception applies, too:
There are two exceptions: enum values may start with a digit, and
names that are downstream extensions (see section `Downstream
extensions`_) start with underscore.
This is of course docs/devel/qapi-code-gen.rst.
I'm willing to tweak the QAPI naming rules within reason.
>> In terms of what we can enforce today, we can block ',',
>> but we can't block '.' without some cleanup, and possibly
>> the same for ':'. Can we assume we don't have any other
>> non-alphanumeric chars used ?
I ran qom-list-types (without 'abstract': true) for all 31
qemu-system-FOO, extracted the type names, and sorted them into buckets.
* I found 3255 distinct names
* 2445 names conform to the QAPI naming rule "only letters, digits,
hyphen, and underscore, starting with a letter"
* 157 more names conform with the enum exception "may start with a
digit"
* The remainder contain unwanted characters
- 9 contain ',' and no other unwanted characters
My "hw: Replace anti-social QOM type names (again)" fixes them.
- 638 contain '.' and no other unwanted characters
That's a lot.
Perhaps we can permit '.' in enum names. Needs thought.
- 6 contain '.' and '+'
Sun-UltraSparc-IIIi+-sparc64-cpu
Sun-UltraSparc-IV+-sparc64-cpu
power5+_v2.1-powerpc64-cpu
power5+_v2.1-spapr-cpu-core
power7+_v2.1-powerpc64-cpu
power7+_v2.1-spapr-cpu-core
Spell out "plus"?
I found no names with ':'. Looks like we use ':' only for abstract
types (which includes interfaces).
The only #define TYPE_FOO with a colon I can see is
#define TYPE_RAM_DISCARD_MANAGER "qemu:ram-discard-manager"
An interface type. Let's ditch the "qemu:".
There are a bunch of interface names containing "::". These come from
type_initialize_interface():
info.name = g_strdup_printf("%s::%s", ti->name, interface_type->name);
>> If so, I think that today we we could probably get away with
>> saying:
>>
>> All QOM type names must begin with a letter, and contain
>> only ASCII letters, digits, hyphen, underscore, period
>> and colon. Usage of period and colon is deprecated.
I think we should reserve colon for QOM internal use.
[...]
prev parent reply other threads:[~2023-11-14 13:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20231114090537.154151-1-thuth@redhat.com>
[not found] ` <ZVM+hvRk5KYn5WYh@redhat.com>
2023-11-14 9:56 ` [RFC PATCH] qom/object: Disallow comma in type names Thomas Huth
2023-11-14 13:22 ` Markus Armbruster [this message]
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=87wmuk8o6p.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=eduardo@habkost.net \
--cc=pbonzini@redhat.com \
--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.