From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N5KPT-00029M-MG for qemu-devel@nongnu.org; Tue, 03 Nov 2009 09:30:59 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N5KPP-000285-Qt for qemu-devel@nongnu.org; Tue, 03 Nov 2009 09:30:59 -0500 Received: from [199.232.76.173] (port=59994 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N5KPP-000282-NM for qemu-devel@nongnu.org; Tue, 03 Nov 2009 09:30:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:8941) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N5KPP-0000W2-8b for qemu-devel@nongnu.org; Tue, 03 Nov 2009 09:30:55 -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 nA3EUsUU022536 for ; Tue, 3 Nov 2009 09:30:54 -0500 From: Amit Shah Date: Tue, 3 Nov 2009 19:59:54 +0530 Message-Id: <1257258596-4556-2-git-send-email-amit.shah@redhat.com> In-Reply-To: <1257258596-4556-1-git-send-email-amit.shah@redhat.com> References: <1257258596-4556-1-git-send-email-amit.shah@redhat.com> Subject: [Qemu-devel] [PATCH 1/3] char: don't limit data sent to backends to 1k per buffer List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Amit Shah chardevs have a 'can_read' function via which backends specify the amount of data they can receive. When can_read returns > 0, apps can start sending data. However, each chardev driver here allows a max. of 1k bytes inspite of the backend being able to receive more. The best we can do here is to allocate s->max_size bytes from the heap on each call (which is the number returned by the backend from the can_read call). This is an intermediate step to bump up the bytes written in each call to 4k. Signed-off-by: Amit Shah --- qemu-char.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 40bd7e8..1f63019 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -97,6 +97,8 @@ #include "qemu_socket.h" +#define READ_BUF_LEN 4096 + /***********************************************************/ /* character device */ @@ -172,7 +174,7 @@ void qemu_chr_accept_input(CharDriverState *s) void qemu_chr_printf(CharDriverState *s, const char *fmt, ...) { - char buf[4096]; + char buf[READ_BUF_LEN]; va_list ap; va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); @@ -555,7 +557,7 @@ static void fd_chr_read(void *opaque) CharDriverState *chr = opaque; FDCharDriver *s = chr->opaque; int size, len; - uint8_t buf[1024]; + uint8_t buf[READ_BUF_LEN]; len = sizeof(buf); if (len > s->max_size) @@ -866,7 +868,7 @@ static void pty_chr_read(void *opaque) CharDriverState *chr = opaque; PtyCharDriver *s = chr->opaque; int size, len; - uint8_t buf[1024]; + uint8_t buf[READ_BUF_LEN]; len = sizeof(buf); if (len > s->read_bytes) @@ -1554,7 +1556,7 @@ static void win_chr_readfile(CharDriverState *chr) { WinCharState *s = chr->opaque; int ret, err; - uint8_t buf[1024]; + uint8_t buf[READ_BUF_LEN]; DWORD size; ZeroMemory(&s->orecv, sizeof(s->orecv)); @@ -1760,7 +1762,7 @@ static CharDriverState *qemu_chr_open_win_file_out(QemuOpts *opts) typedef struct { int fd; - uint8_t buf[1024]; + uint8_t buf[READ_BUF_LEN]; int bufcnt; int bufptr; int max_size; @@ -2020,7 +2022,7 @@ static void tcp_chr_read(void *opaque) { CharDriverState *chr = opaque; TCPCharDriver *s = chr->opaque; - uint8_t buf[1024]; + uint8_t buf[READ_BUF_LEN]; int len, size; if (!s->connected || s->max_size <= 0) -- 1.6.2.5