From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6uXR-0002xg-A9 for qemu-devel@nongnu.org; Thu, 10 Dec 2015 01:17:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a6uXN-00039I-Vn for qemu-devel@nongnu.org; Thu, 10 Dec 2015 01:17:13 -0500 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:33276) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6uXN-00038y-Db for qemu-devel@nongnu.org; Thu, 10 Dec 2015 01:17:09 -0500 Received: from localhost by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Dec 2015 16:17:08 +1000 Received: from d23relay07.au.ibm.com (d23relay07.au.ibm.com [9.190.26.37]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 65F092CE8057 for ; Thu, 10 Dec 2015 17:17:04 +1100 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tBA6GwFN17432738 for ; Thu, 10 Dec 2015 17:17:06 +1100 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tBA6GV2a030653 for ; Thu, 10 Dec 2015 17:16:32 +1100 From: Bharata B Rao Date: Thu, 10 Dec 2015 11:45:44 +0530 Message-Id: <1449728144-6223-10-git-send-email-bharata@linux.vnet.ibm.com> In-Reply-To: <1449728144-6223-1-git-send-email-bharata@linux.vnet.ibm.com> References: <1449728144-6223-1-git-send-email-bharata@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC PATCH v0 9/9] pc: Convert boot CPUs into CPU core device initialization List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, ehabkost@redhat.com, Bharata B Rao , agraf@suse.de, borntraeger@de.ibm.com, imammedo@redhat.com, pbonzini@redhat.com, afaerber@suse.de, david@gibson.dropbear.id.au Initialize boot CPUs specified with -smp option as CPU core devices. Signed-off-by: Bharata B Rao --- hw/i386/pc.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 80a4d98..661e577 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -65,6 +65,7 @@ #include "hw/mem/pc-dimm.h" #include "qapi/visitor.h" #include "qapi-visit.h" +#include "hw/cpu/core.h" /* debug PC/ISA interrupts */ //#define DEBUG_IRQ @@ -1086,11 +1087,10 @@ void pc_hot_add_cpu(const int64_t id, Error **errp) void pc_cpus_init(PCMachineState *pcms) { - int i; - X86CPU *cpu = NULL; + int i, j; MachineState *machine = MACHINE(pcms); - Error *error = NULL; unsigned long apic_id_limit; + int sockets = DIV_ROUND_UP(smp_cpus, smp_cores * smp_threads); /* init CPUs */ if (machine->cpu_model == NULL) { @@ -1109,18 +1109,17 @@ void pc_cpus_init(PCMachineState *pcms) exit(1); } - for (i = 0; i < smp_cpus; i++) { - cpu = pc_new_cpu(machine->cpu_model, x86_cpu_apic_id_from_index(i), - &error); - if (error) { - error_report_err(error); - exit(1); + for (i = 0; i < sockets; i++) { + char sid[32]; + + snprintf(sid, 32, "" TYPE_CPU_SOCKET "%d", i); + for (j = 0; j < smp_cores; j++) { + Object *core = object_new(TYPE_CPU_CORE); + + object_property_set_str(core, sid, "socket", &error_abort); + object_property_set_bool(core, true, "realized", &error_abort); } - object_unref(OBJECT(cpu)); } - - /* tell smbios about cpuid version and features */ - smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]); } /* pci-info ROM file. Little endian format */ @@ -1660,6 +1659,11 @@ static void pc_cpu_plug(HotplugHandler *hotplug_dev, HotplugHandlerClass *hhc; Error *local_err = NULL; PCMachineState *pcms = PC_MACHINE(hotplug_dev); + CPUState *cs = CPU(dev); + X86CPU *cpu = X86_CPU(cs); + + /* tell smbios about cpuid version and features */ + smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]); if (!dev->hotplugged) { goto out; -- 2.1.0