From bc5b2da32ba54d991e8669b14a771afb3a67f408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 21 Jan 2013 17:50:15 +0100 Subject: target-m68k: Detect attempt to instantiate non-CPU type in cpu_init() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Consolidate model checking into a new m68k_cpu_class_by_name(). If the name matches an existing type, also check whether that type is (a sub-type of) TYPE_M68K_CPU. This fixes, e.g., -cpu ide-hd asserting. Signed-off-by: Andreas Färber --- target-m68k/cpu.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'target-m68k/cpu.c') diff --git a/target-m68k/cpu.c b/target-m68k/cpu.c index ce89674a08..b231d9ad38 100644 --- a/target-m68k/cpu.c +++ b/target-m68k/cpu.c @@ -55,6 +55,21 @@ static void m68k_cpu_reset(CPUState *s) /* CPU models */ +static ObjectClass *m68k_cpu_class_by_name(const char *cpu_model) +{ + ObjectClass *oc; + + if (cpu_model == NULL) { + return NULL; + } + + oc = object_class_by_name(cpu_model); + if (oc != NULL && object_class_dynamic_cast(oc, TYPE_M68K_CPU) == NULL) { + return NULL; + } + return oc; +} + static void m5206_cpu_initfn(Object *obj) { M68kCPU *cpu = M68K_CPU(obj); @@ -134,6 +149,8 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) mcc->parent_reset = cc->reset; cc->reset = m68k_cpu_reset; + + cc->class_by_name = m68k_cpu_class_by_name; } static void register_cpu_type(const M68kCPUInfo *info) -- cgit v1.2.1