From: "Andreas Färber" <afaerber@suse.de>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>,
qemu-devel@nongnu.org, Anthony Liguori <anthony@codemonkey.ws>,
Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 11/14] piix: APIs for pc guest info
Date: Sun, 28 Jul 2013 13:08:13 +0200 [thread overview]
Message-ID: <51F4FB9D.2080401@suse.de> (raw)
In-Reply-To: <51F4F2FB.5010800@suse.de>
Am 28.07.2013 12:31, schrieb Andreas Färber:
> Am 28.07.2013 12:14, schrieb Michael S. Tsirkin:
>> On Sun, Jul 28, 2013 at 11:38:17AM +0200, Andreas Färber wrote:
>>> Am 28.07.2013 09:30, schrieb Michael S. Tsirkin:
>>>> On Sun, Jul 28, 2013 at 02:12:49AM +0200, Andreas Färber wrote:
>>>>> Am 25.07.2013 11:32, schrieb Michael S. Tsirkin:
>>>>>> diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
>>>>>> index 3908860..daefdfb 100644
>>>>>> --- a/hw/pci-host/piix.c
>>>>>> +++ b/hw/pci-host/piix.c
>>>>>> @@ -349,6 +349,14 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
>>>>>> return b;
>>>>>> }
>>>>>>
>>>>>> +PCIBus *find_i440fx(void)
>>>>>> +{
>>>>>> + PCIHostState *s = OBJECT_CHECK(PCIHostState,
>>>>>> + object_resolve_path("/machine/i440fx", NULL),
>>>>>> + TYPE_PCI_HOST_BRIDGE);
>>>>>
>>>>> Open-coded OBJECT_CHECK() - should use existing PCI_HOST_BRIDGE(...).
>>>>>
>>>>>> + return s ? s->bus : NULL;
>>>>>> +}
>>>>>
>>>>> Is this function really necessary? /machine/i440fx/pci.0 is a trivial
>>>>> addition to the path that's already being used here. You can do:
>>>>> PCIBus *bus = PCI_BUS(object_resolve_path("/machine/i440fx/pci.0"));
>>>>> where you actually need to access it.
>>>>
>>>>
>>>> I don't mind but I would like to avoid callers hard-coding
>>>> paths, in this case "i440fx".
>>>> Why the aversion to functions?
>>>
>>> Simply because QMP cannot call functions. It has to work with qom-list
>>> and qom-get, so this is a test case showing what is missing and can IMO
>>> easily be addressed for both parties.
>>
>> Fine but if the function calls QOM things internally
>> then where's the problem?
>
> The grief with object_path_resolve_type() is that it's a "hack" Paolo
> has added for his convenience (in audio code?) that QMP cannot use, so
> we need name-based paths to be available.
Add to that, the way I see QOM devices (as opposed to qdev or pre-qdev
devices) is that they are instantiated from the outside - a different
source file or command line or config file - via QOM APIs, and they
allow other source files to interact with them via mydev_foo(MyDev *d,
...) APIs that operate on an instance.
Having functions to create devices often hints at legacy code from
pre-qdev times (we had such a discussion with Alex when I tried to
qdev'ify the prep_pci device), indicating that either something is not
yet accessible via qdev/QOM APIs (e.g., IRQs) or that the device is not
yet implementing composition properly (e.g., creating a bus after the
bridge device rather than in the bridge, or a PCIDevice after the PHB
rather than by the PHB).
Having functions in the device's file to obtain a random instance of
that device in the form MyDev *mydev_get(void) is what I dislike here.
My personal preference (which you may ignore if others disagree) would
be to have accessors, where unavoidable, in the form:
foo mydev_get_bar(MyDev *s)
{
return s->baz;
}
which we can then later easily convert into dynamic property getters,
and it would hopefully spare us new per-device ...Info structs by
obtaining the info where and when you need it.
I admit it's a bit of boilerplate to code, but I've seen at most 4 cases
per device where this would apply and I'm saying this with our
longer-term QOM goals in mind.
I'm skeptical towards Igor's suggestion of adding Last Minute 1.6 qdev
properties (as opposed to a composition property, you force me to become
very explicit in my explanations...) as that would bring ABI stability
rules onto us.
Andreas
> And to clarify, I have been talking about two different time frames:
> Small adjustments that you can make for 1.6 (e.g., casts, q35 property,
> different QOM function/callsite used; if Anthony is okay with taking
> ACPI at this late point) and post-1.6 cleanups to replace interim
> constructs that involve refactorings outside your control (e.g.,
> MemoryRegion QOM'ification, adding properties to random devices).
>
> Andreas
>
>>> The suggested cast to PCI_BUS() lets you use regular qdev functions btw
>>> as a shortcut, QMP users would need to iterate children of that node.
>>>
>>> The suggested "pci.0" is considered stable for -device ...,bus=pci.0
>>> according to review feedback the Xen people have received for libxl.
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
next prev parent reply other threads:[~2013-07-28 11:08 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-24 16:01 [Qemu-devel] [PATCH v3 00/14] qemu: generate acpi tables for the guest Michael S. Tsirkin
2013-07-24 16:01 ` [Qemu-devel] [PATCH v3 01/14] hw/i386/pc.c: move IO_APIC_DEFAULT_ADDRESS to include/hw/i386/apic.h Michael S. Tsirkin
2013-07-25 12:05 ` Gerd Hoffmann
2013-07-28 0:44 ` Andreas Färber
2013-07-24 16:01 ` [Qemu-devel] [PATCH v3 02/14] i386: add ACPI table files from seabios Michael S. Tsirkin
2013-07-24 16:01 ` [Qemu-devel] [PATCH v3 03/14] acpi: add rules to compile ASL source Michael S. Tsirkin
2013-07-25 12:09 ` Gerd Hoffmann
2013-07-24 16:01 ` [Qemu-devel] [PATCH v3 04/14] acpi: pre-compiled ASL files Michael S. Tsirkin
2013-07-24 16:01 ` [Qemu-devel] [PATCH v3 05/14] loader: use file path size from fw_cfg.h Michael S. Tsirkin
2013-07-24 23:42 ` Andreas Färber
2013-07-25 12:10 ` Gerd Hoffmann
2013-07-24 16:01 ` [Qemu-devel] [PATCH v3 06/14] i386: add bios linker/loader Michael S. Tsirkin
2013-07-25 12:11 ` Gerd Hoffmann
2013-07-26 9:42 ` Gerd Hoffmann
2013-07-28 8:08 ` Michael S. Tsirkin
2013-07-24 16:01 ` [Qemu-devel] [PATCH v3 07/14] loader: support for unmapped ROM blobs Michael S. Tsirkin
2013-07-25 12:14 ` Gerd Hoffmann
2013-07-25 12:28 ` Michael S. Tsirkin
2013-07-25 12:43 ` Gerd Hoffmann
2013-07-25 13:03 ` Michael S. Tsirkin
2013-07-25 19:57 ` Michael S. Tsirkin
2013-07-24 16:02 ` [Qemu-devel] [PATCH v3 08/14] loader: allow adding ROMs in done callbacks Michael S. Tsirkin
2013-07-25 12:15 ` Gerd Hoffmann
2013-07-24 16:02 ` [Qemu-devel] [PATCH v3 09/14] i386: define pc guest info Michael S. Tsirkin
2013-07-25 12:31 ` Gerd Hoffmann
2013-07-28 0:41 ` Andreas Färber
2013-07-28 7:36 ` Michael S. Tsirkin
2013-07-24 16:02 ` [Qemu-devel] [PATCH v3 10/14] ich9: APIs for " Michael S. Tsirkin
2013-07-25 12:33 ` Gerd Hoffmann
2013-07-28 0:37 ` Andreas Färber
2013-07-28 7:35 ` Michael S. Tsirkin
2013-07-24 16:02 ` [Qemu-devel] [PATCH v3 11/14] piix: " Michael S. Tsirkin
2013-07-25 9:32 ` Michael S. Tsirkin
2013-07-28 0:12 ` Andreas Färber
2013-07-28 7:30 ` Michael S. Tsirkin
2013-07-28 9:38 ` Andreas Färber
2013-07-28 10:14 ` Michael S. Tsirkin
2013-07-28 10:31 ` Andreas Färber
2013-07-28 11:08 ` Andreas Färber [this message]
2013-07-28 12:19 ` Michael S. Tsirkin
2013-07-25 12:34 ` Gerd Hoffmann
2013-07-24 16:02 ` [Qemu-devel] [PATCH v3 12/14] pvpanic: add API to access io port Michael S. Tsirkin
2013-07-25 10:29 ` Gerd Hoffmann
2013-07-25 10:55 ` Michael S. Tsirkin
2013-07-25 10:58 ` Michael S. Tsirkin
2013-07-25 11:05 ` Gerd Hoffmann
2013-07-25 11:22 ` Michael S. Tsirkin
2013-07-25 12:03 ` Gerd Hoffmann
2013-07-25 12:23 ` Michael S. Tsirkin
2013-07-27 23:58 ` Andreas Färber
2013-07-24 16:02 ` [Qemu-devel] [PATCH v3 13/14] hpet: add API to find it Michael S. Tsirkin
2013-07-25 12:36 ` Gerd Hoffmann
2013-07-27 23:38 ` Andreas Färber
2013-07-24 16:02 ` [Qemu-devel] [PATCH v3 14/14] i386: ACPI table generation code from seabios Michael S. Tsirkin
2013-07-25 13:06 ` Gerd Hoffmann
2013-07-25 13:23 ` Michael S. Tsirkin
2013-07-25 14:58 ` Gerd Hoffmann
2013-07-25 15:14 ` Michael S. Tsirkin
2013-07-26 9:06 ` Gerd Hoffmann
2013-07-26 15:30 ` Gerd Hoffmann
2013-07-28 7:00 ` Michael S. Tsirkin
2013-07-25 15:50 ` [Qemu-devel] [PATCH v3 00/14] qemu: generate acpi tables for the guest Andreas Färber
2013-07-25 16:19 ` Michael S. Tsirkin
2013-07-26 12:19 ` Andreas Färber
2013-07-27 23:22 ` Andreas Färber
2013-09-11 9:57 ` Michael S. Tsirkin
2013-07-25 17:18 ` Michael S. Tsirkin
2013-07-26 12:25 ` Andreas Färber
2013-07-29 15:27 ` 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=51F4FB9D.2080401@suse.de \
--to=afaerber@suse.de \
--cc=anthony@codemonkey.ws \
--cc=aurelien@aurel32.net \
--cc=kraxel@redhat.com \
--cc=mst@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 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.