monitor: remove 'skip_flush' field
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. Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Tested-by: Peter Krempa <pkrempa@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-ID: <20260706135824.2623960-11-berrange@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Daniel P. Berrangé committed
Jul 6, 2026 at 14:57 UTC
ae286229f41ed6869fab4b57883368b47c6acf85
5 files changed
+11
-10
monitor/hmp.c
+1
-1
@@ -1590,7 +1590,7 @@ void monitor_new_hmp(const char *id, const char *chardev_id,
1590
return;
1591
}
1592
1593
- monitor_data_init(&mon->parent_obj, false, false, false);
1593
+ monitor_data_init(&mon->parent_obj, false, false);
1594
1595
if (mon->use_readline) {
1596
mon->rs = readline_init(monitor_readline_printf,
monitor/monitor-internal.h
+1
-3
@@ -112,7 +112,6 @@ struct Monitor {
112
CharFrontend chr;
113
int suspend_cnt; /* Needs to be accessed atomically */
114
bool is_qmp;
115
- bool skip_flush;
115
bool use_io_thread;
116
117
char *mon_cpu_path;
@@ -194,8 +193,7 @@ extern QemuMutex monitor_lock;
193
extern MonitorList mon_list;
194
195
void monitor_complete(Monitor *mon, Error **errp);
197
-void monitor_data_init(Monitor *mon, bool is_qmp, bool skip_flush,
198
- bool use_io_thread);
196
+void monitor_data_init(Monitor *mon, bool is_qmp, bool use_io_thread);
197
void monitor_data_destroy(Monitor *mon);
198
int monitor_can_read(void *opaque);
199
void monitor_list_append(Monitor *mon);
monitor/monitor.c
+7
-4
@@ -190,7 +190,12 @@ void monitor_flush_locked(Monitor *mon)
190
size_t len;
191
const char *buf;
192
193
- if (mon->skip_flush) {
193
+ /*
194
+ * When used by QMP human-monitor-command, no chardev
195
+ * will be connected, as we want to just collect the
196
+ * output in the buffer
197
+ */
198
+ if (!mon->chr.fe_is_open) {
199
return;
200
}
201
@@ -644,8 +649,7 @@ static void monitor_iothread_init(void)
649
mon_iothread = iothread_create("mon_iothread", &error_abort);
650
}
651
647
-void monitor_data_init(Monitor *mon, bool is_qmp, bool skip_flush,
648
- bool use_io_thread)
652
+void monitor_data_init(Monitor *mon, bool is_qmp, bool use_io_thread)
653
{
654
if (use_io_thread && !mon_iothread) {
655
monitor_iothread_init();
@@ -653,7 +657,6 @@ void monitor_data_init(Monitor *mon, bool is_qmp, bool skip_flush,
657
qemu_mutex_init(&mon->mon_lock);
658
mon->is_qmp = is_qmp;
659
mon->outbuf = g_string_new(NULL);
656
- mon->skip_flush = skip_flush;
660
mon->use_io_thread = use_io_thread;
661
}
662
monitor/qmp-cmds.c
+1
-1
@@ -168,7 +168,7 @@ char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,
168
char *output = NULL;
169
MonitorHMP *hmp = MONITOR_HMP(object_new(TYPE_MONITOR_HMP));
170
171
- monitor_data_init(&hmp->parent_obj, false, true, false);
171
+ monitor_data_init(&hmp->parent_obj, false, false);
172
173
if (has_cpu_index) {
174
int ret = monitor_set_cpu(&hmp->parent_obj, cpu_index);
monitor/qmp.c
+1
-1
@@ -572,7 +572,7 @@ void monitor_new_qmp(const char *id, const char *chardev_id,
572
qemu_chr_fe_set_echo(&mon->parent_obj.chr, true);
573
574
/* Note: we run QMP monitor in I/O thread when @chr supports that */
575
- monitor_data_init(&mon->parent_obj, true, false,
575
+ monitor_data_init(&mon->parent_obj, true,
576
qemu_chr_has_feature(mon->parent_obj.chr.chr,
577
QEMU_CHAR_FEATURE_GCONTEXT));
578