From patchwork Tue Apr 22 14:54:45 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: 882988 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp2456698wrs; Tue, 22 Apr 2025 07:56:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUl27MNosRlzPfri1QmQaxpJqcpMRDtxaJboo0ksvzzps4YdpIk0wG31yhUpAYfA/+FFVu8ig==@linaro.org X-Google-Smtp-Source: AGHT+IGHoumNl4eKt2ZpBCP4WW5t6Heur2hCydVejV88uZ4R/zqTlwkN/HWnJanScPiPlfavKb4X X-Received: by 2002:a05:620a:2a11:b0:7c5:602f:51fc with SMTP id af79cd13be357-7c9280119a9mr2441638385a.44.1745333797400; Tue, 22 Apr 2025 07:56:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1745333797; cv=none; d=google.com; s=arc-20240605; b=b2B17wk9g5S3I7z1IFzwJadocqPxv74eLRCzq6JG+F/w97YEL27lTuHqJiY1YCFzM9 7a7wbODMfdrAFSAubqmuZeoyvLCMS4t3rbf13tGNJv06WQMd4/pFJXVsNcK0530amsEO eJDAOoJlcIJyo/JVOEHxo9GLblXfxNd54XGj5vUmL3FFnhMRy8Wm2dq990sf7VQJ126Q yYiltGw1DVWZ/5/qKzxnv5SvsUHHdg1aOXfkB12VGwCBJlh7jPh9rV9AnCOOcqoFNRWy llLfnzBnzZHWX8dzxYoYR2ocLCKXC38TXqAuskGNpdtaVNa98oNZfmXysMAtNZSX4eGs BUnA== 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=ydE2KK63QljieXni2VjK8GOTNoowF9wO+YxCs0gln0U=; fh=98FKcUbfHOMAWlQQi9/5y14VVYgcGa56vjU1mKYkvXI=; b=dvFkZtif1wxvcTq8RauLoO5looM6+xeSw1JW+BBNTS7Y7eUskGC1tLqTMfRa3MWbd3 ZNcLw5Qt9UfVI6z3rtgEEE38e9g2aWOqqCaxc+p2i/HkkWWIFYlgui86yK5C+KEC/RCY 4cYEeCiWikrx4UmxXwBPmPZgZ4VuAQX4TGuxNiFV2VcDJvLmKB0C+dCoXEEyMAuTl7JO ZKQZb+ICH853SH+x1RoDoBt3Ezmolqln/BUq1ikWN+hxNnzhTFrX9+eStc/ZAN7OiiI8 obJdHuAQNMFi4x0i9Hluyu0yG+n8yK/vNa/JI1RN54gEnDWrZ9x8r5KFwnEU9YXRO3z/ SJWQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FwbGXz4K; 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-7c925adb35bsi1077146385a.180.2025.04.22.07.56.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Apr 2025 07:56:37 -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=FwbGXz4K; 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 1u7F1w-0006nv-Ld; Tue, 22 Apr 2025 10:55:25 -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 1u7F1u-0006nX-MY for qemu-devel@nongnu.org; Tue, 22 Apr 2025 10:55:22 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u7F1s-0005BB-Oi for qemu-devel@nongnu.org; Tue, 22 Apr 2025 10:55:22 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-43cfebc343dso45207115e9.2 for ; Tue, 22 Apr 2025 07:55:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745333718; x=1745938518; 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=ydE2KK63QljieXni2VjK8GOTNoowF9wO+YxCs0gln0U=; b=FwbGXz4Kjg14+YEboUlNCy520yejgWJitGGHzUizf5CuJ8Itv4rQg0fHqSOfXrvJG4 49Tq4ho0teMOGBO2lp3TJsJk1ZorLGbMSRnAk40/JwT+lOt3Stl6HVt92UW6BKlvc6rs erM6VN55WndIqZeirINjHYaHw+tH1pzkGb1bXK5FHgQIGYoAn/6kJimU7ZZVznEjA2+K cUhYJ6Sfad8Rb/KTTZ3QCmCM571KbJwh0DmtR4Y+kTs9SZ9rPclBPszNdvKozdRJXngQ kd2KlcQhqBlsA8c6t8FTB7k7dhVJQtzTEVStx8w6r6Z0uqHz6GFcpBbRwfgXfYlszI4c c1fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745333718; x=1745938518; 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=ydE2KK63QljieXni2VjK8GOTNoowF9wO+YxCs0gln0U=; b=aB8j0jZ+w23bC9XpLQ9Ctu0XRTjUI217Ui/vjxndxqoZSBorzLNd8JPBcW1sO0da2d aR4MBKxQQFvr31I0jOVG5stjbobcb9k0jetkQdPJQuiTp30+RMfL5E/u2yqqqlaXHeSK IwQxVg3dt5dkGbR7teT/vpzs2+WLOenMtsOb0DKdTykhvTTcVSoic2CWnHPCdzKpheNZ oU2LpHuYwrP0JWR/aDx+5VDJCGqvI5uSub7mA3JmEbUl9eSW7ReLpRNAvrBneKqLRNGL A6b3R7JVh8zHd5JEVtCgVhTTz7IYk2p/yH+rAYTBEKYO1ojBhUndgOkX/rdZO1akyd6f JIvQ== X-Gm-Message-State: AOJu0Ywz/hjpHDArxJa2jh9qJcun5ZVp/VvEUGRbRVyZIMnAvb4E4yRJ 3u9TIFZTfjjOrDlrplYdWSGhXc7oeD1uWFcoNJ8nw+7bVifHkBG1OcELg0EwV36Yuu7gNE4pCjo n X-Gm-Gg: ASbGnctE8t5O8zb/9jvBFucIxGs6GbLjUQjLEVzvoW680r4PIk5lNl1qAlY0m7ZyTAA 1vKroXGPO098IUsXAGSUfwo5Zr9bBkpBoi06uDZu9W9djj1XwNOB6E9hJ4r2hoFl9xk9WhHUHPX CIaF7VQR44g6Ufa73WEgDJI/xttqCMdc4GGI29lPV5QFpnTGPkDy8jpjyCzO4GQshPqRjGch5qA nqBttetNIVBmaXeXJB5GuPck0FZKUAlcdq6sZleyHPacGkapjQn1AjlKd6UKI0SalTjmyJqhPUp p4yrf55LIqVzxbxTF59ZihHCuyPyEZjiPXSmmdi86wJI/03Yi2QhjGKsD3RLoJBednc1slJjSoj 8m+p74ZunkY4FgRY= X-Received: by 2002:a05:600c:154d:b0:43c:f4b3:b094 with SMTP id 5b1f17b1804b1-4406ab7a726mr124073815e9.6.1745333718382; Tue, 22 Apr 2025 07:55:18 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4408d19ffe8sm10525865e9.3.2025.04.22.07.55.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 22 Apr 2025 07:55:17 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Pierrick Bouvier Cc: Richard Henderson , Anton Johansson Subject: [RFC PATCH v4 03/19] system/vl: Filter machine list available for a particular target binary Date: Tue, 22 Apr 2025 16:54:45 +0200 Message-ID: <20250422145502.70770-4-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250422145502.70770-1-philmd@linaro.org> References: <20250422145502.70770-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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 Binaries can register a QOM type to filter their machines by filling their TargetInfo::machine_typename field. This can be used by example by main() -> machine_help_func() to filter the machines list. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- meson.build | 1 + include/qemu/target-info-impl.h | 3 +++ include/qemu/target-info.h | 8 ++++++++ system/vl.c | 3 ++- target-info-qom.c | 15 +++++++++++++++ target-info-stub.c | 2 ++ target-info.c | 5 +++++ 7 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 target-info-qom.c diff --git a/meson.build b/meson.build index 09b16e2f7ae..a1109b6db3f 100644 --- a/meson.build +++ b/meson.build @@ -3808,6 +3808,7 @@ common_ss.add(pagevary) specific_ss.add(files('page-target.c', 'page-vary-target.c')) common_ss.add(files('target-info.c')) +system_ss.add(files('target-info-qom.c')) specific_ss.add(files('target-info-stub.c')) subdir('backends') diff --git a/include/qemu/target-info-impl.h b/include/qemu/target-info-impl.h index c276b84ceca..4ef54c5136a 100644 --- a/include/qemu/target-info-impl.h +++ b/include/qemu/target-info-impl.h @@ -16,6 +16,9 @@ typedef struct TargetInfo { /* runtime equivalent of TARGET_NAME definition */ const char *const target_name; + /* QOM typename machines for this binary must implement */ + const char *const machine_typename; + } TargetInfo; /** diff --git a/include/qemu/target-info.h b/include/qemu/target-info.h index 1007dc9a5e4..0224b35b166 100644 --- a/include/qemu/target-info.h +++ b/include/qemu/target-info.h @@ -16,4 +16,12 @@ */ const char *target_name(void); +/** + * target_machine_typename: + * + * Returns: Name of the QOM interface implemented by machines + * usable on this target binary. + */ +const char *target_machine_typename(void); + #endif diff --git a/system/vl.c b/system/vl.c index cdf6eb9ee49..e8706a9ce87 100644 --- a/system/vl.c +++ b/system/vl.c @@ -27,6 +27,7 @@ #include "qemu/datadir.h" #include "qemu/units.h" #include "qemu/module.h" +#include "qemu/target-info.h" #include "exec/cpu-common.h" #include "exec/page-vary.h" #include "hw/qdev-properties.h" @@ -1564,7 +1565,7 @@ static void machine_help_func(const QDict *qdict) GSList *el; const char *type = qdict_get_try_str(qdict, "type"); - machines = object_class_get_list(TYPE_MACHINE, false); + machines = object_class_get_list(target_machine_typename(), false); if (type) { ObjectClass *machine_class = OBJECT_CLASS(find_machine(type, machines)); if (machine_class) { diff --git a/target-info-qom.c b/target-info-qom.c new file mode 100644 index 00000000000..a6fd8f1d5a3 --- /dev/null +++ b/target-info-qom.c @@ -0,0 +1,15 @@ +/* + * QEMU binary/target API (QOM types) + * + * Copyright (c) Linaro + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qom/object.h" + +static const TypeInfo target_info_types[] = { +}; + +DEFINE_TYPES(target_info_types) diff --git a/target-info-stub.c b/target-info-stub.c index 076b9254dd0..218e5898e7f 100644 --- a/target-info-stub.c +++ b/target-info-stub.c @@ -8,9 +8,11 @@ #include "qemu/osdep.h" #include "qemu/target-info-impl.h" +#include "hw/boards.h" static const TargetInfo target_info_stub = { .target_name = TARGET_NAME, + .machine_typename = TYPE_MACHINE, }; const TargetInfo *target_info(void) diff --git a/target-info.c b/target-info.c index 84b18931e7e..0042769e3a2 100644 --- a/target-info.c +++ b/target-info.c @@ -14,3 +14,8 @@ const char *target_name(void) { return target_info()->target_name; } + +const char *target_machine_typename(void) +{ + return target_info()->machine_typename; +}