aboutsummaryrefslogtreecommitdiff
path: root/qom
diff options
context:
space:
mode:
authorIgor Mammedov <imammedo@redhat.com>2013-04-23 10:29:41 +0200
committerAndreas Färber <afaerber@suse.de>2013-05-01 13:04:18 +0200
commit997395d3888fcde6ce41535a8208d7aa919d824b (patch)
tree5e6d2bd054bdb7b1f1914916f97dbdd06a7b3374 /qom
parentb8b7456d6ab7edb450ae5ec6473d3cd9a80412f4 (diff)
downloadqemu-997395d3888fcde6ce41535a8208d7aa919d824b.zip
qemu-997395d3888fcde6ce41535a8208d7aa919d824b.tar.gz
qemu-997395d3888fcde6ce41535a8208d7aa919d824b.tar.bz2
cpu: Introduce get_arch_id() method and override it for X86CPU
get_arch_id() adds possibility for generic code to get a guest-visible CPU ID without accessing CPUArchState. If derived classes don't override it, it will return cpu_index. Override it on target-i386 in X86CPU to return the APIC ID. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: liguang <lig.fnst@cn.fujitsu.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'qom')
-rw-r--r--qom/cpu.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/qom/cpu.c b/qom/cpu.c
index 34fa805..9a4457b 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -78,6 +78,11 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp)
}
}
+static int64_t cpu_common_get_arch_id(CPUState *cpu)
+{
+ return cpu->cpu_index;
+}
+
static void cpu_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -85,6 +90,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)
k->class_by_name = cpu_common_class_by_name;
k->reset = cpu_common_reset;
+ k->get_arch_id = cpu_common_get_arch_id;
dc->realize = cpu_common_realizefn;
dc->no_user = 1;
}