From patchwork Tue Jan 11 11:24:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 78362 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 71CB0B6F1E for ; Tue, 11 Jan 2011 23:35:58 +1100 (EST) Received: from localhost ([127.0.0.1]:49098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PcctN-0007Wg-Ua for incoming@patchwork.ozlabs.org; Tue, 11 Jan 2011 07:00:02 -0500 Received: from [140.186.70.92] (port=37030 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PccLK-0007zx-K0 for qemu-devel@nongnu.org; Tue, 11 Jan 2011 06:24:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PccLJ-0008AB-MF for qemu-devel@nongnu.org; Tue, 11 Jan 2011 06:24:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:22271) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PccLJ-00089r-Ew for qemu-devel@nongnu.org; Tue, 11 Jan 2011 06:24:49 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0BBOfS6032091 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 11 Jan 2011 06:24:41 -0500 Received: from localhost (dhcp193-64.pnq.redhat.com [10.65.193.64]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p0BBOeqd029558; Tue, 11 Jan 2011 06:24:40 -0500 From: Amit Shah To: qemu list Date: Tue, 11 Jan 2011 16:54:32 +0530 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Amit Shah , Juan Quintela , Paul Brook , Gerd Hoffmann Subject: [Qemu-devel] [PATCH 1/3] 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 3bd2b79..7c12230 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 */