From nobody Thu Jul 3 21:12:59 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 1486722131940925.6146719605127; Fri, 10 Feb 2017 02:22:11 -0800 (PST) Received: from localhost ([::1]:42931 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cc8LC-0000NV-Gc for importer@patchew.org; Fri, 10 Feb 2017 05:22:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cc8K9-0008OE-DR for qemu-devel@nongnu.org; Fri, 10 Feb 2017 05:21:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cc8K5-00060G-Bk for qemu-devel@nongnu.org; Fri, 10 Feb 2017 05:21:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44028) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cc8K5-0005zp-2b; Fri, 10 Feb 2017 05:21:01 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (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 3FCCE7FB84; Fri, 10 Feb 2017 10:21:01 +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-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1AAKxbi028682; Fri, 10 Feb 2017 05:20:59 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 10 Feb 2017 11:20:57 +0100 Message-Id: <1486722057-180456-1-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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 10 Feb 2017 10:21:01 +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 v2 8/7] machine: replace query_hotpluggable_cpus() callback with has_hotpluggable_cpus flag 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" Generic helper machine_query_hotpluggable_cpus() replaced target specific query_hotpluggable_cpus() callbacks so there is no need in it anymore. However inon NULL callback value is used to detect/report hotpluggable cpus support, therefore it can be removed completely. Replace it with MachineClass.has_hotpluggable_cpus boolean which is sufficient for the task. Suggested-by: David Gibson Signed-off-by: Igor Mammedov --- CC: David Gibson (supporter:sPAPR) CC: Alexander Graf (supporter:sPAPR) CC: qemu-ppc@nongnu.org=20 CC: Bharata B Rao CC: ehabkost@redhat.com CC: drjones@redhat.com CC: Marcel Apfelbaum --- include/hw/boards.h | 8 +++----- hw/i386/pc.c | 4 ++-- hw/ppc/spapr.c | 20 ++++++++++---------- monitor.c | 4 ++-- vl.c | 2 +- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 9040dbb..269d0ba 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -87,10 +87,8 @@ typedef struct { * Returns an array of @CPUArchId architecture-dependent CPU IDs * which includes CPU IDs for present and possible to hotplug CPUs. * Caller is responsible for freeing returned list. - * @query_hotpluggable_cpus: - * Returns a @HotpluggableCPUList, which describes CPUs objects which - * could be added with -device/device_add. - * Caller is responsible for freeing returned list. + * @has_hotpluggable_cpus: + * If true, board supports CPUs creation with -device/device_add. * @minimum_page_bits: * If non-zero, the board promises never to create a CPU with a page si= ze * smaller than this, so QEMU can use a more efficient larger page @@ -136,12 +134,12 @@ struct MachineClass { bool option_rom_has_mr; bool rom_file_has_mr; int minimum_page_bits; + bool has_hotpluggable_cpus; =20 HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev); unsigned (*cpu_index_to_socket_id)(unsigned cpu_index); const CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine); - HotpluggableCPUList *(*query_hotpluggable_cpus)(MachineState *machine); }; =20 /** diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 548628f..a8660d4 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1949,7 +1949,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, } =20 /* if 'address' properties socket-id/core-id/thread-id are not set, se= t them - * so that query_hotpluggable_cpus would show correct values + * so that machine_query_hotpluggable_cpus would show correct values */ /* TODO: move socket_id/core_id/thread_id checks into x86_cpu_realizef= n() * once -smp refactoring is complete and there will be CPU private @@ -2320,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 machine_query_hotpluggable_cpus; + mc->has_hotpluggable_cpus =3D true; 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 49768eb..6f37288 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -958,7 +958,7 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr, _FDT(spapr_drc_populate_dt(fdt, 0, NULL, SPAPR_DR_CONNECTOR_TYPE_L= MB)); } =20 - if (mc->query_hotpluggable_cpus) { + if (mc->has_hotpluggable_cpus) { int offset =3D fdt_path_offset(fdt, "/cpus"); ret =3D spapr_drc_populate_dt(fdt, offset, NULL, SPAPR_DR_CONNECTOR_TYPE_CPU); @@ -1781,7 +1781,7 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) } =20 possible_cpus =3D mc->possible_cpu_arch_ids(machine); - if (mc->query_hotpluggable_cpus) { + if (mc->has_hotpluggable_cpus) { if (smp_cpus % smp_threads) { error_report("smp_cpus (%u) must be multiple of threads (%u)", smp_cpus, smp_threads); @@ -1803,7 +1803,7 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) for (i =3D 0; i < possible_cpus->len; i++) { int core_id =3D i * smp_threads; =20 - if (mc->query_hotpluggable_cpus) { + if (mc->has_hotpluggable_cpus) { sPAPRDRConnector *drc =3D spapr_dr_connector_new(OBJECT(spapr), SPAPR_DR_CONNECTOR_TYPE_CPU, @@ -2575,7 +2575,7 @@ static void spapr_core_plug(HotplugHandler *hotplug_d= ev, DeviceState *dev, } drc =3D spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, index * = smt); =20 - g_assert(drc || !mc->query_hotpluggable_cpus); + g_assert(drc || !mc->has_hotpluggable_cpus); =20 /* * Setup CPU DT entries only for hotplugged CPUs. For boot time or @@ -2626,7 +2626,7 @@ static void spapr_core_pre_plug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, CPUArchId *core_slot; int index; =20 - if (dev->hotplugged && !mc->query_hotpluggable_cpus) { + if (dev->hotplugged && !mc->has_hotpluggable_cpus) { error_setg(&local_err, "CPU hotplug not supported for this machine= "); goto out; } @@ -2719,7 +2719,7 @@ static void spapr_machine_device_unplug(HotplugHandle= r *hotplug_dev, error_setg(errp, "Memory hot unplug not supported for this gue= st"); } } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) { - if (!mc->query_hotpluggable_cpus) { + if (!mc->has_hotpluggable_cpus) { error_setg(errp, "CPU hot unplug not supported on this machine= "); return; } @@ -2746,7 +2746,7 @@ static void spapr_machine_device_unplug_request(Hotpl= ugHandler *hotplug_dev, error_setg(errp, "Memory hot unplug not supported for this gue= st"); } } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) { - if (!mc->query_hotpluggable_cpus) { + if (!mc->has_hotpluggable_cpus) { error_setg(errp, "CPU hot unplug not supported on this machine= "); return; } @@ -2785,7 +2785,7 @@ static const CPUArchIdList *spapr_possible_cpu_arch_i= ds(MachineState *machine) int spapr_max_cores =3D max_cpus / smp_threads; MachineClass *mc =3D MACHINE_GET_CLASS(machine); =20 - if (!mc->query_hotpluggable_cpus) { + if (!mc->has_hotpluggable_cpus) { spapr_max_cores =3D QEMU_ALIGN_UP(smp_cpus, smp_threads) / smp_thr= eads; } if (machine->possible_cpus) { @@ -2897,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 machine_query_hotpluggable_cpus; + mc->has_hotpluggable_cpus =3D true; fwc->get_dev_path =3D spapr_get_fw_dev_path; nc->nmi_monitor_handler =3D spapr_nmi; smc->phb_placement =3D spapr_phb_placement; @@ -3097,7 +3097,7 @@ static void spapr_machine_2_6_instance_options(Machin= eState *machine) static void spapr_machine_2_6_class_options(MachineClass *mc) { spapr_machine_2_7_class_options(mc); - mc->query_hotpluggable_cpus =3D NULL; + mc->has_hotpluggable_cpus =3D false; SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_6); } =20 diff --git a/monitor.c b/monitor.c index 3cd72a9..18bf2f8 100644 --- a/monitor.c +++ b/monitor.c @@ -4155,10 +4155,10 @@ HotpluggableCPUList *qmp_query_hotpluggable_cpus(Er= ror **errp) MachineState *ms =3D MACHINE(qdev_get_machine()); MachineClass *mc =3D MACHINE_GET_CLASS(ms); =20 - if (!mc->query_hotpluggable_cpus) { + if (!mc->has_hotpluggable_cpus) { error_setg(errp, QERR_FEATURE_DISABLED, "query-hotpluggable-cpus"); return NULL; } =20 - return mc->query_hotpluggable_cpus(ms); + return machine_query_hotpluggable_cpus(ms); } diff --git a/vl.c b/vl.c index b4eaf03..93406ba 100644 --- a/vl.c +++ b/vl.c @@ -1519,7 +1519,7 @@ MachineInfoList *qmp_query_machines(Error **errp) =20 info->name =3D g_strdup(mc->name); info->cpu_max =3D !mc->max_cpus ? 1 : mc->max_cpus; - info->hotpluggable_cpus =3D !!mc->query_hotpluggable_cpus; + info->hotpluggable_cpus =3D mc->has_hotpluggable_cpus; =20 entry =3D g_malloc0(sizeof(*entry)); entry->value =3D info; --=20 2.7.4