From: Igor Mammedov <imammedo@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: "Marc-André Lureau" <marcandre.lureau@gmail.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Cornelia Huck" <cohuck@redhat.com>,
"David Hildenbrand" <david@redhat.com>,
QEMU <qemu-devel@nongnu.org>,
"Christian Borntraeger" <borntraeger@de.ibm.com>,
"Qemu-s390x list" <qemu-s390x@nongnu.org>,
"open list:ARM" <qemu-arm@nongnu.org>,
"open list:sPAPR pseries" <qemu-ppc@nongnu.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Richard Henderson" <rth@twiddle.net>,
"David Gibson" <david@gibson.dropbear.id.au>
Subject: Re: [Qemu-devel] [PATCH for-3.2 v4 16/28] hw: apply machine compat properties without touching globals
Date: Tue, 4 Dec 2018 14:17:24 +0100 [thread overview]
Message-ID: <20181204141724.5f06bd1b@redhat.com> (raw)
In-Reply-To: <20181130114142.GV18284@habkost.net>
On Fri, 30 Nov 2018 09:41:42 -0200
Eduardo Habkost <ehabkost@redhat.com> wrote:
> On Fri, Nov 30, 2018 at 11:55:26AM +0100, Igor Mammedov wrote:
> > On Fri, 30 Nov 2018 01:36:03 +0400
> > Marc-André Lureau <marcandre.lureau@gmail.com> wrote:
> >
> > > Hi
> > >
> > > On Thu, Nov 29, 2018 at 9:51 PM Eduardo Habkost <ehabkost@redhat.com> wrote:
> > > >
> > > > On Thu, Nov 29, 2018 at 02:32:18PM +0400, Marc-André Lureau wrote:
> > > > > Hi
> > > > > On Wed, Nov 28, 2018 at 9:53 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > > > > >
> > > > > > On Tue, 27 Nov 2018 11:35:27 -0200
> > > > > > Eduardo Habkost <ehabkost@redhat.com> wrote:
> > > > > >
> > > > > > > On Tue, Nov 27, 2018 at 05:10:05PM +0400, Marc-André Lureau wrote:
> > > > > > > > On Tue, Nov 27, 2018 at 4:57 PM Eduardo Habkost <ehabkost@redhat.com> wrote:
> > > > > > > > >
> > > > > > > > > On Tue, Nov 27, 2018 at 01:27:49PM +0400, Marc-André Lureau wrote:
> > > > > > > > > > Similarly to accel properties, move compat properties out of globals
> > > > > > > > > > registration, and apply the machine compat properties during
> > > > > > > > > > device_post_init().
> > > > > > > > > >
> > > > > > > > > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > > > > > > > [...]
> > > > > > > > > > diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> > > > > > > > > > index 7066d28271..3b31b2c025 100644
> > > > > > > > > > --- a/hw/core/qdev.c
> > > > > > > > > > +++ b/hw/core/qdev.c
> > > > > > > > > > @@ -971,17 +971,26 @@ static void device_initfn(Object *obj)
> > > > > > > > > > }
> > > > > > > > > >
> > > > > > > > > > static const GPtrArray *ac_compat_props;
> > > > > > > > > > +static const GPtrArray *mc_compat_props;
> > > > > > why you didn't use just 'compat_props' for both?
> > > > > > (it would be cleaner have single registry for compat
> > > > > > properties, and the place that takes care of registration
> > > > > > will take care of necessary ordering)
> > > > >
> > > > > There are two arrays, one from the accelerator class, the other from
> > > > > the machine class. We can't make it a singleton (all compats props for
> > > > > the various machines would be mixed).
> > > > >
> > > > > We could create a third array that would be the set of both, but that
> > > > > would require more copy/allocation.
> > > >
> > > > I am failing to see the advantage of replacing the `global_props`
> > > > static variable from qdev-properties.c with a collection of
> > > > separate static variables scattered around the code. I thought
> > > > the main point of the changes was to reduce the amount of
> > > > duplicate data stored in static variables.
> > Main point was to use compats for backends then on top of that
> > we added split global from compat properties goal.
> >
> > > > I was expecting something like this:
> > > >
> > > > accel.c:
> > > >
> > > > void accel_apply_compat_props(AccelState *accel, Object *obj)
> > > > {
> > > > object_apply_global_props(obj, ACCEL_GET_CLASS(accel)->compat_props, &error_abort);
> > > > }
> > > >
> > > > machine.c:
> > > >
> > > > /* Apply compat properties and global properties to an object */
> > > > void machine_apply_compat_props(MachineState *ms, Object *obj)
> > > > {
> > > > accel_apply_compat_props(ms->accel, obj);
> > > > object_apply_global_props(obj, MACHINE_GET_CLASS(ms)->compat_props, &error_abort);
> > > > }
> > > >
> > > > compat-props.c:
> > > >
> > > > static void object_apply_compat_props(Object *obj)
> > > > {
> > > > MachineState *machine = MACHINE(qdev_get_machine());
> > > > machine_apply_compat_props(machine, obj);
> > > > }
> > > >
> > > > qdev.c:
> > > >
> > > > static void device_post_init(Object *obj)
> > > > {
> > > > object_apply_compat_props(obj);
> > > > apply_user_provided_globals(obj);
> > > > }
> > > >
> > > > object_interface.c:
> > > >
> > > > void user_creatable_complete(Object *obj, Error **errp)
> > > > {
> > > > object_apply_compat_props(obj);
> > > > ...
> > > > ucc->complete(...)
> > > > }
> > > >
> > >
> > > I like that solution too (which you also proposed in the other
> > > thread). But we have to decide whether it's acceptable to reference
> > > MachineState, or if the compat properties should be registered.
> > I dislike pulling in machine into basic object code and
> > I think a separate compats would be cleaner interface without
> > layer violation. But to unstuck, lets go with qdev_get_machine()
> > for now.
>
> Which basic object code? The only reference to machine above is
> at compat-props.c. I don't see any layering violation here.
I see compat properties as just a set of arbitrary properties
that's applied to objects depending on configuration.
Which currently includes machine version and accel type
but in no way inherently tied to them.
As for layering violation, we do it in device model cases
as it's machine related (ugly 'acceptable' but helps to cut corners)
and with new interface it will be used wit backends which are not
machine related at all.
Doing like you suggest would make it usable with current machine
initialization order (with some fixes) but if one would consider
a bit earlier time (preconfig time) and creating machine step by
step from there it might be less usable (as it needs machine instance,
it still would be possible but probably more tricky (pure speculation)).
So I'd vote for abstracted from machine compat props that could be
called from any object that implements interface and explicit
compats registration (like we do now) and explicit registration failure
if compats happend to be applied to any object. But in case of this
series I'm fine with any approach just to get compat properties work
with backends for now.
next prev parent reply other threads:[~2018-12-04 13:17 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-27 9:27 [Qemu-devel] [PATCH for-3.2 v4 00/28] Generalize machine compatibility properties Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 01/28] target/xtensa: gdbstub fix register counting Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 02/28] target/xtensa: drop num_[core_]regs from dc232b/dc233c configs Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 03/28] target/xtensa: xtfpga: provide default memory sizes Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 04/28] MAINTAINERS: add missing xtensa patterns Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 05/28] 9p: fix QEMU crash when renaming files Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 06/28] MAINTAINERS: Assign some more files in the hw/arm/ directory Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 07/28] MAINTAINERS: Add an ARM SMMU section Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 08/28] net: cadence_gem: Remove incorrect assert() Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 09/28] tests: qdev_prop_check_globals() doesn't return "all_used" Marc-André Lureau
2018-11-27 13:40 ` Eduardo Habkost
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 10/28] qom: make interface types abstract Marc-André Lureau
2018-11-27 13:41 ` Eduardo Habkost
2018-11-27 13:55 ` Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 11/28] qom: make user_creatable_complete() specific to UserCreatable Marc-André Lureau
2018-11-27 13:45 ` Eduardo Habkost
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 12/28] accel: register global_props like machine globals Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 13/28] qdev: move qdev_prop_register_global_list() to tests Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 14/28] qom: remove unimplemented class_finalize Marc-André Lureau
2018-11-27 12:52 ` Eduardo Habkost
2018-11-28 17:44 ` Igor Mammedov
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 15/28] hw: apply accel compat properties without touching globals Marc-André Lureau
2018-11-27 19:40 ` Eduardo Habkost
2018-11-27 20:02 ` Marc-André Lureau
2018-11-29 16:02 ` Eduardo Habkost
2018-11-28 17:49 ` Igor Mammedov
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 16/28] hw: apply machine " Marc-André Lureau
2018-11-27 12:56 ` Eduardo Habkost
2018-11-27 13:10 ` Marc-André Lureau
2018-11-27 13:35 ` Eduardo Habkost
2018-11-28 17:40 ` Igor Mammedov
2018-11-28 17:53 ` Eduardo Habkost
2018-11-29 10:32 ` Marc-André Lureau
2018-11-29 17:50 ` Eduardo Habkost
2018-11-29 21:36 ` Marc-André Lureau
2018-11-30 10:55 ` Igor Mammedov
2018-11-30 11:41 ` Eduardo Habkost
2018-12-04 13:17 ` Igor Mammedov [this message]
2018-12-04 18:43 ` Eduardo Habkost
2018-11-30 11:37 ` Igor Mammedov
2018-11-29 16:09 ` Eduardo Habkost
2018-11-29 21:32 ` Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 17/28] hw: remove SET_MACHINE_COMPAT Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 18/28] qdev: all globals are now user-provided Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 19/28] qdev-props: convert global_props to GPtrArray Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 20/28] qdev-props: remove errp from GlobalProperty Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 21/28] qdev-props: call object_apply_global_props() Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 22/28] qom: teach interfaces to implement post-init Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 23/28] qom: add object_class_get_class_data() Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 24/28] arm: replace instance_post_init() Marc-André Lureau
2018-11-30 11:48 ` Igor Mammedov
2018-12-01 20:55 ` Marc-André Lureau
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 25/28] machine: add compat-props interface Marc-André Lureau
2018-11-29 17:49 ` Eduardo Habkost
2018-11-30 12:34 ` Igor Mammedov
2018-11-30 12:57 ` Eduardo Habkost
2018-11-30 12:39 ` Igor Mammedov
2018-11-27 9:27 ` [Qemu-devel] [PATCH for-3.2 v4 26/28] hw/i386: add pc-i440fx-3.2 & pc-q35-3.2 Marc-André Lureau
2018-11-27 13:01 ` Eduardo Habkost
2018-11-27 9:28 ` [Qemu-devel] [PATCH for-3.2 v4 27/28] hw/arm/virt: add virt-3.2 machine type Marc-André Lureau
2018-11-27 9:28 ` [Qemu-devel] [PATCH for-3.2 v4 28/28] hostmem: use object id for memory region name with >= 3.1 Marc-André Lureau
2018-11-27 9:53 ` [Qemu-devel] [PATCH for-3.2 v4 00/28] Generalize machine compatibility properties Greg Kurz
2018-11-27 9:58 ` Marc-André Lureau
2018-11-29 1:35 ` no-reply
2018-11-29 1:45 ` no-reply
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=20181204141724.5f06bd1b@redhat.com \
--to=imammedo@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=david@redhat.com \
--cc=ehabkost@redhat.com \
--cc=marcandre.lureau@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=rth@twiddle.net \
/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).