qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Eduardo Habkost <ehabkost@redhat.com>,
	Hu Tao <hutao@cn.fujitsu.com>,
	Anthony Liguori <anthony@codemonkey.ws>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Peter Crosthwaite <peter.crosthwaite@xilinx.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	Igor Mammedov <imammedo@redhat.com>,
	Anthony Liguori <aliguori@us.ibm.com>
Subject: Re: [Qemu-devel] [PATCH 21/26] kvmclock: use realize for kvmclock
Date: Sun, 30 Jun 2013 16:36:13 +0200	[thread overview]
Message-ID: <51D0425D.60603@suse.de> (raw)
In-Reply-To: <20130625174555.GA11420@otherpad.lan.raisama.net>

Am 25.06.2013 19:45, schrieb Eduardo Habkost:
> On Tue, Jun 25, 2013 at 10:20:08AM +0800, Hu Tao wrote:
> [...]
>>> Is TYPE_SYS_BUS_DEVICE guaranteed to never override ->realize() itself?
>>>
>>> From DeviceClass documentation:
>>>
>>>  * If a type derived directly from TYPE_DEVICE implements @realize, it does
>>>  * not need to implement @init and therefore does not need to store and call
>>>  * #DeviceClass' default @realize callback.
>>>  * For other types consult the documentation and implementation of the
>>>  * respective parent types.
>>>
>>> The problem is that there's no documentation about ->realize() on
>>> SysBusDeviceClass. Can we please explicitly document SysBusDeviceClass
>>> expectations about ->realize() first, before making those changes?

If someone wants to add a paragraph to sysbus.h:SysBusDeviceClass
documentation I would happily ack or pick that up. :)

>> IIUC, subclass's overriding ->realize should call parent's ->realize at
>> some point. Peter Crosthwaite has a patchset to access a object's parent
>> class at http://lists.nongnu.org/archive/html/qemu-devel/2013-06/msg02982.html
>>
>> Regarding SysBusDevice::init and SysBusDevice::realize, I think it's the
>> same as in the case of DeviceClass. If you agree I'll document it as in
>> DeviceClass.
> 
> I believe it is reasonable to document that SysBusDevice subclasses
> don't need to call the parent ->realize() method, like on DeviceClass.
> This is exactly what this patch set does, after all, and I haven't seen
> anybody complaining about it yet.

So the thing is that SysBusDevice's DeviceClass::init implementation,
called by DeviceState's DeviceClass::realize implementation, just calls
SysBusDeviceClass::init if non-NULL. When we introduce our own device's
realizefn to replace our SysBusDeviceClass::init implementation, there
is no point calling that effectively no-op DeviceClass::realize
implementation. And if we tried to, ...
* ... how would we decide whether to call the parent's implementation
first or last? It's not yes or no, it's no or when. Changing between
either is more than just moving one line, it affects error handling and
with knowledge about parent implementation never failing we could so far
save us some work.
* ... with the current QOM method scheme we'd go insane introducing a
FooClass per device to save SysBusDevice's DeviceClass::realize in
FooClass::parent_realize. Still waiting for Anthony on whether and how
we want to change our scheme.

Long story short: If someone wants to mess with base classes they get to
check derived classes for compatibility with their change.

Ideally qtest would help automate that to some degree.
I would be all in favor if someone wanted to add a dummy test case per
non-default, non-KVM device converted so that we can see that we didn't
screw up -device instantiation too badly.

Regards,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

  reply	other threads:[~2013-06-30 14:36 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-22  8:50 [Qemu-devel] [PATCH 00/26] use realizefn for SysBusDevice, part 1 Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 01/26] ohci: use realize for ohci Hu Tao
2013-06-24  5:54   ` Peter Crosthwaite
2013-06-24  6:11     ` Hu Tao
2013-06-24  6:17       ` Peter Crosthwaite
2013-06-25  1:54         ` Hu Tao
2013-06-24 14:01   ` Eduardo Habkost
2013-06-22  8:50 ` [Qemu-devel] [PATCH 02/26] ohci: QOM'ify some more Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 03/26] i440fx-pcihost: use realize for i440fx-pcihost Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 04/26] i440fx: use type-safe cast instead of directly access of parent dev Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 05/26] q35: use realize for q35 host Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 06/26] q35: use type-safe cast instead of directly access of parent dev Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 07/26] fdc: use realize for fdc Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 08/26] fdc: QOM'ify some more Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 09/26] pflash_cfi01: use realize for pflash_cfi01 Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 10/26] pflash-cfi01: QOM'ify some more Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 11/26] pflash_cfi02: use realize for pflash_cfi02 Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 12/26] pflash-cfi02: QOM'ify some more Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 13/26] ahci: use realize for ahci Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 14/26] ahci: QOM'ify some more Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 15/26] fwcfg: use realize for fwcfg Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 16/26] fwcfg: QOM'ify some more Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 17/26] scsi esp: use realize for scsi esp Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 18/26] scsi esp: QOM'ify some more Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 19/26] hpet: use realize for hpet Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 20/26] hpet: QOM'ify some more Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 21/26] kvmclock: use realize for kvmclock Hu Tao
2013-06-24 10:14   ` Igor Mammedov
2013-06-25  1:55     ` Hu Tao
2013-06-24 14:01   ` Eduardo Habkost
2013-06-25  2:20     ` Hu Tao
2013-06-25 17:45       ` Eduardo Habkost
2013-06-30 14:36         ` Andreas Färber [this message]
2013-07-01  9:31           ` Hu Tao
2013-07-01 10:20             ` Andreas Färber
2013-06-22  8:50 ` [Qemu-devel] [PATCH 22/26] kvmclock: QOM'ify some more Hu Tao
2013-06-24 13:33   ` Eduardo Habkost
2013-06-22  8:50 ` [Qemu-devel] [PATCH 23/26] kvmvapic realize Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 24/26] ioapic: use realize for ioapic Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 25/26] isa bus: use realize for isa bus Hu Tao
2013-06-30 14:57   ` Andreas Färber
2013-07-01  5:30     ` Hu Tao
2013-06-22  8:50 ` [Qemu-devel] [PATCH 26/26] ehci: use realize for ehci Hu Tao
2013-06-22 10:38   ` Andreas Färber
2013-06-30 14:41     ` Andreas Färber
2013-06-30 16:45 ` [Qemu-devel] [PATCH 00/26] use realizefn for SysBusDevice, part 1 Andreas Färber
2013-07-01  5:31   ` Hu Tao

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=51D0425D.60603@suse.de \
    --to=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=anthony@codemonkey.ws \
    --cc=ehabkost@redhat.com \
    --cc=hutao@cn.fujitsu.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.crosthwaite@xilinx.com \
    --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 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).