aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Färber <afaerber@suse.de>2012-04-17 23:02:26 +0200
committerAndreas Färber <afaerber@suse.de>2012-04-25 10:51:35 +0200
commit63e886ebef04c3c8b40735a1467a11caf3efda4a (patch)
treef8c23a9dc3828ae5d2200d38bee433f545d1778b
parent35112e415a771507fd94cca3b1a4ba4f99dd18d1 (diff)
target-i386: Add property getter for CPU model-id
Signed-off-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com>
-rw-r--r--target-i386/cpu.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 2ff5142950..8b5c47d7a0 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -711,6 +711,21 @@ static void x86_cpuid_version_set_stepping(Object *obj, Visitor *v,
env->cpuid_version |= value & 0xf;
}
+static char *x86_cpuid_get_model_id(Object *obj, Error **errp)
+{
+ X86CPU *cpu = X86_CPU(obj);
+ CPUX86State *env = &cpu->env;
+ char *value;
+ int i;
+
+ value = g_malloc(48 + 1);
+ for (i = 0; i < 48; i++) {
+ value[i] = env->cpuid_model[i >> 2] >> (8 * (i & 3));
+ }
+ value[48] = '\0';
+ return value;
+}
+
static void x86_cpuid_set_model_id(Object *obj, const char *model_id,
Error **errp)
{
@@ -1585,7 +1600,7 @@ static void x86_cpu_initfn(Object *obj)
x86_cpuid_version_get_stepping,
x86_cpuid_version_set_stepping, NULL, NULL, NULL);
object_property_add_str(obj, "model-id",
- NULL,
+ x86_cpuid_get_model_id,
x86_cpuid_set_model_id, NULL);
env->cpuid_apic_id = env->cpu_index;