From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:45926) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCw9R-0007NL-3S for qemu-devel@nongnu.org; Tue, 05 Mar 2013 13:04:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UCw7Z-0000rB-5M for qemu-devel@nongnu.org; Tue, 05 Mar 2013 12:59:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45890) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCw7Y-0000r0-UZ for qemu-devel@nongnu.org; Tue, 05 Mar 2013 12:57:49 -0500 From: Amit Shah Date: Tue, 5 Mar 2013 23:21:34 +0530 Message-Id: In-Reply-To: References: In-Reply-To: References: Subject: [Qemu-devel] [PATCH 19/20] virtio: console: add flow control List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu list Cc: Amit Shah , Anthony Liguori The virtio-serial-bus already has the logic to make flow control work properly. Hook into the char layer's new ability to signal a backend is writable again. Signed-off-by: Amit Shah --- hw/virtio-console.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/virtio-console.c b/hw/virtio-console.c index 46072a0..b3ee074 100644 --- a/hw/virtio-console.c +++ b/hw/virtio-console.c @@ -20,6 +20,18 @@ typedef struct VirtConsole { CharDriverState *chr; } VirtConsole; +/* + * Callback function that's called from chardevs when backend becomes + * writable. + */ +static gboolean chr_write_unblocked(GIOChannel *chan, GIOCondition cond, + void *opaque) +{ + VirtConsole *vcon = opaque; + + virtio_serial_throttle_port(&vcon->port, false); + return FALSE; +} /* Callback function that's called when the guest sends us data */ static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len) @@ -48,6 +60,7 @@ static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len) * do_flush_queued_data(). */ ret = 0; + qemu_chr_fe_add_watch(vcon->chr, G_IO_OUT, chr_write_unblocked, vcon); } return ret; } -- 1.8.1.2