render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

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

Justin M. Forbes 5e10b1
From 66945912c4bd1bc70f3221288a4e7acc5717b336 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
Justin M. Forbes 5e10b1
Subject: [PATCH 04/13] 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
Justin M. Forbes 5e10b1
index 1c33828..ec4eb68 100644
Hans de Goede 3f1f29
--- a/qemu-char.c
Hans de Goede 3f1f29
+++ b/qemu-char.c
Justin M. Forbes 5e10b1
@@ -214,11 +214,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
Justin M. Forbes 5e10b1
index 9fe1b82..68e7b5b 100644
Hans de Goede 3f1f29
--- a/qemu-char.h
Hans de Goede 3f1f29
+++ b/qemu-char.h
Justin M. Forbes 5e10b1
@@ -62,6 +62,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);
Justin M. Forbes 5e10b1
@@ -75,6 +78,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