提交 f628926b 编写于 作者: G Gerd Hoffmann 提交者: Anthony Liguori

fix monitor

chardev flow control broke monitor, fix it by adding watch support.
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 2d62a957
......@@ -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);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册