summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2011-03-21 21:41:42 +0100
committerHans de Goede <hdegoede@redhat.com>2011-05-04 13:33:06 +0200
commit9d1c043c2860aac57f95cf76947617b32b689161 (patch)
tree08cb9cb51b0656eb7607b2611dfc4e63acf5177b
parent1e0c2e4c978fc67d62b6a2abf2aa31f5b7cb102c (diff)
char: Add framework for a 'write unblocked' callback
The char layer can let users know that the driver will block on further input. For users interested in not blocking, they can assign a function pointer that will be called back when the driver becomes writable. This patch just adds the function pointers to the CharDriverState structure, future patches will enable the nonblocking and callback functionality. Signed-off-by: Amit Shah <amit.shah@redhat.com>
-rw-r--r--qemu-char.c3
-rw-r--r--qemu-char.h5
2 files changed, 8 insertions, 0 deletions
diff --git a/qemu-char.c b/qemu-char.c
index 3a31d8b0ac..ce7641142d 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -206,11 +206,14 @@ void qemu_chr_add_handlers(CharDriverState *s,
}
s->chr_can_read = handlers->fd_can_read;
s->chr_read = handlers->fd_read;
+ s->chr_write_unblocked = handlers->fd_write_unblocked;
s->chr_event = handlers->fd_event;
s->handler_opaque = opaque;
if (s->chr_update_read_handler)
s->chr_update_read_handler(s);
+ s->write_blocked = false;
+
/* We're connecting to an already opened device, so let's make sure we
also get the open event */
if (s->opened) {
diff --git a/qemu-char.h b/qemu-char.h
index 185377c2f3..bf06da012b 100644
--- a/qemu-char.h
+++ b/qemu-char.h
@@ -61,6 +61,9 @@ struct CharDriverState {
IOEventHandler *chr_event;
IOCanReadHandler *chr_can_read;
IOReadHandler *chr_read;
+ IOHandler *chr_write_unblocked;
+ void (*chr_enable_write_fd_handler)(struct CharDriverState *chr);
+ void (*chr_disable_write_fd_handler)(struct CharDriverState *chr);
void *handler_opaque;
void (*chr_send_event)(struct CharDriverState *chr, int event);
void (*chr_close)(struct CharDriverState *chr);
@@ -71,6 +74,8 @@ struct CharDriverState {
char *label;
char *filename;
int opened;
+ /* Are we in a blocked state? */
+ bool write_blocked;
QTAILQ_ENTRY(CharDriverState) next;
};