From: Paolo Bonzini <pbonzini@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: kwolf@redhat.com, peter.maydell@linaro.org,
peter.crosthwaite@xilinx.com, stefanha@redhat.com,
"Stefan Hajnoczi" <stefanha@gmail.com>,
qemu-devel@nongnu.org, "Anthony Liguori" <aliguori@amazon.com>,
"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] IDs in QOM
Date: Tue, 07 Oct 2014 12:03:58 +0200 [thread overview]
Message-ID: <5433BA8E.9070101@redhat.com> (raw)
In-Reply-To: <87k34c71gi.fsf@blackfin.pond.sub.org>
Il 07/10/2014 10:01, Markus Armbruster ha scritto:
> "Automatic arrayification" isn't about array-valued properties, it's a
> convenience feature for creating a bunch of properties with a common
> type, accessors and so forth, named in a peculiar way: "foo[0]",
> "foo[1]", ...
>
> The feature saves the caller the trouble of generating the names.
> That's all there is to it.
>
> Once created, QOM assumes no particular relation between the properties.
>
> Weird: if you create a "foo[2]", then three "foo[*]", the three become
> "foo[0]", "foo[1]", "foo[3]".
>
> Correct so far?
>
> If yes, then I retract my "isn't this type matter" remark: it isn't,
> it's just a fancy way to generate names.
Exactly. Regarding the "weird part", it is really a case of "if it
hurts, do not do it". :) For example, most memory regions are created
at or before realize time, and live until the parent device is
hot-unplugged or QEMU exits. Unattached devices are created statically
at or before machine creation, and live until they are hot-unplugged or
QEMU exits.
> However, I now have a different one: should we really bake fancy ways to
> generate names into object_property_add()?
>
> Wouldn't having a separate name generator be cleaner?
Possibly, except this would propagate all the way through the APIs. For
example, right now [*] is added automatically to MemoryRegion
properties, but this can change in the future since many MemoryRegions
do not need array-like names. Then you would have two sets of
MemoryRegion creation APIs, one that array-ifies names and one that doesn't.
> Why is it a good idea have two separate restrictions on property names?
> A loser one that applies always (anything but '\0' and '/'), and a
> stricter one that applies sometimes (letters, digits, '-', '.', '_',
> starting with a letter).
>
> If yes, how is "sometimes" defined?
It applies to objects created by the user (either in
/machine/peripheral, or in /objects). Why the restriction? For
-object, because creating the object involves QemuOpts. You then have
two ways to satisfy the principle of least astonishment:
1) always use the same restriction when a user creates objects;
2) do not introduce restrictions when a user is not using QemuOpts.
We've been doing (2) so far; often it is just because QMP wrappers also
used QemuOpts, but not necessarily. So object_add just does the same.
> Are -object and object_add the only ways to create children of /objects?
Yes (of course you could do that programmatically in C, but I don't see
why you should/would do that).
> Hmm, I'm afraid my working definition of the loser one is incorrect.
> It's actually "anything but '\0' and '/' not ending with '[*]'.
True.
Paolo
next prev parent reply other threads:[~2014-10-07 10:04 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-30 11:59 [Qemu-devel] [PATCH] util: Emancipate id_wellformed() from QemuOpts Markus Armbruster
2014-09-30 15:30 ` Eric Blake
2014-10-01 12:33 ` [Qemu-devel] IDs in QOM (was: [PATCH] util: Emancipate id_wellformed() from QemuOpts) Markus Armbruster
2014-10-02 13:21 ` Stefan Hajnoczi
2014-10-02 13:26 ` [Qemu-devel] IDs in QOM Andreas Färber
2014-10-02 14:10 ` Stefan Hajnoczi
2014-10-02 14:21 ` Markus Armbruster
2014-10-02 14:28 ` Andreas Färber
2014-10-02 14:59 ` Markus Armbruster
2014-10-02 17:41 ` Paolo Bonzini
2014-10-07 8:01 ` Markus Armbruster
2014-10-07 10:03 ` Paolo Bonzini [this message]
2014-10-07 12:16 ` Markus Armbruster
2014-10-07 15:14 ` Paolo Bonzini
2014-10-07 18:39 ` Markus Armbruster
2014-10-07 18:42 ` Paolo Bonzini
2014-10-07 18:41 ` Kevin Wolf
2014-10-07 18:45 ` Paolo Bonzini
2014-10-02 13:18 ` [Qemu-devel] [PATCH] util: Emancipate id_wellformed() from QemuOpts Stefan Hajnoczi
2014-10-02 13:42 ` Markus Armbruster
2014-10-02 14:11 ` Stefan Hajnoczi
2014-10-03 8:46 ` Stefan Hajnoczi
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=5433BA8E.9070101@redhat.com \
--to=pbonzini@redhat.com \
--cc=afaerber@suse.de \
--cc=aliguori@amazon.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
--cc=stefanha@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.