diff options
author | Philippe Mathieu-Daudé <philmd@linaro.org> | 2023-09-08 10:09:23 +0200 |
---|---|---|
committer | Philippe Mathieu-Daudé <philmd@linaro.org> | 2024-01-05 16:20:14 +0100 |
commit | d5be19f514ece5e20baf560f466ee46766e7d5a3 (patch) | |
tree | abe15eb7e9e0bb6716b586f83ffef48927e3a7b0 /hw/core | |
parent | b0b8fa181472a7e745cb0c2c33b5c84dbb3b34ef (diff) | |
download | qemu-d5be19f514ece5e20baf560f466ee46766e7d5a3.zip qemu-d5be19f514ece5e20baf560f466ee46766e7d5a3.tar.gz qemu-d5be19f514ece5e20baf560f466ee46766e7d5a3.tar.bz2 |
cpu: Call object_class_dynamic_cast() once in cpu_class_by_name()
For all targets, the CPU class returned from CPUClass::class_by_name()
and object_class_dynamic_cast(oc, CPU_RESOLVING_TYPE) need to be
compatible. Lets apply the check in cpu_class_by_name() for once,
instead of having the check in CPUClass::class_by_name() for individual
target.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Gavin Shan <gshan@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Gavin Shan <gshan@redhat.com>
Message-ID: <20231114235628.534334-4-gshan@redhat.com>
Diffstat (limited to 'hw/core')
-rw-r--r-- | hw/core/cpu-common.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 82dae51..d0e7bbd 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -154,10 +154,12 @@ ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model) assert(cc->class_by_name); assert(cpu_model); oc = cc->class_by_name(cpu_model); - if (oc == NULL || object_class_is_abstract(oc)) { - return NULL; + if (object_class_dynamic_cast(oc, typename) && + !object_class_is_abstract(oc)) { + return oc; } - return oc; + + return NULL; } static void cpu_common_parse_features(const char *typename, char *features, |