From: Anthony Liguori <anthony@codemonkey.ws>
To: Kevin O'Connor <kevin@koconnor.net>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Anthony Liguori <aliguori@us.ibm.com>,
qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 01/27] qom: add the base Object class
Date: Thu, 22 Dec 2011 13:57:20 -0600 [thread overview]
Message-ID: <4EF38BA0.1090706@codemonkey.ws> (raw)
In-Reply-To: <20111222180018.GA29733@morn.localdomain>
On 12/22/2011 12:00 PM, Kevin O'Connor wrote:
> On Thu, Dec 22, 2011 at 11:41:08AM -0600, Anthony Liguori wrote:
>> On 12/22/2011 11:25 AM, Kevin O'Connor wrote:
>>> On Wed, Dec 21, 2011 at 08:35:16AM -0600, Anthony Liguori wrote:
>>>> I used a symbolic type name to avoid the problem of dependencies.
>>>> In order to create a type in gobject, you have to reference the
>>>> parent's GType which usually means you have to call the _get_type()
>>>> function which acts as a singleton which registers the type.
>>>>
>>>> Since you have to specify the parent via a function call, you can't
>>>> define the type in a unit-level static structure which I viewed as a
>>>> critical requirement.
>>>
>>> Why not declare types with something like the following:
>>>
>>> TypeInfo my_device_info = {
>>> .name = "my-device",
>>> .parentinfo =&device_info,
>>> .instance_size = sizeof(MyDevice),
>>> };
>>>
>>> That is, instead of looking up the TypeImpl via a string, lookup the
>>> TypeImpl via the address of the TypeInfo. (Or possibly store a
>>> pointer to TypeImpl in TypeInfo during registration.)
>>>
>>> Module order shouldn't matter - all the info needed to register the
>>> parent is there so it can be registered during first use.
>>
>> The only problem with this is that if a .so implements the type, it
>> means that you have to have a way to figure out the dependency order
>> as you load the modules.
>>
>> OTOH, with the current approach, you can dlopen() all of the modules
>> and register the types, and then when the first object is
>> instantiated, that's when the type resolution will happen.
>
> If "device_info" is a symbol in basedevice.so and mymodule.so has a
> reference to "device_info", wont dlopen("mymodule.so") automatically
> bring in basedevice.so?
>
> If not, then it seems like things would get sticky anyway - if the
> underlying struct in mymodule.so is defined as:
>
> typedef struct MyDevice
> {
> DeviceState parent;
>
> int reg0, reg1, reg2;
> } MyDevice;
>
> it would seem likely that mymodule.so would have assorted references
> to basedevice.so for calls on mydev.parent.
Yes, thinking about it, I think you're correct that .parent could refer to some
sort of type handle.
But I think it's a bit nicer to have a string identify the parent type than an
extern struct. I guess it's more a matter of taste than anything else :-)
Regards,
Anthony Liguori
> I think maybe I'm not understanding the use case.
>
> Cheers,
> -Kevin
>
next prev parent reply other threads:[~2011-12-22 19:57 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-20 16:51 [Qemu-devel] [PATCH 00/27] qom: add QEMU Object Model type hierarchy to qdev Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 01/27] qom: add the base Object class Anthony Liguori
2011-12-21 13:35 ` Paolo Bonzini
2011-12-21 14:35 ` Anthony Liguori
2011-12-21 15:28 ` Paolo Bonzini
2011-12-22 17:25 ` Kevin O'Connor
2011-12-22 17:41 ` Anthony Liguori
2011-12-22 18:00 ` Kevin O'Connor
2011-12-22 19:57 ` Anthony Liguori [this message]
2012-01-02 23:01 ` Andreas Färber
2012-01-03 0:56 ` Anthony Liguori
2011-12-22 20:25 ` Paolo Bonzini
2012-01-02 17:59 ` Paolo Bonzini
2012-01-03 1:18 ` Anthony Liguori
2012-01-03 8:57 ` Paolo Bonzini
2011-12-20 16:51 ` [Qemu-devel] [PATCH 02/27] qdev: integrate with QEMU Object Model Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 03/27] qdev: move qdev->info to class Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 04/27] qdev: don't access name through info Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 05/27] qdev: use a wrapper to access reset and promote reset to a class method Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 06/27] pci: check for an initialized QOM object instead of looking for an info link Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 07/27] qdev: add a interface to register subclasses Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 08/27] qdev: add class_init to DeviceInfo Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 09/27] qdev: prepare source tree for code conversion Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 10/27] not-for-upstream: disable non-qdev pci devices Anthony Liguori
2012-01-02 22:55 ` Andreas Färber
2012-01-03 0:55 ` Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 11/27] isa: convert to QEMU Object Model Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 12/27] usb: " Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 13/27] ccid: " Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 14/27] ssi: " Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 15/27] i2c: rename i2c_slave -> I2CSlave Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 16/27] i2c: smbus: convert to QEMU Object Model Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 17/27] hda-codec: " Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 18/27] ide: " Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 19/27] scsi: " Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 20/27] not-for-upstream: spapr: break default console Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 21/27] spapr: convert to QEMU Object Model Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 22/27] not-for-upstream: virtio-serial: stub out a strange hack Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 23/27] virtio-serial: convert to QEMU Object Model Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 24/27] grackle: remove broken pci device Anthony Liguori
2012-01-02 22:41 ` Andreas Färber
2012-01-03 0:53 ` Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 25/27] unin_pci: remove phantom qdev devices in unin_pci Anthony Liguori
2012-01-02 22:44 ` Andreas Färber
2011-12-20 16:51 ` [Qemu-devel] [PATCH 26/27] pci: convert to QEMU Object Model Anthony Liguori
2011-12-20 16:51 ` [Qemu-devel] [PATCH 27/27] sysbus: " Anthony Liguori
2011-12-20 16:55 ` [Qemu-devel] [PATCH 00/27] qom: add QEMU Object Model type hierarchy to qdev 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=4EF38BA0.1090706@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=aliguori@us.ibm.com \
--cc=armbru@redhat.com \
--cc=kevin@koconnor.net \
--cc=pbonzini@redhat.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).