From: Emanuele <e.emanuelegiuseppe@gmail.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Laurent Vivier" <lvivier@redhat.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/7] tests/qgraph: pci-pc driver and interface nodes
Date: Wed, 18 Jul 2018 20:29:40 +0200 [thread overview]
Message-ID: <2d822611-d227-1e9e-bfb4-d119f78a0282@gmail.com> (raw)
In-Reply-To: <20180718142927.GN21825@stefanha-x1.localdomain>
On 07/18/2018 04:29 PM, Stefan Hajnoczi wrote:
> On Wed, Jul 11, 2018 at 05:18:03PM +0200, Paolo Bonzini wrote:
>> On 11/07/2018 16:49, Stefan Hajnoczi wrote:
>>> On Mon, Jul 09, 2018 at 11:11:31AM +0200, Emanuele Giuseppe Esposito wrote:
>>>> -QPCIBus *qpci_init_pc(QTestState *qts, QGuestAllocator *alloc)
>>>> +static void *qpci_get_driver(void *obj, const char *interface)
>>>> {
>>>> - QPCIBusPC *ret = g_new0(QPCIBusPC, 1);
>>>> + QPCIBusPC *qpci = obj;
>>>> + if (!g_strcmp0(interface, "pci-bus")) {
>>>> + return &qpci->bus;
>>>> + }
>>>> + printf("%s not present in pci-bus-pc", interface);
>>>> + abort();
>>>> +}
>>> At this point I wonder if it makes sense to use the QEMU Object Model
>>> (QOM), which has interfaces and inheritance. qgraph duplicates part of
>>> the object model.
>> Replying for Emanuele on this point since we didn't really go through
>> QOM yet; I'll let him answer the comments that are more related to the code.
>>
>> QOM is much heavier weight than qgraph, and adds a lot more boilerplate:
>>
>> - QOM properties interact with QAPI and bring in a lot of baggage;
>> qgraph would only use "child" properties to implement containment.
>>
>> - QOM objects are long-lived, qgraph objects only last for the duration
>> of a single test. qgraph doesn't need reference counting or complex
>> two-phase initialization like "realize" or "user_complete"
>>
>> - QOM's hierarchy is shallow, but qgraph doesn't really need _any_
>> hierarchy. Because it focuses on interface rather than hierarchy,
>> everything can be expressed simply through structs contained into one
>> another.
>>
>> Consider that qgraph is 1/4th the size of QOM, and a large part of it is
>> the graph data structure that (as you said) would not be provided by QOM.
>>
>> There are two things where using QOM would save a little bit of
>> duplicated concepts, namely the get_driver (get interface, what you
>> quote above) and get_device (get contained object) callbacks. However,
>> it wouldn't simplify the code at all, because it would require the
>> introduction of separate instance and class structs. We didn't want to
>> add all too much boilerplate for people that want to write qtest, as you
>> pointed out in the review of patch 4.
> Yes, I think these are good points. QOM does involve a lot of
> boilerplate for defining objects.
>
>>>> +void qpci_set_pc(QPCIBusPC *ret, QTestState *qts, QGuestAllocator *alloc)
>>> It's not clear to me what the purpose of this function is - at least the
>>> name is a bit cryptic since it seems more like an initialization
>>> function than 'setting pc' on QPCIBusPC. How about inlining this in
>>> qpci_init_pc() instead of keeping a separate function?
>> I agree about the naming. Perhaps we can rename the existing
>> qpci_init_pc to qpci_pc_new, and qpci_set_pc to qpci_pc_init.
>>
>> Would you prefer if the split was done in the patch that introduces the
>> user for qpci_set_pc (patch 5)? We did it here because this patch
>> prepares qpci-pc
> Either way is fine. I suggested inlining mainly because it avoids the
> need to pick a good name :).
I had to put this patch here because it also introduces
qpci_device_init, used by sdhci (patch 3).
For the next version I plan to have a patch X where I rename all
occurrences of qpci_init_pc in qpci_pc_new, and a patch X+1 that
introduces qpci_init_pc (was qpci_set_pc) and the other changes.
Should I only introduce qpci_device_init in patch 3 and the remaining
things in patch 5?
I think the general problem here is that in some patches I create
functions that are planned to only be used only in next patches (of the
current series).
> Stefan
next prev parent reply other threads:[~2018-07-18 18:29 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-09 9:11 [Qemu-devel] [PATCH 0/7] Qtest driver framework Emanuele Giuseppe Esposito
2018-07-09 9:11 ` [Qemu-devel] [PATCH 1/7] tests: qgraph API for the qtest " Emanuele Giuseppe Esposito
2018-07-11 14:28 ` Stefan Hajnoczi
2018-07-11 14:58 ` Paolo Bonzini
2018-07-18 14:23 ` Stefan Hajnoczi
2018-07-18 18:05 ` Emanuele
2018-07-18 19:28 ` Paolo Bonzini
2018-07-18 21:13 ` Emanuele
2018-07-27 12:54 ` Stefan Hajnoczi
2018-07-09 9:11 ` [Qemu-devel] [PATCH 2/7] tests/qgraph: pci-pc driver and interface nodes Emanuele Giuseppe Esposito
2018-07-11 14:49 ` Stefan Hajnoczi
2018-07-11 15:18 ` Paolo Bonzini
2018-07-18 14:29 ` Stefan Hajnoczi
2018-07-18 18:29 ` Emanuele [this message]
2018-07-18 19:33 ` Paolo Bonzini
2018-07-18 20:49 ` Emanuele
2018-07-11 17:46 ` Emanuele
2018-07-18 15:02 ` Stefan Hajnoczi
2018-07-18 19:38 ` Paolo Bonzini
2018-07-11 20:05 ` Philippe Mathieu-Daudé
2018-07-09 9:11 ` [Qemu-devel] [PATCH 3/7] tests/qgraph: sdhci " Emanuele Giuseppe Esposito
2018-07-11 20:13 ` Philippe Mathieu-Daudé
2018-07-11 20:44 ` Emanuele
2018-07-09 9:11 ` [Qemu-devel] [PATCH 4/7] tests/qgraph: arm/raspi2 machine node Emanuele Giuseppe Esposito
2018-07-11 14:59 ` Stefan Hajnoczi
2018-07-11 15:30 ` Paolo Bonzini
2018-07-11 20:19 ` Philippe Mathieu-Daudé
2018-07-09 9:11 ` [Qemu-devel] [PATCH 5/7] tests/qgraph: x86_64/pc " Emanuele Giuseppe Esposito
2018-07-09 9:11 ` [Qemu-devel] [PATCH 6/7] tests/qgraph: gtest integration Emanuele Giuseppe Esposito
2018-07-11 15:02 ` Stefan Hajnoczi
2018-07-09 9:11 ` [Qemu-devel] [PATCH 7/7] tests/qgraph: sdhci test node Emanuele Giuseppe Esposito
2018-07-11 15:15 ` Stefan Hajnoczi
2018-07-11 17:52 ` Emanuele
2018-07-12 12:07 ` Paolo Bonzini
2018-07-11 14:00 ` [Qemu-devel] [PATCH 0/7] Qtest driver framework Stefan Hajnoczi
2018-07-11 14:17 ` Emanuele
2018-07-11 15:27 ` Stefan Hajnoczi
2018-07-18 17:14 ` Markus Armbruster
2018-07-18 19:35 ` Paolo Bonzini
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=2d822611-d227-1e9e-bfb4-d119f78a0282@gmail.com \
--to=e.emanuelegiuseppe@gmail.com \
--cc=f4bug@amsat.org \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.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 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).