fc5c27
>From 3ad2ca8e46ba078e69254ca5886de89b30f823bb Mon Sep 17 00:00:00 2001
3f1f29
From: Amit Shah <amit.shah@redhat.com>
3f1f29
Date: Mon, 21 Mar 2011 21:41:42 +0100
fc5c27
Subject: [PATCH 04/28] char: Add framework for a 'write unblocked' callback
3f1f29
3f1f29
The char layer can let users know that the driver will block on further
3f1f29
input.  For users interested in not blocking, they can assign a function
3f1f29
pointer that will be called back when the driver becomes writable.  This
3f1f29
patch just adds the function pointers to the CharDriverState structure,
3f1f29
future patches will enable the nonblocking and callback functionality.
3f1f29
3f1f29
Signed-off-by: Amit Shah <amit.shah@redhat.com>
3f1f29
---
3f1f29
 qemu-char.c |    3 +++
3f1f29
 qemu-char.h |    4 ++++
3f1f29
 2 files changed, 7 insertions(+), 0 deletions(-)
3f1f29
3f1f29
diff --git a/qemu-char.c b/qemu-char.c
13f703
index 52bcc0e..bc07b20 100644
3f1f29
--- a/qemu-char.c
3f1f29
+++ b/qemu-char.c
5e10b1
@@ -214,11 +214,14 @@ void qemu_chr_add_handlers(CharDriverState *s,
3f1f29
     }
3f1f29
     s->chr_can_read = handlers->fd_can_read;
3f1f29
     s->chr_read = handlers->fd_read;
3f1f29
+    s->chr_write_unblocked = handlers->fd_write_unblocked;
3f1f29
     s->chr_event = handlers->fd_event;
3f1f29
     s->handler_opaque = opaque;
3f1f29
     if (s->chr_update_read_handler)
3f1f29
         s->chr_update_read_handler(s);
3f1f29
 
3f1f29
+    s->write_blocked = false;
3f1f29
+
3f1f29
     /* We're connecting to an already opened device, so let's make sure we
3f1f29
        also get the open event */
3f1f29
     if (s->opened) {
3f1f29
diff --git a/qemu-char.h b/qemu-char.h
5e10b1
index 9fe1b82..68e7b5b 100644
3f1f29
--- a/qemu-char.h
3f1f29
+++ b/qemu-char.h
5e10b1
@@ -62,6 +62,9 @@ struct CharDriverState {
3f1f29
     IOEventHandler *chr_event;
3f1f29
     IOCanReadHandler *chr_can_read;
3f1f29
     IOReadHandler *chr_read;
3f1f29
+    IOHandler *chr_write_unblocked;
3f1f29
+    void (*chr_enable_write_fd_handler)(struct CharDriverState *chr);
3f1f29
+    void (*chr_disable_write_fd_handler)(struct CharDriverState *chr);
3f1f29
     void *handler_opaque;
3f1f29
     void (*chr_send_event)(struct CharDriverState *chr, int event);
3f1f29
     void (*chr_close)(struct CharDriverState *chr);
5e10b1
@@ -75,6 +78,7 @@ struct CharDriverState {
3f1f29
     char *filename;
3f1f29
     int opened;
3f1f29
     int avail_connections;
3f1f29
+    bool write_blocked; /* Are we in a blocked state? */
3f1f29
     QTAILQ_ENTRY(CharDriverState) next;
3f1f29
 };
3f1f29
 
3f1f29
-- 
3f1f29
1.7.5.1
3f1f29