[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH for-3.2 v5 08/19] hw: apply machine compat prope
From: |
Eduardo Habkost |
Subject: |
Re: [Qemu-devel] [PATCH for-3.2 v5 08/19] hw: apply machine compat properties without touching globals |
Date: |
Tue, 11 Dec 2018 15:43:03 -0200 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
On Tue, Dec 11, 2018 at 04:52:29PM +0100, Igor Mammedov wrote:
> On Tue, 11 Dec 2018 18:30:32 +0400
> Marc-André Lureau <address@hidden> wrote:
>
> > Hi
> >
> > On Tue, Dec 11, 2018 at 6:24 PM Eduardo Habkost <address@hidden> wrote:
> > >
> > > I have specific questions about the approach we are using to
> > > eliminate the macros.
> > >
> > > My main goal when asking this to be moved to a separate patch is
> > > to not make this discussion block the register_global_properties() &
> > > device_post_init() changes (which look good to me).
> > >
> > >
> > > On Tue, Dec 04, 2018 at 06:20:12PM +0400, Marc-André Lureau wrote:
> > > [...]
> > > > -#define VIRT_COMPAT_3_0 \
> > > > +static GlobalProperty virt_compat_3_0[] = {
> > > > HW_COMPAT_3_0
> > > > +};
> > >
> > > What about moving the array inside virt_machine_3_0_options()?
> >
> > Sure
> >
> > >
> > > >
> > > > static void virt_3_0_instance_init(Object *obj)
> > > > {
> > > > @@ -1883,12 +1884,14 @@ static void virt_3_0_instance_init(Object *obj)
> > > > static void virt_machine_3_0_options(MachineClass *mc)
> > > > {
> > > > virt_machine_3_1_options(mc);
> > > > - SET_MACHINE_COMPAT(mc, VIRT_COMPAT_3_0);
> > > > + compat_props_add(mc->compat_props,
> > > > + virt_compat_3_0, G_N_ELEMENTS(virt_compat_3_0));
> > > > }
> > > > DEFINE_VIRT_MACHINE(3, 0)
> > >
> > > This is nice, because it's basically the same amount of
> > > boilerplate code, but I would find a NULL-terminated array much
> > > easier to use than having to use G_N_ELEMENTS().
> >
> > But easier to get wrong too. I prefer the explicit N arguments. (it
> > also gives some flexibility, since you can point to inner pointer +
> > size, although we don't care at this point)
> +1 to explicit array size,
> it also allows to drop terminating NULL entry in compat declarations
I don't mind using G_N_ELEMENTS if you really think it's better,
but I wonder if it will be an obstacle for making
compat_props_add(compat_props, hw_compat_3_0, ...)
work, because the size of hw_compat_3_0 won't be known by
compat.h or spapr.c.
--
Eduardo
- Re: [Qemu-devel] [PATCH for-3.2 v5 12/19] qdev-props: convert global_props to GPtrArray, (continued)
Re: [Qemu-devel] [PATCH for-3.2 v5 12/19] qdev-props: convert global_props to GPtrArray, Igor Mammedov, 2018/12/11
[Qemu-devel] [PATCH for-3.2 v5 08/19] hw: apply machine compat properties without touching globals, Marc-André Lureau, 2018/12/04
Re: [Qemu-devel] [PATCH for-3.2 v5 08/19] hw: apply machine compat properties without touching globals, Eduardo Habkost, 2018/12/11
[Qemu-devel] [PATCH for-3.2 v5 13/19] qdev-props: remove errp from GlobalProperty, Marc-André Lureau, 2018/12/04
[Qemu-devel] [PATCH for-3.2 v5 14/19] qdev-props: call object_apply_global_props(), Marc-André Lureau, 2018/12/04
Re: [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties, Marc-André Lureau, 2018/12/04
[Qemu-devel] [PATCH for-3.2 v5 15/19] qom: add object_class_get_class_data(), Marc-André Lureau, 2018/12/04
[Qemu-devel] [PATCH for-3.2 v5 17/19] hw/i386: add pc-i440fx-4.0 & pc-q35-4.0, Marc-André Lureau, 2018/12/04
[Qemu-devel] [PATCH for-3.2 v5 16/19] RFC: arm: replace instance_post_init(), Marc-André Lureau, 2018/12/04