render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

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

Justin M. Forbes d4cdad
From 6d5337e1dc8d926f9183e2f5eb5e97c438203527 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
Justin M. Forbes d4cdad
Subject: [PATCH 109/118] 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
---
Justin M. Forbes d4cdad
 qemu-char.c |    3 +++
Justin M. Forbes d4cdad
 qemu-char.h |    4 ++++
Justin M. Forbes d4cdad
 2 files changed, 7 insertions(+), 0 deletions(-)
Justin M. Forbes d4cdad
Justin M. Forbes d4cdad
diff --git a/qemu-char.c b/qemu-char.c
Justin M. Forbes d4cdad
index d2a99a6..66b5887 100644
Justin M. Forbes d4cdad
--- a/qemu-char.c
Justin M. Forbes d4cdad
+++ b/qemu-char.c
Justin M. Forbes d4cdad
@@ -208,11 +208,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);
Justin M. Forbes d4cdad
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
Justin M. Forbes d4cdad
index 564e688..2628bee 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
 };
Justin M. Forbes d4cdad
Justin M. Forbes d4cdad
-- 
Justin M. Forbes d4cdad
1.7.7.5
Justin M. Forbes d4cdad