dcavalca / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

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

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