summaryrefslogtreecommitdiff
path: root/target-unicore32/helper.c
diff options
context:
space:
mode:
authorAndreas Färber <afaerber@suse.de>2013-01-23 12:07:17 +0100
committerAndreas Färber <afaerber@suse.de>2013-01-27 23:33:25 +0100
commitd89e12188d50f7f8a894027789f32fa7ba6226ad (patch)
treee10fc11fa7f82fc4c85dfba0ef4426f292df5542 /target-unicore32/helper.c
parentbd039ce0094f3724a87a193c846ee8468ce652b0 (diff)
downloadqemu-d89e12188d50f7f8a894027789f32fa7ba6226ad.tar.gz
target-unicore32: Detect attempt to instantiate non-CPU type in cpu_init()
Consolidate model checking into a new uc32_cpu_class_by_name(). If the name matches an existing type, also check whether that type is actually (a sub-type of) TYPE_UNICORE32_CPU. This fixes, e.g., -cpu puv3_dma asserting. Cc: qemu-stable@nongnu.org Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'target-unicore32/helper.c')
-rw-r--r--target-unicore32/helper.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c
index 5359538ea5..183b5b3577 100644
--- a/target-unicore32/helper.c
+++ b/target-unicore32/helper.c
@@ -29,12 +29,14 @@ CPUUniCore32State *uc32_cpu_init(const char *cpu_model)
{
UniCore32CPU *cpu;
CPUUniCore32State *env;
+ ObjectClass *oc;
static int inited = 1;
- if (object_class_by_name(cpu_model) == NULL) {
+ oc = cpu_class_by_name(TYPE_UNICORE32_CPU, cpu_model);
+ if (oc == NULL) {
return NULL;
}
- cpu = UNICORE32_CPU(object_new(cpu_model));
+ cpu = UNICORE32_CPU(object_new(object_class_get_name(oc)));
env = &cpu->env;
if (inited) {