[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 10/29] cpu: Add helper cpu_exists(), to check if CPU
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PATCH 10/29] cpu: Add helper cpu_exists(), to check if CPU with specified id exists |
Date: |
Thu, 2 May 2013 15:35:36 +0200 |
From: Igor Mammedov <address@hidden>
Signed-off-by: Igor Mammedov <address@hidden>
Signed-off-by: Andreas Färber <address@hidden>
---
include/qom/cpu.h | 10 ++++++++++
qom/cpu.c | 26 ++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index a28e5ff..e54579b 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -234,6 +234,16 @@ void qemu_for_each_cpu(void (*func)(CPUState *cpu, void
*data), void *data);
*/
CPUState *qemu_get_cpu(int index);
+/**
+ * cpu_exists:
+ * @id: Guest-exposed CPU ID to lookup.
+ *
+ * Search for CPU with specified ID.
+ *
+ * Returns: %true - CPU is found, %false - CPU isn't found.
+ */
+bool cpu_exists(int64_t id);
+
#ifndef CONFIG_USER_ONLY
typedef void (*CPUInterruptHandler)(CPUState *, int);
diff --git a/qom/cpu.c b/qom/cpu.c
index 9a4457b..3dc8208 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -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);
--
1.8.1.4
- [Qemu-devel] [PULL for-1.5 00/29] QOM CPUState patch queue 2013-05-02, Andreas Färber, 2013/05/02
- [Qemu-devel] [PATCH 02/29] cpu: Call cpu_synchronize_post_init() from DeviceClass::realize(), Andreas Färber, 2013/05/02
- [Qemu-devel] [PATCH 01/29] cpu: Make kvm-stub.o available outside softmmu, Andreas Färber, 2013/05/02
- [Qemu-devel] [PATCH 10/29] cpu: Add helper cpu_exists(), to check if CPU with specified id exists,
Andreas Färber <=
- [Qemu-devel] [PATCH 12/29] target-i386: Introduce feat2prop() for CPU properties, Andreas Färber, 2013/05/02
- [Qemu-devel] [PATCH 13/29] target-i386: Introduce apic-id CPU property, Andreas Färber, 2013/05/02
- [Qemu-devel] [PATCH 05/29] cpu: Introduce CPU hot-plug notifier, Andreas Färber, 2013/05/02
- [Qemu-devel] [PATCH 09/29] cpus: Use qemu_for_each_cpu() in TCG thread, Andreas Färber, 2013/05/02
- [Qemu-devel] [PATCH 04/29] cpu: Resume CPU from DeviceClass::realize() if hot-plugged, Andreas Färber, 2013/05/02
- [Qemu-devel] [PATCH 08/29] cpu: Add qemu_for_each_cpu(), Andreas Färber, 2013/05/02
- [Qemu-devel] [PATCH 21/29] Add hot_add_cpu hook to QEMUMachine, Andreas Färber, 2013/05/02
- [Qemu-devel] [PATCH 14/29] target-i386: Do not allow to set apic-id once CPU is realized, Andreas Färber, 2013/05/02
- [Qemu-devel] [PATCH 03/29] cpu: Introduce cpu_resume(), for single CPU, Andreas Färber, 2013/05/02
- [Qemu-devel] [PATCH 11/29] acpi_piix4: Add infrastructure to send CPU hot-plug GPE to guest, Andreas Färber, 2013/05/02