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