Received: by 2002:a17:906:5a52:b0:9d0:bf65:29fa with SMTP id my18csp3315587ejc; Wed, 15 Nov 2023 23:40:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IEV0XNXNMgQmzDTtFpGSkYufv2AbJrfPnDDANgin5WPb734cx8RGMO1a8j+pMLsRXK4In+W X-Received: by 2002:a1f:a80b:0:b0:4ab:cf9d:b305 with SMTP id r11-20020a1fa80b000000b004abcf9db305mr13990971vke.0.1700120431074; Wed, 15 Nov 2023 23:40:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700120431; cv=none; d=google.com; s=arc-20160816; b=bTZC7wvajbSJfbR+sdBdsb05/fur2uQiOINM6kV1A/hsgKUh2uqm1W5+ipSA5lgTm4 3G1FL9k4vUNPUWuYoQQo5BC9lIRx7ce1Y9iQ96FvtEyRZ3szHS+EdbkzL3BxPDH6Uf3G hUi2JvXHL0p4iC7feYRraP3YpDK/Y1QkgURwwAlYNrUxQH6r4jK+p5rtwIYRsCgrLlLd Zz915PxL9zSBn9JsDqp/xGRY2NsezDCfnlKlrLAs5JTFS4z/WW4haqDqeMqq9aWCkVEa oMvEIyAxcca3Rzxv3DLupUH1in1h9FT/wGldCWqgLlXsWb4DdAGlQRxQQi/wE1eNT4+S zRmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=3nJglrJHM96BrOxQ7yaaayAhXcBPoScHrFicrVIEwhk=; fh=MNy/s+eWWV9V6tfmhb2gUwit/2o7TQkLbQD1zQm6hqY=; b=mf0exoOj67QPk6DYz5/TqZl38zmOcxX3aW+cX6wtbQ5nTIFF3CQNcJjTpEYIue6B8s 7wNJfL8H8LJO2wk5qAkUm6uJzgh6+4zoXoeERs/47KjNIfAJjaoqPcW/1N1mogtkVWoC 2vV4eZGqMpIDTkcFxJ2WFsiizV++EQfQ+Ff3//JGepH+QMVmGdFH9CaQOy2527afZH2N szHIwv35VxUcILlg+V33BeFmsvpwOzltyBEulE7l0vZBeV7qovwaj0nwoY06ap7xPZVy L2VUs0AhYGmvIRb0AjT4vhB9ictpCEFdtygRvYQmkO/ul5TF80N16a4TzgcZYqA8qwtU uJ/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="QwZ104B/"; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t28-20020a05622a181c00b0040fd2d2b423si11231712qtc.584.2023.11.15.23.40.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Nov 2023 23:40:31 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="QwZ104B/"; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r3Wyx-0003SM-1a; Thu, 16 Nov 2023 02:40:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r3Wyt-0003Ql-QD for qemu-devel@nongnu.org; Thu, 16 Nov 2023 02:40:08 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r3Wyp-0001zU-HY for qemu-devel@nongnu.org; Thu, 16 Nov 2023 02:40:05 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-32da7ac5c4fso357615f8f.1 for ; Wed, 15 Nov 2023 23:40:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700120400; x=1700725200; darn=nongnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=3nJglrJHM96BrOxQ7yaaayAhXcBPoScHrFicrVIEwhk=; b=QwZ104B/vcqmbOQ6ovhRiCxGRhr9IiQkMjatGBjjP6ceDZgeTdYHxM/d81fZwOUdXR hasb/4Ef+R8PnfCoSSHKjY8MEhP4mY2I6j6GM6hoKELWXdE8RxCdmoS2/Q/PGGaoHNH6 f9MjUvM2mJMvn7Q9nEHV1fqMvXB5InBXSeIX15Nnbr39whZUKKY5VZBRcSAwaM2dSHyC P44jBMhR1A7oCc1lRC/uWY9yij4zGql3fE9GJSbAVL3BGXPDgNdtozn8G60IMNVQNkma z5y0cVMQ7/BimJwI7mXlmpNqIcLkSN2dRZEky/N6V/wEeRjHdcWupZtgsD/qQzdMEw1/ J85A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700120400; x=1700725200; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3nJglrJHM96BrOxQ7yaaayAhXcBPoScHrFicrVIEwhk=; b=kw+lRusOoStOocksdmGCan5ueJ4DgbZJqz0osfRXhBIzMLgGMy696AkH9VwtKYMx9A wQ9ZPYF+mukH8Z1MfwfkJORG+5erDhWhJ1nWQ/ij12zaa5Z5C/VAgv020OBY/jnMnNkm Bphfq0aphkqlrYREarmw8pswtZnxiVhpZm12BVOk+hL+Mi046JTF9nknzZLFwT6Ucmt7 IEoMl+HEahnS21L9B7XraQ0yV4fAyGbUjHskEzZdJtyhepVsTo/ZLTKG1o7f4+wFBuYX rs9GJhNskdztTkd0blE/MNncdtFBdT3YlsJ2gDAERt6Vbi6iVOM75XRnFebnzU7y3ZEd KOUA== X-Gm-Message-State: AOJu0YzX2XQnhhOGN52LEfj7JZfxtiy0CLlLG+0XU/fwnSRH8uectSGt 3DMeCepeLa9bgUU6Vsm1JAWBwA== X-Received: by 2002:a05:6000:1865:b0:32f:a48f:3658 with SMTP id d5-20020a056000186500b0032fa48f3658mr15956372wri.69.1700120400598; Wed, 15 Nov 2023 23:40:00 -0800 (PST) Received: from [192.168.69.100] ([176.187.220.205]) by smtp.gmail.com with ESMTPSA id q2-20020a056000136200b003313a1e0ba1sm12597012wrz.89.2023.11.15.23.39.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Nov 2023 23:40:00 -0800 (PST) Message-ID: <80da2d00-0d96-4252-b2aa-f7859e44bece@linaro.org> Date: Thu, 16 Nov 2023 08:39:55 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 06/31] cpu: Add generic cpu_list() Content-Language: en-US To: Gavin Shan , qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org, qemu-ppc@nongnu.org, imp@bsdimp.com, kevans@freebsd.org, richard.henderson@linaro.org, pbonzini@redhat.com, peter.maydell@linaro.org, imammedo@redhat.com, b.galvani@gmail.com, strahinja.p.jankovic@gmail.com, sundeep.lkml@gmail.com, kfting@nuvoton.com, wuhaotsh@google.com, nieklinnenbank@gmail.com, rad@semihalf.com, quic_llindhol@quicinc.com, marcin.juszkiewicz@linaro.org, eduardo@habkost.net, marcel.apfelbaum@gmail.com, wangyanan55@huawei.com, laurent@vivier.eu, vijai@behindbytes.com, palmer@dabbelt.com, alistair.francis@wdc.com, bin.meng@windriver.com, liwei1518@gmail.com, dbarboza@ventanamicro.com, zhiwei_liu@linux.alibaba.com, mrolnik@gmail.com, edgar.iglesias@gmail.com, bcain@quicinc.com, gaosong@loongson.cn, aurelien@aurel32.net, jiaxun.yang@flygoat.com, aleksandar.rikalo@syrmia.com, chenhuacai@kernel.org, shorne@gmail.com, npiggin@gmail.com, clg@kaod.org, ysato@users.sourceforge.jp, kbastian@mail.uni-paderborn.de, jcmvbkbc@gmail.com, shan.gavin@gmail.com References: <20231114235628.534334-1-gshan@redhat.com> <20231114235628.534334-7-gshan@redhat.com> From: =?UTF-8?Q?Philippe_Mathieu-Daud=C3=A9?= In-Reply-To: <20231114235628.534334-7-gshan@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: N75VF86H9Tw0 Hi Gavin, On 15/11/23 00:56, Gavin Shan wrote: > Add generic cpu_list() to replace the individual target's implementation > in the subsequent commits. Currently, there are 3 targets with no cpu_list() > implementation: microblaze and nios2. With this applied, those two targets > switch to the generic cpu_list(). > > [gshan@gshan q]$ ./build/qemu-system-microblaze -cpu ? > Available CPUs: > microblaze-cpu > > [gshan@gshan q]$ ./build/qemu-system-nios2 -cpu ? > Available CPUs: > nios2-cpu > > Suggested-by: Richard Henderson > Signed-off-by: Gavin Shan > --- > bsd-user/main.c | 5 +---- > cpu-target.c | 29 ++++++++++++++++++++++++++--- > 2 files changed, 27 insertions(+), 7 deletions(-) > diff --git a/cpu-target.c b/cpu-target.c > index c078c0e91b..acfc654b95 100644 > --- a/cpu-target.c > +++ b/cpu-target.c > @@ -24,6 +24,7 @@ > #include "hw/qdev-core.h" > #include "hw/qdev-properties.h" > #include "qemu/error-report.h" > +#include "qemu/qemu-print.h" > #include "migration/vmstate.h" > #ifdef CONFIG_USER_ONLY > #include "qemu.h" > @@ -283,12 +284,34 @@ const char *parse_cpu_option(const char *cpu_option) > return cpu_type; > } > > +#ifndef cpu_list > +static void cpu_list_entry(gpointer data, gpointer user_data) > +{ > + CPUClass *cc = CPU_CLASS(OBJECT_CLASS(data)); > + const char *typename = object_class_get_name(OBJECT_CLASS(data)); > + g_autofree char *model = cpu_model_from_type(typename); > + > + if (cc->deprecation_note) { > + qemu_printf(" %s (deprecated)\n", model); > + } else { > + qemu_printf(" %s\n", model); > + } > +} > + > +static void cpu_list(void) > +{ > + GSList *list; > + > + list = object_class_get_list_sorted(TYPE_CPU, false); > + qemu_printf("Available CPUs:\n"); Since this output will likely be displayed a lot, IMHO it is worth doing a first pass to get the number of available CPUs. If it is 1, print using singular but even better smth like: "This machine can only be used with the following CPU:" That said, this can be done later on top, so: Reviewed-by: Philippe Mathieu-Daudé > + g_slist_foreach(list, cpu_list_entry, NULL); > + g_slist_free(list); > +} > +#endif