Patchwork [05/12] char: add read functions for backend and frontend

login
register
mail settings
Submitter Anthony Liguori
Date Aug. 1, 2011, 2:23 p.m.
Message ID <1312208590-25502-6-git-send-email-aliguori@us.ibm.com>
Download mbox | patch
Permalink /patch/107755/
State New
Headers show

Comments

Anthony Liguori - Aug. 1, 2011, 2:23 p.m.
Instead of waiting for a callback to send data, allow for reading the backend
and frontend tx queues directly.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 qemu-char.c |   10 ++++++++++
 qemu-char.h |    2 ++
 2 files changed, 12 insertions(+), 0 deletions(-)

Patch

diff --git a/qemu-char.c b/qemu-char.c
index 2746652..0e4a30c 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -205,6 +205,11 @@  int qemu_chr_fe_write(CharDriverState *s, const uint8_t *buf, int len)
     return ret;
 }
 
+int qemu_chr_fe_read(CharDriverState *s, uint8_t *buf, int len)
+{
+    return char_queue_read(&s->be_tx, buf, len);
+}
+
 static void qemu_chr_flush_be_tx(CharDriverState *s)
 {
     uint8_t buf[MAX_CHAR_QUEUE_RING];
@@ -243,6 +248,11 @@  int qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len)
     return ret;
 }
 
+int qemu_chr_be_read(CharDriverState *s, uint8_t *buf, int len)
+{
+    return char_queue_read(&s->fe_tx, buf, len);
+}
+
 int qemu_chr_ioctl(CharDriverState *s, int cmd, void *arg)
 {
     if (!s->chr_ioctl)
diff --git a/qemu-char.h b/qemu-char.h
index 85735b5..a75bd1c 100644
--- a/qemu-char.h
+++ b/qemu-char.h
@@ -101,6 +101,7 @@  void qemu_chr_close(CharDriverState *chr);
 void qemu_chr_printf(CharDriverState *s, const char *fmt, ...)
     GCC_FMT_ATTR(2, 3);
 int qemu_chr_fe_write(CharDriverState *s, const uint8_t *buf, int len);
+int qemu_chr_fe_read(CharDriverState *s, uint8_t *buf, int len);
 void qemu_chr_send_event(CharDriverState *s, int event);
 void qemu_chr_add_handlers(CharDriverState *s,
                            IOCanReadHandler *fd_can_read,
@@ -111,6 +112,7 @@  int qemu_chr_ioctl(CharDriverState *s, int cmd, void *arg);
 void qemu_chr_generic_open(CharDriverState *s);
 int qemu_chr_be_can_write(CharDriverState *s);
 int qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len);
+int qemu_chr_be_read(CharDriverState *s, uint8_t *buf, int len);
 int qemu_chr_get_msgfd(CharDriverState *s);
 void qemu_chr_accept_input(CharDriverState *s);
 int qemu_chr_add_client(CharDriverState *s, int fd);