From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47906) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHx03-0000OW-Rg for qemu-devel@nongnu.org; Tue, 19 Mar 2013 09:54:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UHwzz-000252-2n for qemu-devel@nongnu.org; Tue, 19 Mar 2013 09:54:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23694) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHwzy-00024u-QO for qemu-devel@nongnu.org; Tue, 19 Mar 2013 09:54:43 -0400 Message-ID: <51486EE9.2070907@redhat.com> Date: Tue, 19 Mar 2013 14:58:01 +0100 From: Hans de Goede MIME-Version: 1.0 References: <1363687076-11878-1-git-send-email-kraxel@redhat.com> In-Reply-To: <1363687076-11878-1-git-send-email-kraxel@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] fix monitor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: amit.shah@redhat.com, Luiz Capitulino , qemu-devel@nongnu.org, anthony@codemonkey.ws, Markus Armbruster Hi, Looks good, one minor nitpick. On 03/19/2013 10:57 AM, Gerd Hoffmann wrote: > chardev flow control broke monitor, fix it by adding watch support. > --- > monitor.c | 23 +++++++++++++++++++++-- > 1 file changed, 21 insertions(+), 2 deletions(-) > > diff --git a/monitor.c b/monitor.c > index 112e920..680d344 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 */ Typo in the comment. > + 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); > } > } > > Regards, Hans