From patchwork Thu Apr 3 23:49:14 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: 877995 Delivered-To: patch@linaro.org Received: by 2002:a5d:6dae:0:b0:38f:210b:807b with SMTP id u14csp3527745wrs; Thu, 3 Apr 2025 16:52:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUftmMI10jKOjtV41h66djxAcREuz9Y0vo6op/HVRWUazVfqF50SufXUGuYP8pO0qOtft6HaQ==@linaro.org X-Google-Smtp-Source: AGHT+IFAeeTib5sXLKcWNWB7vg9LJyG2QojOQGMnUzQFz3UDv3TVb+aZIJrAH9ckL3a6flFoct7r X-Received: by 2002:a05:622a:1189:b0:476:a90b:986b with SMTP id d75a77b69052e-4792598e588mr13149471cf.28.1743724340243; Thu, 03 Apr 2025 16:52:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1743724340; cv=none; d=google.com; s=arc-20240605; b=IpWxKPW7towIxkYiyFb9SCWSWB3wiYTRor0sele/htxbsmTultAfu4Q6ylgy+V3SJx COgHwsx5bV22hytexuafWpt1ciQkhC5uascLh8o581+8X6pJRDOS5J3+Cr0lUM5z76vW iNZCi2h40m1YIFMFFn4mCEkfqnifCcDN5wF7X0PCFOuVpMDzZUxJj3IiqCA00c/jYGPC lqBPrJJqkNPYTWiyUODCe1ZlpVMvKQUJYLYRXPp1im5hPf4IJAftAAgRIfflgOAv1hKO RUH8mAoZ+Ydu1dhqy4MV7R4ezpvRclJw5X0PMbLCTLPDAQTytcTcjG/s/s8VCrQGOFA0 OFsg== 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=s9D7OVdkybNmWN2++NNfk6FW5LKGK74MGZPvn0u97ZU=; fh=ISslU+6AOAPvfm3mmMuq/p0l7xeUGlnJLjUVX+iCVao=; b=ag4vkPKM/qxtPLY4ZKcs0/31wMc59iLjMqwVPxDWAdxjSE60h3Ke2MfEdkr7aY6euE sY9hlaDWHz3uhxcgs/S2pYF6mwWg6VhF/VDz96/lWkJFsOYTgAcbp63hiHJgWtOeuXUt 9PEDwhhGujnKqjkn5qLs0R0EaTH0Wv2gbucyYZLxIHhFBGd1/tg/lVgHMihOp2sXNJZH rVZiEgQ/MKqV5v+N1P8uIk0vfKPpaPw+l2fGF3c0z8ET4Iigwfdabxg4UqS2uLO3e7KA qvdlBYT3YHzL225Vx7vZfnUTAMXHPn86DZENrjpNeCeqYPrDTGAQ+WrD/4HB1jdDUzFg 88QA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hbCX75dG; 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 d75a77b69052e-4791b05c648si21436951cf.6.2025.04.03.16.52.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 03 Apr 2025 16:52:20 -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=hbCX75dG; 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 1u0ULC-00049G-MI; Thu, 03 Apr 2025 19:51:22 -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 1u0UL9-0003vi-VS for qemu-devel@nongnu.org; Thu, 03 Apr 2025 19:51:20 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u0UL8-0000qz-Ag for qemu-devel@nongnu.org; Thu, 03 Apr 2025 19:51:19 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-43690d4605dso10148175e9.0 for ; Thu, 03 Apr 2025 16:51:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1743724276; x=1744329076; 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=s9D7OVdkybNmWN2++NNfk6FW5LKGK74MGZPvn0u97ZU=; b=hbCX75dGzV61rvsaqORDQlXql59mPdvHBd9bXleksi4qlHwQWkeQE2jb8R6ve7BzYI up+jR91Vh8JVVsAYmsLws2mh0xTS5rPFxebeqVIpIawPPE8shOds4VjyGm2QJL/iTw9i N7aaOdYrtgqZMnOxNozUQ45xJ2an/HD933ZQZ1pz5quaN0C27UXxUId1d9mUW/eUNCqQ 6N/JwO4iFzn8fhqOEI5DDrexXcUGDmLKFvfW7FL/LX2XG/NHXxS88zgoCQPI6HZXBnfu dqnGVikn7L0sFv5HZpLtn2mc6MlI51FH6TftGUGpipVO9S+E83K+1YRG+EOzYNUY1Pla I3Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743724276; x=1744329076; 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=s9D7OVdkybNmWN2++NNfk6FW5LKGK74MGZPvn0u97ZU=; b=lGHq/WHHa+bcUGAzzIXwRytMcvOuXrFqwCkDO7UgVoD6yYWhRHBdZH6+E3T3DkGd4X 3vN9Txa8yV2Dcouakr4efohiABvOjq87vcgSDGrmBomD8YcHPs6y3gqlKI7ehmrzkPG6 EpbPyvWyqYtxFPPMucQoujzLJEdoZkjhv3sRPdo0c3SxxpD/o9Mxu89tLelD+xsHM7FS VKRkWd8J8bST7Cwd2rmXGIn/sysbGHBGR6t0fB87jxklS0odDuFXmcr+ARvpwXr8nyUW OQ1Papnoms4eJW5abItQBNFYIBv7AekzDwD2QyzcLyzWbE+wpntenH0R2WhYTNBjzjm1 nInQ== X-Gm-Message-State: AOJu0YyVWFQQZHxqygHQx6VpJ8V2uc83V4BF9lnRi32j6mzXFXB7WyfN TenkWZPIdfdb4Xf328PGi8bEPbEoykLqv0pQVHa9WJfR9KVOt4pDVpDXwl+zW9PzJhxvx4ePpMv A X-Gm-Gg: ASbGncsnWkgcsLjTQkCjoYdhNp9TUkCsLN5pKGdVWHinuX1zmOM1XAcmqV50xFotvnR 15X3pTzrGuhwr4q/CclasIF2hhwRQK8hUyrNXWFg8JIeh/XDQxKJTIPX8h94dbQVqwjTXcu816L z1tS5TO5EDvdkvXlc2sZtHnn8PrvLrdQuEJf3B6Kha7sdG6a19UNZKV4f0qpbRYLsCfhWR8FvIA RTBbx2a/iS8/C9f8R8VUYUJerlVJJy1VRq7bD5rPC6LgrA9Z5WtXZmckZaXP6EoLExsRbpZBHVX 49xGBSFPYx7PzxgzccyyDBsTotn4V2Eet1cb6wLFdiiDIOh5JQ9HuWo9TtHHFtgRHMqIeNY4gS1 fKluesiYJeOYMW+EQkws= X-Received: by 2002:a05:6000:220b:b0:39c:2692:4259 with SMTP id ffacd0b85a97d-39cb35981fdmr993481f8f.21.1743724276616; Thu, 03 Apr 2025 16:51:16 -0700 (PDT) Received: from localhost.localdomain (184.170.88.92.rev.sfr.net. [92.88.170.184]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39c301a67a1sm2918546f8f.24.2025.04.03.16.51.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Apr 2025 16:51:15 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Markus Armbruster , Richard Henderson , Pierrick Bouvier Subject: [RFC PATCH-for-10.1 19/19] system/vl: Filter machine list for binary using machine_binary_filter() Date: Fri, 4 Apr 2025 01:49:14 +0200 Message-ID: <20250403234914.9154-20-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250403234914.9154-1-philmd@linaro.org> References: <20250403234914.9154-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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é --- system/vl.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/system/vl.c b/system/vl.c index d8a0fe713c9..554f5f2a467 100644 --- a/system/vl.c +++ b/system/vl.c @@ -27,6 +27,8 @@ #include "qemu/datadir.h" #include "qemu/units.h" #include "qemu/module.h" +#include "qemu/target_info.h" +#include "qemu/target_info-qom.h" #include "exec/cpu-common.h" #include "exec/page-vary.h" #include "hw/qdev-properties.h" @@ -833,14 +835,29 @@ static bool usb_parse(const char *cmdline, Error **errp) /***********************************************************/ /* machine registration */ +static char *machine_binary_filter(void) +{ + if (target_info_is_stub()) { + return NULL; + } + return g_strconcat(TYPE_LEGACY_BINARY_PREFIX, + "qemu-system-", target_name(), NULL); +} + static MachineClass *find_machine(const char *name, GSList *machines) { GSList *el; + g_autofree char *binary_filter = machine_binary_filter(); for (el = machines; el; el = el->next) { MachineClass *mc = el->data; if (!strcmp(mc->name, name) || !g_strcmp0(mc->alias, name)) { + if (binary_filter && !object_class_dynamic_cast(el->data, + binary_filter)) { + /* Machine is not for this binary: fail */ + return NULL; + } return mc; } } @@ -1563,6 +1580,7 @@ static void machine_help_func(const QDict *qdict) g_autoptr(GSList) machines = NULL; GSList *el; const char *type = qdict_get_try_str(qdict, "type"); + g_autofree char *binary_filter = machine_binary_filter(); machines = object_class_get_list(TYPE_MACHINE, false); if (type) { @@ -1577,6 +1595,12 @@ static void machine_help_func(const QDict *qdict) machines = g_slist_sort(machines, machine_class_cmp); for (el = machines; el; el = el->next) { MachineClass *mc = el->data; + + if (binary_filter && !object_class_dynamic_cast(el->data, + binary_filter)) { + /* Machine is not for this binary: skip */ + continue; + } if (mc->alias) { printf("%-20s %s (alias of %s)\n", mc->alias, mc->desc, mc->name); }