aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2011-02-01 22:15:47 +0100
committerMarcelo Tosatti <mtosatti@redhat.com>2011-02-14 12:39:44 -0200
commit46481d3921b86ef5ded7be7b5ce8194608f30e6b (patch)
treeff9342abfc7b5a0ccaf65edc7681de8c519806cb
parent8e1b90ecc59573c4c5e9fc4934b4e30476b43e2f (diff)
Flatten the main loop
First of all, vm_can_run is a misnomer, it actually means "no request pending". Moreover, there is no need to check all pending requests twice, the first time via the inner loop check and then again when actually processing the requests. We can simply remove the inner loop and do the checks directly. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
-rw-r--r--vl.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/vl.c b/vl.c
index 9c628f01d6..c9fa266157 100644
--- a/vl.c
+++ b/vl.c
@@ -1389,14 +1389,16 @@ void main_loop_wait(int nonblocking)
}
-static int vm_can_run(void)
+#ifndef CONFIG_IOTHREAD
+static int vm_request_pending(void)
{
- return !(powerdown_requested ||
- reset_requested ||
- shutdown_requested ||
- debug_requested ||
- vmstop_requested);
+ return powerdown_requested ||
+ reset_requested ||
+ shutdown_requested ||
+ debug_requested ||
+ vmstop_requested;
}
+#endif
qemu_irq qemu_system_powerdown;
@@ -1411,21 +1413,19 @@ static void main_loop(void)
qemu_main_loop_start();
for (;;) {
- do {
#ifndef CONFIG_IOTHREAD
- nonblocking = cpu_exec_all();
- if (!vm_can_run()) {
- nonblocking = true;
- }
+ nonblocking = cpu_exec_all();
+ if (vm_request_pending()) {
+ nonblocking = true;
+ }
#endif
#ifdef CONFIG_PROFILER
- ti = profile_getclock();
+ ti = profile_getclock();
#endif
- main_loop_wait(nonblocking);
+ main_loop_wait(nonblocking);
#ifdef CONFIG_PROFILER
- dev_time += profile_getclock() - ti;
+ dev_time += profile_getclock() - ti;
#endif
- } while (vm_can_run());
if ((r = qemu_debug_requested())) {
vm_stop(r);