From patchwork Mon Feb 4 12:50:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 217901 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F2CE92C02A7 for ; Mon, 4 Feb 2013 23:51:57 +1100 (EST) Received: from localhost ([::1]:60445 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2LWe-0006jR-2k for incoming@patchwork.ozlabs.org; Mon, 04 Feb 2013 07:51:56 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50140) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2LWO-0006Z7-MQ for qemu-devel@nongnu.org; Mon, 04 Feb 2013 07:51:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U2LWN-0003MT-MK for qemu-devel@nongnu.org; Mon, 04 Feb 2013 07:51:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39279) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2LWN-0003MM-F0 for qemu-devel@nongnu.org; Mon, 04 Feb 2013 07:51:39 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r14CpcS9019681 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 4 Feb 2013 07:51:38 -0500 Received: from localhost ([10.3.113.7]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r14CpWmc031987; Mon, 4 Feb 2013 07:51:35 -0500 From: Amit Shah To: Anthony Liguori Date: Mon, 4 Feb 2013 18:20:50 +0530 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Amit Shah , qemu list Subject: [Qemu-devel] [PATCH 4/4] virtio: console: add flow control X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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..0cf6072 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; }