qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 04/10] target-i386: convert 'hv_spinlocks' to st


From: Eduardo Habkost
Subject: Re: [Qemu-devel] [PATCH 04/10] target-i386: convert 'hv_spinlocks' to static property
Date: Tue, 26 Feb 2013 11:42:08 -0300
User-agent: Mutt/1.5.21 (2010-09-15)

On Mon, Feb 25, 2013 at 02:03:03AM +0100, Igor Mammedov wrote:
[...]
> +static void x86_set_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
> +                                 const char *name, Error **errp)
> +{
> +    const int64_t min = 0xFFF;
> +    const int64_t max = UINT_MAX;
> +    X86CPU *cpu = X86_CPU(obj);
> +    int64_t value;
> +
> +    visit_type_int(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
> +                  " (minimum: %" PRId64 ", maximum: %" PRId64 ")",
> +                  object_get_typename(obj), name ? name : "null",
> +                  value, min, max);
> +        return;
> +    }
> +    cpu->env.hyperv_spinlock_attempts = value;
> +}
[...]
> @@ -1421,6 +1466,7 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char 
> *features, Error **errp)
>              } else if (!strcmp(featurestr, "hv-spinlocks")) {
>                  char *err;
>                  const int min = 0xFFF;
> +                char num[32];
>                  numvalue = strtoul(val, &err, 0);
>                  if (!*val || *err) {
>                      error_setg(errp, "bad numerical value %s", val);
> @@ -1432,7 +1478,8 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char 
> *features, Error **errp)
>                              min);
>                      numvalue = min;
>                  }
> -                env->hyperv_spinlock_attempts = numvalue;
> +                snprintf(num, sizeof(num), "%" PRId32, numvalue);

Isn't the above validation code already inside x86_set_hv_spinlocks()?
Why do we need it here in cpu_x86_parse_featurestr() too?

> +                object_property_parse(OBJECT(cpu), num, featurestr, errp);
>              } else {
>                  error_setg(errp, "unrecognized feature %s", featurestr);
>                  goto out;
> @@ -1597,7 +1644,6 @@ static void cpu_x86_register(X86CPU *cpu, const char 
> *name, Error **errp)
>          def->kvm_features |= kvm_default_features;
>      }
>      def->ext_features |= CPUID_EXT_HYPERVISOR;
> -    env->hyperv_spinlock_attempts = HYPERV_SPINLOCK_NEVER_RETRY;
>  
>      object_property_set_str(OBJECT(cpu), def->vendor, "vendor", errp);
>      object_property_set_int(OBJECT(cpu), def->level, "level", errp);
> -- 
> 1.7.1
> 

-- 
Eduardo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]