qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] how to handle QOM 'container' objects whose contents depend on QOM properties?
@ 2018-02-06 18:18 Peter Maydell
  2018-02-06 19:04 ` Eduardo Habkost
  2018-02-07 12:35 ` Igor Mammedov
  0 siblings, 2 replies; 11+ messages in thread
From: Peter Maydell @ 2018-02-06 18:18 UTC (permalink / raw)
  To: QEMU Developers
  Cc: Paolo Bonzini, Igor Mammedov, Eduardo Habkost, Marcel Apfelbaum

[I've cc'd a fairly random selection of people who I thought
might be interested or have an opinion.]

It's fairly common to have a setup where we have a QOM container
object (like an SoC) which in turn instantiates a lot of child
objects (for all the devices). The neat way of doing this looks
like hw/arm/xlnx-zynqmp.c -- in the container's init function,
we use object_initialize() to init all the child objects. If the
container exposes some properties that are really just being
forwarded to one of its children it can set those up in init
with object_property_add_alias(). Finally, in realize the container
realizes all its children.

Unfortunately, this pattern interacts badly with the idea that
you might want to use a QOM property to determine aspects of
the container that affect what child objects it creates.
(Examples would include wanting a "which CPU is this" property
on an SoC object, or if the SoC has a couple of variants which
maybe have extra devices.)

One current approach to that is that instead of init'ing those
child objects in the container init, we postpone that to
container realize. This looks pretty ugly, and it also means
that you can't do "forward this property" using add_alias if the
target is the late-inited child (instead you have to have a
real property on the container and set the property on the child
manually after it's inited). You can see an example of this kind
of thing in hw/arm/armv7m.c.

Another approach is that instead of having a "what CPU" or "what
SoC variant" property on the container, we create one container
type per variation. Then instead of "create container, set QOM
property to specify variant" the user creates the correct container
type for the variant. hw/arm/aspeed_soc.c has an example of this.
That looks pretty nice code-wise, but if there are a lot of
possible options for the variants it could result in a large
number of QOM types.

The other popular approach to this is "don't let the container
be as configurable as it ideally ought to be"...

So, does anybody have a view on what the best way to structure
this kind of container object is? I feel like I'm running into
the annoyances of the approach that armv7m.c is currently taking,
so if there's a better way I'd like to do that instead.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-02-07 17:35 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-06 18:18 [Qemu-devel] how to handle QOM 'container' objects whose contents depend on QOM properties? Peter Maydell
2018-02-06 19:04 ` Eduardo Habkost
2018-02-06 19:27   ` Peter Maydell
2018-02-06 19:52     ` Eduardo Habkost
2018-02-07 15:41     ` Paolo Bonzini
2018-02-07 16:22       ` Peter Maydell
2018-02-07 16:38         ` Paolo Bonzini
2018-02-07 16:49           ` Peter Maydell
2018-02-07 17:28             ` Paolo Bonzini
2018-02-07 17:34               ` Peter Maydell
2018-02-07 12:35 ` Igor Mammedov

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).