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>
This commit is contained in:
parent
8e1b90ecc5
commit
46481d3921
12
vl.c
12
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 ||
|
||||
return powerdown_requested ||
|
||||
reset_requested ||
|
||||
shutdown_requested ||
|
||||
debug_requested ||
|
||||
vmstop_requested);
|
||||
vmstop_requested;
|
||||
}
|
||||
#endif
|
||||
|
||||
qemu_irq qemu_system_powerdown;
|
||||
|
||||
@ -1411,10 +1413,9 @@ static void main_loop(void)
|
||||
qemu_main_loop_start();
|
||||
|
||||
for (;;) {
|
||||
do {
|
||||
#ifndef CONFIG_IOTHREAD
|
||||
nonblocking = cpu_exec_all();
|
||||
if (!vm_can_run()) {
|
||||
if (vm_request_pending()) {
|
||||
nonblocking = true;
|
||||
}
|
||||
#endif
|
||||
@ -1425,7 +1426,6 @@ static void main_loop(void)
|
||||
#ifdef CONFIG_PROFILER
|
||||
dev_time += profile_getclock() - ti;
|
||||
#endif
|
||||
} while (vm_can_run());
|
||||
|
||||
if ((r = qemu_debug_requested())) {
|
||||
vm_stop(r);
|
||||
|
Loading…
Reference in New Issue
Block a user