qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 4/7] char: udp: Use new iohandler api


From: Amit Shah
Subject: [Qemu-devel] [PATCH 4/7] char: udp: Use new iohandler api
Date: Tue, 22 Feb 2011 15:48:33 +0530

Update the udp 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 <address@hidden>
---
 qemu-char.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index ba58c18..61f8358 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1842,13 +1842,29 @@ static void udp_chr_read(void *opaque)
     }
 }
 
+static int udp_iohandler(void *opaque, unsigned int mask)
+{
+    int ret;
+
+    ret = 0;
+    switch(mask) {
+    case IOH_MASK_CAN_READ:
+        ret = udp_chr_read_poll(opaque);
+        break;
+    case IOH_MASK_READ:
+        udp_chr_read(opaque);
+        break;
+    }
+    return ret;
+}
+
 static void udp_chr_update_read_handler(CharDriverState *chr)
 {
     NetCharDriver *s = chr->opaque;
 
     if (s->fd >= 0) {
-        qemu_set_fd_handler2(s->fd, udp_chr_read_poll,
-                             udp_chr_read, NULL, chr);
+        assign_iohandler(s->fd, udp_iohandler,
+                          IOH_MASK_CAN_READ|IOH_MASK_READ, chr);
     }
 }
 
@@ -1856,7 +1872,7 @@ static void udp_chr_close(CharDriverState *chr)
 {
     NetCharDriver *s = chr->opaque;
     if (s->fd >= 0) {
-        qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
+        remove_iohandler(s->fd);
         closesocket(s->fd);
     }
     qemu_free(s);
-- 
1.7.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]