From patchwork Sun Mar 23 22:40:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 875640 Delivered-To: patch@linaro.org Received: by 2002:a5d:5f4c:0:b0:38f:210b:807b with SMTP id cm12csp1881134wrb; Sun, 23 Mar 2025 15:42:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWuQr6ACAoau7xEj7cRi5escfhBIUatpbQO5TQrGGEcbCn76dCtOo6K4YOmqsdVa0RUn0KUtA==@linaro.org X-Google-Smtp-Source: AGHT+IHiB9QB+mmp6K2wRHMLs/EfZExDx77B9qmQeKMT2RuuwWWKTjt/X1qPLwaM4msqxmhL3XHY X-Received: by 2002:a05:620a:1a05:b0:7c3:d711:6ffb with SMTP id af79cd13be357-7c5ba1ded89mr1543768885a.41.1742769745264; Sun, 23 Mar 2025 15:42:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1742769745; cv=none; d=google.com; s=arc-20240605; b=XnfWBLmuR4r+dZNRyoJqFFNsH7ZVCOC22P8lXVOKwcR/zUwfjVDxHXzco0c6P+Qgbb PY1RRe3dqo8lZacv/JbeBQCOpux3OJVxU5h2Va6ZTeL6Oo5bSF1e5vrzhgAuRQ0jTK49 KzjjgOUsOQ0Pa9IAFmwHxQT0EVZOXD3UD+fj5pyadiTnTrbwXbOQdjr6AQZR2Pa/HGJ/ Io/Bp1F3HQ0D/Yb93y7ewBMbuK8mEqjx5TsjlcEzGcjEkNG5Pxf0Ky+uP4gRRdxR5E3b 6yds9gm19ax2qesRIyBKktzUvV9N+LTXiu/v9vd9cWn1O2VYgxEEfrtY4QAX+dQiiy/4 033g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nhKX0vmLXuR6wN4mzYTdPit8e/28nQp1dDgh0h4fk/k=; fh=fS/4rnnLwcRgvOOCJ1cvfiQufE+14bwOLEAj2Zueb4I=; b=YIYB0INNnymecwDLtRzfhbr9ojfSzDogXBydInpBRFUBFfmdE0AIej3ZHLdgsyJwn/ esAle7bOlgC+Q9iRxbw0RkSr99Oc6jvoXUaEytnIr79MKIfDdwcF8Ccb8oa2eKPAbu3U HOwr9LdIaeXi66D0xf59BgGD5PRiamdV558RNCrE3or0t29xPhy/wTpQackFxOUlQsJG yGA4ym3hH37+ohckEcYSFPfv/WFlvpwnZ/LZ+wEbdSUipF+DzqWVKLNYAEtFe0uJyMet c9En5tamdl0QeYVy3bWzNw5ZioBg7PDl3URXjOYIwOo2NLjMxRoWWhsUP90afwkfk59W 3k6g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VBanfnSJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7c5b9362304si632813285a.483.2025.03.23.15.42.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Mar 2025 15:42:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=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=VBanfnSJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twTzt-0005y6-Kx; Sun, 23 Mar 2025 18:40:49 -0400 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 1twTzs-0005xQ-71 for qemu-devel@nongnu.org; Sun, 23 Mar 2025 18:40:48 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1twTzo-000693-TG for qemu-devel@nongnu.org; Sun, 23 Mar 2025 18:40:47 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3996af42857so3065906f8f.0 for ; Sun, 23 Mar 2025 15:40:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1742769643; x=1743374443; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nhKX0vmLXuR6wN4mzYTdPit8e/28nQp1dDgh0h4fk/k=; b=VBanfnSJMwgvfUJsf7NDjByC2mw8c9ktWIf+o6ljSb7CvRzMQLUwDb1czmZmUnUShl U0fKH61HqwmH3NE0cop0TqJxxqeqc2gCQv33hn+m2hMQt0wgB+LpuLJT8NvDOZupV67o 4jcmaPwnZTNy6JR27EHC7JqSaCylEoiY0pNaNKDKw4sjYf2Y5K6DK9bICYXjgn+7HuGZ ZbT63t+6uX3IRMw7E6R2KEkXcTMfTcv4Vo04wucjoA0pKQuU4raYFo5notwY4sbKs7tt pmMkiTxRw3VaOQh0BFVqs3Hd8mz6768aQ+geK27VgTxg6CynDIcBFnL0bJtwECrk5aWm rhDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742769643; x=1743374443; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nhKX0vmLXuR6wN4mzYTdPit8e/28nQp1dDgh0h4fk/k=; b=NLu6u4HO7X5arrynuO235Aqa8Rz80v+6JVDwhFgk+Ju3Kt+FvgrO8zefVNHML9WdHs cGxv+SClC+IYHO7KUqhmbS7vrR2rDAsCru5jX4MfzbCkVQ19EjdTGhPsBar2ZJScEpjd +D/F7sFwY9dnNjqho4lSKMeBOWXkmIecLYNXlGmcQ3WkzErrirdfU/tMhX763e2Ib1wg 4rS29VV6072BP17xAQ8qTdxgjU8kRJNF2EaT67qnmG88miTzSkE1chwkQLyqIHKfrz5d tN9e4HdN4tXqwL1Eqbq6pvW7L2jf4M1m7VRZNclbmakPUQ2X9ZsYlJBhdV/LcS+pBLXt 6rHw== X-Gm-Message-State: AOJu0YxPMbvMQCi8ojpJhQRwb7jZg5oKF4/tx4vGDaoOOAc5o0MOQORJ roQ1RqExwtkqEsEKrTfys24FnXhEfs83+0YUajdXyAgHI3x3FWRt9niQ4k/lPxSx1s6cv94411w 2 X-Gm-Gg: ASbGnctsL7B43kgXhV6dj33Lsg2LJoJGpw3Mwc8TUOLo5SCZb3DhAFNbN9TVzIFicwv f1dcaxGFDvvZtlsGlemhRFOES9je1X1UF2+xvEQCUzfeaP+wM1UmzNeI5A51oRxq3aWti8kMeyD 6B6iIh5XbJc+95pnNVR1riR8xLKKEcPN2gyMPsCxM5nJTYqnre/IGnqAB30hYxynLt4zg85h0h7 j8U9Y6Vv5xOGPrJNglnbYhTZPDW/TPMxL0lWoxMqJbqiFqiMcJWz5+uYriYTQTksHW6H+47993g o5tOxQbfpbVqQFg1ORLQrgxkogo34oOK4tLwtg5t4tqvTCoqbUjqAs3bNhk/JeMk0hfOnNUX88J C+DYm4ZxUQt5fz5WUaOq9bNpC X-Received: by 2002:a5d:5889:0:b0:390:f9d0:5e7 with SMTP id ffacd0b85a97d-3997f90f2f2mr10700608f8f.13.1742769642913; Sun, 23 Mar 2025 15:40:42 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3997f9e6550sm8950122f8f.78.2025.03.23.15.40.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 23 Mar 2025 15:40:41 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Daniel Henrique Barboza , qemu-s390x@nongnu.org, Artyom Tarasenko , Thomas Huth , Nicholas Piggin , qemu-ppc@nongnu.org, Zhao Liu , Richard Henderson , Pierrick Bouvier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-10.1 1/6] cpus: Introduce CPUClass::list_cpus() callback Date: Sun, 23 Mar 2025 23:40:30 +0100 Message-ID: <20250323224035.34698-2-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250323224035.34698-1-philmd@linaro.org> References: <20250323224035.34698-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Some targets define cpu_list to a method listing their CPUs on stdout. In order to make list_cpus() generic, introduce the CPUClass::list_cpus() callback. When no callback is registered, list_cpus() defaults to the cpu_list definition. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth --- include/hw/core/cpu.h | 2 ++ cpu-target.c | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 5d11d26556a..ccfcd3eb3a6 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -102,6 +102,7 @@ struct SysemuCPUOps; * CPUClass: * @class_by_name: Callback to map -cpu command line model name to an * instantiatable CPU type. + * @list_cpus: list available CPU models and flags. * @parse_features: Callback to parse command line arguments. * @reset_dump_flags: #CPUDumpFlags to use for reset logging. * @mmu_index: Callback for choosing softmmu mmu index; @@ -150,6 +151,7 @@ struct CPUClass { /*< public >*/ ObjectClass *(*class_by_name)(const char *cpu_model); + void (*list_cpus)(void); void (*parse_features)(const char *typename, char *str, Error **errp); int (*mmu_index)(CPUState *cpu, bool ifetch); diff --git a/cpu-target.c b/cpu-target.c index cae77374b38..5947ca31a0a 100644 --- a/cpu-target.c +++ b/cpu-target.c @@ -98,7 +98,13 @@ static void cpu_list(void) void list_cpus(void) { - cpu_list(); + CPUClass *cc = CPU_CLASS(object_class_by_name(CPU_RESOLVING_TYPE)); + + if (cc->list_cpus) { + cc->list_cpus(); + } else { + cpu_list(); + } } /* enable or disable single step mode. EXCP_DEBUG is returned by the