From patchwork Wed Jan 19 12:27:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 79457 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 023E9B70B3 for ; Wed, 19 Jan 2011 23:33:45 +1100 (EST) Received: from localhost ([127.0.0.1]:37196 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PfXEM-00030w-49 for incoming@patchwork.ozlabs.org; Wed, 19 Jan 2011 07:33:42 -0500 Received: from [140.186.70.92] (port=53555 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PfX8k-0000Iu-AW for qemu-devel@nongnu.org; Wed, 19 Jan 2011 07:27:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PfX8i-0007VY-M6 for qemu-devel@nongnu.org; Wed, 19 Jan 2011 07:27:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:10394) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PfX8i-0007VS-Bo for qemu-devel@nongnu.org; Wed, 19 Jan 2011 07:27:52 -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.13.8/8.13.8) with ESMTP id p0JCRbZF001991 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 19 Jan 2011 07:27:37 -0500 Received: from localhost (dhcp193-64.pnq.redhat.com [10.65.193.64]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0JCRaKl031759; Wed, 19 Jan 2011 07:27:37 -0500 From: Amit Shah To: qemu list Date: Wed, 19 Jan 2011 17:57:17 +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: Genre and OS details not recognized. Cc: Amit Shah , Juan Quintela , Gerd Hoffmann , Paul Brook Subject: [Qemu-devel] [PATCH 5/7] virtio-serial: Let virtio-serial-bus know if all data was consumed X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The have_data() API to hand off guest data to apps using virtio-serial so far assumed all the data was consumed. Relax this assumption. Future commits will allow for incomplete writes. Signed-off-by: Amit Shah --- hw/virtio-console.c | 4 ++-- hw/virtio-serial.h | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/hw/virtio-console.c b/hw/virtio-console.c index d0b9354..62624ec 100644 --- a/hw/virtio-console.c +++ b/hw/virtio-console.c @@ -20,11 +20,11 @@ typedef struct VirtConsole { /* Callback function that's called when the guest sends us data */ -static void flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len) +static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len) { VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port); - qemu_chr_write(vcon->chr, buf, len); + return qemu_chr_write(vcon->chr, buf, len); } /* Readiness of the guest to accept data on a port */ diff --git a/hw/virtio-serial.h b/hw/virtio-serial.h index ff08c40..9cc0fb3 100644 --- a/hw/virtio-serial.h +++ b/hw/virtio-serial.h @@ -137,10 +137,11 @@ struct VirtIOSerialPortInfo { /* * Guest wrote some data to the port. This data is handed over to - * the app via this callback. The app is supposed to consume all - * the data that is presented to it. + * the app via this callback. The app can return a size less than + * 'len'. In this case, throttling will be enabled for this port. */ - void (*have_data)(VirtIOSerialPort *port, const uint8_t *buf, size_t len); + ssize_t (*have_data)(VirtIOSerialPort *port, const uint8_t *buf, + size_t len); }; /* Interface to the virtio-serial bus */