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>
*/
static int do_quit(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
- exit(0);
+ monitor_suspend(mon);
+ qemu_system_exit_request();
return 0;
}
void qemu_system_reset_request(void);
void qemu_system_shutdown_request(void);
void qemu_system_powerdown_request(void);
+void qemu_system_exit_request(void);
int qemu_shutdown_requested(void);
int qemu_reset_requested(void);
int qemu_powerdown_requested(void);
+int qemu_exit_requested(void);
extern qemu_irq qemu_system_powerdown;
void qemu_system_reset(void);
static int powerdown_requested;
int debug_requested;
int vmstop_requested;
+static int exit_requested;
int qemu_shutdown_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;
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)
{
return 0;
if (debug_requested)
return 0;
+ if (exit_requested)
+ return 0;
return 1;
}
if ((r = qemu_vmstop_requested())) {
vm_stop(r);
}
+ if (qemu_exit_requested()) {
+ exit(0);
+ }
}
pause_all_vcpus();
}