All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC][PATCH 0/21] QEMU Object Model
Date: Wed, 27 Jul 2011 07:48:28 -0500	[thread overview]
Message-ID: <4E30091C.3070404@codemonkey.ws> (raw)
In-Reply-To: <4E2FD28F.2070206@redhat.com>

On 07/27/2011 03:55 AM, Paolo Bonzini wrote:
> Yes, this looks nice (modulo s/Rtl8139/Rtl8139 */). But it is not that
> much more flexible than qdev 1.0.
>
> You're right that for the case of two parents above we were looking at a
> contrived example. The Goldfish platform provides a more interesting
> one. There you have an interrupt controller and a bus enumerator device.
> Most devices are connected to both, but conflating them is wrong for
> many reasons;
>
> 1) the bus enumerator itself uses an interrupt (raised on hotplug);
>
> 2) you can enumerate devices that do not have an interrupt line, and you
> shouldn't need to connect such a device to an interrupt controller;
>
> 3) the interrupt controller and bus enumerator use two separate MMIO areas;
>
> 4) in principle, other devices could use the interrupt controller (which
> is the only component connected to the CPU's interrupt line) without
> being enumerated.
>
> 5) A device with two interrupts has two "interrupt interfaces" and only
> one "enumerator interface".
>
> 6) The enumerator interface does not have bus semantics. The enumerator
> also enumerates itself so it would act as both the bus host and a device
> on the bus.

I think I understand what your saying here.  But interrupt routing is an 
interesting problem and I've been thinking about it differently then we 
do it today.

The core is:

class Pin : public Device {
    bool level;
};

You can connect a signal to the level to detect edge changes.  You can 
also connect two pins together such that if one raises high, the other 
raises high.

An interrupt controller looks like:

struct InterruptController
{
    Pin *irq[256];
};

In the simple case, you have:

struct UART : public Device
{
    Pin irq;
};

And then you'd set the irq by doing:

apic = new InterruptController()
uart = new UART()

apic->irq[0] = &uart->irq;

Or at the qmp layer:

(qemu) plug_get uart irq
uart::irq
(qemu) plug_set apic irq[0] uart::irq

I mention this because I don't think your example below assumes a model 
like this.

> Composition then lets you use something like this:
>
> class GoldfishPIC : Device {
> Pin parent;
> GoldfishInterruptPin *children[32];
> Pin (*init_socket_for_irq_num) (GoldfishInterruptPin *, int);
> };

So the idea here is that the PIC will multiplex a bunch of interrupts 
into a single line?  I would do this simply as:

class GoldfishPIC : Device {
    Pin out;
    Pin *in[32];
};

The IRQ number is implicit in the socket index, no?  I'm also not sure 
that there's a strong need to have a typed Pin.

>
> class GoldfishInterruptPin {
> GoldfishPIC *pic;
> Pin irqnum;
> };
>
> class GoldfishEnumerator : Device {
> GoldfishInterruptPin irq;
> GoldfishBusDeviceInfo info;
> List<GoldfishBusDeviceInfo> allDevices;
> ...
> };
>
> class GoldfishBusDeviceInfo {
> GoldfishEnumerator *parent;
> char *name;
> int id;
> ram_addr_t mmio;
> int mmio_size;
> int irq_base;
> int irq_count;
> };

Is the enumerator something that has an interface to devices where the 
devices hold this info?  Or is the enumerator just a bank of flash 
that's preprogrammed with fixed info?

If it's the later, I would suggest that we model is in that fashion.  No 
need to teach every single device about the enumerator if they wouldn't 
normally have information about it.

>> We need lots of new transitions, we need to strive to make things
>> better. But we need to do things in such a way that:
>>
>> (1) we have a good idea of what we're going to end up with at the end of
>> the day
>>
>> (2) there is incremental value being added to QEMU at every step of
>> the way
>>
>> This cannot be done by simply hacking some bits here and there. It
>> requires design, planning, and flag days when appropriate.
>
> Agreed. The problem I have with QOM is (2). I am not sure we do get
> incremental value at every step of the way. We do get incremental value
> in the char layer, but we also get additional complexity until the
> transition is over.

So roughly speaking, my plan is:

