From nobody Wed Nov 5 10:58:05 2025 Return-Path: qemu-devel-bounces+famz=redhat.com@nongnu.org Received: from zmta03.collab.prod.int.phx2.redhat.com (LHLO zmta03.collab.prod.int.phx2.redhat.com) (10.5.81.10) by zmail26.collab.prod.int.phx2.redhat.com with LMTP; Mon, 4 Sep 2017 10:05:34 -0400 (EDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by zmta03.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id 08F3B4564F for ; Mon, 4 Sep 2017 10:05:34 -0400 (EDT) Received: by smtp.corp.redhat.com (Postfix) id 029271252C6; Mon, 4 Sep 2017 14:05:34 +0000 (UTC) Delivered-To: famz@redhat.com Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F0AD31252C8 for ; Mon, 4 Sep 2017 14:05:24 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5F7793F745 for ; Mon, 4 Sep 2017 14:05:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5F7793F745 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=qemu-devel-bounces+famz=redhat.com@nongnu.org DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5F7793F745 Received: from localhost ([::1]:44754 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dos0A-0005aO-He for famz@redhat.com; Mon, 04 Sep 2017 10:05:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48029) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dorwJ-0003g4-Sx for qemu-devel@nongnu.org; Mon, 04 Sep 2017 10:01:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dorwF-00041H-6B for qemu-devel@nongnu.org; Mon, 04 Sep 2017 10:01:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39252) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dorwE-00040D-TQ for qemu-devel@nongnu.org; Mon, 04 Sep 2017 10:01:19 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D9DC93F731; Mon, 4 Sep 2017 14:01:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D9DC93F731 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0B8B820A2; Mon, 4 Sep 2017 14:01:14 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 16:01:00 +0200 Message-Id: <1504533662-198084-5-git-send-email-imammedo@redhat.com> In-Reply-To: <1504533662-198084-1-git-send-email-imammedo@redhat.com> References: <1504533662-198084-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 04 Sep 2017 14:01:18 +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 4/6] vl.c: convert cpu_model to cpu type and set of global properties before machine_init() 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 , Paolo Bonzini , Andrew Jones , Eduardo Habkost , Richard Henderson Errors-To: qemu-devel-bounces+famz=redhat.com@nongnu.org Sender: "Qemu-devel" X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 205 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 04 Sep 2017 14:05:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 04 Sep 2017 14:05:23 +0000 (UTC) for IP:'208.118.235.17' DOMAIN:'lists.gnu.org' HELO:'lists.gnu.org' FROM:'redhat.com@nongnu.org' RCPT:'' X-RedHat-Spam-Score: -5.02 (HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS) 208.118.235.17 lists.gnu.org 208.118.235.17 lists.gnu.org X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Content-Length: 3576 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" All machines that support user specified cpu_model either call cpu_generic_init() or cpu_class_by_name()/CPUClass::parse_features to parse feature string and to get CPU type to create. Which leads to code duplication and hard-codding default CPU model within machine_foo_init() code. Which makes it impossible to get CPU type before machine_init() is run. So instead of setting default CPUs models and doing parsing in target specific machine_foo_init() in various ways, provide a generic data driven cpu_model parsing before machine_init() is called. in follow up per target patches, it will allow to: * define default CPU type in consistent/generic manner per machine type and drop custom code that fallbacks to default if cpu_model is NULL * drop custom features parsing in targets and do it in centralized way. * for cases of cpu_generic_init(TYPE_BASE/DEFAULT_CPU, "some_cpu") replace it with cpu_create(machine->cpu_type) || cpu_create(TYPE_FOO) depending if CPU type is user settable or not. not doing useless parsing and clearly documenting where CPU model is user settable or fixed one. Patch allows machine subclasses to define default CPU type per machine class at class_init() time and if that is set generic code will parse cpu_model into a MachineState::cpu_type which will be used to create CPUs for that machine instance and allows gradual per board conversion. Signed-off-by: Igor Mammedov --- Target specific changes will split into separate per target/machine patches to make changes reviewable. CC: Marcel Apfelbaum CC: Paolo Bonzini CC: Eduardo Habkost --- include/hw/boards.h | 6 ++++++ vl.c | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/hw/boards.h b/include/hw/boards.h index 3363dd1..b8f255a 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -131,6 +131,10 @@ typedef struct { * size than the target architecture's minimum. (Attempting to create * such a CPU will fail.) Note that changing this is a migration * compatibility break for the machine. + * @default_cpu_type: + * specifies default CPU_TYPE, which will be used for parsing target + * specific features and for creating CPUs if CPU name wasn't provided + * explicitly at CLI */ struct MachineClass { /*< private >*/ @@ -167,6 +171,7 @@ struct MachineClass { GArray *compat_props; const char *hw_version; ram_addr_t default_ram_size; + const char *default_cpu_type; bool option_rom_has_mr; bool rom_file_has_mr; int minimum_page_bits; @@ -220,6 +225,7 @@ struct MachineState { char *kernel_cmdline; char *initrd_filename; const char *cpu_model; + const char *cpu_type; AccelState *accelerator; CPUArchIdList *possible_cpus; }; diff --git a/vl.c b/vl.c index 8e247cc..9ae6001 100644 --- a/vl.c +++ b/vl.c @@ -4630,6 +4630,16 @@ int main(int argc, char **argv, char **envp) current_machine->boot_order =3D boot_order; current_machine->cpu_model =3D cpu_model; =20 + + /* 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; + if (cpu_model) { + current_machine->cpu_type =3D + cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_m= odel); + } + } + machine_run_board_init(current_machine); =20 realtime_init(); --=20 2.7.4