From nobody Wed May 1 07:23:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555470160; cv=none; d=zoho.com; s=zohoarc; b=lvgMnWEXtqL+g2FuQCoBKgGYcroEvLyfPIYoO1dlCCF3ltNxYPXAkaXIeN9WbQL2f3vXvY4MEyx2pNsl+p7r1iSX1J9hLF9wa4UX9RGHFzYwqrXIyNXzN3JfNfgWPpVHBX7gjQFu0q5VbWHGU2G7KuGYnZpPXiuzetC15gKEjAU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555470160; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=JJ9cbKdy5OgNmIJLFc6cZq7dcM9z8Dumy1a0nquFXVk=; b=PYHRCK2yQbOEG33yAkRhKqZjd3BUn/Ukfe36VyhW+BxBFe4VioXD2qOau6a16Smqm2maBctKJhmkUXv2v96kZltioRG319wVQJMsXoJ7AaaJh+drZ5fmhtAbXOqNW37sZtf0isWLTBjIF6rFtndE/EB2+x4/uf6HJau4ducAuks= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555470160742897.808688816631; Tue, 16 Apr 2019 20:02:40 -0700 (PDT) Received: from localhost ([127.0.0.1]:45928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGaqL-0004G8-Ka for importer@patchew.org; Tue, 16 Apr 2019 23:02:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58062) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGanh-0002k9-4y for qemu-devel@nongnu.org; Tue, 16 Apr 2019 22:59:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGanf-0007il-Up for qemu-devel@nongnu.org; Tue, 16 Apr 2019 22:59:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14063) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGanf-0007hy-IW; Tue, 16 Apr 2019 22:59:51 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BE5CA3082133; Wed, 17 Apr 2019 02:59:50 +0000 (UTC) Received: from localhost (ovpn-116-9.gru2.redhat.com [10.97.116.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 321D31001E65; Wed, 17 Apr 2019 02:59:50 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Tue, 16 Apr 2019 23:59:40 -0300 Message-Id: <20190417025944.16154-2-ehabkost@redhat.com> In-Reply-To: <20190417025944.16154-1-ehabkost@redhat.com> References: <20190417025944.16154-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 17 Apr 2019 02:59:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/5] cpu: Rename parse_cpu_model() to parse_cpu_option() 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: Peter Maydell , Thomas Huth , Eduardo Habkost , Like Xu , Riku Voipio , Mark Cave-Ayland , Laurent Vivier , Markus Armbruster , qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The "model[,option...]" string parsed by the function is not just a CPU model. Rename the function and its argument to indicate it expects the full "-cpu" option to be provided. Signed-off-by: Eduardo Habkost Reviewed-by: David Gibson Reviewed-by: Igor Mammedov Reviewed-by: Markus Armbruster --- include/qom/cpu.h | 6 +++--- bsd-user/main.c | 2 +- exec.c | 4 ++-- linux-user/main.c | 2 +- vl.c | 18 +++++++++--------- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 1d6099e5d4..d28c690b27 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -689,15 +689,15 @@ ObjectClass *cpu_class_by_name(const char *typename, = const char *cpu_model); CPUState *cpu_create(const char *typename); =20 /** - * parse_cpu_model: - * @cpu_model: The model string including optional parameters. + * parse_cpu_option: + * @cpu_option: The -cpu option including optional parameters. * * processes optional parameters and registers them as global properties * * Returns: type of CPU to create or prints error and terminates process * if an error occurred. */ -const char *parse_cpu_model(const char *cpu_model); +const char *parse_cpu_option(const char *cpu_option); =20 /** * cpu_has_work: diff --git a/bsd-user/main.c b/bsd-user/main.c index 0d3156974c..a6c055f5fb 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -903,7 +903,7 @@ int main(int argc, char **argv) /* init tcg before creating CPUs and to get qemu_host_page_size */ tcg_exec_init(0); =20 - cpu_type =3D parse_cpu_model(cpu_model); + cpu_type =3D parse_cpu_option(cpu_model); cpu =3D cpu_create(cpu_type); env =3D cpu->env_ptr; #if defined(TARGET_SPARC) || defined(TARGET_PPC) diff --git a/exec.c b/exec.c index 6ab62f4eee..840677f15f 100644 --- a/exec.c +++ b/exec.c @@ -982,14 +982,14 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) #endif } =20 -const char *parse_cpu_model(const char *cpu_model) +const char *parse_cpu_option(const char *cpu_option) { ObjectClass *oc; CPUClass *cc; gchar **model_pieces; const char *cpu_type; =20 - model_pieces =3D g_strsplit(cpu_model, ",", 2); + model_pieces =3D g_strsplit(cpu_option, ",", 2); =20 oc =3D cpu_class_by_name(CPU_RESOLVING_TYPE, model_pieces[0]); if (oc =3D=3D NULL) { diff --git a/linux-user/main.c b/linux-user/main.c index a0aba9cb1e..20e0f51cfa 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -660,7 +660,7 @@ int main(int argc, char **argv, char **envp) if (cpu_model =3D=3D NULL) { cpu_model =3D cpu_get_model(get_elf_eflags(execfd)); } - cpu_type =3D parse_cpu_model(cpu_model); + cpu_type =3D parse_cpu_option(cpu_model); =20 /* init tcg before creating CPUs and to get qemu_host_page_size */ tcg_exec_init(0); diff --git a/vl.c b/vl.c index c696ad2a13..c57e28d1da 100644 --- a/vl.c +++ b/vl.c @@ -3002,7 +3002,7 @@ int main(int argc, char **argv, char **envp) const char *optarg; const char *loadvm =3D NULL; MachineClass *machine_class; - const char *cpu_model; + const char *cpu_option; const char *vga_model =3D NULL; const char *qtest_chrdev =3D NULL; const char *qtest_log =3D NULL; @@ -3081,7 +3081,7 @@ int main(int argc, char **argv, char **envp) QLIST_INIT (&vm_change_state_head); os_setup_early_signal_handling(); =20 - cpu_model =3D NULL; + cpu_option =3D NULL; snapshot =3D 0; =20 nb_nics =3D 0; @@ -3133,7 +3133,7 @@ int main(int argc, char **argv, char **envp) switch(popt->index) { case QEMU_OPTION_cpu: /* hw initialization will check this */ - cpu_model =3D optarg; + cpu_option =3D optarg; break; case QEMU_OPTION_hda: case QEMU_OPTION_hdb: @@ -4050,8 +4050,8 @@ int main(int argc, char **argv, char **envp) qemu_set_hw_version(machine_class->hw_version); } =20 - if (cpu_model && is_help_option(cpu_model)) { - list_cpus(stdout, &fprintf, cpu_model); + if (cpu_option && is_help_option(cpu_option)) { + list_cpus(stdout, &fprintf, cpu_option); exit(0); } =20 @@ -4299,9 +4299,9 @@ int main(int argc, char **argv, char **envp) * Global properties get set up by qdev_prop_register_global(), * called from user_register_global_props(), and certain option * desugaring. Also in CPU feature desugaring (buried in - * parse_cpu_model()), which happens below this point, but may + * parse_cpu_option()), which happens below this point, but may * only target the CPU type, which can only be created after - * parse_cpu_model() returned the type. + * parse_cpu_option() returned the type. * * Machine compat properties: object_set_machine_compat_props(). * Accelerator compat props: object_set_accelerator_compat_props(), @@ -4465,8 +4465,8 @@ int main(int argc, char **argv, char **envp) =20 /* parse features once if machine provides default cpu_type */ current_machine->cpu_type =3D machine_class->default_cpu_type; - if (cpu_model) { - current_machine->cpu_type =3D parse_cpu_model(cpu_model); + if (cpu_option) { + current_machine->cpu_type =3D parse_cpu_option(cpu_option); } parse_numa_opts(current_machine); =20 --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Wed May 1 07:23:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555470150; cv=none; d=zoho.com; s=zohoarc; b=VPvglUdWqDiVd2OcS4fP7ibDbIGbj4oUj2ZnA5mmIZK0i4r6tQE5E1MWmN9uofadh7uerlYo/wsx4U3710PursRkgxdRD9WzKFjyFNdHMWyEZQmea7dKY+Q1a1PHJqR6soQ6W484Bj4VeLzogsvCN2VNBX4FEQl5l7HCRWqI5WE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555470150; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=uSnOmWSKvCPsuxrrOvXHZVfkmQn+cyut2ZMMpL1BJ/Y=; b=KFk6MjZ9DwIBbfTonX5Vhqi9MSJRIobIu2hYplVOmAyBS5djDhvwuxW0/WegMBFTMKj5CDgbff5FM15fWpIvM0O/rjVoR45FXnkqj3elzLH75IlS8moiyCaZdGTRJtpVxq88kkMvr2qFin38jBktVHyMHZvDMTnZGM2zdC6aIMA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15554701505801014.6886146288113; Tue, 16 Apr 2019 20:02:30 -0700 (PDT) Received: from localhost ([127.0.0.1]:45926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGaq7-00044S-Cp for importer@patchew.org; Tue, 16 Apr 2019 23:02:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGank-0002lb-6u for qemu-devel@nongnu.org; Tue, 16 Apr 2019 22:59:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGanh-0007k0-P7 for qemu-devel@nongnu.org; Tue, 16 Apr 2019 22:59:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47666) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGanh-0007jE-I9; Tue, 16 Apr 2019 22:59:53 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A75813084212; Wed, 17 Apr 2019 02:59:52 +0000 (UTC) Received: from localhost (ovpn-116-9.gru2.redhat.com [10.97.116.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 330C05D707; Wed, 17 Apr 2019 02:59:52 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Tue, 16 Apr 2019 23:59:41 -0300 Message-Id: <20190417025944.16154-3-ehabkost@redhat.com> In-Reply-To: <20190417025944.16154-1-ehabkost@redhat.com> References: <20190417025944.16154-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 17 Apr 2019 02:59:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/5] cpu: Extract CPU class lookup from parse_cpu_option() 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: Peter Maydell , Thomas Huth , Eduardo Habkost , Like Xu , Riku Voipio , Mark Cave-Ayland , Laurent Vivier , Markus Armbruster , qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The new function will be useful in user mode, when we already have a CPU model and don't need to parse any extra options. Signed-off-by: Eduardo Habkost Reviewed-by: David Gibson Reviewed-by: Markus Armbruster --- include/qom/cpu.h | 9 +++++++++ exec.c | 22 ++++++++++++---------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index d28c690b27..e11b14d9ac 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -699,6 +699,15 @@ CPUState *cpu_create(const char *typename); */ const char *parse_cpu_option(const char *cpu_option); =20 +/** + * lookup_cpu_class: + * @cpu_model: CPU model name + * + * Look up CPU class corresponding to a given CPU model name. + */ +CPUClass *lookup_cpu_class(const char *cpu_model, Error **errp); + + /** * cpu_has_work: * @cpu: The vCPU to check. diff --git a/exec.c b/exec.c index 840677f15f..d359e709a6 100644 --- a/exec.c +++ b/exec.c @@ -982,24 +982,26 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) #endif } =20 +CPUClass *lookup_cpu_class(const char *cpu_model, Error **errp) +{ + ObjectClass *oc =3D cpu_class_by_name(CPU_RESOLVING_TYPE, cpu_model); + if (oc =3D=3D NULL) { + error_setg(errp, "unable to find CPU model '%s'", cpu_model); + return NULL; + } + return CPU_CLASS(oc); +} + const char *parse_cpu_option(const char *cpu_option) { - ObjectClass *oc; CPUClass *cc; gchar **model_pieces; const char *cpu_type; =20 model_pieces =3D g_strsplit(cpu_option, ",", 2); =20 - oc =3D cpu_class_by_name(CPU_RESOLVING_TYPE, model_pieces[0]); - if (oc =3D=3D NULL) { - error_report("unable to find CPU model '%s'", model_pieces[0]); - g_strfreev(model_pieces); - exit(EXIT_FAILURE); - } - - cpu_type =3D object_class_get_name(oc); - cc =3D CPU_CLASS(oc); + cc =3D lookup_cpu_class(model_pieces[0], &error_fatal); + cpu_type =3D object_class_get_name(OBJECT_CLASS(cc)); cc->parse_features(cpu_type, model_pieces[1], &error_fatal); g_strfreev(model_pieces); return cpu_type; --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Wed May 1 07:23:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555470225; cv=none; d=zoho.com; s=zohoarc; b=iTLiWPFV9kKxzFxXzC4XOiFS7lVkZ2g8pYHDXrbYrTzO2yKXnE32iD6uQLDbccGxsc2sN9SHk86SnZmisBkHYnlSnmiKv3A0GKwF6bgv+9KBRrukqX5pCiIQQQqLhwwQahizL+0I88d/kWc5NEALjWqzbYTweo5Ltq3kqLxbIU0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555470225; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=zCYaQ/EW0g0Z+lUWjEegLdNBd0/I3ZTmXXyL4RvL1vs=; b=XdBt1S6vsZdzI2NxCD+K93nkyHea7mg7Z+09xQ2/N/sPYT0iCJYB2AFR60+Xw8PmJJcOkW/JxOHZr4VCdrh45kZ6vu/LcBdUycLvg8/7VLoJyX4WX+9mYJeKVjQiCFiHxfzlTL06ZVnslDLHNi0cBhCVkvHv7+E2QTBr+X6tZEs= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555470225072233.9906772104465; Tue, 16 Apr 2019 20:03:45 -0700 (PDT) Received: from localhost ([127.0.0.1]:45930 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGarJ-0004xL-3Q for importer@patchew.org; Tue, 16 Apr 2019 23:03:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58106) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGanm-0002nd-6O for qemu-devel@nongnu.org; Tue, 16 Apr 2019 22:59:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGanl-0007lq-CC for qemu-devel@nongnu.org; Tue, 16 Apr 2019 22:59:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51430) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGank-0007kX-5S; Tue, 16 Apr 2019 22:59:56 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 88D0A307D910; Wed, 17 Apr 2019 02:59:54 +0000 (UTC) Received: from localhost (ovpn-116-9.gru2.redhat.com [10.97.116.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 166E85D707; Wed, 17 Apr 2019 02:59:53 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Tue, 16 Apr 2019 23:59:42 -0300 Message-Id: <20190417025944.16154-4-ehabkost@redhat.com> In-Reply-To: <20190417025944.16154-1-ehabkost@redhat.com> References: <20190417025944.16154-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 17 Apr 2019 02:59:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/5] linux-user: Use lookup_cpu_class() 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: Peter Maydell , Thomas Huth , Eduardo Habkost , Like Xu , Riku Voipio , Mark Cave-Ayland , Laurent Vivier , Markus Armbruster , qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The return value of cpu_get_model() is just a CPU model name and never includes extra options. We don't need to call parse_cpu_option(). Signed-off-by: Eduardo Habkost Reviewed-by: David Gibson Reviewed-by: Markus Armbruster --- linux-user/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/linux-user/main.c b/linux-user/main.c index 20e0f51cfa..d74108e05c 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -592,6 +592,7 @@ int main(int argc, char **argv, char **envp) TaskState *ts; CPUArchState *env; CPUState *cpu; + CPUClass *cc; int optind; char **target_environ, **wrk; char **target_argv; @@ -660,7 +661,8 @@ int main(int argc, char **argv, char **envp) if (cpu_model =3D=3D NULL) { cpu_model =3D cpu_get_model(get_elf_eflags(execfd)); } - cpu_type =3D parse_cpu_option(cpu_model); + cc =3D lookup_cpu_class(cpu_model, &error_fatal); + cpu_type =3D object_class_get_name(OBJECT_CLASS(cc)); =20 /* init tcg before creating CPUs and to get qemu_host_page_size */ tcg_exec_init(0); --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Wed May 1 07:23:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555470312; cv=none; d=zoho.com; s=zohoarc; b=NePC90xVkR3KuMnt2kLgKmKAnWfM0hFdj3GSzFjAepxyoj5lbWJ87d9nPms7m0ar83Q10luk2gOnA6aCLW02DzxIVIEFaQQmZoLBqUnsKMSnVyDxfYar2jM6TJz68BC8IpeHhEeGcR4wnMdBF4CEWdkTjPbYk9A54lWDaNX2Y4I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555470312; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=zUBziI/cTnko9D5CPn7awJ0VF1yLsAkknfn3PVmdLSY=; b=BrVdB21kfz0j7ZL0RLtWlCXFYjcZ9rWNiLoQz2Mw8yLEM7R2Il9ud7TctRiI5A+xB66951ORzArPOMjD2j0+uZM6OaAkFB1fzam3cVykbB1nQcm5AvrYFTtuVgNXPNzvG0Omfsik5i1PCcRL/+IiRWyr6rc2zMUYeweK81cupKE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555470312322379.9732179195637; Tue, 16 Apr 2019 20:05:12 -0700 (PDT) Received: from localhost ([127.0.0.1]:45954 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGasn-0006Ci-ER for importer@patchew.org; Tue, 16 Apr 2019 23:05:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58123) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGano-0002pP-0V for qemu-devel@nongnu.org; Tue, 16 Apr 2019 23:00:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGanm-0007me-Rd for qemu-devel@nongnu.org; Tue, 16 Apr 2019 22:59:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40744) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGanm-0007lT-4k; Tue, 16 Apr 2019 22:59:58 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7CFA43DE10; Wed, 17 Apr 2019 02:59:56 +0000 (UTC) Received: from localhost (ovpn-116-9.gru2.redhat.com [10.97.116.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09EB519C67; Wed, 17 Apr 2019 02:59:55 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Tue, 16 Apr 2019 23:59:43 -0300 Message-Id: <20190417025944.16154-5-ehabkost@redhat.com> In-Reply-To: <20190417025944.16154-1-ehabkost@redhat.com> References: <20190417025944.16154-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 17 Apr 2019 02:59:56 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 4/5] bsd-user: Use lookup_cpu_class() 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: Peter Maydell , Thomas Huth , Eduardo Habkost , Like Xu , Riku Voipio , Mark Cave-Ayland , Laurent Vivier , Markus Armbruster , qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The hardcoded CPU models in the code are just CPU models and don't include any extra options. We don't need to call parse_cpu_options(). Signed-off-by: Eduardo Habkost Reviewed-by: David Gibson Reviewed-by: Markus Armbruster --- bsd-user/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index a6c055f5fb..d2915a9951 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -732,6 +732,7 @@ int main(int argc, char **argv) TaskState ts1, *ts =3D &ts1; CPUArchState *env; CPUState *cpu; + CPUClass *cc; int optind; const char *r; int gdbstub_port =3D 0; @@ -903,7 +904,8 @@ int main(int argc, char **argv) /* init tcg before creating CPUs and to get qemu_host_page_size */ tcg_exec_init(0); =20 - cpu_type =3D parse_cpu_option(cpu_model); + cc =3D lookup_cpu_class(cpu_model, &error_fatal); + cpu_type =3D object_class_get_name(OBJECT_CLASS(cc)); cpu =3D cpu_create(cpu_type); env =3D cpu->env_ptr; #if defined(TARGET_SPARC) || defined(TARGET_PPC) --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Wed May 1 07:23:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555470361; cv=none; d=zoho.com; s=zohoarc; b=f+RKEdMMTlH01N/FDDnr4Q6QP52CCN0sqqQ0LzUVXnpnSIDUMtB+PzSR8IjaKawwgOn63+8Arl8Q1hyocNP6TwTStGBoWtnGiF7hq0zOeYwkIsVIS8zPOewg1VP0JXRVG7MUbz6kingIO8A5ZhGC1HFMrE2uKnX1skgtMkTYSQw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555470361; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=JXQaT5PySexffrrbgK28dLWz6wkgKnkHXBdqAd7L6vY=; b=c2KHGah3Yn+FVXpa8VmnC0Xj5ceqD1BHW3u+1O9rLWUxhlCZJD75Ut/bnurXTKfYHnNe6nv+PjPYiyb22hJZLeDIAARTni60nakHyKeDTGKeLo1tHA+/kKsDNsvhaj9Oz1ngMDcUSwohYAygrdkzVowJuoSM1Z62MhZnA523ad8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555470361559564.1733897356739; Tue, 16 Apr 2019 20:06:01 -0700 (PDT) Received: from localhost ([127.0.0.1]:45983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGatT-0006Wb-9e for importer@patchew.org; Tue, 16 Apr 2019 23:05:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGans-0002uT-60 for qemu-devel@nongnu.org; Tue, 16 Apr 2019 23:00:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGanp-0007o4-3d for qemu-devel@nongnu.org; Tue, 16 Apr 2019 23:00:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35816) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGann-0007mY-VJ; Tue, 16 Apr 2019 23:00:00 -0400 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 7DFCE3081244; Wed, 17 Apr 2019 02:59:58 +0000 (UTC) Received: from localhost (ovpn-116-9.gru2.redhat.com [10.97.116.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDF6F608A4; Wed, 17 Apr 2019 02:59:57 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Tue, 16 Apr 2019 23:59:44 -0300 Message-Id: <20190417025944.16154-6-ehabkost@redhat.com> In-Reply-To: <20190417025944.16154-1-ehabkost@redhat.com> References: <20190417025944.16154-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.49]); Wed, 17 Apr 2019 02:59:58 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 5/5] cpu: Add MachineState parameter to parse_features() 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: Peter Maydell , Thomas Huth , Eduardo Habkost , Like Xu , Riku Voipio , Mark Cave-Ayland , Laurent Vivier , Markus Armbruster , qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The ppc implementation of parse_features() requires the machine object to be created before it gets called. This is far from obvious when reading the code at main(). Instead of making it call qdev_get_machine(), require the caller of parse_cpu_option() to provide the machine object. This makes the initialization dependency explicit at main(), and will let us move qdev_get_machine() to CONFIG_SOFTMMU in the future. Signed-off-by: Eduardo Habkost Acked-by: David Gibson Reviewed-by: David Gibson Reviewed-by: Markus Armbruster --- include/qom/cpu.h | 5 +++-- target/ppc/cpu-qom.h | 3 ++- exec.c | 4 ++-- qom/cpu.c | 3 ++- target/i386/cpu.c | 3 ++- target/ppc/translate_init.inc.c | 7 ++++--- target/sparc/cpu.c | 3 ++- vl.c | 3 ++- 8 files changed, 19 insertions(+), 12 deletions(-) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index e11b14d9ac..cbc8e103bb 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -164,7 +164,8 @@ typedef struct CPUClass { /*< public >*/ =20 ObjectClass *(*class_by_name)(const char *cpu_model); - void (*parse_features)(const char *typename, char *str, Error **errp); + void (*parse_features)(MachineState *machine, const char *typename, + char *str, Error **errp); =20 void (*reset)(CPUState *cpu); int reset_dump_flags; @@ -697,7 +698,7 @@ CPUState *cpu_create(const char *typename); * Returns: type of CPU to create or prints error and terminates process * if an error occurred. */ -const char *parse_cpu_option(const char *cpu_option); +const char *parse_cpu_option(MachineState *machine, const char *cpu_option= ); =20 /** * lookup_cpu_class: diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index be9b4c30c3..7891465554 100644 --- a/target/ppc/cpu-qom.h +++ b/target/ppc/cpu-qom.h @@ -167,7 +167,8 @@ typedef struct PowerPCCPUClass { DeviceRealize parent_realize; DeviceUnrealize parent_unrealize; void (*parent_reset)(CPUState *cpu); - void (*parent_parse_features)(const char *type, char *str, Error **err= p); + void (*parent_parse_features)(MachineState *machine, const char *type, + char *str, Error **errp); =20 uint32_t pvr; bool (*pvr_match)(struct PowerPCCPUClass *pcc, uint32_t pvr); diff --git a/exec.c b/exec.c index d359e709a6..1ca95df9d8 100644 --- a/exec.c +++ b/exec.c @@ -992,7 +992,7 @@ CPUClass *lookup_cpu_class(const char *cpu_model, Error= **errp) return CPU_CLASS(oc); } =20 -const char *parse_cpu_option(const char *cpu_option) +const char *parse_cpu_option(MachineState *machine, const char *cpu_option) { CPUClass *cc; gchar **model_pieces; @@ -1002,7 +1002,7 @@ const char *parse_cpu_option(const char *cpu_option) =20 cc =3D lookup_cpu_class(model_pieces[0], &error_fatal); cpu_type =3D object_class_get_name(OBJECT_CLASS(cc)); - cc->parse_features(cpu_type, model_pieces[1], &error_fatal); + cc->parse_features(machine, cpu_type, model_pieces[1], &error_fatal); g_strfreev(model_pieces); return cpu_type; } diff --git a/qom/cpu.c b/qom/cpu.c index a8d2958956..c8a7b56148 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -291,7 +291,8 @@ ObjectClass *cpu_class_by_name(const char *typename, co= nst char *cpu_model) return cc->class_by_name(cpu_model); } =20 -static void cpu_common_parse_features(const char *typename, char *features, +static void cpu_common_parse_features(MachineState *machine, + const char *typename, char *features, Error **errp) { char *val; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index d6bb57d210..f5e15ac5da 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3528,7 +3528,8 @@ static gint compare_string(gconstpointer a, gconstpoi= nter b) =20 /* Parse "+feature,-feature,feature=3Dfoo" CPU feature string */ -static void x86_cpu_parse_featurestr(const char *typename, char *features, +static void x86_cpu_parse_featurestr(MachineState *machine, + const char *typename, char *features, Error **errp) { char *featurestr; /* Single 'key=3Dvalue" string being parsed */ diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.in= c.c index 0bd555eb19..2ad223fcca 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -10119,10 +10119,11 @@ static ObjectClass *ppc_cpu_class_by_name(const c= har *name) return oc; } =20 -static void ppc_cpu_parse_featurestr(const char *type, char *features, +static void ppc_cpu_parse_featurestr(MachineState *ms, + const char *type, char *features, Error **errp) { - Object *machine =3D qdev_get_machine(); + Object *machine =3D OBJECT(ms); const PowerPCCPUClass *pcc =3D POWERPC_CPU_CLASS(object_class_by_name(= type)); =20 if (!features) { @@ -10171,7 +10172,7 @@ static void ppc_cpu_parse_featurestr(const char *ty= pe, char *features, } =20 /* do property processing with generic handler */ - pcc->parent_parse_features(type, features, errp); + pcc->parent_parse_features(ms, type, features, errp); } =20 PowerPCCPUClass *ppc_cpu_get_family_class(PowerPCCPUClass *pcc) diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 4a4445bdf5..7e360de5ee 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -115,7 +115,8 @@ cpu_add_feat_as_prop(const char *typename, const char *= name, const char *val) } =20 /* Parse "+feature,-feature,feature=3Dfoo" CPU feature string */ -static void sparc_cpu_parse_features(const char *typename, char *features, +static void sparc_cpu_parse_features(MachineState *machine, + const char *typename, char *features, Error **errp) { GList *l, *plus_features =3D NULL, *minus_features =3D NULL; diff --git a/vl.c b/vl.c index c57e28d1da..e78c4d5a53 100644 --- a/vl.c +++ b/vl.c @@ -4466,7 +4466,8 @@ int main(int argc, char **argv, char **envp) /* parse features once if machine provides default cpu_type */ current_machine->cpu_type =3D machine_class->default_cpu_type; if (cpu_option) { - current_machine->cpu_type =3D parse_cpu_option(cpu_option); + current_machine->cpu_type =3D + parse_cpu_option(current_machine, cpu_option); } parse_numa_opts(current_machine); =20 --=20 2.18.0.rc1.1.g3f1ff2140