From: Paolo Bonzini <pbonzini@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Pratik Parvati" <pratikp@vayavyalabs.com>,
qemu-devel@nongnu.org
Subject: Re: sysbus_create_simple Vs qdev_create
Date: Tue, 28 Jul 2020 19:38:27 +0200 [thread overview]
Message-ID: <759959d1-f320-734a-ac5e-a60db6b1bc23@redhat.com> (raw)
In-Reply-To: <87lfj4f6nz.fsf@dusky.pond.sub.org>
On 28/07/20 09:19, Markus Armbruster wrote:
>> the composition tree generally mirrors things that are born and die
>> at the same time, and creating children is generally reserved to the
>> object itself.
>
> Yes. Notable exceptions: containers /machine/peripheral,
> /machine/peripheral-anon, /machine/unattached.
And /objects too. Apart from /machine/unattached, all these dynamic
objects are created by the monitor or the command line.
>> Children are usually embedded directly in a struct, for
>> example.
>
> We sometimes use object_new() + object_property_add_child() instead.
> Extra indirection. I guess we'd be better off without the extra
> indirection most of the time. Implementation detail.
>
> We sometimes use object_new() without object_property_add_child(), and
> have qdev_realize() put the device in the /machine/unattached orphanage.
> Meh. I guess the orphanage feature exists to make conversion to QOM
> slightly easier. Could we ban its use for new boards at least?
Banning perhaps is too strong, but yes /machine/unattached is an
anti-pattern.
>> 3) accessing the QOM graph is slow (it requires hash table lookups,
>> string comparisons and all that), so the pointers that cache the
>> parent-child links are needed for use in hot paths.
>
> True, but only because QOM's design opts for generality, efficiency be
> damned :)
Remember that QOM's essential feature is the visitors: unlike GObject,
QOM is not targeted at programming languages but rather at CLI and RPC.
> I never quite understood why we need to build properties at run time.
I think it was (for once) Anthony reasoning that good is better than
perfect. You do need run-time properties for /machine/unattached,
/machine/peripheral, etc., so he decided to only have run-time
properties. Introspection wasn't considered a primary design goal.
Also, even though child properties are quite often the same for all
objects after initialization (and possibly realization) is complete,
this does not cover in two cases:
1) before the corresponding objects are created---so static child
properties would only be possible if creation of all children is moved
to instance_init, which is guaranteed not to fail.
2) there are cases in which a property (e.g. an int) governs how many of
those children exist, so you cannot create all children in instance_init.
Paolo
> It's makes reasoning about properties harder, and introspection brittle.
next prev parent reply other threads:[~2020-07-28 17:39 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-14 16:09 sysbus_create_simple Vs qdev_create Pratik Parvati
2020-07-14 16:17 ` Pratik Parvati
2020-07-14 17:02 ` Philippe Mathieu-Daudé
2020-07-15 8:32 ` Markus Armbruster
2020-07-15 13:58 ` Pratik Parvati
2020-07-15 14:11 ` Peter Maydell
2020-07-15 14:37 ` Markus Armbruster
2020-07-16 22:21 ` Eduardo Habkost
2020-07-17 5:10 ` Markus Armbruster
2020-07-17 16:23 ` Eduardo Habkost
2020-07-17 16:30 ` Daniel P. Berrangé
2020-07-17 17:15 ` Peter Maydell
2020-07-20 7:39 ` Markus Armbruster
2020-07-20 7:38 ` Markus Armbruster
2020-07-20 15:59 ` Eduardo Habkost
2020-07-21 6:00 ` Markus Armbruster
2020-07-27 14:29 ` Paolo Bonzini
2020-07-28 7:19 ` Markus Armbruster
2020-07-28 17:38 ` Paolo Bonzini [this message]
2020-07-28 22:47 ` Eduardo Habkost
2020-07-29 9:54 ` Paolo Bonzini
2020-07-29 13:18 ` Markus Armbruster
2020-07-29 16:08 ` Paolo Bonzini
2020-07-30 10:03 ` Markus Armbruster
2020-07-30 11:09 ` Paolo Bonzini
2020-07-30 12:36 ` Markus Armbruster
2020-07-30 13:38 ` Paolo Bonzini
2020-07-29 14:32 ` Eduardo Habkost
2020-07-29 16:01 ` Paolo Bonzini
2020-07-29 16:08 ` Eduardo Habkost
2020-07-29 16:14 ` Paolo Bonzini
2020-07-29 7:46 ` 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=759959d1-f320-734a-ac5e-a60db6b1bc23@redhat.com \
--to=pbonzini@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=ehabkost@redhat.com \
--cc=philmd@redhat.com \
--cc=pratikp@vayavyalabs.com \
--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).