From nobody Mon Oct 27 18:35:01 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516242478498391.22388604630703; Wed, 17 Jan 2018 18:27:58 -0800 (PST) Received: from localhost ([::1]:52634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebzvn-0005xv-Jw for importer@patchew.org; Wed, 17 Jan 2018 21:27:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46375) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebzg6-0001Ra-3c for qemu-devel@nongnu.org; Wed, 17 Jan 2018 21:11:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebzg1-00056b-EX for qemu-devel@nongnu.org; Wed, 17 Jan 2018 21:11:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57504) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ebzg1-000566-60 for qemu-devel@nongnu.org; Wed, 17 Jan 2018 21:11:37 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 286D15F7AF; Thu, 18 Jan 2018 02:11:36 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9EB1C60BE9; Thu, 18 Jan 2018 02:11:35 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 18 Jan 2018 00:09:59 -0200 Message-Id: <20180118021000.27203-19-ehabkost@redhat.com> In-Reply-To: <20180118021000.27203-1-ehabkost@redhat.com> References: <20180118021000.27203-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 18 Jan 2018 02:11:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 18/19] possible_cpus: add CPUArchId::type field X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcel Apfelbaum , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Remove dependency of possible_cpus on 1st CPU instance, which decouples configuration data from CPU instances that are created using that data. Also later it would be used for enabling early cpu to numa node configuration at runtime qmp_query_hotpluggable_cpus() should provide a list of available cpu slots at early stage, before machine_init() is called and the 1st cpu is created, so that mgmt might be able to call it and use output to set numa mapping. Use MachineClass::possible_cpu_arch_ids() callback to set cpu type info, along with the rest of possible cpu properties, to let machine define which cpu type* will be used. * for SPAPR it will be a spapr core type and for ARM/s390x/x86 a respective descendant of CPUClass. Move parse_numa_opts() in vl.c after cpu_model is parsed into cpu_type so that possible_cpu_arch_ids() would know which cpu_type to use during layout initialization. Signed-off-by: Igor Mammedov Reviewed-by: David Gibson Message-Id: <1515597770-268979-1-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- include/hw/boards.h | 2 ++ hw/arm/virt.c | 3 ++- hw/core/machine.c | 12 ++++++------ hw/i386/pc.c | 4 +++- hw/ppc/spapr.c | 13 ++++++++----- hw/s390x/s390-virtio-ccw.c | 1 + vl.c | 3 +-- 7 files changed, 23 insertions(+), 15 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 041bc08971..efb0a9edfd 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -83,6 +83,7 @@ void machine_class_allow_dynamic_sysbus_dev(MachineClass = *mc, const char *type); * CPUArchId: * @arch_id - architecture-dependent CPU ID of present or possible CPU * @cpu - pointer to corresponding CPU object if it's present on NULL othe= rwise + * @type - QOM class name of possible @cpu object * @props - CPU object properties, initialized by board * #vcpus_count - number of threads provided by @cpu object */ @@ -91,6 +92,7 @@ typedef struct { int64_t vcpus_count; CpuInstanceProperties props; Object *cpu; + const char *type; } CPUArchId; =20 /** diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 4a6fdcc4f5..a4537af400 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1359,7 +1359,7 @@ static void machvirt_init(MachineState *machine) break; } =20 - cpuobj =3D object_new(machine->cpu_type); + cpuobj =3D object_new(possible_cpus->cpus[n].type); object_property_set_int(cpuobj, possible_cpus->cpus[n].arch_id, "mp-affinity", NULL); =20 @@ -1575,6 +1575,7 @@ static const CPUArchIdList *virt_possible_cpu_arch_id= s(MachineState *ms) sizeof(CPUArchId) * max_cpus); ms->possible_cpus->len =3D max_cpus; for (n =3D 0; n < ms->possible_cpus->len; n++) { + ms->possible_cpus->cpus[n].type =3D ms->cpu_type; ms->possible_cpus->cpus[n].arch_id =3D virt_cpu_mp_affinity(vms, n); ms->possible_cpus->cpus[n].props.has_thread_id =3D true; diff --git a/hw/core/machine.c b/hw/core/machine.c index 0320a8efa1..cdc1163dc6 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -377,18 +377,18 @@ static void machine_init_notify(Notifier *notifier, v= oid *data) HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine) { int i; - Object *cpu; HotpluggableCPUList *head =3D NULL; - const char *cpu_type; + MachineClass *mc =3D MACHINE_GET_CLASS(machine); + + /* force board to initialize possible_cpus if it hasn't been done yet = */ + mc->possible_cpu_arch_ids(machine); =20 - cpu =3D machine->possible_cpus->cpus[0].cpu; - assert(cpu); /* Boot cpu is always present */ - cpu_type =3D object_get_typename(cpu); for (i =3D 0; i < machine->possible_cpus->len; i++) { + Object *cpu; HotpluggableCPUList *list_item =3D g_new0(typeof(*list_item), 1); HotpluggableCPU *cpu_item =3D g_new0(typeof(*cpu_item), 1); =20 - cpu_item->type =3D g_strdup(cpu_type); + cpu_item->type =3D g_strdup(machine->possible_cpus->cpus[i].type); cpu_item->vcpus_count =3D machine->possible_cpus->cpus[i].vcpus_co= unt; cpu_item->props =3D g_memdup(&machine->possible_cpus->cpus[i].prop= s, sizeof(*cpu_item->props)); diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 55686bf5d8..ccc50baa85 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1148,7 +1148,8 @@ void pc_cpus_init(PCMachineState *pcms) pcms->apic_id_limit =3D x86_cpu_apic_id_from_index(max_cpus - 1) + 1; possible_cpus =3D mc->possible_cpu_arch_ids(ms); for (i =3D 0; i < smp_cpus; i++) { - pc_new_cpu(ms->cpu_type, possible_cpus->cpus[i].arch_id, &error_fa= tal); + pc_new_cpu(possible_cpus->cpus[i].type, possible_cpus->cpus[i].arc= h_id, + &error_fatal); } } =20 @@ -2307,6 +2308,7 @@ static const CPUArchIdList *pc_possible_cpu_arch_ids(= MachineState *ms) for (i =3D 0; i < ms->possible_cpus->len; i++) { X86CPUTopoInfo topo; =20 + ms->possible_cpus->cpus[i].type =3D ms->cpu_type; ms->possible_cpus->cpus[i].vcpus_count =3D 1; ms->possible_cpus->cpus[i].arch_id =3D x86_cpu_apic_id_from_index(= i); x86_topo_ids_from_apicid(ms->possible_cpus->cpus[i].arch_id, diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 583fbe483f..8f4d26e1d8 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2186,11 +2186,6 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) int boot_cores_nr =3D smp_cpus / smp_threads; int i; =20 - if (!type) { - error_report("Unable to find sPAPR CPU Core definition"); - exit(1); - } - possible_cpus =3D mc->possible_cpu_arch_ids(machine); if (mc->has_hotpluggable_cpus) { if (smp_cpus % smp_threads) { @@ -3488,6 +3483,7 @@ static int64_t spapr_get_default_cpu_node_id(const Ma= chineState *ms, int idx) static const CPUArchIdList *spapr_possible_cpu_arch_ids(MachineState *mach= ine) { int i; + const char *core_type; int spapr_max_cores =3D max_cpus / smp_threads; MachineClass *mc =3D MACHINE_GET_CLASS(machine); =20 @@ -3499,12 +3495,19 @@ static const CPUArchIdList *spapr_possible_cpu_arch= _ids(MachineState *machine) return machine->possible_cpus; } =20 + core_type =3D spapr_get_cpu_core_type(machine->cpu_type); + if (!core_type) { + error_report("Unable to find sPAPR CPU Core definition"); + exit(1); + } + machine->possible_cpus =3D g_malloc0(sizeof(CPUArchIdList) + sizeof(CPUArchId) * spapr_max_cores); machine->possible_cpus->len =3D spapr_max_cores; for (i =3D 0; i < machine->possible_cpus->len; i++) { int core_id =3D i * smp_threads; =20 + machine->possible_cpus->cpus[i].type =3D core_type; machine->possible_cpus->cpus[i].vcpus_count =3D smp_threads; machine->possible_cpus->cpus[i].arch_id =3D core_id; machine->possible_cpus->cpus[i].props.has_core_id =3D true; diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 35df7e19c5..3807dcb097 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -414,6 +414,7 @@ static const CPUArchIdList *s390_possible_cpu_arch_ids(= MachineState *ms) sizeof(CPUArchId) * max_cpus); ms->possible_cpus->len =3D max_cpus; for (i =3D 0; i < ms->possible_cpus->len; i++) { + ms->possible_cpus->cpus[i].type =3D ms->cpu_type; ms->possible_cpus->cpus[i].vcpus_count =3D 1; ms->possible_cpus->cpus[i].arch_id =3D i; ms->possible_cpus->cpus[i].props.has_core_id =3D true; diff --git a/vl.c b/vl.c index 2586f25952..e725ecbc08 100644 --- a/vl.c +++ b/vl.c @@ -4611,8 +4611,6 @@ int main(int argc, char **argv, char **envp) current_machine->boot_order =3D boot_order; current_machine->cpu_model =3D cpu_model; =20 - parse_numa_opts(current_machine); - /* parse features once if machine provides default cpu_type */ if (machine_class->default_cpu_type) { current_machine->cpu_type =3D machine_class->default_cpu_type; @@ -4621,6 +4619,7 @@ int main(int argc, char **argv, char **envp) cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_m= odel); } } + parse_numa_opts(current_machine); =20 machine_run_board_init(current_machine); =20 --=20 2.14.3