From nobody Mon Feb 9 04:28:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1768667553; cv=none; d=zohomail.com; s=zohoarc; b=LS1/yGZBN/nrdG5y3jbH8e48NZmA9e6eSzdddyk7NMyQAsMzT289E92aR9S8+b+D+te2ogxkoO3tlMVPbrX+vjCjkptiTE6VeKx3Yng/niReQRAQTIohbaFoIuu2vKeyTHTLmJZ+agYiH9XCU3r2WEvTmAgiu4Jm/Oeoj/oYicc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768667553; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VE48XhslujFFPaSi8GGvuDBQGKWSJZ383NSYBz4qQHI=; b=W2mBEkE5qTj+s4xTFyB7awy9B6Mqm8Dq0OflLnzRrgsE5OtjhNQeodfh1wCIdTQQHJyQqj6IkV0J/pyMgGEPIg8wSW7hpyI5HMLQgBiBZlLkqAtOHctqyPWro9q5rz5wYBDt6ASk9kHR4aFcRvIltqQ/UFb2mW6dKD42ivyVlGY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1768667553610999.3247070498272; Sat, 17 Jan 2026 08:32:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vh9BT-0003gj-SI; Sat, 17 Jan 2026 11:29:55 -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 1vh9BR-0003cF-JA for qemu-devel@nongnu.org; Sat, 17 Jan 2026 11:29:53 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vh9BP-0006Fh-Sb for qemu-devel@nongnu.org; Sat, 17 Jan 2026 11:29:53 -0500 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-431048c4068so1675568f8f.1 for ; Sat, 17 Jan 2026 08:29:51 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4356999824csm11693454f8f.39.2026.01.17.08.29.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 17 Jan 2026 08:29:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1768667390; x=1769272190; 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=VE48XhslujFFPaSi8GGvuDBQGKWSJZ383NSYBz4qQHI=; b=jUoCImypK8gVWmReFJoQK0cbADwXsqqK/qLBFUo8PB2i/rmXeWYR1XhkbV7nkeV6vu 9sWp6efaKjN1OC9U5EqoOxTjTBd+RuKPqtlB1/oI/ingfdfKCnoo3UwkpSKvAXpHZlMO BIzA8xK3VwZqYwrBLw4h3Y14rO/YVWP8uJYXlqZ5X8qOvtPcU5NUzNR+pAUY/+PkOUiu RbPaSBXNV4XhO3bd6H9Fn2BsgTaiHfOeBwxsIyOncb1CDwo+Zds06zD+FpovBwVSEdFr X7xYSzoCH/Ch8IKMzzJVk/h0bDJdgaTFbRJ861/KbvGmSbPs7fCJljs9qC5PMRYApT4E /Ebg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768667390; x=1769272190; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=VE48XhslujFFPaSi8GGvuDBQGKWSJZ383NSYBz4qQHI=; b=OP3MgoDrHqXKHO7+/ypdUhDUhvwopdg6NcJ0iIUL3g1KGLQK3FMQ5wyQoiLGwJYSMI QzCLqGNQ/3KpJNlCNQ4ZM9xLHIyBwnMbJRTE5dkegf6nvliSrAeQ14SrqtofBhmpgCCD rm2mWpdPUNXCGg+lu6kEYp0nU1YcuvQ7eGcF0UiUJwiqxhu4I1G0s4Uot5le/VTh0NiT CcaQRIeB/fzjfFPmpcqEOX/GJPMZsH6Z2iJ/J8dhEv43eQABGWtrQx0hm5Ngh4SOTFEG uyt5TX65SkKN8YzRG3qACsck60i+KfN6/qdBcBiGPc0yKhFpZdQSratoUncdb8DbTqhL 6/2A== X-Gm-Message-State: AOJu0YxFLdZejRJNupz3pQ9+KA/Ma/hzw1hAa8JG/fMPz8Dhr541k3M+ +H6RxVZAMgxV8yjpTXC91ZUY7YfeSqi8YuS5vnkrdUjFgo8HcdAaIxiQwNVrR1aeAR6CgKKZL0X AFbgQKq8= X-Gm-Gg: AY/fxX6WqgcyNZllrHvlYbvNKaoVwgOyben3AKo/HHCu4+h53L68lKj0HwuZM60kzCY F5mNDoyUlIMxU1T+b3MPnbXjnoq1mlaXHcejqea+oS9n93tpXehsNVM/ezwD2rV1CArIdFGSPzZ UVGIIgD8VSb3WhK/iPCP/UYPKD9MA6J9CNuL52vfUJWbnk15Y/dUQ/qsKHneZ4yMw1H3YIPKfkh nq1nReL8SLC7A92uMJuNQ+8kuddl7rV9EjWhdbNrIdZRKBboZsIf1JbNzDDOo4b8mmrGZh8BWdx wX98UaMEiPv8k9zGbXBPu6XVf958V8uR29MtE692Ldq5/zVANsl+l4k8pSHyEBG6hnSs8COuSgQ SkhKHTL0zbLxjbRT5eXbEVm9xVArYZwh/5GoUVxAoSBAA3h2YqXynCOoZQCzsQdDgE+jDJHZk2h UN3bZyPd8mPFxXDFncA+FWNPB1/NwHGm5rWbOcR0IO+OGR/em/C9jygFG8LjsH X-Received: by 2002:a05:6000:2dc9:b0:430:2773:84d6 with SMTP id ffacd0b85a97d-435695652f7mr8157855f8f.24.1768667389858; Sat, 17 Jan 2026 08:29:49 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Paolo Bonzini , Pierrick Bouvier , "Dr. David Alan Gilbert" , Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 3/8] monitor: Reduce target-specific methods Date: Sat, 17 Jan 2026 17:29:21 +0100 Message-ID: <20260117162926.74225-4-philmd@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260117162926.74225-1-philmd@linaro.org> References: <20260117162926.74225-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1768667555310158500 The following methods don't use target-specific code anymore: - hmp_compare_cmd() - monitor_register_hmp() - monitor_register_hmp_info_hrt() Move them to hmp.c which is target-agnostic, being built once. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- monitor/hmp-target.c | 57 -------------------------------------------- monitor/hmp.c | 55 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 57 deletions(-) diff --git a/monitor/hmp-target.c b/monitor/hmp-target.c index 59c60d13b52..420969bd6eb 100644 --- a/monitor/hmp-target.c +++ b/monitor/hmp-target.c @@ -33,8 +33,6 @@ #include "qapi/qapi-commands-control.h" #include "qapi/qapi-commands-misc.h" #include "qapi/qapi-commands-machine.h" -#include "qapi/error.h" -#include "qemu/cutils.h" =20 #if defined(TARGET_S390X) #include "hw/s390x/storage-keys.h" @@ -44,29 +42,6 @@ /* Make devices configuration available for use in hmp-commands*.hx templa= tes */ #include CONFIG_DEVICES =20 -/** - * Is @name in the '|' separated list of names @list? - */ -int hmp_compare_cmd(const char *name, const char *list) -{ - const char *p, *pstart; - int len; - len =3D strlen(name); - p =3D list; - for (;;) { - pstart =3D p; - p =3D qemu_strchrnul(p, '|'); - if ((p - pstart) =3D=3D len && !memcmp(pstart, name, len)) { - return 1; - } - if (*p =3D=3D '\0') { - break; - } - p++; - } - return 0; -} - /* Please update hmp-commands.hx when adding or changing commands */ static HMPCommand hmp_info_cmds[] =3D { #include "hmp-commands-info.h" @@ -147,35 +122,3 @@ static void __attribute__((__constructor__)) sortcmdli= st(void) sizeof(*hmp_info_cmds), compare_mon_cmd); } - -void monitor_register_hmp(const char *name, bool info, - void (*cmd)(Monitor *mon, const QDict *qdict)) -{ - HMPCommand *table =3D hmp_cmds_for_target(info); - - while (table->name !=3D NULL) { - if (strcmp(table->name, name) =3D=3D 0) { - g_assert(table->cmd =3D=3D NULL && table->cmd_info_hrt =3D=3D = NULL); - table->cmd =3D cmd; - return; - } - table++; - } - g_assert_not_reached(); -} - -void monitor_register_hmp_info_hrt(const char *name, - HumanReadableText *(*handler)(Error **e= rrp)) -{ - HMPCommand *table =3D hmp_cmds_for_target(true); - - while (table->name !=3D NULL) { - if (strcmp(table->name, name) =3D=3D 0) { - g_assert(table->cmd =3D=3D NULL && table->cmd_info_hrt =3D=3D = NULL); - table->cmd_info_hrt =3D handler; - return; - } - table++; - } - g_assert_not_reached(); -} diff --git a/monitor/hmp.c b/monitor/hmp.c index 17e5756986f..0a5bbf82197 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -1497,3 +1497,58 @@ void monitor_init_hmp(Chardev *chr, bool use_readlin= e, Error **errp) monitor_event, NULL, &mon->common, NULL, true= ); monitor_list_append(&mon->common); } + +/** + * Is @name in the '|' separated list of names @list? + */ +int hmp_compare_cmd(const char *name, const char *list) +{ + const char *p, *pstart; + int len; + len =3D strlen(name); + p =3D list; + for (;;) { + pstart =3D p; + p =3D qemu_strchrnul(p, '|'); + if ((p - pstart) =3D=3D len && !memcmp(pstart, name, len)) { + return 1; + } + if (*p =3D=3D '\0') { + break; + } + p++; + } + return 0; +} + +void monitor_register_hmp(const char *name, bool info, + void (*cmd)(Monitor *mon, const QDict *qdict)) +{ + HMPCommand *table =3D hmp_cmds_for_target(info); + + while (table->name !=3D NULL) { + if (strcmp(table->name, name) =3D=3D 0) { + g_assert(table->cmd =3D=3D NULL && table->cmd_info_hrt =3D=3D = NULL); + table->cmd =3D cmd; + return; + } + table++; + } + g_assert_not_reached(); +} + +void monitor_register_hmp_info_hrt(const char *name, + HumanReadableText *(*handler)(Error **e= rrp)) +{ + HMPCommand *table =3D hmp_cmds_for_target(true); + + while (table->name !=3D NULL) { + if (strcmp(table->name, name) =3D=3D 0) { + g_assert(table->cmd =3D=3D NULL && table->cmd_info_hrt =3D=3D = NULL); + table->cmd_info_hrt =3D handler; + return; + } + table++; + } + g_assert_not_reached(); +} --=20 2.52.0