From: "Volker Rümelin" <vr_qemu@t-online.de>
To: "Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Markus Armbruster <armbru@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>, qemu-devel@nongnu.org
Subject: [PATCH] monitor/hmp: schedule qemu_chr_fe_accept_input() after read
Date: Sat, 7 Aug 2021 21:29:10 +0200 [thread overview]
Message-ID: <20210807192910.26283-1-vr_qemu@t-online.de> (raw)
In-Reply-To: <70e3486e-b486-887b-4d57-44a3fd9766ad@t-online.de>
Since commit 584af1f1d9 (ui/gtk: add a keyboard fifo to the VTE
consoles) a GTK VTE console chardev backend relies on the
connected chardev frontend to call qemu_chr_fe_accept_input()
whenever it can receive new characters. The HMP monitor doesn't
do this. It only schedules a call to qemu_chr_fe_accept_input()
after it handled a HMP command in monitor_command_cb().
This is a problem if you paste a few characters into the GTK
monitor console. Even entering a UTF-8 multibyte character leads
to the same problem.
Schedule a call to qemu_chr_fe_accept_input() after handling the
received bytes to fix the HMP monitor.
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
---
monitor/hmp.c | 1 +
monitor/monitor-internal.h | 1 +
monitor/monitor.c | 19 +++++++++++++++++--
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/monitor/hmp.c b/monitor/hmp.c
index d50c3124e1..470f56a71d 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -1349,6 +1349,7 @@ static void monitor_read(void *opaque, const uint8_t *buf, int size)
for (i = 0; i < size; i++) {
readline_handle_byte(mon->rs, buf[i]);
}
+ monitor_accept_input(&mon->common);
} else {
if (size == 0 || buf[size - 1] != 0) {
monitor_printf(&mon->common, "corrupted command\n");
diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h
index 9c3a09cb01..af33c3c617 100644
--- a/monitor/monitor-internal.h
+++ b/monitor/monitor-internal.h
@@ -170,6 +170,7 @@ int monitor_puts(Monitor *mon, const char *str);
void monitor_data_init(Monitor *mon, bool is_qmp, bool skip_flush,
bool use_io_thread);
void monitor_data_destroy(Monitor *mon);
+void monitor_accept_input(Monitor *mon);
int monitor_can_read(void *opaque);
void monitor_list_append(Monitor *mon);
void monitor_fdsets_cleanup(void);
diff --git a/monitor/monitor.c b/monitor/monitor.c
index 46a171bca6..8e3cf4ad98 100644
--- a/monitor/monitor.c
+++ b/monitor/monitor.c
@@ -519,13 +519,28 @@ int monitor_suspend(Monitor *mon)
return 0;
}
-static void monitor_accept_input(void *opaque)
+static void monitor_accept_input_bh(void *opaque)
{
Monitor *mon = opaque;
qemu_chr_fe_accept_input(&mon->chr);
}
+void monitor_accept_input(Monitor *mon)
+{
+ if (!qatomic_mb_read(&mon->suspend_cnt)) {
+ AioContext *ctx;
+
+ if (mon->use_io_thread) {
+ ctx = iothread_get_aio_context(mon_iothread);
+ } else {
+ ctx = qemu_get_aio_context();
+ }
+
+ aio_bh_schedule_oneshot(ctx, monitor_accept_input_bh, mon);
+ }
+}
+
void monitor_resume(Monitor *mon)
{
if (monitor_is_hmp_non_interactive(mon)) {
@@ -547,7 +562,7 @@ void monitor_resume(Monitor *mon)
readline_show_prompt(hmp_mon->rs);
}
- aio_bh_schedule_oneshot(ctx, monitor_accept_input, mon);
+ aio_bh_schedule_oneshot(ctx, monitor_accept_input_bh, mon);
}
trace_monitor_suspend(mon, -1);
--
2.26.2
next prev parent reply other threads:[~2021-08-07 19:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-07 19:27 [PATCH for 6.1 0/1] Fix chardev frontend bug in HMP Volker Rümelin
2021-08-07 19:29 ` Volker Rümelin [this message]
2021-08-09 9:57 ` [PATCH] monitor/hmp: schedule qemu_chr_fe_accept_input() after read Marc-André Lureau
2021-08-10 5:18 ` Volker Rümelin
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=20210807192910.26283-1-vr_qemu@t-online.de \
--to=vr_qemu@t-online.de \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=kraxel@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).