From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVlNx-0003Hb-1E for qemu-devel@nongnu.org; Fri, 26 Apr 2013 12:20:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVlNv-0004y4-CA for qemu-devel@nongnu.org; Fri, 26 Apr 2013 12:20:32 -0400 Received: from cantor2.suse.de ([195.135.220.15]:35046 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVlNu-0004xg-VH for qemu-devel@nongnu.org; Fri, 26 Apr 2013 12:20:31 -0400 Message-ID: <517AA94D.5080104@suse.de> Date: Fri, 26 Apr 2013 18:20:29 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1361754189-29809-1-git-send-email-imammedo@redhat.com> <1361754189-29809-3-git-send-email-imammedo@redhat.com> In-Reply-To: <1361754189-29809-3-git-send-email-imammedo@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 02/10] target-i386: cpu: convert existing dynamic properties into static properties List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: qemu-devel@nongnu.org, ehabkost@redhat.com Am 25.02.2013 02:03, schrieb Igor Mammedov: > Following properties are converted: > * vendor > * xlevel > * custom setter/getter replaced by qdev's DEFINE_PROP_UINT32 > * level > * custom setter/getter replaced by qdev's DEFINE_PROP_UINT32 > * tsc-frequency > * stepping > * model > * family > * model-id > * check "if (model_id =3D=3D NULL)" looks unnecessary now, sinc= e all > builtin model-ids are not NULL and user shouldn't be able to se= t > it NULL (cpumodel string parsing code takes care of it, if feat= ure > is specified as "model-id=3D" on command line, its parsing will > result in an empty string as value). >=20 > Common changes to all properties: > * string properties: changed function signature to conform to form = used in > qdev-properties.c >=20 > * extra change is addition of feat2prop() helper to deal with propertie= s > naming using '-' instead of '_'. Used in this patch for 'model_id' na= me > conversion and converting along the way 'hv-spinlocks', but will be > reused in following patches for "hv_*" and +-foo conversions as well. >=20 > Signed-off-by: Igor Mammedov > v2: > - removed s/error_set/error_setg/;s/QERR*/with similar message/ > - made PropertyInfo static > - Left setters/getters atwher they have been, only signature change > + usin visitors where needed > - use g_malloc0() instead of g_malloc() in x86_cpuid_get_model_id() > --- > target-i386/cpu.c | 174 ++++++++++++++++++++++++++++++++-------------= -------- > 1 files changed, 105 insertions(+), 69 deletions(-) >=20 > diff --git a/target-i386/cpu.c b/target-i386/cpu.c > index dfcf86e..5626931 100644 > --- a/target-i386/cpu.c > +++ b/target-i386/cpu.c [...] > @@ -1297,6 +1345,17 @@ static int cpu_x86_find_by_name(x86_def_t *x86_c= pu_def, const char *name) > return -1; > } > =20 > +/* It converts all '_' in a feature string option name to '-', to make > + * feature name to conform property naming rule which uses '-' instead= of '_' > + */ > +static inline void feat2prop(char *s) > +{ > + char *delimiter =3D strchr(s, '=3D'); > + while ((s =3D strchr(s, '_')) && ((delimiter =3D=3D NULL) || (s < = delimiter))) { > + *s =3D '-'; > + } > +} > + > /* Parse "+feature,-feature,feature=3Dfoo" CPU feature string > */ > static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Erro= r **errp) > @@ -1318,6 +1377,7 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu,= char *features, Error **errp) > } else if (featurestr[0] =3D=3D '-') { > add_flagname_to_bitmaps(featurestr + 1, minus_features); > } else if ((val =3D strchr(featurestr, '=3D'))) { > + feat2prop(featurestr); > *val =3D 0; val++; > if (!strcmp(featurestr, "family")) { > object_property_parse(OBJECT(cpu), val, featurestr, er= rp); > @@ -1345,9 +1405,9 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu,= char *features, Error **errp) > object_property_parse(OBJECT(cpu), num, featurestr, er= rp); > } else if (!strcmp(featurestr, "vendor")) { > object_property_parse(OBJECT(cpu), val, featurestr, er= rp); > - } else if (!strcmp(featurestr, "model_id")) { > - object_property_parse(OBJECT(cpu), val, "model-id", er= rp); > - } else if (!strcmp(featurestr, "tsc_freq")) { > + } else if (!strcmp(featurestr, "model-id")) { > + object_property_parse(OBJECT(cpu), val, featurestr, er= rp); > + } else if (!strcmp(featurestr, "tsc-freq")) { > int64_t tsc_freq; > char *err; > char num[32]; > @@ -1360,7 +1420,7 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu,= char *features, Error **errp) > } > snprintf(num, sizeof(num), "%" PRId64, tsc_freq); > object_property_parse(OBJECT(cpu), num, "tsc-frequency= ", errp); > - } else if (!strcmp(featurestr, "hv_spinlocks")) { > + } else if (!strcmp(featurestr, "hv-spinlocks")) { > char *err; > numvalue =3D strtoul(val, &err, 0); > if (!*val || *err) { [snip] Thanks, split this part off and applied to qom-cpu (modified as below): https://github.com/afaerber/qemu-cpu/commits/qom-cpu Andreas diff --git a/target-i386/cpu.c b/target-i386/cpu.c index f34ba23..697848d 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1307,6 +1307,16 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, c onst char *name) return -1; } +/* Convert all '_' in a feature string option name to '-', to make featu= re + * name conform to QOM property naming rule, which uses '-' instead of '= _'. + */ +static inline void feat2prop(char *s) +{ + while ((s =3D strchr(s, '_'))) { + *s =3D '-'; + } +} + /* Parse "+feature,-feature,feature=3Dfoo" CPU feature string */ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp) @@ -1329,6 +1339,7 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *fe atures, Error **errp) add_flagname_to_bitmaps(featurestr + 1, minus_features); } else if ((val =3D strchr(featurestr, '=3D'))) { *val =3D 0; val++; + feat2prop(featurestr); if (!strcmp(featurestr, "family")) { object_property_parse(OBJECT(cpu), val, featurestr, errp= ); } else if (!strcmp(featurestr, "model")) { @@ -1355,9 +1366,9 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *fe atures, Error **errp) object_property_parse(OBJECT(cpu), num, featurestr, errp= ); } else if (!strcmp(featurestr, "vendor")) { object_property_parse(OBJECT(cpu), val, featurestr, errp= ); - } else if (!strcmp(featurestr, "model_id")) { - object_property_parse(OBJECT(cpu), val, "model-id", errp= ); - } else if (!strcmp(featurestr, "tsc_freq")) { + } else if (!strcmp(featurestr, "model-id")) { + object_property_parse(OBJECT(cpu), val, featurestr, errp= ); + } else if (!strcmp(featurestr, "tsc-freq")) { int64_t tsc_freq; char *err; char num[32]; @@ -1370,7 +1381,7 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp) } snprintf(num, sizeof(num), "%" PRId64, tsc_freq); object_property_parse(OBJECT(cpu), num, "tsc-frequency", errp); - } else if (!strcmp(featurestr, "hv_spinlocks")) { + } else if (!strcmp(featurestr, "hv-spinlocks")) { char *err; numvalue =3D strtoul(val, &err, 0); if (!*val || *err) { --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg