Patchwork [3/5] vl.c: consolidate qemu_system_xxx_request() logic.

login
register
mail settings
Submitter Isaku Yamahata
Date Aug. 30, 2010, 7:49 a.m.
Message ID <e811a79aa7ff223d3d63d2d65920d823dba94f7b.1283152674.git.yamahata@valinux.co.jp>
Download mbox | patch
Permalink /patch/63004/
State New
Headers show

Comments

Isaku Yamahata - Aug. 30, 2010, 7:49 a.m.
don't repeat same logic in qemu_system_xxx_request() logic.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 vl.c |   25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)

Patch

diff --git a/vl.c b/vl.c
index aba3786..2a89f4f 100644
--- a/vl.c
+++ b/vl.c
@@ -1195,26 +1195,33 @@  static void qemu_system_reset(void)
     cpu_synchronize_all_post_reset();
 }
 
-void qemu_system_reset_request(void)
+static void qemu_system_request(int *requested)
+{
+    *requested = 1;
+    qemu_notify_event();
+}
+
+static void qemu_system_request_reboot_check(int *requested)
 {
     if (no_reboot) {
-        shutdown_requested = 1;
-    } else {
-        reset_requested = 1;
+        requested = &shutdown_requested;
     }
-    qemu_notify_event();
+    qemu_system_request(requested);
+}
+
+void qemu_system_reset_request(void)
+{
+    qemu_system_request_reboot_check(&reset_requested);
 }
 
 void qemu_system_shutdown_request(void)
 {
-    shutdown_requested = 1;
-    qemu_notify_event();
+    qemu_system_request(&shutdown_requested);
 }
 
 void qemu_system_powerdown_request(void)
 {
-    powerdown_requested = 1;
-    qemu_notify_event();
+    qemu_system_request(&powerdown_requested);
 }
 
 void main_loop_wait(int nonblocking)