From nobody Thu Jul 3 18:42:19 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.zoho.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 1486639146086976.912316970514; Thu, 9 Feb 2017 03:19:06 -0800 (PST) Received: from localhost ([::1]:37039 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbmki-0000t2-Bk for importer@patchew.org; Thu, 09 Feb 2017 06:19:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbmaw-0001m6-Qb for qemu-devel@nongnu.org; Thu, 09 Feb 2017 06:09:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cbmav-0004Nx-BM for qemu-devel@nongnu.org; Thu, 09 Feb 2017 06:08:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36864) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cbmau-0004MG-Kv; Thu, 09 Feb 2017 06:08:57 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DEFA3C0016A9; Thu, 9 Feb 2017 11:08:56 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v19B8e73022393; Thu, 9 Feb 2017 06:08:55 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 9 Feb 2017 12:08:38 +0100 Message-Id: <1486638518-171446-8-git-send-email-imammedo@redhat.com> In-Reply-To: <1486638518-171446-1-git-send-email-imammedo@redhat.com> References: <1486638518-171446-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 09 Feb 2017 11:08:56 +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] [PATCH 7/7] machine: unify [pc_|spapr_]query_hotpluggable_cpus() callbacks 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: drjones@redhat.com, ehabkost@redhat.com, Alexander Graf , qemu-ppc@nongnu.org, Bharata B Rao , Marcel Apfelbaum , David Gibson 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" All callbacks FOO_query_hotpluggable_cpus() are practically the same except of setting vcpus_count to different values. Convert them to a generic machine_query_hotpluggable_cpus() callback by moving vcpus_count initialization to per machine specific callback possible_cpu_arch_ids(). Signed-off-by: Igor Mammedov Reviewed-by: David Gibson --- include/hw/boards.h | 3 +++ hw/core/machine.c | 31 +++++++++++++++++++++++++++++++ hw/i386/pc.c | 36 ++---------------------------------- hw/ppc/spapr.c | 34 ++-------------------------------- 4 files changed, 38 insertions(+), 66 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 60209df..9040dbb 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -41,15 +41,18 @@ int machine_phandle_start(MachineState *machine); bool machine_dump_guest_core(MachineState *machine); bool machine_mem_merge(MachineState *machine); void machine_register_compat_props(MachineState *machine); +HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine= ); =20 /** * 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 * @props - CPU object properties, initialized by board + * #vcpus_count - number of threads provided by @cpu object */ typedef struct { uint64_t arch_id; + int64_t vcpus_count; CpuInstanceProperties props; Object *cpu; } CPUArchId; diff --git a/hw/core/machine.c b/hw/core/machine.c index b0fd91f..0699750 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -357,6 +357,37 @@ static void machine_init_notify(Notifier *notifier, vo= id *data) foreach_dynamic_sysbus_device(error_on_sysbus_device, NULL); } =20 +HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine) +{ + int i; + Object *cpu; + HotpluggableCPUList *head =3D NULL; + const char *cpu_type; + + 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++) { + HotpluggableCPUList *list_item =3D g_new0(typeof(*list_item), 1); + HotpluggableCPU *cpu_item =3D g_new0(typeof(*cpu_item), 1); + + cpu_item->type =3D g_strdup(cpu_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)); + + cpu =3D machine->possible_cpus->cpus[i].cpu; + if (cpu) { + cpu_item->has_qom_path =3D true; + cpu_item->qom_path =3D object_get_canonical_path(cpu); + } + list_item->value =3D cpu_item; + list_item->next =3D head; + head =3D list_item; + } + return head; +} + static void machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); diff --git a/hw/i386/pc.c b/hw/i386/pc.c index afaae15..548628f 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2266,6 +2266,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].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, smp_cores, smp_threads, &topo); @@ -2279,39 +2280,6 @@ static const CPUArchIdList *pc_possible_cpu_arch_ids= (MachineState *ms) return ms->possible_cpus; } =20 -static HotpluggableCPUList *pc_query_hotpluggable_cpus(MachineState *machi= ne) -{ - int i; - Object *cpu; - HotpluggableCPUList *head =3D NULL; - const char *cpu_type; - - cpu =3D machine->possible_cpus->cpus[0].cpu; - assert(cpu); /* BSP is always present */ - cpu_type =3D object_get_typename(cpu); - - for (i =3D 0; i < machine->possible_cpus->len; i++) { - HotpluggableCPUList *list_item =3D g_new0(typeof(*list_item), 1); - HotpluggableCPU *cpu_item =3D g_new0(typeof(*cpu_item), 1); - - cpu_item->type =3D g_strdup(cpu_type); - cpu_item->vcpus_count =3D 1; - cpu_item->props =3D g_memdup(&machine->possible_cpus->cpus[i].prop= s, - sizeof(*cpu_item->props)); - - cpu =3D machine->possible_cpus->cpus[i].cpu; - if (cpu) { - cpu_item->has_qom_path =3D true; - cpu_item->qom_path =3D object_get_canonical_path(cpu); - } - - list_item->value =3D cpu_item; - list_item->next =3D head; - head =3D list_item; - } - return head; -} - static void x86_nmi(NMIState *n, int cpu_index, Error **errp) { /* cpu index isn't used */ @@ -2352,7 +2320,7 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) mc->get_hotplug_handler =3D pc_get_hotpug_handler; mc->cpu_index_to_socket_id =3D pc_cpu_index_to_socket_id; mc->possible_cpu_arch_ids =3D pc_possible_cpu_arch_ids; - mc->query_hotpluggable_cpus =3D pc_query_hotpluggable_cpus; + mc->query_hotpluggable_cpus =3D machine_query_hotpluggable_cpus; mc->default_boot_order =3D "cad"; mc->hot_add_cpu =3D pc_hot_add_cpu; mc->max_cpus =3D 255; diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 8d039ae..3c4d632 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2799,6 +2799,7 @@ static const CPUArchIdList *spapr_possible_cpu_arch_i= ds(MachineState *machine) for (i =3D 0; i < machine->possible_cpus->len; i++) { int core_id =3D i * smp_threads; =20 + 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; machine->possible_cpus->cpus[i].props.core_id =3D core_id; @@ -2808,37 +2809,6 @@ static const CPUArchIdList *spapr_possible_cpu_arch_= ids(MachineState *machine) return machine->possible_cpus; } =20 -static HotpluggableCPUList *spapr_query_hotpluggable_cpus(MachineState *ma= chine) -{ - int i; - Object *cpu; - HotpluggableCPUList *head =3D NULL; - const char *cpu_type; - - 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++) { - HotpluggableCPUList *list_item =3D g_new0(typeof(*list_item), 1); - HotpluggableCPU *cpu_item =3D g_new0(typeof(*cpu_item), 1); - - cpu_item->type =3D g_strdup(cpu_type); - cpu_item->vcpus_count =3D smp_threads; // TODO: ??? generalize - cpu_item->props =3D g_memdup(&machine->possible_cpus->cpus[i].prop= s, - sizeof(*cpu_item->props)); - - cpu =3D machine->possible_cpus->cpus[i].cpu; - if (cpu) { - cpu_item->has_qom_path =3D true; - cpu_item->qom_path =3D object_get_canonical_path(cpu); - } - list_item->value =3D cpu_item; - list_item->next =3D head; - head =3D list_item; - } - return head; -} - static void spapr_phb_placement(sPAPRMachineState *spapr, uint32_t index, uint64_t *buid, hwaddr *pio, hwaddr *mmio32, hwaddr *mmio64, @@ -2927,7 +2897,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) =20 smc->dr_lmb_enabled =3D true; smc->tcg_default_cpu =3D "POWER8"; - mc->query_hotpluggable_cpus =3D spapr_query_hotpluggable_cpus; + mc->query_hotpluggable_cpus =3D machine_query_hotpluggable_cpus; fwc->get_dev_path =3D spapr_get_fw_dev_path; nc->nmi_monitor_handler =3D spapr_nmi; smc->phb_placement =3D spapr_phb_placement; --=20 2.7.4