[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 12/22] cpu: add helper cpu_exists(), to check if
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 12/22] cpu: add helper cpu_exists(), to check if CPU with specified id exists |
Date: |
Tue, 09 Apr 2013 13:25:03 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4 |
Il 05/04/2013 16:37, Igor Mammedov ha scritto:
> ... it should be used only on slow path since it does recursive search
> on /machine QOM tree for objects of TYPE_CPU
>
> Signed-off-by: Igor Mammedov <address@hidden>
> ---
> include/qom/cpu.h | 10 ++++++++++
> qom/cpu.c | 21 +++++++++++++++++++++
> 2 files changed, 31 insertions(+)
>
> diff --git a/include/qom/cpu.h b/include/qom/cpu.h
> index 0d33009..5cac79b 100644
> --- a/include/qom/cpu.h
> +++ b/include/qom/cpu.h
> @@ -227,6 +227,16 @@ void 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
> + *
> + * 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 a54d4d1..46b77d3 100644
> --- a/qom/cpu.c
> +++ b/qom/cpu.c
> @@ -24,6 +24,27 @@
> #include "qemu/notify.h"
> #include "sysemu/sysemu.h"
>
> +static int cpu_exist_cb(Object *obj, void *opaque)
> +{
> + int64_t id = *(int64_t *)opaque;
> + Object *cpu_obj = object_dynamic_cast(obj, TYPE_CPU);
> +
> + if (cpu_obj) {
> + CPUState *cpu = CPU(cpu_obj);
> + CPUClass *klass = CPU_GET_CLASS(cpu);
> +
> + if (klass->get_firmware_id && klass->get_firmware_id(cpu) == id) {
> + return 1;
> + }
> + }
> + return object_child_foreach(obj, cpu_exist_cb, opaque);
> +}
> +
> +bool cpu_exists(int64_t id)
> +{
> + return cpu_exist_cb(qdev_get_machine(), &id) ? true : false;
> +}
> +
> /* CPU hot-plug notifiers */
> static NotifierList cpu_added_notifiers =
> NOTIFIER_LIST_INITIALIZER(cpu_add_notifiers);
>
Reviewed-by: Paolo Bonzini <address@hidden>
- Re: [Qemu-devel] [PATCH 18/22] target-i386: move APIC to ICC bus, (continued)
- [Qemu-devel] [PATCH 14/22] target-i386: introduce apic-id property, Igor Mammedov, 2013/04/05
- [Qemu-devel] [PATCH 09/22] introduce CPU hot-plug notifier, Igor Mammedov, 2013/04/05
- [Qemu-devel] [PATCH 21/22] target-i386: expose all possible CPUs as /machine/icc-bridge/cpu[0..N] links, Igor Mammedov, 2013/04/05
- [Qemu-devel] [PATCH 22/22] add cpu-add qmp command and implement CPU hot-add for target-i386, Igor Mammedov, 2013/04/05
- [Qemu-devel] [PATCH 12/22] cpu: add helper cpu_exists(), to check if CPU with specified id exists, Igor Mammedov, 2013/04/05
- Re: [Qemu-devel] [PATCH 12/22] cpu: add helper cpu_exists(), to check if CPU with specified id exists,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 19/22] target-i386: move IOAPIC to ICC bus, Igor Mammedov, 2013/04/05
- [Qemu-devel] [PATCH 20/22] qdev: set device's parent before calling realize() down inheritance chain., Igor Mammedov, 2013/04/05
- [Qemu-devel] [PATCH 19/22] target-i386: move APIC to ICC bus, Igor Mammedov, 2013/04/05
- [Qemu-devel] [PATCH 15/22] introduce ICC bus/device/bridge, Igor Mammedov, 2013/04/05
- [Qemu-devel] [PATCH 05/22] cpu: call cpu_synchronize_post_init() from CPUClass.realize() if hotplugged, Igor Mammedov, 2013/04/05