summaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2013-03-19 10:57:56 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2013-03-19 07:52:10 -0500
commitf628926bb423fa8a7e0b114511400ea9df38b76a (patch)
tree759d03faa04764b7c2e04010280adc94c6f8c75a /monitor.c
parent2d62a95766025e6a0a333528278936e2cc8bf978 (diff)
downloadqemu-f628926bb423fa8a7e0b114511400ea9df38b76a.tar.gz
fix monitor
chardev flow control broke monitor, fix it by adding watch support. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/monitor.c b/monitor.c
index 112e92064d..680d344211 100644
--- a/monitor.c
+++ b/monitor.c
@@ -261,11 +261,30 @@ int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func,
}
}
+static gboolean monitor_unblocked(GIOChannel *chan, GIOCondition cond,
+ void *opaque)
+{
+ monitor_flush(opaque);
+ return FALSE;
+}
+
void monitor_flush(Monitor *mon)
{
+ int rc;
+
if (mon && mon->outbuf_index != 0 && !mon->mux_out) {
- qemu_chr_fe_write(mon->chr, mon->outbuf, mon->outbuf_index);
- mon->outbuf_index = 0;
+ rc = qemu_chr_fe_write(mon->chr, mon->outbuf, mon->outbuf_index);
+ if (rc == mon->outbuf_index) {
+ /* all flushed */
+ mon->outbuf_index = 0;
+ return;
+ }
+ if (rc > 0) {
+ /* partinal write */
+ memmove(mon->outbuf, mon->outbuf + rc, mon->outbuf_index - rc);
+ mon->outbuf_index -= rc;
+ }
+ qemu_chr_fe_add_watch(mon->chr, G_IO_OUT, monitor_unblocked, mon);
}
}