From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUYfv-0007Kn-Hq for qemu-devel@nongnu.org; Tue, 23 Apr 2013 04:34:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UUYfq-00021U-TP for qemu-devel@nongnu.org; Tue, 23 Apr 2013 04:34:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46560) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUYfq-00021L-Iq for qemu-devel@nongnu.org; Tue, 23 Apr 2013 04:34:02 -0400 From: Igor Mammedov Date: Tue, 23 Apr 2013 10:29:54 +0200 Message-Id: <1366705795-24732-21-git-send-email-imammedo@redhat.com> In-Reply-To: <1366705795-24732-1-git-send-email-imammedo@redhat.com> References: <1366705795-24732-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH 20/21] target-i386: implement machine->hot_add_cpu hook List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, gleb@redhat.com, mst@redhat.com, jan.kiszka@siemens.com, lcapitulino@redhat.com, blauwirbel@gmail.com, kraxel@redhat.com, quintela@redhat.com, armbru@redhat.com, yang.z.zhang@intel.com, ehabkost@redhat.com, stefano.stabellini@eu.citrix.com, aderumier@odiso.com, anthony.perard@citrix.com, alex.williamson@redhat.com, rth@twiddle.net, kwolf@redhat.com, aliguori@us.ibm.com, claudio.fontana@huawei.com, pbonzini@redhat.com, afaerber@suse.de Signed-off-by: Igor Mammedov --- hw/i386/pc.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 5e50127..b649ed5 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -54,6 +54,7 @@ #include "qemu/config-file.h" #include "hw/acpi/acpi.h" #include "hw/cpu/icc_bus.h" +#include "hw/boards.h" /* debug PC/ISA interrupts */ //#define DEBUG_IRQ @@ -914,6 +915,25 @@ static X86CPU *pc_new_cpu(const char *cpu_model, int64_t apic_id, Error **errp) return cpu; } +static void do_cpu_hot_add(const int64_t id, Error **errp) +{ + int64_t apic_id = x86_cpu_apic_id_from_index(id); + + if (cpu_exists(apic_id)) { + error_setg(errp, "Unable to add CPU: %" PRIi64 + ", it already exists", id); + return; + } + + if (id >= max_cpus) { + error_setg(errp, "Unable to add CPU: %" PRIi64 + ", max allowed: %d", id, max_cpus - 1); + return; + } + + pc_new_cpu(machine_args->cpu_model, apic_id, errp); +} + void pc_cpus_init(const char *cpu_model) { int i; @@ -928,7 +948,9 @@ void pc_cpus_init(const char *cpu_model) #else cpu_model = "qemu32"; #endif + machine_args->cpu_model = cpu_model; } + current_machine->hot_add_cpu = do_cpu_hot_add; icc_bridge = SYS_BUS_DEVICE(object_resolve_path_type("icc-bridge", TYPE_ICC_BRIDGE, NULL)); -- 1.7.1