From: "Dr. David Alan Gilbert" <dave@treblig.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: qemu-devel@nongnu.org,
Richard Henderson <richard.henderson@linaro.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Pierrick Bouvier <pierrick.bouvier@linaro.org>,
Markus Armbruster <armbru@redhat.com>
Subject: Re: [PATCH v2 3/8] monitor: Reduce target-specific methods
Date: Mon, 19 Jan 2026 00:50:50 +0000 [thread overview]
Message-ID: <aW1_6lacDJaXHCFj@gallifrey> (raw)
In-Reply-To: <20260117162926.74225-4-philmd@linaro.org>
* Philippe Mathieu-Daudé (philmd@linaro.org) wrote:
> 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é <philmd@linaro.org>
Reviewed-by: Dr. David Alan Gilbert <dave@treblig.org>
> ---
> 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"
>
> #if defined(TARGET_S390X)
> #include "hw/s390x/storage-keys.h"
> @@ -44,29 +42,6 @@
> /* Make devices configuration available for use in hmp-commands*.hx templates */
> #include CONFIG_DEVICES
>
> -/**
> - * 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 = strlen(name);
> - p = list;
> - for (;;) {
> - pstart = p;
> - p = qemu_strchrnul(p, '|');
> - if ((p - pstart) == len && !memcmp(pstart, name, len)) {
> - return 1;
> - }
> - if (*p == '\0') {
> - break;
> - }
> - p++;
> - }
> - return 0;
> -}
> -
> /* Please update hmp-commands.hx when adding or changing commands */
> static HMPCommand hmp_info_cmds[] = {
> #include "hmp-commands-info.h"
> @@ -147,35 +122,3 @@ static void __attribute__((__constructor__)) sortcmdlist(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 = hmp_cmds_for_target(info);
> -
> - while (table->name != NULL) {
> - if (strcmp(table->name, name) == 0) {
> - g_assert(table->cmd == NULL && table->cmd_info_hrt == NULL);
> - table->cmd = cmd;
> - return;
> - }
> - table++;
> - }
> - g_assert_not_reached();
> -}
> -
> -void monitor_register_hmp_info_hrt(const char *name,
> - HumanReadableText *(*handler)(Error **errp))
> -{
> - HMPCommand *table = hmp_cmds_for_target(true);
> -
> - while (table->name != NULL) {
> - if (strcmp(table->name, name) == 0) {
> - g_assert(table->cmd == NULL && table->cmd_info_hrt == NULL);
> - table->cmd_info_hrt = 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_readline, 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 = strlen(name);
> + p = list;
> + for (;;) {
> + pstart = p;
> + p = qemu_strchrnul(p, '|');
> + if ((p - pstart) == len && !memcmp(pstart, name, len)) {
> + return 1;
> + }
> + if (*p == '\0') {
> + break;
> + }
> + p++;
> + }
> + return 0;
> +}
> +
> +void monitor_register_hmp(const char *name, bool info,
> + void (*cmd)(Monitor *mon, const QDict *qdict))
> +{
> + HMPCommand *table = hmp_cmds_for_target(info);
> +
> + while (table->name != NULL) {
> + if (strcmp(table->name, name) == 0) {
> + g_assert(table->cmd == NULL && table->cmd_info_hrt == NULL);
> + table->cmd = cmd;
> + return;
> + }
> + table++;
> + }
> + g_assert_not_reached();
> +}
> +
> +void monitor_register_hmp_info_hrt(const char *name,
> + HumanReadableText *(*handler)(Error **errp))
> +{
> + HMPCommand *table = hmp_cmds_for_target(true);
> +
> + while (table->name != NULL) {
> + if (strcmp(table->name, name) == 0) {
> + g_assert(table->cmd == NULL && table->cmd_info_hrt == NULL);
> + table->cmd_info_hrt = handler;
> + return;
> + }
> + table++;
> + }
> + g_assert_not_reached();
> +}
> --
> 2.52.0
>
--
-----Open up your eyes, open up your mind, open up your code -------
/ Dr. David Alan Gilbert | Running GNU/Linux | Happy \
\ dave @ treblig.org | | In Hex /
\ _________________________|_____ http://www.treblig.org |_______/
next prev parent reply other threads:[~2026-01-19 0:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-17 16:29 [PATCH v2 0/8] monitor/hmp: Reduce target-specific definitions Philippe Mathieu-Daudé
2026-01-17 16:29 ` [PATCH v2 1/8] target/i386: Include missing 'svm.h' header in 'sev.h' Philippe Mathieu-Daudé
2026-01-19 5:37 ` Zhao Liu
2026-01-17 16:29 ` [PATCH v2 2/8] monitor: Add hmp_cmds_for_target() helper Philippe Mathieu-Daudé
2026-01-19 2:04 ` Dr. David Alan Gilbert
2026-01-17 16:29 ` [PATCH v2 3/8] monitor: Reduce target-specific methods Philippe Mathieu-Daudé
2026-01-19 0:50 ` Dr. David Alan Gilbert [this message]
2026-01-17 16:29 ` [PATCH v2 4/8] monitor: Have MonitorDef::get_value() return an unsigned type Philippe Mathieu-Daudé
2026-01-19 0:59 ` Dr. David Alan Gilbert
2026-01-17 16:29 ` [PATCH v2 5/8] monitor: Have *get_monitor_def() fill an unsigned value Philippe Mathieu-Daudé
2026-01-19 1:12 ` Dr. David Alan Gilbert
2026-01-17 16:29 ` [PATCH v2 6/8] monitor: Truncate target register using ldn_he_p() API Philippe Mathieu-Daudé
2026-01-17 16:29 ` [PATCH v2 7/8] monitor: Reduce target-specific methods further Philippe Mathieu-Daudé
2026-01-19 2:01 ` Dr. David Alan Gilbert
2026-01-17 16:29 ` [PATCH v2 8/8] monitor: Remove 'monitor/hmp-target.h' header Philippe Mathieu-Daudé
2026-01-19 2:03 ` Dr. David Alan Gilbert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aW1_6lacDJaXHCFj@gallifrey \
--to=dave@treblig.org \
--cc=armbru@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.