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

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