Received: from eggs.gnu.org ([208.118.235.92]:52998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwDGe-0007x0-3S for qemu-devel@nongnu.org; Fri, 18 Jan 2013 09:50:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TwDGb-0005Ci-LQ for qemu-devel@nongnu.org; Fri, 18 Jan 2013 09:50:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58403) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwDGb-0005CC-DP for qemu-devel@nongnu.org; Fri, 18 Jan 2013 09:50:01 -0500 Date: Fri, 18 Jan 2013 15:49:57 +0100 From: Igor Mammedov Message-ID: <20130118154957.12f5d909@nial.usersys.redhat.com> In-Reply-To: <20130117174445.GP10683@otherpad.lan.raisama.net> References: <1358435794-8406-1-git-send-email-imammedo@redhat.com> <1358435794-8406-5-git-send-email-imammedo@redhat.com> <20130117174445.GP10683@otherpad.lan.raisama.net> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 4/5] target-i386: set custom features/properties without intermediate x86_def_t List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: qemu-devel@nongnu.org, afaerber@suse.de On Thu, 17 Jan 2013 15:44:45 -0200 Eduardo Habkost 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 > > --- > > 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 > > */ [...]