qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-devel@nongnu.org, afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH 4/5] target-i386: set custom features/properties without intermediate x86_def_t
Date: Fri, 18 Jan 2013 15:49:57 +0100	[thread overview]
Message-ID: <20130118154957.12f5d909@nial.usersys.redhat.com> (raw)
In-Reply-To: <20130117174445.GP10683@otherpad.lan.raisama.net>

On Thu, 17 Jan 2013 15:44:45 -0200
Eduardo Habkost <ehabkost@redhat.com> wrote:

> On Thu, Jan 17, 2013 at 04:16:33PM +0100, Igor Mammedov wrote:
> > Move custom features parsing after built-in cpu_model defaults are set
> > and set custom features directly on CPU instance. That allows to make
> > clear distinction between built-in cpu model defaults that eventually
> > should go into clas_init() and extra property setting which is done
> > after defaults are set on CPU instance.
> > 
> > Impl. details:
> >  - features that are already properties, are converted to normalized
> >    (name, values) list. And after featurestr has been parsed,
> >    properties from the list are applied directly to CPU instance.
> >    * For now it provides uniform handling of properties with single
> >      object_property_parse() property setter.
> >    * And after current features/properties are converted into static
> >      properties, it will take a trivial patch to switch to global
> > properties. Which will allow to:
> >      * get CPU instance initialized with all parameters passed on -cpu ...
> >        cmd. line from object_new() call.
> >      * call cpu_model/featurestr parsing only once before CPUs are created
> >      * open a road for removing CPUxxxState.cpu_model_str field, when
> > other CPUs are similarly converted to subclasses and static properties.
> >  - re-factor error handling, to use Error instead of fprintf()s, since
> >    it is anyway passed in for property setter.
> > 
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> >  target-i386/cpu.c |  144
> > ++++++++++++++++++++++++++++------------------------- 1 files changed, 77
> > insertions(+), 67 deletions(-)
> > 
> > diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> > index 5cd7917..50e10b1 100644
> > --- a/target-i386/cpu.c
> > +++ b/target-i386/cpu.c
> > @@ -1302,9 +1302,24 @@ static int cpu_x86_find_by_name(x86_def_t
> > *x86_cpu_def, const char *name) return 0;
> >  }
> >  
> > +typedef struct NameValuePair {
> > +    char *name;
> > +    char *value;
> > +    QTAILQ_ENTRY(NameValuePair) next;
> > +} NameValuePair;
> > +typedef QTAILQ_HEAD(NVList, NameValuePair) NVList;
> > +
> > +static void x86_cpu_add_nv_pair(NVList *list, const char *name,
> > +                                const char *value) {
> > +    NameValuePair *p = g_malloc0(sizeof(*p));
> > +    p->name = g_strdup(name);
> > +    p->value = g_strdup(value);
> > +    QTAILQ_INSERT_TAIL(list, p, next);
> > +}
> 
> I am not sure I like this extra complexity. We don't need it if we
> simply set/register the properties directly.
> 
> I have a different proposal:
> 
> 1) By now, use:
>       object_property_parse(OBJECT(cpu), P, V, errp)
>    in the places you are using:
>       x86_cpu_add_nv_pair(&props, P, V)
>    below.
> 
> 2) The day we move to global properties, we just need to mechanically
>    replace the occurrences of:
>      object_property_parse(OBJECT(cpu), P, V, errp)
>    with:
>      qdev_prop_register_global("X86CPU", P, V)
> 
> What do you think?
Agreed, changes, when switching to global properties, will be mechanical
and not in many places, so it makes sense to drop list approach.
I'll resubmit series.

> 
> 
> > +        object_property_parse(OBJECT(cpu), p->value, p->name, errp);
> > +
> >  /* Parse "+feature,-feature,feature=foo" CPU feature string
> >   */
[...]

  reply	other threads:[~2013-01-18 14:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-17 15:16 [Qemu-devel] [PATCH qom-cpu 0/5] x86 CPU cleanup, part 4 Igor Mammedov
2013-01-17 15:16 ` [Qemu-devel] [PATCH 1/5] target-i386: print deprecated warning if xlevel < 0x80000000 Igor Mammedov
2013-01-21  8:39   ` Andreas Färber
2013-01-21 12:14     ` Igor Mammedov
2013-01-17 15:16 ` [Qemu-devel] [PATCH 2/5] target-i386: replace uint32_t vendor fields by vendor string in x86_def_t Igor Mammedov
2013-01-17 15:29   ` Eduardo Habkost
2013-01-18  7:12   ` li guang
2013-01-18 13:40     ` Igor Mammedov
2013-01-21  3:16       ` li guang
2013-01-21  8:18   ` Andreas Färber
2013-01-17 15:16 ` [Qemu-devel] [PATCH 3/5] target-i386: remove vendor_override field from CPUX86State Igor Mammedov
2013-01-17 15:30   ` Eduardo Habkost
2013-01-17 15:16 ` [Qemu-devel] [PATCH 4/5] target-i386: set custom features/properties without intermediate x86_def_t Igor Mammedov
2013-01-17 17:44   ` Eduardo Habkost
2013-01-18 14:49     ` Igor Mammedov [this message]
2013-01-17 15:16 ` [Qemu-devel] [PATCH 5/5] target-i386: remove setting tsc-frequency from x86_def_t Igor Mammedov

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=20130118154957.12f5d909@nial.usersys.redhat.com \
    --to=imammedo@redhat.com \
    --cc=afaerber@suse.de \
    --cc=ehabkost@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).