From: Thomas Huth <thuth@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
qemu-devel@nongnu.org, "Eduardo Habkost" <eduardo@habkost.net>,
"David Hildenbrand" <david@redhat.com>
Subject: Re: [PATCH] qom/object: Limit type names to alphanumerical and some few special characters
Date: Thu, 16 Nov 2023 12:17:15 +0100 [thread overview]
Message-ID: <e04933cf-1c74-4475-8007-888d9d0591f2@redhat.com> (raw)
In-Reply-To: <CAFEAcA_LcmowH28KG9LXRQRPFkAbmDCoPz5RDDK0TG+Am-p73w@mail.gmail.com>
On 14/11/2023 14.21, Peter Maydell wrote:
> On Tue, 14 Nov 2023 at 13:05, Thomas Huth <thuth@redhat.com> 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 restrict the set of acceptable characters during the
>> type registration.
>>
>> Ideally, we'd apply here the same rules as for QAPI, i.e. all type
>> names should begin with a letter, and contain only ASCII letters,
>> digits, hyphen, and underscore. However, we already have so many
>> pre-existing types like:
>>
>> 486-x86_64-cpu
>> cfi.pflash01
>> power5+_v2.1-spapr-cpu-core
>> virt-2.6-machine::hotplug-handler
>> aspeed.i2c.slave::vmstate-if
>> pc-i440fx-3.0-machine::nmi
>
> I think all these '::' are specifically interface types --
> see type_initialize_interface(), which constructs the
> interface type name by gluing together the class name and
> the interface name with a '::'. The rule we ought to be
> requiring for ':' I think is "no : in the type name, unless
> it is the one generated by type_initialize_interface()".
>
> I think we could do that by having the type_name_is_valid()
> checks done in:
> * type_initialize_interface(), on ti->name and interface_type->name
> * type_register_internal(), on info->name
>
> If we do that, can we take ':' out of the list of characters
> we permit in type_name_is_valid() ?
Thanks, that's a very good idea! Actually, after looking at the code for a
while, I think it should even be enough to add a check to
type_register_internal(), since type_initialize_interface() is rather used
with base types and interface types that should have been registered already
via type_register...() before.
There just seem to be two stragglers left:
1) #define TYPE_DUMMY "qemu:dummy" in tests/unit/test-io-task.c ...
easy to fix, it's just a unit test anyway
2) #define TYPE_RAM_DISCARD_MANAGER "qemu:ram-discard-manager"
in include/exec/memory.h ... I believe it should be OK to
simply rename it, since it's about an interface type...
Or do we use these interface names in migration streams, too?
I'll try to come up with some patches to rename them ... let's see how it
goes...
Thomas
next prev parent reply other threads:[~2023-11-16 11:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-14 13:04 [PATCH] qom/object: Limit type names to alphanumerical and some few special characters Thomas Huth
2023-11-14 13:21 ` Peter Maydell
2023-11-16 11:17 ` Thomas Huth [this message]
2023-11-16 11:37 ` Peter Maydell
2023-11-16 13:21 ` Philippe Mathieu-Daudé
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=e04933cf-1c74-4475-8007-888d9d0591f2@redhat.com \
--to=thuth@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=david@redhat.com \
--cc=eduardo@habkost.net \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--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).