From: "Dr. David Alan Gilbert" <dave@treblig.org>
To: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Christian Brauner" <brauner@kernel.org>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Fabiano Rosas" <farosas@suse.de>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Peter Xu" <peterx@redhat.com>, "Kevin Wolf" <kwolf@redhat.com>,
qemu-block@nongnu.org, "Eric Blake" <eblake@redhat.com>
Subject: Re: [PATCH 05/17] monitor: remove 'skip_flush' field
Date: Mon, 13 Apr 2026 01:28:13 +0000 [thread overview]
Message-ID: <adxGrbCi4LfS0lsT@gallifrey> (raw)
In-Reply-To: <20260410160458.3778874-6-berrange@redhat.com>
* Daniel P. Berrangé (berrange@redhat.com) wrote:
> The 'skip_flush' field is set on the dummy throwaway HMP monitor
> object created by QMP's 'human-monitor-command', as an indication
> not to try to write data to the chardev. Instead the QMP command
> impl will grab the data straight out of the in-memory buffer.
>
> The flag is redundant, however, as the monitor code could instead
> simply check the 'fe_is_open' field on the CharFrontend, which
> will be false in the same scenarios that 'skip_flush' is true.
For monitors on sockets where the other end isn't connected, does that
change the behaviour? Does that also have !fe_is_open and can that hit this
case?
Dave
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
> monitor/hmp.c | 2 +-
> monitor/monitor-internal.h | 4 +---
> monitor/monitor.c | 11 +++++++----
> monitor/qmp-cmds.c | 2 +-
> monitor/qmp.c | 2 +-
> 5 files changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/monitor/hmp.c b/monitor/hmp.c
> index 614d9a3707..72f8303662 100644
> --- a/monitor/hmp.c
> +++ b/monitor/hmp.c
> @@ -1539,7 +1539,7 @@ void monitor_new_hmp(Chardev *chr, bool use_readline, Error **errp)
> return;
> }
>
> - monitor_data_init(&mon->parent, false, false, false);
> + monitor_data_init(&mon->parent, false, false);
>
> mon->use_readline = use_readline;
> if (mon->use_readline) {
> diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h
> index 25320928a7..84117805b7 100644
> --- a/monitor/monitor-internal.h
> +++ b/monitor/monitor-internal.h
> @@ -102,7 +102,6 @@ struct Monitor {
> CharFrontend chr;
> int suspend_cnt; /* Needs to be accessed atomically */
> bool is_qmp;
> - bool skip_flush;
> bool use_io_thread;
>
> char *mon_cpu_path;
> @@ -183,8 +182,7 @@ extern QmpCommandList qmp_commands, qmp_cap_negotiation_commands;
> extern QemuMutex monitor_lock;
> extern MonitorList mon_list;
>
> -void monitor_data_init(Monitor *mon, bool is_qmp, bool skip_flush,
> - bool use_io_thread);
> +void monitor_data_init(Monitor *mon, bool is_qmp, bool use_io_thread);
> void monitor_data_destroy(Monitor *mon);
> int monitor_can_read(void *opaque);
> void monitor_list_append(Monitor *mon);
> diff --git a/monitor/monitor.c b/monitor/monitor.c
> index 7936e2ab22..f7e3708d2f 100644
> --- a/monitor/monitor.c
> +++ b/monitor/monitor.c
> @@ -167,7 +167,12 @@ void monitor_flush_locked(Monitor *mon)
> size_t len;
> const char *buf;
>
> - if (mon->skip_flush) {
> + /*
> + * When used by QMP human-monitor-command, no chardev
> + * will be connected, as we want to just collect the
> + * output in the buffer
> + */
> + if (!mon->chr.fe_is_open) {
> return;
> }
>
> @@ -621,8 +626,7 @@ static void monitor_iothread_init(void)
> mon_iothread = iothread_create("mon_iothread", &error_abort);
> }
>
> -void monitor_data_init(Monitor *mon, bool is_qmp, bool skip_flush,
> - bool use_io_thread)
> +void monitor_data_init(Monitor *mon, bool is_qmp, bool use_io_thread)
> {
> if (use_io_thread && !mon_iothread) {
> monitor_iothread_init();
> @@ -630,7 +634,6 @@ void monitor_data_init(Monitor *mon, bool is_qmp, bool skip_flush,
> qemu_mutex_init(&mon->mon_lock);
> mon->is_qmp = is_qmp;
> mon->outbuf = g_string_new(NULL);
> - mon->skip_flush = skip_flush;
> mon->use_io_thread = use_io_thread;
> }
>
> diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
> index d0ed241d6a..be2bd985b7 100644
> --- a/monitor/qmp-cmds.c
> +++ b/monitor/qmp-cmds.c
> @@ -168,7 +168,7 @@ char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,
> char *output = NULL;
> MonitorHMP *hmp = MONITOR_HMP(object_new(TYPE_MONITOR_HMP));
>
> - monitor_data_init(&hmp->parent, false, true, false);
> + monitor_data_init(&hmp->parent, false, false);
>
> if (has_cpu_index) {
> int ret = monitor_set_cpu(&hmp->parent, cpu_index);
> diff --git a/monitor/qmp.c b/monitor/qmp.c
> index 36cb078f30..fe2aec9ce9 100644
> --- a/monitor/qmp.c
> +++ b/monitor/qmp.c
> @@ -538,7 +538,7 @@ void monitor_new_qmp(Chardev *chr, bool pretty, Error **errp)
> qemu_chr_fe_set_echo(&mon->parent.chr, true);
>
> /* Note: we run QMP monitor in I/O thread when @chr supports that */
> - monitor_data_init(&mon->parent, true, false,
> + monitor_data_init(&mon->parent, true,
> qemu_chr_has_feature(chr, QEMU_CHAR_FEATURE_GCONTEXT));
>
> mon->pretty = pretty;
> --
> 2.53.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-04-13 1:29 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-10 16:04 [PATCH RFC 00/17] monitor: turn QMP and HMP into QOM objects Daniel P. Berrangé
2026-04-10 16:04 ` [PATCH 01/17] monitor: replace 'common' with 'parent' in MonitorHMP Daniel P. Berrangé
2026-04-10 21:05 ` Dr. David Alan Gilbert
2026-04-10 16:04 ` [PATCH 02/17] monitor: replace 'common' with 'parent' in MonitorQMP Daniel P. Berrangé
2026-04-14 15:15 ` Mark Cave-Ayland
2026-04-14 15:25 ` Daniel P. Berrangé
2026-04-14 17:54 ` Dr. David Alan Gilbert
2026-04-10 16:04 ` [PATCH 03/17] monitor: rename monitor_init* to monitor_new* Daniel P. Berrangé
2026-04-10 22:57 ` Dr. David Alan Gilbert
2026-04-10 16:04 ` [PATCH 04/17] monitor: minimal conversion of monitors to QOM Daniel P. Berrangé
2026-04-10 23:32 ` Dr. David Alan Gilbert
2026-04-10 16:04 ` [PATCH 05/17] monitor: remove 'skip_flush' field Daniel P. Berrangé
2026-04-13 1:28 ` Dr. David Alan Gilbert [this message]
2026-04-13 10:00 ` Daniel P. Berrangé
2026-04-13 15:22 ` Dr. David Alan Gilbert
2026-04-10 16:04 ` [PATCH 06/17] monitor: move monitor_data_(init|destroy) into QOM init/finalize Daniel P. Berrangé
2026-04-10 16:04 ` [PATCH 07/17] monitor: use class methods for monitor_vprintf Daniel P. Berrangé
2026-04-13 1:32 ` Dr. David Alan Gilbert
2026-04-10 16:04 ` [PATCH 08/17] monitor: use class methods for monitor_qapi_event_emit Daniel P. Berrangé
2026-04-10 16:04 ` [PATCH 09/17] monitor: use class methods for monitor_accept_input Daniel P. Berrangé
2026-04-13 17:43 ` Dr. David Alan Gilbert
2026-04-10 16:04 ` [PATCH 10/17] monitor: use dynamic cast in monitor_qmp_requests_pop_any_with_lock Daniel P. Berrangé
2026-04-10 16:04 ` [PATCH 11/17] util: use dynamic cast in error vreport Daniel P. Berrangé
2026-04-10 16:04 ` [PATCH 12/17] monitor: drop unused monitor_cur_is_qmp Daniel P. Berrangé
2026-04-10 16:04 ` [PATCH 13/17] monitor: use dynamic cast in QMP commands Daniel P. Berrangé
2026-04-10 16:04 ` [PATCH 14/17] monitor: use dynamic cast in monitor_is_hmp_non_interactive Daniel P. Berrangé
2026-04-10 16:04 ` [PATCH 15/17] monitor: drop unused monitor_is_qmp method Daniel P. Berrangé
2026-04-10 16:04 ` [PATCH 16/17] monitor: eliminate monitor_is_hmp_non_interactive method Daniel P. Berrangé
2026-04-13 22:47 ` Dr. David Alan Gilbert
2026-04-10 16:04 ` [PATCH 17/17] FIXME: monitor: implement "user creatable" interface Daniel P. Berrangé
2026-04-27 6:35 ` [PATCH RFC 00/17] monitor: turn QMP and HMP into QOM objects Markus Armbruster
2026-04-27 7:04 ` Daniel P. Berrangé
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=adxGrbCi4LfS0lsT@gallifrey \
--to=dave@treblig.org \
--cc=alex.bennee@linaro.org \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=brauner@kernel.org \
--cc=eblake@redhat.com \
--cc=farosas@suse.de \
--cc=kwolf@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.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.