mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 17:53:56 -06:00
cpu: cpu_by_arch_id() helper
The helper can be used for CPU object lookup using the CPU's arch-specific ID (the one returned by CPUClass::get_arch_id()). Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> [Yi Wang: Added documentation comments] Signed-off-by: Yi Wang <wang.yi59@zte.com.cn> Signed-off-by: Yun Liu <liu.yunh@zte.com.cn> [ehabkost: extracted cpu_by_arch_id() to a separate patch] Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
parent
3beacfb98b
commit
5ce46cb34e
2 changed files with 18 additions and 3 deletions
11
qom/cpu.c
11
qom/cpu.c
|
@ -34,7 +34,7 @@
|
|||
|
||||
CPUInterruptHandler cpu_interrupt_handler;
|
||||
|
||||
bool cpu_exists(int64_t id)
|
||||
CPUState *cpu_by_arch_id(int64_t id)
|
||||
{
|
||||
CPUState *cpu;
|
||||
|
||||
|
@ -42,10 +42,15 @@ bool cpu_exists(int64_t id)
|
|||
CPUClass *cc = CPU_GET_CLASS(cpu);
|
||||
|
||||
if (cc->get_arch_id(cpu) == id) {
|
||||
return true;
|
||||
return cpu;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool cpu_exists(int64_t id)
|
||||
{
|
||||
return !!cpu_by_arch_id(id);
|
||||
}
|
||||
|
||||
CPUState *cpu_generic_init(const char *typename, const char *cpu_model)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue