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

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