1) Char layer
  - we get dynamic add of CDS, which enables hot plug of virtio-serial
  - we get ability to change CDS properties dynamically

2) Block layer
  - we get -blockdev

3) Display layer
  - we get dynamic add of VGA devices

4) fsdev
  - dynamic add of virtio-9p devices

5) network layer
  - no new features, but better commonality

At each phase, we also get significantly better modularity.  The block 
layer is already good here, but the other backends aren't.

My only real concern is how to attack the device layer incrementally.  I 
don't think it's impossible but it requires careful thought.

I think we can probably retrofit DeviceState as a QOM base class and 
just systematically convert the types over to QOM.  The next step would 
be to change the property registration to be QOM-like.  I think they we 
could probably push out a lot of what's in DeviceState today into 
another base class, then introduce a better Device base class.  Since a 
lot of subsystems should just inherit from Device, that gives us a nice 
way to attack things one subsystem at a time.

I think an approach like this can have incremental value.  The first 
step of retrofitting is pretty systematic and allows for devices be 
created and composed through the plug interfaces.  I think we could 
pretty much eliminate machines after this phase which would be a huge 
win for compatibility.

Regards,

Anthony Liguori

>
> Paolo
>

  reply	other threads:[~2011-07-27 12:48 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-25  1:44 [Qemu-devel] [RFC][PATCH 0/21] QEMU Object Model Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 01/21] qom: add make infrastructure Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 02/21] qom: convert QAPI to use Qconfig build system Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 03/21] qom: Add core type system Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 04/21] qom: add Plug class Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 05/21] plug: add Plug property type Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 06/21] plug: add socket " Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 07/21] plug: add generated property types Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 08/21] qom: add plug_create QMP command Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 09/21] qom: add plug_list " Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 10/21] qom: add plug_get " Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 11/21] qom: add plug_set " Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 12/21] qom: add plug_list_props " Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 13/21] qom: add plug_destroy command Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 14/21] qom: add example qsh command Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 15/21] qom: add Device class Anthony Liguori
2011-07-27 15:10   ` Peter Maydell
2011-07-27 16:07     ` Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 16/21] qom-devices: add a Pin class Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 17/21] qom: add CharDriver class Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 18/21] qom-chrdrv: add memory character driver Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 19/21] qom-chrdrv: add Socket base class Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 20/21] qom-chrdrv: add TCPServer class Anthony Liguori
2011-07-25  1:44 ` [Qemu-devel] [PATCH 21/21] qom-chrdrv: add UnixServer Anthony Liguori
2011-07-25 11:21 ` [Qemu-devel] [RFC][PATCH 0/21] QEMU Object Model Kevin Wolf
2011-07-25 12:45   ` Anthony Liguori
2011-07-25 13:08     ` Kevin Wolf
2011-07-25 13:10       ` Anthony Liguori
2011-07-26 12:59 ` Paolo Bonzini
2011-07-26 14:02   ` Anthony Liguori
2011-07-26 14:35     ` Paolo Bonzini
2011-07-26 15:34       ` Anthony Liguori
2011-07-26 18:26         ` Paolo Bonzini
2011-07-26 19:23           ` Anthony Liguori
2011-07-27  8:55             ` Paolo Bonzini
2011-07-27 12:48               ` Anthony Liguori [this message]
2011-07-27 15:33                 ` Paolo Bonzini
2011-07-27 16:19                   ` Anthony Liguori
2011-07-27 16:28                   ` Anthony Liguori
2011-07-27 18:51                     ` Paolo Bonzini
2011-07-27 20:01                       ` Anthony Liguori
2011-07-28  7:36                         ` Paolo Bonzini
2011-07-28 12:46                           ` Anthony Liguori
2011-07-28 13:50                             ` Paolo Bonzini
2011-07-28 14:03                               ` Anthony Liguori
2011-07-28 14:41                                 ` Paolo Bonzini
2011-07-28 15:04                                   ` Anthony Liguori
2011-07-28 15:47                                     ` Paolo Bonzini
2011-07-28 17:59                                       ` Anthony Liguori
2011-07-29  7:19                                         ` Paolo Bonzini
2011-07-27 21:33     ` Peter Maydell
2011-07-27 22:31       ` 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=4E30091C.3070404@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=pbonzini@redhat.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.