mirror of https://github.com/xemu-project/xemu.git
char: don't limit data sent to backends to 1k per buffer
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 <amit.shah@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
0ef849d751
commit
9bd7854e1e
14
qemu-char.c
14
qemu-char.c
|
@ -97,6 +97,8 @@
|
||||||
|
|
||||||
#include "qemu_socket.h"
|
#include "qemu_socket.h"
|
||||||
|
|
||||||
|
#define READ_BUF_LEN 4096
|
||||||
|
|
||||||
/***********************************************************/
|
/***********************************************************/
|
||||||
/* character device */
|
/* character device */
|
||||||
|
|
||||||
|
@ -172,7 +174,7 @@ void qemu_chr_accept_input(CharDriverState *s)
|
||||||
|
|
||||||
void qemu_chr_printf(CharDriverState *s, const char *fmt, ...)
|
void qemu_chr_printf(CharDriverState *s, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char buf[4096];
|
char buf[READ_BUF_LEN];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||||
|
@ -555,7 +557,7 @@ static void fd_chr_read(void *opaque)
|
||||||
CharDriverState *chr = opaque;
|
CharDriverState *chr = opaque;
|
||||||
FDCharDriver *s = chr->opaque;
|
FDCharDriver *s = chr->opaque;
|
||||||
int size, len;
|
int size, len;
|
||||||
uint8_t buf[1024];
|
uint8_t buf[READ_BUF_LEN];
|
||||||
|
|
||||||
len = sizeof(buf);
|
len = sizeof(buf);
|
||||||
if (len > s->max_size)
|
if (len > s->max_size)
|
||||||
|
@ -866,7 +868,7 @@ static void pty_chr_read(void *opaque)
|
||||||
CharDriverState *chr = opaque;
|
CharDriverState *chr = opaque;
|
||||||
PtyCharDriver *s = chr->opaque;
|
PtyCharDriver *s = chr->opaque;
|
||||||
int size, len;
|
int size, len;
|
||||||
uint8_t buf[1024];
|
uint8_t buf[READ_BUF_LEN];
|
||||||
|
|
||||||
len = sizeof(buf);
|
len = sizeof(buf);
|
||||||
if (len > s->read_bytes)
|
if (len > s->read_bytes)
|
||||||
|
@ -1554,7 +1556,7 @@ static void win_chr_readfile(CharDriverState *chr)
|
||||||
{
|
{
|
||||||
WinCharState *s = chr->opaque;
|
WinCharState *s = chr->opaque;
|
||||||
int ret, err;
|
int ret, err;
|
||||||
uint8_t buf[1024];
|
uint8_t buf[READ_BUF_LEN];
|
||||||
DWORD size;
|
DWORD size;
|
||||||
|
|
||||||
ZeroMemory(&s->orecv, sizeof(s->orecv));
|
ZeroMemory(&s->orecv, sizeof(s->orecv));
|
||||||
|
@ -1760,7 +1762,7 @@ static CharDriverState *qemu_chr_open_win_file_out(QemuOpts *opts)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int fd;
|
int fd;
|
||||||
uint8_t buf[1024];
|
uint8_t buf[READ_BUF_LEN];
|
||||||
int bufcnt;
|
int bufcnt;
|
||||||
int bufptr;
|
int bufptr;
|
||||||
int max_size;
|
int max_size;
|
||||||
|
@ -2020,7 +2022,7 @@ static void tcp_chr_read(void *opaque)
|
||||||
{
|
{
|
||||||
CharDriverState *chr = opaque;
|
CharDriverState *chr = opaque;
|
||||||
TCPCharDriver *s = chr->opaque;
|
TCPCharDriver *s = chr->opaque;
|
||||||
uint8_t buf[1024];
|
uint8_t buf[READ_BUF_LEN];
|
||||||
int len, size;
|
int len, size;
|
||||||
|
|
||||||
if (!s->connected || s->max_size <= 0)
|
if (!s->connected || s->max_size <= 0)
|
||||||
|
|
Loading…
Reference in New Issue