Patchwork [6/7] char: stdio: Use new iohandler api

login
register
mail settings
Submitter Amit Shah
Date Feb. 22, 2011, 10:18 a.m.
Message ID <119549d84e2a32415d90a1e8b6bc6007b1a3b4a9.1298369272.git.amit.shah@redhat.com>
Download mbox | patch
Permalink /patch/83953/
State New
Headers show

Comments

Amit Shah - Feb. 22, 2011, 10:18 a.m.
Update the stdio 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 |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

Patch

diff --git a/qemu-char.c b/qemu-char.c
index d93820e..ade28ba 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -717,7 +717,7 @@  static void stdio_read(void *opaque)
     size = read(0, buf, 1);
     if (size == 0) {
         /* stdin has been closed. Remove it from the active list.  */
-        qemu_set_fd_handler2(0, NULL, NULL, NULL, NULL);
+        remove_iohandler(0);
         qemu_chr_event(chr, CHR_EVENT_CLOSED);
         return;
     }
@@ -730,6 +730,22 @@  static void stdio_read(void *opaque)
     }
 }
 
+static int stdio_iohandler(void *opaque, unsigned int mask)
+{
+    int ret;
+
+    ret = 0;
+    switch(mask) {
+    case IOH_MASK_CAN_READ:
+        ret = stdio_read_poll(opaque);
+        break;
+    case IOH_MASK_READ:
+        stdio_read(opaque);
+        break;
+    }
+    return ret;
+}
+
 /* init terminal so that we can grab keys */
 static struct termios oldtty;
 static int old_fd0_flags;
@@ -767,7 +783,7 @@  static void qemu_chr_close_stdio(struct CharDriverState *chr)
 {
     term_exit();
     stdio_nb_clients--;
-    qemu_set_fd_handler2(0, NULL, NULL, NULL, NULL);
+    remove_iohandler(0);
     fd_chr_close(chr);
 }
 
@@ -787,7 +803,7 @@  static CharDriverState *qemu_chr_open_stdio(QemuOpts *opts)
     chr = qemu_chr_open_fd(0, 1);
     chr->chr_close = qemu_chr_close_stdio;
     chr->chr_set_echo = qemu_chr_set_echo_stdio;
-    qemu_set_fd_handler2(0, stdio_read_poll, stdio_read, NULL, chr);
+    assign_iohandler(0, stdio_iohandler, IOH_MASK_CAN_READ|IOH_MASK_READ, chr);
     stdio_nb_clients++;
     stdio_allow_signal = qemu_opt_get_bool(opts, "signal",
                                            display_type != DT_NOGRAPHIC);