qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH qom-cpu for-1.5 3/4] target-i386: Emulate X86CPU


From: Eduardo Habkost
Subject: Re: [Qemu-devel] [PATCH qom-cpu for-1.5 3/4] target-i386: Emulate X86CPU subclasses for global properties
Date: Thu, 2 May 2013 12:03:30 -0300
User-agent: Mutt/1.5.21 (2010-09-15)

On Wed, May 01, 2013 at 06:07:19PM +0200, Andreas Färber wrote:
> After initializing the object from its x86_def_t and before setting any
> additional -cpu arguments, set any global properties for the designated
> subclass <name>-{i386,x86_64}-cpu.
> 
> Signed-off-by: Andreas Färber <address@hidden>
> ---
>  target-i386/cpu.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index bba41fe..8a9563b 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -1626,6 +1626,7 @@ X86CPU *cpu_x86_create(const char *cpu_model, 
> DeviceState *icc_bridge,
>      CPUX86State *env;
>      gchar **model_pieces;
>      char *name, *features;
> +    char *typename;
>      Error *error = NULL;
>  
>      model_pieces = g_strsplit(cpu_model, ",", 2);
> @@ -1653,6 +1654,14 @@ X86CPU *cpu_x86_create(const char *cpu_model, 
> DeviceState *icc_bridge,
>          goto out;
>      }
>  
> +    /* Emulate per-model subclasses for global properties */
> +    typename = g_strdup_printf("%s-" TYPE_X86_CPU, name);
> +    qdev_prop_set_custom_globals(DEVICE(cpu), typename, &error);
> +    g_free(typename);
> +    if (error) {
> +        goto out;
> +    }

I really like this solution.

I find it ironic that we spent 2 or 3 releases struggling with the
imposed restriction that global-properties can't be used to set dynamic
QOM properties (only static properties), and now we are introducing a
mechanism to do exactly that.  :-)

Reviewed-by: Eduardo Habkost <address@hidden>


> +
>      cpu_x86_parse_featurestr(cpu, features, &error);
>      if (error) {
>          goto out;
> -- 
> 1.8.1.4
> 

-- 
Eduardo



reply via email to

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