From: Jan Kiszka <jan.kiszka@web.de>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Alexander Graf" <agraf@suse.de>,
qemu-devel@nongnu.org, "Blue Swirl" <blauwirbel@gmail.com>,
"Andreas Färber" <andreas.faerber@web.de>,
qemu-ppc@nongnu.org, "Paul Brook" <paul@codesourcery.com>,
"Aurelien Jarno" <aurelien@aurel32.net>,
"Gerd Hoffmann" <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 27/28] sysbus: apic: ioapic: convert to QEMU Object Model
Date: Tue, 24 Jan 2012 23:06:47 +0100 [thread overview]
Message-ID: <4F1F2B77.2020703@web.de> (raw)
In-Reply-To: <4F1F2875.3050509@codemonkey.ws>
[-- Attachment #1: Type: text/plain, Size: 3157 bytes --]
On 2012-01-24 22:53, Anthony Liguori wrote:
> On 01/24/2012 03:31 PM, Jan Kiszka wrote:
>> On 2012-01-24 22:11, Anthony Liguori wrote:
>>> On 01/24/2012 03:01 PM, Jan Kiszka wrote:
>>>> On 2012-01-24 21:21, Anthony Liguori wrote:
>>>>>> Also, I see a lot of programmatic initialization and a lot of
>>>>>> repeating
>>>>>> patterns (specifically regarding trivial class initialization) -
>>>>>> there
>>>>>> is no better alternative?
>>>>>
>>>>> Not really, no. It looks bad now because you have DeviceInfo still.
>>>>> Once DeviceInfo goes away, all of the initialization will happen in
>>>>> the
>>>>> class_init function.
>>>>>
>>>>> The design of QOM is such that a lot of what was previously done via
>>>>> declarative structures is now done imperatively. But the code bloat
>>>>> that came in this patch series will decrease significantly with the
>>>>> next
>>>>> series as we eliminate DeviceInfo.
>>>>
>>>> Are there examples of fully converted devices to get an impression?
>>>
>>> https://github.com/aliguori/qemu/tree/qom-rebase.8
>>>
>>> Has everything fully converted (including BusState).
>>>
>>> If you look at qdev.[ch], you'll notice the remaining qdev
>>> infrastructure becomes greatly simplified.
>>
>> But I don't get yet why all these repeating initialization tasks need to
>> be open-coded instead of remaining declarative.
>
> It would look like:
>
> static void device_generic_class_init(ObjectClass *klass, void *data)
> {
> DeviceClass *dc = DEVICE_CLASS(klass);
> DeviceTypeInfo *ti = data;
>
> if (ti->reset) {
> dc->reset = ti->reset;
> }
> if (ti->vmsd) {
> dc->vmsd = ti->vmsd;
> }
> }
>
> void device_type_register_static(DeviceTypeInfo *ti)
> {
> TypeInfo ti = {
> .class_init = device_generic_class_init,
> .class_data = ti,
> // ...
> }
> type_register_static(&ti);
> }
>
> But I don't like this. The problem is that the declarative syntax we
> have doesn't distinguish between "not-specified" and
> "zero-initialized".
That's surely solvable.
> It's also tempting to just drop the if (ti->reset)
> check but that means that you unconditionally override the base class
> implementation even if it's not specified.
That as well, just wrap this repeating pattern in a macro.
>
> I don't see any tangible benefits to a declarative syntax except that it
> makes it harder to get right because you have to write per-base class
> initialization functions and it's very easy to get polymorphism wrong
> there.
Now you have to write way more derived class init functions - provided a
base class is used more than once.
>
> We're not talking about a code size difference. It's a wash in terms of
> number of lines of code.
We are. Code size will be smaller, so the number of lines. How much,
that depends on the number of users per base class.
>
> Imperative allows you to explicit zero-initialize, accept the previous
> version (from the base class), or override with a new value.
None of this is impossible with a declarative approach.
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
next prev parent reply other threads:[~2012-01-24 22:06 UTC|newest]
Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-24 19:32 [Qemu-devel] [PATCH v3 0/28] qom: add QEMU Object Model type hierarchy to qdev Anthony Liguori
2012-01-24 19:32 ` [Qemu-devel] [PATCH 01/28] macio: convert " Anthony Liguori
2012-01-26 23:17 ` [Qemu-devel] [PATCH] macio: Convert " Andreas Färber
2012-03-06 22:56 ` Alexander Graf
2012-01-24 19:32 ` [Qemu-devel] [PATCH 02/28] openpic: remove dead code to make a PCI device version Anthony Liguori
2012-01-26 23:57 ` Andreas Färber
2012-01-24 19:32 ` [Qemu-devel] [PATCH 03/28] pci: call reset unconditionally Anthony Liguori
2012-01-25 12:42 ` Michael S. Tsirkin
2012-01-25 13:28 ` Anthony Liguori
2012-01-24 19:32 ` [Qemu-devel] [PATCH 04/28] qom: add the base Object class (v2) Anthony Liguori
2012-01-25 21:30 ` Andreas Färber
2012-01-25 21:37 ` Anthony Liguori
2012-01-26 7:43 ` Paolo Bonzini
2012-01-27 15:05 ` Andreas Färber
2012-01-27 15:42 ` Anthony Liguori
2012-01-27 15:43 ` Andreas Färber
2012-01-24 19:32 ` [Qemu-devel] [PATCH 05/28] qdev: integrate with QEMU Object Model (v2) Anthony Liguori
2012-01-24 19:32 ` [Qemu-devel] [PATCH 06/28] qdev: move qdev->info to class Anthony Liguori
2012-01-24 19:32 ` [Qemu-devel] [PATCH 07/28] qdev: don't access name through info Anthony Liguori
2012-01-24 19:33 ` [Qemu-devel] [PATCH 08/28] qdev: use a wrapper to access reset and promote reset to a class method Anthony Liguori
2012-01-24 19:33 ` [Qemu-devel] [PATCH 09/28] qdev: add a interface to register subclasses Anthony Liguori
2012-01-24 19:33 ` [Qemu-devel] [PATCH 10/28] qdev: add class_init to DeviceInfo Anthony Liguori
2012-01-24 19:33 ` [Qemu-devel] [PATCH 11/28] qdev: prepare source tree for code conversion Anthony Liguori
2012-01-26 17:35 ` [Qemu-devel] [PATCH 1/3] es1370: Drop dead code Andreas Färber
2012-01-26 17:35 ` [Qemu-devel] [PATCH 2/3] marvell_88w8618_audio: Use DEFINE_PROP_* macros Andreas Färber
2012-01-26 17:35 ` [Qemu-devel] [PATCH 3/3] qdev: prepare source tree for code conversion Andreas Färber
2012-01-24 19:33 ` [Qemu-devel] [PATCH 12/28] isa: pic: convert to QEMU Object Model Anthony Liguori
2012-01-24 19:33 ` [Qemu-devel] [PATCH 13/28] usb: " Anthony Liguori
2012-01-24 19:33 ` [Qemu-devel] [PATCH 14/28] ccid: " Anthony Liguori
2012-01-24 19:33 ` [Qemu-devel] [PATCH 15/28] ssi: " Anthony Liguori
2012-01-24 19:33 ` [Qemu-devel] [PATCH 16/28] i2c: rename i2c_slave -> I2CSlave Anthony Liguori
2012-01-24 19:33 ` [Qemu-devel] [PATCH 17/28] i2c: smbus: convert to QEMU Object Model Anthony Liguori
2012-01-24 19:33 ` [Qemu-devel] [PATCH 18/28] hda-codec: " Anthony Liguori
2012-01-24 19:33 ` [Qemu-devel] [PATCH 19/28] ide: " Anthony Liguori
2012-01-24 19:33 ` [Qemu-devel] [PATCH 20/28] scsi: " Anthony Liguori
2012-01-24 19:33 ` [Qemu-devel] [PATCH 21/28] spapr: convert to QEMU Object Model (v2) Anthony Liguori
2012-01-24 19:33 ` [Qemu-devel] [PATCH 22/28] virtio-serial: convert to QEMU Object Model Anthony Liguori
2012-01-24 19:59 ` Amit Shah
2012-01-24 20:13 ` Anthony Liguori
2012-01-24 19:33 ` [Qemu-devel] [PATCH 23/28] unin_pci: Clean up qdev names Anthony Liguori
2012-01-24 19:33 ` [Qemu-devel] [PATCH 24/28] unin_pci: Drop duplicate busdev Anthony Liguori
2012-01-24 19:33 ` [Qemu-devel] [PATCH 25/28] unin_pci: Drop unused reset handler Anthony Liguori
2012-01-24 19:33 ` [Qemu-devel] [PATCH 26/28] pci: convert to QEMU Object Model Anthony Liguori
2012-01-24 19:33 ` Anthony Liguori
2012-01-25 12:41 ` [Qemu-devel] " Michael S. Tsirkin
2012-01-25 12:41 ` Michael S. Tsirkin
2012-01-25 13:34 ` [Qemu-devel] " Anthony Liguori
2012-01-25 13:34 ` Anthony Liguori
2012-01-24 19:33 ` [Qemu-devel] [PATCH 27/28] sysbus: apic: ioapic: " Anthony Liguori
2012-01-24 20:01 ` Jan Kiszka
2012-01-24 20:21 ` Anthony Liguori
2012-01-24 21:01 ` Jan Kiszka
2012-01-24 21:11 ` Anthony Liguori
2012-01-24 21:31 ` Jan Kiszka
2012-01-24 21:53 ` Anthony Liguori
2012-01-24 22:06 ` Jan Kiszka [this message]
2012-01-24 23:03 ` Anthony Liguori
2012-01-25 8:33 ` Andreas Färber
2012-01-25 12:09 ` Avi Kivity
2012-01-25 13:02 ` Paul Brook
2012-01-25 14:25 ` Anthony Liguori
2012-01-25 8:37 ` Jan Kiszka
2012-01-25 10:15 ` Paolo Bonzini
2012-01-25 10:27 ` Jan Kiszka
2012-01-25 11:15 ` Paolo Bonzini
2012-01-25 14:00 ` Anthony Liguori
2012-01-25 14:23 ` Jan Kiszka
2012-01-25 14:40 ` Anthony Liguori
2012-01-25 15:18 ` Andreas Färber
2012-01-25 15:34 ` Eric Blake
2012-01-24 19:33 ` [Qemu-devel] [PATCH 28/28] virtio-s390: " Anthony Liguori
2012-01-24 23:13 ` [Qemu-devel] [PATCH v3 0/28] qom: add QEMU Object Model type hierarchy to qdev Peter Maydell
2012-01-24 23:16 ` Anthony Liguori
2012-01-25 18:31 ` Blue Swirl
2012-01-25 19:43 ` Anthony Liguori
2012-01-25 20:09 ` Blue Swirl
2012-01-27 17:34 ` 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=4F1F2B77.2020703@web.de \
--to=jan.kiszka@web.de \
--cc=agraf@suse.de \
--cc=andreas.faerber@web.de \
--cc=anthony@codemonkey.ws \
--cc=aurelien@aurel32.net \
--cc=blauwirbel@gmail.com \
--cc=kraxel@redhat.com \
--cc=mst@redhat.com \
--cc=paul@codesourcery.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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.