qemu-char: remove use of QEMUTimer in favor of glib idle function
authorAnthony Liguori <aliguori@us.ibm.com>
Tue, 5 Mar 2013 17:51:27 +0000 (23:21 +0530)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 8 Mar 2013 19:57:15 +0000 (13:57 -0600)
qemu-char is now independent of the QEMU main loop.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Message-id: 3cda0bbcfb94912df8a767983a52bb71a4a3231d.1362505276.git.amit.shah@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
include/char/char.h
qemu-char.c

index 09ac4014dd469e56dd35b27ba88d0a9618057d1f..e8b781cd5e713ada1808e843e44c7a4a5e395ed9 100644 (file)
@@ -71,7 +71,7 @@ struct CharDriverState {
     void (*chr_guest_open)(struct CharDriverState *chr);
     void (*chr_guest_close)(struct CharDriverState *chr);
     void *opaque;
-    QEMUTimer *open_timer;
+    int idle_tag;
     char *label;
     char *filename;
     int opened;
index 6dba943667ffbba9714614f50ac4cdaf915b7492..2c7c929085dcd9b4637019b7921a55fb65c9646a 100644 (file)
@@ -122,20 +122,18 @@ void qemu_chr_be_event(CharDriverState *s, int event)
     s->chr_event(s->handler_opaque, event);
 }
 
-static void qemu_chr_fire_open_event(void *opaque)
+static gboolean qemu_chr_generic_open_bh(gpointer opaque)
 {
     CharDriverState *s = opaque;
     qemu_chr_be_event(s, CHR_EVENT_OPENED);
-    qemu_free_timer(s->open_timer);
-    s->open_timer = NULL;
+    s->idle_tag = 0;
+    return FALSE;
 }
 
 void qemu_chr_generic_open(CharDriverState *s)
 {
-    if (s->open_timer == NULL) {
-        s->open_timer = qemu_new_timer_ms(rt_clock,
-                                          qemu_chr_fire_open_event, s);
-        qemu_mod_timer(s->open_timer, qemu_get_clock_ms(rt_clock) - 1);
+    if (s->idle_tag == 0) {
+        s->idle_tag = g_idle_add(qemu_chr_generic_open_bh, s);
     }
 }