From: Anthony Liguori <anthony@codemonkey.ws>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
Markus Armbruster <armbru@redhat.com>,
qemu-devel <qemu-devel@nongnu.org>, Avi Kivity <avi@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [RFC] QEMU Object Model status/merge plan
Date: Tue, 13 Dec 2011 07:43:26 -0600 [thread overview]
Message-ID: <4EE7567E.3070702@codemonkey.ws> (raw)
In-Reply-To: <CAJSP0QXaX8cxBizXOAbW4cPWLZf4OLJsjfzCfpc9B5nU0E9RDQ@mail.gmail.com>
On 12/13/2011 05:35 AM, Stefan Hajnoczi wrote:
> On Mon, Dec 12, 2011 at 7:36 PM, Anthony Liguori<anthony@codemonkey.ws> wrote:
>> I choose the serial device to showcase what we'll eventually be able to do.
>> The three relevant files are:
>>
>> https://github.com/aliguori/qemu/blob/qom-next/hw/isa-serial.c
>>
>> https://github.com/aliguori/qemu/blob/qom-next/hw/mm-serial.c
>>
>> https://github.com/aliguori/qemu/blob/qom-next/hw/serial.c
>
> I'm not sure I understand how init functions are called for derived
> classes.
There are three types of init functions:
class_init
==========
This lives in (TypeInit) and is called when a class is first created for a type.
It is only ever called once. Within this function, you should override any
methods in your base classes and set default implementations for any methods you
implement.
instance_init
=============
This is the constructor for a type. It is called when an object is created and
chained such that the base class constructors are called first to initialize the
object.
DeviceState::init
=================
This is the qdev initialize function. It is called sometime after properties
are set and before the guest starts running for the first time. Long term, I
plan to change this to "DeviceState::realize" and remove explicit calls to
qdev_init() in favor of a propagated realize signal.
But for now, I'm trying to avoid churn in the tree.
> On one hand mm-serial.c calls its superclass init function,
> on the other hand isa-bus.c:isa_qdev_init() calls an init function
> that its child class must provide. One is calling its parent, the
> other is calling its child. Is there a consistent way of doing this
> and what did I miss :)?
Yes, this is all DeviceState::init. This is what is called when you invoke
qdev_init(). Right now, you have to do it explicitly and in the case of
composition, since the device is creating another device, it must be the one
that calls qdev_init() for that device.
In the case of inheritance, we're just calling the superclass's init function
because DeviceState::init is just a normal method so we have to explicitly chain
it if we want that behavior.
Regards,
Anthony Liguori
>
> Stefan
>
next prev parent reply other threads:[~2011-12-13 13:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-12 19:36 [Qemu-devel] [RFC] QEMU Object Model status/merge plan Anthony Liguori
2011-12-13 11:35 ` Stefan Hajnoczi
2011-12-13 13:43 ` Anthony Liguori [this message]
2011-12-13 15:05 ` Kevin Wolf
2011-12-13 16:02 ` Anthony Liguori
2011-12-14 10:33 ` Kevin Wolf
2011-12-14 13:46 ` 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=4EE7567E.3070702@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=armbru@redhat.com \
--cc=avi@redhat.com \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
--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.