peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

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

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