From: Paolo Bonzini <pbonzini@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
Anthony Liguori <aliguori@us.ibm.com>,
Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
Jan Kiszka <jan.kiszka@siemens.com>,
qemu-devel@nongnu.org, Luiz Capitulino <lcapitulino@redhat.com>,
Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 00/20] qom: dynamic properties and composition tree
Date: Fri, 16 Dec 2011 14:28:34 +0100 [thread overview]
Message-ID: <4EEB4782.9090707@redhat.com> (raw)
In-Reply-To: <4EEB3FA4.9010807@redhat.com>
On 12/16/2011 01:55 PM, Kevin Wolf wrote:
> I don't think that not remembering the child device because you don't
> need to reference it any more makes it any less static. You could easily
> add the struct member, assign it once and then it matches your
> definition of static.
I think in that case you would add a link property, not a child.
> And it's not even true of all child devices, for example PCII440FXState
> does have a pointer to its piix3 already.
It's unused, actually. You're right, even though I'm not sure whether a
child<Pin> will be stored in the parent as a Pin or as a qemu_irq.
> > I think Anthony convinced me this is not the case (unlike links). Even
> > if buses and similar objects are changed to pointers because the
> > implementation needs that, those pointers should never be NULL (or if
> > they can, the child property should not exist when they are NULL).
>
> So child properties are never configurable, and if a device is optional
> or you can choose between multiple devices then it should be a link
> instead. That is, device composition in term of "child devices" happens
> only hard-coded and the user doesn't do it.
>
> Is this a reasonably accurate description of the intention?
It does sound accurate. In addition, a child property should really
model a parent-child relationship and should create a tree.
As an example, say you want to join two devices ("A" and "B"), by adding
a connection from B to A. Assuming you cannot simply add A as a
child<A> to B, you can do it in several ways:
1) directly add a link<A> property to B.
Examples:
- a local APIC has a link<CPUX86State>
2) generalizing (1), you can add a link<X> property to B, where X can be
any superclass of A or an interface implemented by A.
Examples:
- an object representing a PCI bus has a link<PCIDevice> for each
slot (PCIDevice is an abstract class)
- a SCSIBus can have a link<SCSIBusAdapter> to the parent (assuming
SCSIBus is a class and SCSIBusAdapter is an interface)
3) using composition ("has-a") instead of inheritance, you can add a
child<X> property to A and a link<X> property to B.
Example:
- a SCSI bus adapter is a device that has a child<SCSIBus>.
A SCSIDevice doesn't have a link to the adapter, but only
a link<SCSIBus>.
- instead of representing PCIDevice as a class, you could have a
child<PCIConnector> in the children, and a link<PCIConnector> in
the bus. (I would actually prefer this to an abstract PCIDevice
class, but we agreed that it would be too much churn for now).
- X can be simply a "Pin".
All of these examples match your definition, I tihnk.
For bidirectional links you can have any combination of the above.
Paolo
next prev parent reply other threads:[~2011-12-16 13:28 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-12 20:29 [Qemu-devel] [PATCH v3 00/20] qom: dynamic properties and composition tree Anthony Liguori
2011-12-12 20:29 ` [Qemu-devel] [PATCH v3 01/20] qom: add a reference count to qdev objects Anthony Liguori
2011-12-12 20:29 ` [Qemu-devel] [PATCH v3 02/20] qom: add new dynamic property infrastructure based on Visitors (v2) Anthony Liguori
2011-12-12 20:29 ` [Qemu-devel] [PATCH v3 03/20] qom: register legacy properties as new style properties (v2) Anthony Liguori
2011-12-12 20:29 ` [Qemu-devel] [PATCH v3 04/20] qom: introduce root device Anthony Liguori
2011-12-12 20:29 ` [Qemu-devel] [PATCH v3 05/20] qdev: provide an interface to return canonical path from root (v2) Anthony Liguori
2011-12-12 20:29 ` [Qemu-devel] [PATCH v3 06/20] qdev: provide a path resolution (v2) Anthony Liguori
2011-12-12 20:29 ` [Qemu-devel] [PATCH v3 07/20] qom: add child properties (composition) (v3) Anthony Liguori
2011-12-12 20:29 ` [Qemu-devel] [PATCH v3 08/20] qom: add link properties (v2) Anthony Liguori
2011-12-12 20:29 ` [Qemu-devel] [PATCH v3 09/20] qapi: allow a 'gen' key to suppress code generation Anthony Liguori
2011-12-12 20:29 ` [Qemu-devel] [PATCH v3 10/20] qmp: add qom-list command Anthony Liguori
2011-12-12 20:29 ` [Qemu-devel] [PATCH v3 11/20] qom: qom_{get, set} monitor commands (v2) Anthony Liguori
2011-12-12 20:29 ` [Qemu-devel] [PATCH v3 12/20] qdev: add explicitly named devices to the root complex Anthony Liguori
2011-12-12 20:29 ` [Qemu-devel] [PATCH v3 13/20] dev: add an anonymous peripheral container Anthony Liguori
2011-12-12 20:29 ` [Qemu-devel] [PATCH v3 14/20] rtc: make piix3 set the rtc as a child (v2) Anthony Liguori
2011-12-12 20:29 ` [Qemu-devel] [PATCH v3 15/20] rtc: add a dynamic property for retrieving the date Anthony Liguori
2011-12-12 20:29 ` [Qemu-devel] [PATCH v3 16/20] qom: optimize qdev_get_canonical_path using a parent link Anthony Liguori
2011-12-12 20:29 ` [Qemu-devel] [PATCH v3 17/20] qom: add vga node to the pc composition tree Anthony Liguori
2011-12-12 20:29 ` [Qemu-devel] [PATCH v3 18/20] qom: add string property type Anthony Liguori
2011-12-12 20:29 ` [Qemu-devel] [PATCH v3 19/20] qdev: add a qdev_get_type() function and expose as a 'type' property Anthony Liguori
2011-12-15 18:10 ` [Qemu-devel] [PATCH v3 00/20] qom: dynamic properties and composition tree Anthony Liguori
2011-12-16 9:42 ` Kevin Wolf
2011-12-16 10:17 ` Paolo Bonzini
2011-12-16 10:36 ` Kevin Wolf
2011-12-16 12:24 ` Paolo Bonzini
2011-12-16 12:55 ` Kevin Wolf
2011-12-16 13:28 ` Paolo Bonzini [this message]
2011-12-16 13:52 ` Anthony Liguori
2011-12-16 13:51 ` Anthony Liguori
2011-12-16 13:52 ` Paolo Bonzini
2011-12-16 14:11 ` Anthony Liguori
2011-12-16 14:18 ` Kevin Wolf
2011-12-16 14:54 ` Anthony Liguori
2011-12-16 14:56 ` Paolo Bonzini
2011-12-16 15:10 ` Kevin Wolf
2011-12-16 13:49 ` Anthony Liguori
2011-12-16 13:48 ` Anthony Liguori
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=4EEB4782.9090707@redhat.com \
--to=pbonzini@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=armbru@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@linux.vnet.ibm.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.