From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:51097) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRVAC-0003c0-Q7 for qemu-devel@nongnu.org; Thu, 25 Oct 2012 17:40:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TRVAB-00052T-4t for qemu-devel@nongnu.org; Thu, 25 Oct 2012 17:40:28 -0400 Received: from hub021-nj-2.exch021.serverdata.net ([206.225.164.217]:39574) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRVAB-00051j-0L for qemu-devel@nongnu.org; Thu, 25 Oct 2012 17:40:27 -0400 Message-ID: <5089B1C8.6020605@CloudSwitch.Com> Date: Thu, 25 Oct 2012 17:40:24 -0400 From: Don Slutz MIME-Version: 1.0 References: <1350918203-25198-1-git-send-email-imammedo@redhat.com> <1350918203-25198-28-git-send-email-imammedo@redhat.com> In-Reply-To: <1350918203-25198-28-git-send-email-imammedo@redhat.com> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 27/37] target-i386: convert "tsc-frequency" to static property List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: aliguori@us.ibm.com, ehabkost@redhat.com, jan.kiszka@siemens.com, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, blauwirbel@gmail.com, stefanha@redhat.com, pbonzini@redhat.com, afaerber@suse.de On 10/22/12 11:03, Igor Mammedov wrote: > Signed-off-by: Igor Mammedov > --- > * in addition use error_setg() instead of error_set() > --- > target-i386/cpu.c | 75 ++++++++++++++++++++++++++++++------------------------- > 1 file changed, 41 insertions(+), 34 deletions(-) > > diff --git a/target-i386/cpu.c b/target-i386/cpu.c > index a1790aa..8d3f4cc 100644 > --- a/target-i386/cpu.c > +++ b/target-i386/cpu.c > @@ -351,6 +351,46 @@ PropertyInfo qdev_prop_vendor = { > #define DEFINE_PROP_VENDOR(_n, _s, _f) \ > DEFINE_PROP(_n, _s, _f, qdev_prop_vendor, uint32_t) > > +static void x86_cpuid_get_tsc_freq(Object *obj, Visitor *v, void *opaque, > + const char *name, Error **errp) > +{ > + X86CPU *cpu = X86_CPU(obj); > + int64_t value; > + > + value = cpu->env.tsc_khz * 1000; > + visit_type_int(v, &value, name, errp); > +} > + > +static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, > + const char *name, Error **errp) > +{ > + X86CPU *cpu = X86_CPU(obj); > + const int64_t min = 0; > + const int64_t max = INT64_MAX; > + int64_t value; > + > + visit_type_freq(v, &value, name, errp); > + if (error_is_set(errp)) { > + return; > + } > + if (value < min || value > max) { > + error_setg(errp, "Property %s.%s doesn't take value %" PRId64 " (min" > + "imum: %" PRId64 ", maximum: %" PRId64, > + object_get_typename(obj), name, value, min, max); > + return; > + } > + > + cpu->env.tsc_khz = value / 1000; > +} > + > +PropertyInfo qdev_prop_tsc_freq = { > + .name = "int32", This should be at least int64. Better is 'frequency', since strtosz_suffix_unit() is used. I.E. 2.4G is valid for this. > + .get = x86_cpuid_get_tsc_freq, > + .set = x86_cpuid_set_tsc_freq, > +}; > +#define DEFINE_PROP_TSC_FREQ(_n, _s, _f) \ > + DEFINE_PROP(_n, _s, _f, qdev_prop_tsc_freq, int32_t) > + > static Property cpu_x86_properties[] = { > DEFINE_PROP_BIT("f-fpu", X86CPU, env.cpuid_features, 0, false), > DEFINE_PROP_BIT("f-vme", X86CPU, env.cpuid_features, 1, false), > @@ -471,6 +511,7 @@ static Property cpu_x86_properties[] = { > DEFINE_PROP_CHECK("check"), > DEFINE_PROP_ENFORCE("enforce"), > DEFINE_PROP_VENDOR("vendor", X86CPU, env.cpuid_vendor1), > + DEFINE_PROP_TSC_FREQ("tsc-frequency", X86CPU, env.tsc_khz), > DEFINE_PROP_END_OF_LIST(), > }; > > @@ -1329,37 +1370,6 @@ static void x86_cpuid_set_model_id(Object *obj, const char *model_id, > } > } > > -static void x86_cpuid_get_tsc_freq(Object *obj, Visitor *v, void *opaque, > - const char *name, Error **errp) > -{ > - X86CPU *cpu = X86_CPU(obj); > - int64_t value; > - > - value = cpu->env.tsc_khz * 1000; > - visit_type_int(v, &value, name, errp); > -} > - > -static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, > - const char *name, Error **errp) > -{ > - X86CPU *cpu = X86_CPU(obj); > - const int64_t min = 0; > - const int64_t max = INT64_MAX; > - int64_t value; > - > - visit_type_freq(v, &value, name, errp); > - if (error_is_set(errp)) { > - return; > - } > - if (value < min || value > max) { > - error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "", > - name ? name : "null", value, min, max); > - return; > - } > - > - cpu->env.tsc_khz = value / 1000; > -} > - > static void cpudef_2_x86_cpu(X86CPU *cpu, x86_def_t *def, Error **errp) > { > CPUX86State *env = &cpu->env; > @@ -2236,9 +2246,6 @@ static void x86_cpu_initfn(Object *obj) > object_property_add_str(obj, "model-id", > x86_cpuid_get_model_id, > x86_cpuid_set_model_id, NULL); > - object_property_add(obj, "tsc-frequency", "int", > - x86_cpuid_get_tsc_freq, > - x86_cpuid_set_tsc_freq, NULL, NULL, NULL); > > env->cpuid_apic_id = env->cpu_index; > The rest looks correct. -Don Slutz