qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Amit Shah <amit.shah@redhat.com>
To: qemu list <qemu-devel@nongnu.org>
Cc: Amit Shah <amit.shah@redhat.com>,
	Paul Brook <paul@codesourcery.com>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 3/5] char: Add framework for a 'write unblocked' callback
Date: Tue, 11 Jan 2011 16:40:32 +0530	[thread overview]
Message-ID: <3b7fddd6f8538bfdcb01f46935f4fc0760296ea6.1294743490.git.amit.shah@redhat.com> (raw)
In-Reply-To: <cover.1294743490.git.amit.shah@redhat.com>
In-Reply-To: <cover.1294743490.git.amit.shah@redhat.com>

The char layer can let users know that the driver will block on further
input.  For users interested in not blocking, they can assign a function
pointer that will be called back when the driver becomes writable.  This
patch just adds the function pointers to the CharDriverState structure,
future patches will enable the nonblocking and callback functionality.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 qemu-char.c |    3 +++
 qemu-char.h |    5 +++++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index 2420b6b..9a132b6 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -202,11 +202,14 @@ void qemu_chr_add_handlers(CharDriverState *s,
     }
     s->chr_can_read = handlers->fd_can_read;
     s->chr_read = handlers->fd_read;
+    s->chr_write_unblocked = handlers->fd_write_unblocked;
     s->chr_event = handlers->fd_event;
     s->handler_opaque = opaque;
     if (s->chr_update_read_handler)
         s->chr_update_read_handler(s);
 
+    s->write_blocked = false;
+
     /* We're connecting to an already opened device, so let's make sure we
        also get the open event */
     if (s->opened) {
diff --git a/qemu-char.h b/qemu-char.h
index 8ed0ffd..0c2c445 100644
--- a/qemu-char.h
+++ b/qemu-char.h
@@ -60,6 +60,9 @@ struct CharDriverState {
     IOEventHandler *chr_event;
     IOCanReadHandler *chr_can_read;
     IOReadHandler *chr_read;
+    IOHandler *chr_write_unblocked;
+    void (*update_fd_handlers)(struct CharDriverState *chr,
+                               bool poll_out);
     void *handler_opaque;
     void (*chr_send_event)(struct CharDriverState *chr, int event);
     void (*chr_close)(struct CharDriverState *chr);
@@ -69,6 +72,8 @@ struct CharDriverState {
     char *label;
     char *filename;
     int opened;
+    /* Are we in a blocked state? */
+    bool write_blocked;
     QTAILQ_ENTRY(CharDriverState) next;
 };
 
-- 
1.7.3.4

  parent reply	other threads:[~2011-01-11 11:11 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-11 11:10 [Qemu-devel] [PATCH v9 0/5] char: Add support for nonblocking writes Amit Shah
2011-01-11 11:10 ` [Qemu-devel] [PATCH 1/5] char: Add a QemuChrHandlers struct to initialise chardev handlers Amit Shah
2011-01-11 14:17   ` [Qemu-devel] " Gerd Hoffmann
2011-01-11 17:13   ` [Qemu-devel] " Blue Swirl
2011-01-12  6:07     ` Amit Shah
2011-01-12 18:01       ` Michael Roth
2011-01-12 19:03         ` Blue Swirl
2011-01-13  6:14           ` Amit Shah
2011-01-13 21:29             ` Blue Swirl
2011-01-11 11:10 ` [Qemu-devel] [PATCH 2/5] char: Introduce char_set/remove_fd_handlers() Amit Shah
2011-01-11 14:39   ` [Qemu-devel] " Gerd Hoffmann
2011-01-11 15:38     ` Amit Shah
2011-01-11 15:54       ` Gerd Hoffmann
2011-01-11 17:23         ` Amit Shah
2011-01-12  9:11           ` Gerd Hoffmann
2011-01-11 11:10 ` Amit Shah [this message]
2011-01-11 14:43   ` [Qemu-devel] Re: [PATCH 3/5] char: Add framework for a 'write unblocked' callback Gerd Hoffmann
2011-01-11 11:10 ` [Qemu-devel] [PATCH 4/5] char: Update send_all() to handle nonblocking chardev write requests Amit Shah
2011-01-11 11:10 ` [Qemu-devel] [PATCH 5/5] char: Equip the unix/tcp backend to handle nonblocking writes Amit Shah
2011-01-11 13:38   ` [Qemu-devel] " Paolo Bonzini
2011-01-12  6:16     ` Amit Shah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3b7fddd6f8538bfdcb01f46935f4fc0760296ea6.1294743490.git.amit.shah@redhat.com \
    --to=amit.shah@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=paul@codesourcery.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).