From patchwork Fri May 2 21:45:47 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: 886649 Delivered-To: patch@linaro.org Received: by 2002:a5d:430f:0:b0:38f:210b:807b with SMTP id h15csp1018427wrq; Fri, 2 May 2025 14:46:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW4eIYeKAn9OQc8LxIJyZVYuViAj9lGtWpY994M7MH5LX6LcG/PUEc1CCoBFQQaE84riM58UQ==@linaro.org X-Google-Smtp-Source: AGHT+IGxqAtmGacCUYhTBiMuhE08h9CckiVVSHPZap5YfaoIo3lcswjENOmdTsgiMVwil4XgJgi6 X-Received: by 2002:a05:620a:2550:b0:7c7:a536:66d1 with SMTP id af79cd13be357-7cad572b1c1mr670249485a.6.1746222400983; Fri, 02 May 2025 14:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1746222400; cv=none; d=google.com; s=arc-20240605; b=eH46CneO2FOlsiYSeugedbD/jWIP7MMACtxtv5nPd3Jh86472lDA5cfwMgfnObWsJx AllnX4ntLdAERkH3GKrgKlnipBFBmlvi3g/OoYUjrZi77IcdGk6jVT8G9yGt5yQmTwYH 1PMZZQQN8Df9rcRiLGfzHcSOIEaj7QujFQwrZOuYBjCcP/Na4gmVwK7W+RSQcHk4wm+W CmXttT0yvT6/XW75PPJg3ZY8k05UJ60G56yaJzoZyZPebyqX3ucDz7k3z0f/lGsVD6QW oNUw2ImfNbWrrPJJB107cR5u0jNZUVpQ5d5rKPPjs7+jSc4l/F/EoTfcaA+9ilMev69m oZZw== 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=LXgZidSSSrLiEhibf6u0N42Azn0PbvpjkuJ4Pt+Naxo=; fh=w9UtuAm08K0O6DwRXOEWzl92QaS8M3PoE8G3rbCBQ9s=; b=ZE1NUiZyNjEyFrHKVy2unMaT/UiHFcdNSSoF/Z5V52/snn50w+0bPfT+hPPkJFKuA/ WOep34jT5NYIDxBdBHpVqxnLOhQcHjvlAGhS/PtP/offhTddUhspWCjC6wqwoC2G+PQv +mPD6leAvrhZyfi1lJTJ40OkDbmBMrKF9xN2bh8pXzfjZ8guWKKVsuRMKNNNgQhRg9g3 RqpI0zVITHeqbhbW3yJDO7dm69yJTb4eqK0DtI9eo+6+NtRE668QRgzSCoQ047sUTA/v KtHBuzGm4E6NEt3SNuMG2/U9WSh4eLjVLTEudbcZ/eqHmu9XsIQG1b/SEJFDQcLPFhEj bSvg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ws/sVr45"; 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-7cad2432612si399049085a.368.2025.05.02.14.46.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 May 2025 14:46:40 -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="ws/sVr45"; 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 1uAyCr-0000gR-DZ; Fri, 02 May 2025 17:46:05 -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 1uAyCp-0000fT-BP for qemu-devel@nongnu.org; Fri, 02 May 2025 17:46:03 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uAyCn-0003VN-JR for qemu-devel@nongnu.org; Fri, 02 May 2025 17:46:03 -0400 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-ac2bb7ca40bso404386966b.3 for ; Fri, 02 May 2025 14:46:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1746222359; x=1746827159; 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=LXgZidSSSrLiEhibf6u0N42Azn0PbvpjkuJ4Pt+Naxo=; b=ws/sVr45ff9wSgY51A6PofgVsR4PMqlB/g4gVXA+GUJn/mRHMbDeBCuYBPrcnyO/kO v5IBd9ylynEqKmEhVdPOkjRyUXUL4L3dz71xAzGBgUNMFGi5XKVuB+N04bSTc1g4q0fs KaxS2RKgjcIZgixbVZD3MSYzOTV6mBEJ11z2s8q83xJoG2xwc0blrSQda8e6LoIQW8Rl 8wgWkCxs9uoPUBGjFi7jfR7r7A9BQ54N8sRsXKnQDQcvbNoFI33AJqUqYP7NlBOVAoxO afCWnuTNUU+69BLfaVcji9X3Py2FCDVURoLzu+niYlNLffKZWKS5IzeTF7TFBbwk4lKo G8+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746222359; x=1746827159; 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=LXgZidSSSrLiEhibf6u0N42Azn0PbvpjkuJ4Pt+Naxo=; b=U0/m5ZLt/j481yXGVgZJBIprwTyGjfpLke/mpcWvWLBvAtHqb/WtvHfM+jfXdC8dIs +dyhwWafgOUxNu+gcBJxyZyiFyrHN7W1BMv2fgj/A6AfYD4iZ3tVdb0VMkhwSCM/laA3 FK+fFlVdtcd4HJJGO59FPQJ3LltYaFhWTQwaDdERvWS5lx+UJw1pOxVb2jAvunBtX2Lb kFPHLzzo73m8sYM1QC3P1r9eruHPbPI7zdz+HI9NR7lv/sMiMn4u6xdbwwS5u4N2aEhX u7nf5e0J73EjPIlmUrns5HMKUpGSeZL9DwO+CyI8uV7NC1+LBlU5Qw8IHBPILwtbv7C6 belw== X-Gm-Message-State: AOJu0YwITXw3jLYm7XxajXw3YTPS7L/5JTIfDZiDrI3mgLa+rUFzhsoY uZ4s5Xr995FxdnvAbcN1PCKdC3XgVnmxsKpRNiwhtDLlBOyGfb4aaHDjX+p3lkiRowxKiZQbyf+ o X-Gm-Gg: ASbGnctHoXtffbSfPP1LPXr2MZbxADhx33Wpf7bQSU6d5rr9Fdo2M3RGoFrOAfrriyD zz51iWVhh6D1gUJ741aOUHr/G3OcM79lHguA1ju06f9ssjk6SQAmloM/Fd91bDYwvspYKltDuKD 8n6g6W9T4Z2IcJq9PNmf2PkPXm6WVYdd/NAYUb1FKr9vpAMbarWxj+VXXPVmeq2BUiCoXkkorE9 DCYFYq29ZseDDvTUxRUYkssxaPBxeEv0vRgzEcdLl2bbyPsuIcuU7s7syHCe8MLYDBhzAnNW7ZS fAJ0iPSAyfDhvjTvlOl36QgdQsjJr0o6Ljw4CH7ELADbuB3hKwCpMVFaatBPYNuEWeIGx5ufN+9 SEtfH74ACuArSebY= X-Received: by 2002:a17:906:22db:b0:ad1:8f1b:21b5 with SMTP id a640c23a62f3a-ad18f1b2528mr101985766b.36.1746222359478; Fri, 02 May 2025 14:45:59 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ad189146f74sm104922166b.17.2025.05.02.14.45.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 02 May 2025 14:45:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , Zhao Liu , Yanan Wang , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Thomas Huth , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 1/5] qemu/target-info: Factor target_system_arch() out Date: Fri, 2 May 2025 23:45:47 +0200 Message-ID: <20250502214551.80401-2-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250502214551.80401-1-philmd@linaro.org> References: <20250502214551.80401-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=philmd@linaro.org; helo=mail-ej1-x636.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=ham 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 Signed-off-by: Philippe Mathieu-Daudé --- include/qemu/target-info.h | 9 +++++++++ hw/core/machine-qmp-cmds.c | 6 ++---- target-info.c | 12 ++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/include/qemu/target-info.h b/include/qemu/target-info.h index 850a2958b9c..87b4b0e0cbb 100644 --- a/include/qemu/target-info.h +++ b/include/qemu/target-info.h @@ -9,6 +9,8 @@ #ifndef QEMU_TARGET_INFO_H #define QEMU_TARGET_INFO_H +#include "qapi/qapi-types-machine.h" + /** * target_name: * @@ -16,6 +18,13 @@ */ const char *target_name(void); +/** + * target_system_arch: + * + * Returns: QAPI SysEmuTarget enum (i.e. SYS_EMU_TARGET_I386). + */ +SysEmuTarget target_system_arch(void); + /** * target_long_bits: * diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index d82043e1c68..8f491dba441 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -37,8 +37,7 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp) MachineState *ms = MACHINE(qdev_get_machine()); MachineClass *mc = MACHINE_GET_CLASS(ms); CpuInfoFastList *head = NULL, **tail = &head; - SysEmuTarget target = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), - -1, &error_abort); + SysEmuTarget target = target_system_arch(); CPUState *cpu; CPU_FOREACH(cpu) { @@ -139,8 +138,7 @@ QemuTargetInfo *qmp_query_target(Error **errp) { QemuTargetInfo *info = g_malloc0(sizeof(*info)); - info->arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1, - &error_abort); + info->arch = target_system_arch(); return info; } diff --git a/target-info.c b/target-info.c index 16fdca7aaaf..8232d488870 100644 --- a/target-info.c +++ b/target-info.c @@ -9,6 +9,7 @@ #include "qemu/osdep.h" #include "qemu/target-info.h" #include "qemu/target-info-impl.h" +#include "qapi/error.h" const char *target_name(void) { @@ -20,6 +21,17 @@ unsigned target_long_bits(void) return target_info()->long_bits; } +SysEmuTarget target_system_arch(void) +{ + static SysEmuTarget system_arch = SYS_EMU_TARGET__MAX; + + if (system_arch == SYS_EMU_TARGET__MAX) { + system_arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1, + &error_abort); + } + return system_arch; +} + const char *target_cpu_type(void) { return target_info()->cpu_type;