render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

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

b6dd5a
From 73426a9cec4f1a32553b122c78d083a297412cf4 Mon Sep 17 00:00:00 2001
Justin M. Forbes d4cdad
From: Amit Shah <amit.shah@redhat.com>
Justin M. Forbes d4cdad
Date: Mon, 21 Mar 2011 21:41:42 +0100
b6dd5a
Subject: [PATCH] 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>
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
b6dd5a
index 5c5ae1e..1b70447 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