diff options
author | Igor Mammedov <imammedo@redhat.com> | 2013-04-25 16:05:24 +0200 |
---|---|---|
committer | Andreas Färber <afaerber@suse.de> | 2013-05-01 13:04:18 +0200 |
commit | 69e5ff067ae724155fd7465119ee6db5721288b6 (patch) | |
tree | 61f6bad7b182abc129904155a7d27f47d118a8d3 /qom | |
parent | a37677c32bb313f5ba48aaf89f81cdc10c23ce56 (diff) |
cpu: Add helper cpu_exists(), to check if CPU with specified id exists
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'qom')
-rw-r--r-- | qom/cpu.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -24,6 +24,32 @@ #include "qemu/notify.h" #include "sysemu/sysemu.h" +typedef struct CPUExistsArgs { + int64_t id; + bool found; +} CPUExistsArgs; + +static void cpu_exist_cb(CPUState *cpu, void *data) +{ + CPUClass *klass = CPU_GET_CLASS(cpu); + CPUExistsArgs *arg = data; + + if (klass->get_arch_id(cpu) == arg->id) { + arg->found = true; + } +} + +bool cpu_exists(int64_t id) +{ + CPUExistsArgs data = { + .id = id, + .found = false, + }; + + qemu_for_each_cpu(cpu_exist_cb, &data); + return data.found; +} + /* CPU hot-plug notifiers */ static NotifierList cpu_added_notifiers = NOTIFIER_LIST_INITIALIZER(cpu_add_notifiers); |