From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Amit Shah Date: Tue, 11 Jan 2011 16:54:32 +0530 Message-Id: In-Reply-To: References: In-Reply-To: References: Subject: [Qemu-devel] [PATCH 1/3] virtio-serial: Let virtio-serial-bus know if all data was consumed List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu list Cc: Amit Shah , Juan Quintela , Paul Brook , Gerd Hoffmann 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 */ -- 1.7.3.4