Patchwork [9/9] main-loop: refactor qemu_system_vmstop_request()

login
register
mail settings
Submitter Anthony Liguori
Date Feb. 20, 2013, 3:32 p.m.
Message ID <1361374369-19024-10-git-send-email-aliguori@us.ibm.com>
Download mbox | patch
Permalink /patch/222142/
State New
Headers show

Comments

Anthony Liguori - Feb. 20, 2013, 3:32 p.m.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 vl.c | 28 ++++++----------------------
 1 file changed, 6 insertions(+), 22 deletions(-)

Patch

diff --git a/vl.c b/vl.c
index 39b2a5c..b9aa106 100644
--- a/vl.c
+++ b/vl.c
@@ -1705,7 +1705,6 @@  static NotifierList suspend_notifiers =
 static NotifierList wakeup_notifiers =
     NOTIFIER_LIST_INITIALIZER(wakeup_notifiers);
 static uint32_t wakeup_reason_mask = ~0;
-static RunState vmstop_requested = RUN_STATE_MAX;
 
 int qemu_shutdown_requested_get(void)
 {
@@ -1756,18 +1755,6 @@  static gboolean qemu_wakeup(gpointer unused)
     return FALSE;
 }
 
-/* We use RUN_STATE_MAX but any invalid value will do */
-static bool qemu_vmstop_requested(RunState *r)
-{
-    if (vmstop_requested < RUN_STATE_MAX) {
-        *r = vmstop_requested;
-        vmstop_requested = RUN_STATE_MAX;
-        return true;
-    }
-
-    return false;
-}
-
 void qemu_register_reset(QEMUResetHandler *func, void *opaque)
 {
     QEMUResetEntry *re = g_malloc0(sizeof(QEMUResetEntry));
@@ -1927,18 +1914,16 @@  void qemu_system_debug_request(void)
     g_idle_add(qemu_system_debug, NULL);
 }
 
-void qemu_system_vmstop_request(RunState state)
+static gboolean qemu_system_vmstop(gpointer opaque)
 {
-    vmstop_requested = state;
-    qemu_notify_event();
+    RunState r = (RunState)opaque;
+    vm_stop(r);
+    return FALSE;
 }
 
-static void main_loop_junk(void)
+void qemu_system_vmstop_request(RunState state)
 {
-    RunState r;
-    if (qemu_vmstop_requested(&r)) {
-        vm_stop(r);
-    }
+    g_idle_add(qemu_system_vmstop, (gpointer)state);
 }
 
 static void main_loop(void)
@@ -1957,7 +1942,6 @@  static void main_loop(void)
 #ifdef CONFIG_PROFILER
         dev_time += profile_getclock() - ti;
 #endif
-        main_loop_junk();
     } while (!main_loop_should_quit());
 }