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>, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 7/7] char: pty: Use new iohandler api
Date: Tue, 22 Feb 2011 15:48:36 +0530	[thread overview]
Message-ID: <f7f04d12c331b98aef36d9b01b37f534f89cce33.1298369272.git.amit.shah@redhat.com> (raw)
In-Reply-To: <cover.1298369272.git.amit.shah@redhat.com>
In-Reply-To: <cover.1298369272.git.amit.shah@redhat.com>

Update the pty code to use the new iohandler api.  The change is mostly
mechanical with a new iohandler function calling the older functions
depending on the value of the 'mask' field.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 qemu-char.c |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index ade28ba..6875b00 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -929,12 +929,28 @@ static void pty_chr_read(void *opaque)
     }
 }
 
+static int pty_iohandler(void *opaque, unsigned int mask)
+{
+    int ret;
+
+    ret = 0;
+    switch(mask) {
+    case IOH_MASK_CAN_READ:
+        ret = pty_chr_read_poll(opaque);
+        break;
+    case IOH_MASK_READ:
+        pty_chr_read(opaque);
+        break;
+    }
+    return ret;
+}
+
 static void pty_chr_update_read_handler(CharDriverState *chr)
 {
     PtyCharDriver *s = chr->opaque;
 
-    qemu_set_fd_handler2(s->fd, pty_chr_read_poll,
-                         pty_chr_read, NULL, chr);
+    assign_iohandler(s->fd, pty_iohandler, IOH_MASK_CAN_READ|IOH_MASK_READ,
+                     chr);
     s->polling = 1;
     /*
      * Short timeout here: just need wait long enougth that qemu makes
@@ -952,7 +968,7 @@ static void pty_chr_state(CharDriverState *chr, int connected)
     PtyCharDriver *s = chr->opaque;
 
     if (!connected) {
-        qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
+        remove_iohandler(s->fd);
         s->connected = 0;
         s->polling = 0;
         /* (re-)connect poll interval for idle guests: once per second.
@@ -988,7 +1004,7 @@ static void pty_chr_close(struct CharDriverState *chr)
 {
     PtyCharDriver *s = chr->opaque;
 
-    qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
+    remove_iohandler(s->fd);
     close(s->fd);
     qemu_del_timer(s->timer);
     qemu_free_timer(s->timer);
-- 
1.7.4

      parent reply	other threads:[~2011-02-22 10:20 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-22 10:18 [Qemu-devel] [PATCH 0/7] New iohandler API Amit Shah
2011-02-22 10:18 ` [Qemu-devel] [PATCH 1/7] iohandlers: Mark current implementation as 'old' Amit Shah
2011-02-22 11:09   ` Avi Kivity
2011-02-22 11:17     ` Amit Shah
2011-02-22 13:28       ` Avi Kivity
2011-02-22 14:37         ` Amit Shah
2011-02-22 14:43           ` Avi Kivity
2011-02-22 10:18 ` [Qemu-devel] [PATCH 2/7] iohandlers: Introduce a new API Amit Shah
2011-02-22 12:39   ` Alon Levy
2011-02-22 13:09     ` Amit Shah
2011-02-22 13:28   ` Avi Kivity
2011-02-22 14:39     ` Amit Shah
2011-02-22 15:00     ` Anthony Liguori
2011-02-22 16:21       ` Avi Kivity
2011-02-22 18:21         ` Anthony Liguori
2011-02-23 12:40           ` Avi Kivity
2011-02-22 14:49   ` [Qemu-devel] " Anthony Liguori
2011-02-22 10:18 ` [Qemu-devel] [PATCH 3/7] char: tcp: Use new iohandler api Amit Shah
2011-02-22 10:18 ` [Qemu-devel] [PATCH 4/7] char: udp: " Amit Shah
2011-02-22 10:18 ` [Qemu-devel] [PATCH 5/7] char: fd: " Amit Shah
2011-02-22 10:18 ` [Qemu-devel] [PATCH 6/7] char: stdio: " Amit Shah
2011-02-22 10:18 ` Amit Shah [this message]

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=f7f04d12c331b98aef36d9b01b37f534f89cce33.1298369272.git.amit.shah@redhat.com \
    --to=amit.shah@redhat.com \
    --cc=kraxel@redhat.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).