summaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@redhat.com>2010-04-06 18:55:54 -0300
committerLuiz Capitulino <lcapitulino@redhat.com>2010-04-26 16:36:01 -0300
commit0e8d2b5575938b8876a3c4bb66ee13c5d306fb6d (patch)
treecd646883393e059e29c83e434a7cb9055d3441c3 /vl.c
parent04f8c053cca9c329eebb761f3a1ffef3d349b84c (diff)
downloadqemu-0e8d2b5575938b8876a3c4bb66ee13c5d306fb6d.tar.gz
qemu-0e8d2b5575938b8876a3c4bb66ee13c5d306fb6d.tar.bz2
qemu-0e8d2b5575938b8876a3c4bb66ee13c5d306fb6d.zip
Monitor: Return before exiting with 'quit'
The 'quit' Monitor command (implemented by do_quit()) calls exit() directly, this is problematic under QMP because QEMU exits before having a chance to send the ok response. Clients don't know if QEMU exited because of a problem or because the 'quit' command has been executed. This commit fixes that by moving the exit() call to the main loop, so that do_quit() requests the system to quit, instead of calling exit() directly. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/vl.c b/vl.c
index a5a0f41729..9ef6f2cbef 100644
--- a/vl.c
+++ b/vl.c
@@ -1697,6 +1697,7 @@ static int shutdown_requested;
static int powerdown_requested;
int debug_requested;
int vmstop_requested;
+static int exit_requested;
int qemu_shutdown_requested(void)
{
@@ -1719,6 +1720,12 @@ int qemu_powerdown_requested(void)
return r;
}
+int qemu_exit_requested(void)
+{
+ /* just return it, we'll exit() anyway */
+ return exit_requested;
+}
+
static int qemu_debug_requested(void)
{
int r = debug_requested;
@@ -1789,6 +1796,12 @@ void qemu_system_powerdown_request(void)
qemu_notify_event();
}
+void qemu_system_exit_request(void)
+{
+ exit_requested = 1;
+ qemu_notify_event();
+}
+
#ifdef _WIN32
static void host_main_loop_wait(int *timeout)
{
@@ -1925,6 +1938,8 @@ static int vm_can_run(void)
return 0;
if (debug_requested)
return 0;
+ if (exit_requested)
+ return 0;
return 1;
}
@@ -1977,6 +1992,9 @@ static void main_loop(void)
if ((r = qemu_vmstop_requested())) {
vm_stop(r);
}
+ if (qemu_exit_requested()) {
+ exit(0);
+ }
}
pause_all_vcpus();
}