[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 01/10] cpu: rename cpu_exists() to qemu_get_cpu_b
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH v2 01/10] cpu: rename cpu_exists() to qemu_get_cpu_by_arch_id() |
Date: |
Fri, 5 Feb 2016 19:06:57 +0100 |
cpu_exists() already does CPU lookup but
discards found CPU and returns boolean instead.
Make it more useful by returning a found CPU
and also rename it more descriptive name.
Signed-off-by: Igor Mammedov <address@hidden>
Reviewed-by: Eduardo Habkost <address@hidden>
---
hw/i386/pc.c | 2 +-
include/qom/cpu.h | 10 +++++-----
qom/cpu.c | 6 +++---
target-i386/cpu.c | 2 +-
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index fd8524f..9227bde 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1088,7 +1088,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
return;
}
- if (cpu_exists(apic_id)) {
+ if (qemu_get_cpu_by_arch_id(apic_id)) {
error_setg(errp, "Unable to add CPU: %" PRIi64
", it already exists", id);
return;
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 035179c..bd26bf5 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -622,14 +622,14 @@ void async_run_on_cpu(CPUState *cpu, void (*func)(void
*data), void *data);
CPUState *qemu_get_cpu(int index);
/**
- * cpu_exists:
- * @id: Guest-exposed CPU ID to lookup.
+ * qemu_get_cpu_by_arch_id:
+ * @id: Guest-exposed CPU ID to lookup returned by address@hidden()
*
- * Search for CPU with specified ID.
+ * Gets a CPU matching @id.
*
- * Returns: %true - CPU is found, %false - CPU isn't found.
+ * Returns: The CPU or %NULL if there is no matching CPU.
*/
-bool cpu_exists(int64_t id);
+CPUState *qemu_get_cpu_by_arch_id(int id);
/**
* cpu_throttle_set:
diff --git a/qom/cpu.c b/qom/cpu.c
index 38dc713..2c4a4e3 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -27,7 +27,7 @@
#include "qemu/error-report.h"
#include "sysemu/sysemu.h"
-bool cpu_exists(int64_t id)
+CPUState *qemu_get_cpu_by_arch_id(int id)
{
CPUState *cpu;
@@ -35,10 +35,10 @@ 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;
}
CPUState *cpu_generic_init(const char *typename, const char *cpu_model)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index b255644..3918f01 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1789,7 +1789,7 @@ static void x86_cpuid_set_apic_id(Object *obj, Visitor
*v, void *opaque,
return;
}
- if ((value != cpu->apic_id) && cpu_exists(value)) {
+ if ((value != cpu->apic_id) && qemu_get_cpu_by_arch_id(value)) {
error_setg(errp, "CPU with APIC ID %" PRIi64 " exists", value);
return;
}
--
1.8.3.1
- [Qemu-devel] [PATCH v2 00/10] pc: do not create invalid MADT.LAPIC/Processor entries, Igor Mammedov, 2016/02/05
- [Qemu-devel] [PATCH v2 02/10] machine: introduce MachineClass.possible_cpu_arch_ids() hook, Igor Mammedov, 2016/02/05
- [Qemu-devel] [PATCH v2 01/10] cpu: rename cpu_exists() to qemu_get_cpu_by_arch_id(),
Igor Mammedov <=
- [Qemu-devel] [PATCH v2 03/10] pc: init pcms->apic_id_limit once and use it throughout pc.c, Igor Mammedov, 2016/02/05
- [Qemu-devel] [PATCH v2 04/10] pc: acpi: cleanup qdev_get_machine() calls, Igor Mammedov, 2016/02/05
- [Qemu-devel] [PATCH v2 05/10] pc: acpi: SRAT: create only valid processor lapic entries, Igor Mammedov, 2016/02/05
- [Qemu-devel] [PATCH v2 06/10] pc: acpi: create Processor and Notify objects only for valid lapics, Igor Mammedov, 2016/02/05
- [Qemu-devel] [PATCH v2 07/10] pc: acpi: create MADT.lapic entries only for valid lapics, Igor Mammedov, 2016/02/05
- [Qemu-devel] [PATCH v2 10/10] pc: acpi: remove NOP assignment, Igor Mammedov, 2016/02/05
- [Qemu-devel] [PATCH v2 08/10] pc: acpi: move cpu->found_cpus bitmap to build_processor_devices(), Igor Mammedov, 2016/02/05
- [Qemu-devel] [PATCH v2 09/10] pc: acpi: clarify why possible LAPIC entries must be present in MADT, Igor Mammedov, 2016/02/05