From: Anthony Liguori <anthony@codemonkey.ws>
To: Paul Brook <paul@codesourcery.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
Jan Kiszka <jan.kiszka@siemens.com>,
qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Subject: Re: [Qemu-devel] [RFC] Plan for moving forward with QOM
Date: Tue, 13 Dec 2011 15:53:25 -0600 [thread overview]
Message-ID: <4EE7C955.5000101@codemonkey.ws> (raw)
In-Reply-To: <201112132036.01441.paul@codesourcery.com>
On 12/13/2011 02:36 PM, Paul Brook wrote:
>> Composition == "etching to the same piece of silicon". Nothing more,
>> nothing less.
>
> That's a really crappy definition. Most ARM systems are comprised of
> approximately one piece of silicon. There may be dozens of variants of a
> particular chip, with the same device models stamped into the silicon slightly
> different ways.
>
> IMO it would be much better to split on logical device boundaries. Especially
> when the functionality provided (pci to ISA bridge) works perfectly well
> without the child device.
What I'm really after is to have a way to do "-device piix3" and get all of the
devices that would normally live on the piix3. If it's desirable to split out
piix3 into piix3-isa-bridge which is part of piix3 and can be used independently
such that piix3 is just a thin container of piix3-isa-bridge and everything
behind it, that's fine by me.
We should do whatever makes sense for the machine/target. For pc, I've seen
absolutely zero interest in someone creating a pc machine without an i8042 or an
RTC. I don't think it's the use-case to optimize for.
>> A device has no knowledge of the fact that it is a child of another device.
>>
>>> If you're wanting to provide a convenient way of instantiating common
>>> clumps of devices then I think that should be separate. Likewise
>>> defining convenient machine specific aliases for users.
>>
>> There is a separate container device that lets you create arbitrary
>> collections of devices, but in many cases, we can achieve better code
>> reuse by using composition.
>>
>> Consider the serial device. In QOM, I've got it modelled as:
>>
>> MMSerial has-a UART
>> ISASerial has-a UART
>>
>> And there are lots of cases where a design is compatible with a UART16650A
>> but adds additional logic/features. In those cases, we would do:
>>
>> MCFSerial is-a UART
>
> Are you using UART as shorthand for UART16550A?
Yes.
> Or is UART a base object that
> implements pure virtual methods for register access and properties for
> CharDevice and IRQ output. UART16550 inherits from and provides the
> implementation? So a UART8250 or UART6551 could act as drop-in replacements
> (replacing has-a UART with links-to-a UART).
>
>> Now you could certainly remove the has-a logic and make it so something had
>> to instantiate a UART separately from the ISASerial device and connect
>> things up but that's overly complicated IMHO.
>
> Why not ISASerial is-a UART?
That's actually how I implemented MMSerial just to show that it's possible.
I prefer has-a because if you had a real life ISA card with a UART16550A on it,
the ISA card would have an identifiable UART16650A on it. I think it's unlikely
that you would have a single chip with an ISA-compatible pin-out that happened
to be compatible with a UART16550A.
> I guess because both are stateful, so not allowed
> by our inheritance model?
Right, but ISADevice could very easily become an Interface as it has no state today.
> We could presumably do:
> ISASerial is-a UART has-a ISADevice
> It seems like a map-isa-io-to-registers device has at least as may reuse
> opportunities as register-based-uart.
We could also do that, but we still need to work out how to expose MemoryRegions
and AddressSpaces in the new device model.
>
> How is MCFSerial different? Are we expecting MCFSerial to poke around in
> private UART16550 rather than just feeding it cooked data? If so isn't it
> mode likely to end up as:
Yes, it could go either way really but I would expect that MCFSerial would
override the ioport_read() and ioport_write functions and implement custom
functionality that way.
>
> UARTMCF is-a UART16550 // with knobs on.
> MCFSerial is-a ColdfireBusDevice has-a UART
>
>>> So the link is to an Interface, not a device?
>>
>> Devices are Objects
>>
>> All Objects have Types. An interface is just another Type. Types can
>> inherit from other types.
>
> Ah, I think I see. The trick is that this effectively gives multiple
> inheritance as long as no more than one base type has state (i.e. data
> members).
Exactly.
>
>> All devices inherit from the DeviceState type.
>>
>> A link has a Type associated with it. The Type can be an interface, or it
>> can be a stateful base class, or it can be a Type that isn't derived at
>> all from Device (like a CharDriverState).
>
> Ok. I suspect we may have slightly different ideas what constitutes a
> "Device", but I'll leave that for now.
>
>>> To support multiple instances
>>> of the same interface we use a closure-like proxy object?
>>
>> If you needed to, but I think most of the time, that's not necessary.
>
> I don't see how this can work without a closure object. We need a central
> device that is capable of recieving signals from many client devices. Those
> client devices don't know where they are, they just shout down a point-point
> link. I'd say this is a fairly common topology.
>
> If the central device implements that point-point interface directly then it
> has no idea which device is talking to it. We need to create child objects
> with a port ID property and implementing the p-p interface, then bind each
> client device to one of these child objects. The child objects can't do
> anything useful on their own, so need to proxy the signal to an interface on
> the main object, adding in their port id.
If you aren't using inheritance, yes, you need to pass closures to the child
objects. I dislike that kind of proxy modeling.
I wonder how common is it though to have this kind of scenario where the bus
protocol doesn't have any kind of identifier that identifies the target bus. I
presume in most cases you're thinking about, there's a single transport that can
multiplex communications, no?
If there is a bus identifier in the various interface commands, there is no need
to implement the interface multiple times. You can just inherit from it once
and use the bus identifier to determine which bus it's intended for.
Regards,
Anthony Liguori
>
> Paul
>
next prev parent reply other threads:[~2011-12-13 21:53 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-14 18:04 [Qemu-devel] [RFC] Plan for moving forward with QOM Anthony Liguori
2011-09-14 18:49 ` Anthony Liguori
2011-09-14 19:30 ` Jan Kiszka
2011-09-14 19:42 ` Anthony Liguori
2011-09-14 21:15 ` Jan Kiszka
2011-09-14 22:11 ` Anthony Liguori
2011-09-15 13:43 ` Jan Kiszka
2011-09-15 14:11 ` Anthony Liguori
2011-09-15 16:38 ` Jan Kiszka
2011-09-15 18:01 ` Anthony Liguori
2011-09-16 10:12 ` Kevin Wolf
2011-09-16 13:00 ` Anthony Liguori
2011-09-14 20:00 ` Edgar E. Iglesias
2011-09-14 20:22 ` Anthony Liguori
2011-09-14 20:27 ` Edgar E. Iglesias
2011-09-14 20:37 ` Blue Swirl
2011-09-14 21:25 ` Anthony Liguori
2011-09-15 6:31 ` Gleb Natapov
2011-09-15 10:49 ` Stefan Hajnoczi
2011-09-15 13:08 ` Anthony Liguori
2011-09-15 13:17 ` Anthony Liguori
2011-09-15 14:23 ` Gleb Natapov
2011-09-16 14:46 ` John Williams
2011-09-16 16:10 ` Anthony Liguori
2011-09-17 1:11 ` Edgar E. Iglesias
2011-09-17 2:12 ` Anthony Liguori
2011-09-17 2:35 ` Edgar E. Iglesias
2011-09-15 13:57 ` Anthony Liguori
2011-09-15 14:14 ` Paolo Bonzini
2011-09-15 14:25 ` Gleb Natapov
2011-09-15 15:28 ` Anthony Liguori
2011-09-15 15:38 ` Gleb Natapov
2011-09-15 16:33 ` Anthony Liguori
2011-09-15 16:59 ` Gleb Natapov
2011-09-15 17:51 ` Anthony Liguori
2011-09-15 20:29 ` Gleb Natapov
2011-09-15 20:45 ` Peter Maydell
2011-09-15 21:15 ` Anthony Liguori
2011-09-16 16:33 ` Gleb Natapov
2011-09-16 17:47 ` Peter Maydell
2011-09-16 18:08 ` Anthony Liguori
2011-09-16 18:22 ` Gleb Natapov
2011-09-16 18:42 ` Anthony Liguori
2011-09-16 19:13 ` Gleb Natapov
2011-09-16 19:29 ` Anthony Liguori
2011-09-16 20:48 ` Gleb Natapov
2011-09-16 21:03 ` Anthony Liguori
2011-09-17 0:01 ` Edgar E. Iglesias
2011-09-16 18:18 ` Gleb Natapov
2011-09-15 20:50 ` Anthony Liguori
2011-09-16 16:47 ` Gleb Natapov
2011-09-17 0:48 ` Edgar E. Iglesias
2011-09-17 2:17 ` Anthony Liguori
2011-09-17 2:29 ` Anthony Liguori
2011-09-17 2:41 ` Edgar E. Iglesias
2011-09-15 6:47 ` Paolo Bonzini
2011-09-15 13:26 ` Anthony Liguori
2011-09-15 13:35 ` Paolo Bonzini
2011-09-15 13:54 ` Peter Maydell
2011-09-15 14:18 ` Anthony Liguori
2011-09-15 14:33 ` Paolo Bonzini
2011-09-15 14:48 ` Peter Maydell
2011-09-15 15:31 ` Anthony Liguori
2011-09-15 15:47 ` Paolo Bonzini
2011-09-15 20:23 ` Avi Kivity
2011-09-15 20:52 ` Anthony Liguori
2011-09-18 7:56 ` Avi Kivity
2011-09-18 14:00 ` Avi Kivity
2011-09-16 9:36 ` Gerd Hoffmann
2011-12-13 4:47 ` Paul Brook
2011-12-13 13:22 ` Anthony Liguori
2011-12-13 17:40 ` Paul Brook
2011-12-13 18:00 ` Anthony Liguori
2011-12-13 20:36 ` Paul Brook
2011-12-13 21:53 ` Anthony Liguori [this message]
2011-12-14 0:39 ` Paul Brook
2011-12-14 13:53 ` Anthony Liguori
2011-12-14 14:01 ` Avi Kivity
2011-12-14 14:11 ` Anthony Liguori
2011-12-14 14:35 ` Avi Kivity
2011-12-14 14:46 ` Anthony Liguori
2011-12-14 14:50 ` Avi Kivity
2011-12-15 18:59 ` Paul Brook
2011-12-15 19:12 ` Anthony Liguori
2011-12-15 21:28 ` Paul Brook
2011-12-16 2:08 ` Anthony Liguori
2011-12-16 5:11 ` Paul Brook
2011-12-14 9:11 ` Andreas Färber
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=4EE7C955.5000101@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=armbru@redhat.com \
--cc=edgar.iglesias@gmail.com \
--cc=jan.kiszka@siemens.com \
--cc=kraxel@redhat.com \
--cc=paul@codesourcery.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 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.