Blame 0104-char-Add-framework-for-a-write-unblocked-callback.patch

bd56df
From 8767b055fe84811f1caec3854b55a5d5541f72c9 Mon Sep 17 00:00:00 2001
bd56df
Message-Id: <8767b055fe84811f1caec3854b55a5d5541f72c9.1346162949.git.crobinso@redhat.com>
bd56df
In-Reply-To: <90a59d545ad6759c105b0bfcfca70f574482584f.1346162949.git.crobinso@redhat.com>
bd56df
References: <90a59d545ad6759c105b0bfcfca70f574482584f.1346162949.git.crobinso@redhat.com>
Justin M. Forbes d4cdad
From: Amit Shah <amit.shah@redhat.com>
Justin M. Forbes d4cdad
Date: Mon, 21 Mar 2011 21:41:42 +0100
bd56df
Subject: [PATCH 104/114] char: Add framework for a 'write unblocked' callback
Justin M. Forbes d4cdad
Justin M. Forbes d4cdad
The char layer can let users know that the driver will block on further
Justin M. Forbes d4cdad
input.  For users interested in not blocking, they can assign a function
Justin M. Forbes d4cdad
pointer that will be called back when the driver becomes writable.  This
Justin M. Forbes d4cdad
patch just adds the function pointers to the CharDriverState structure,
Justin M. Forbes d4cdad
future patches will enable the nonblocking and callback functionality.
Justin M. Forbes d4cdad
Justin M. Forbes d4cdad
Signed-off-by: Amit Shah <amit.shah@redhat.com>
bd56df
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Justin M. Forbes d4cdad
---
b6dd5a
 qemu-char.c | 3 +++
b6dd5a
 qemu-char.h | 4 ++++
Hans de Goede 329b58
 2 files changed, 7 insertions(+)
Justin M. Forbes d4cdad
Justin M. Forbes d4cdad
diff --git a/qemu-char.c b/qemu-char.c
bd56df
index 19ae993..2c573fb 100644
Justin M. Forbes d4cdad
--- a/qemu-char.c
Justin M. Forbes d4cdad
+++ b/qemu-char.c
Hans de Goede 329b58
@@ -211,11 +211,14 @@ void qemu_chr_add_handlers(CharDriverState *s,
Justin M. Forbes d4cdad
     }
Justin M. Forbes d4cdad
     s->chr_can_read = handlers->fd_can_read;
Justin M. Forbes d4cdad
     s->chr_read = handlers->fd_read;
Justin M. Forbes d4cdad
+    s->chr_write_unblocked = handlers->fd_write_unblocked;
Justin M. Forbes d4cdad
     s->chr_event = handlers->fd_event;
Justin M. Forbes d4cdad
     s->handler_opaque = opaque;
Justin M. Forbes d4cdad
     if (s->chr_update_read_handler)
Justin M. Forbes d4cdad
         s->chr_update_read_handler(s);
Hans de Goede 329b58
 
Justin M. Forbes d4cdad
+    s->write_blocked = false;
Justin M. Forbes d4cdad
+
Justin M. Forbes d4cdad
     /* We're connecting to an already opened device, so let's make sure we
Justin M. Forbes d4cdad
        also get the open event */
Justin M. Forbes d4cdad
     if (s->opened) {
Justin M. Forbes d4cdad
diff --git a/qemu-char.h b/qemu-char.h
Hans de Goede 329b58
index dfa8c2d..b5e23a4 100644
Justin M. Forbes d4cdad
--- a/qemu-char.h
Justin M. Forbes d4cdad
+++ b/qemu-char.h
Justin M. Forbes d4cdad
@@ -62,6 +62,9 @@ struct CharDriverState {
Justin M. Forbes d4cdad
     IOEventHandler *chr_event;
Justin M. Forbes d4cdad
     IOCanReadHandler *chr_can_read;
Justin M. Forbes d4cdad
     IOReadHandler *chr_read;
Justin M. Forbes d4cdad
+    IOHandler *chr_write_unblocked;
Justin M. Forbes d4cdad
+    void (*chr_enable_write_fd_handler)(struct CharDriverState *chr);
Justin M. Forbes d4cdad
+    void (*chr_disable_write_fd_handler)(struct CharDriverState *chr);
Justin M. Forbes d4cdad
     void *handler_opaque;
Justin M. Forbes d4cdad
     void (*chr_close)(struct CharDriverState *chr);
Justin M. Forbes d4cdad
     void (*chr_accept_input)(struct CharDriverState *chr);
Justin M. Forbes d4cdad
@@ -74,6 +77,7 @@ struct CharDriverState {
Justin M. Forbes d4cdad
     char *filename;
Justin M. Forbes d4cdad
     int opened;
Justin M. Forbes d4cdad
     int avail_connections;
Justin M. Forbes d4cdad
+    bool write_blocked; /* Are we in a blocked state? */
Justin M. Forbes d4cdad
     QTAILQ_ENTRY(CharDriverState) next;
Justin M. Forbes d4cdad
 };
Hans de Goede 329b58
 
Justin M. Forbes d4cdad
-- 
b6dd5a
1.7.11.2
Justin M. Forbes d4cdad