Skip to content

Commit

Permalink
fix monitor
Browse files Browse the repository at this point in the history
chardev flow control broke monitor, fix it by adding watch support.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
  • Loading branch information
kraxel authored and Anthony Liguori committed Mar 19, 2013
1 parent 2d62a95 commit f628926
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions monitor.c
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit f628926

Please sign in to comment.