Skip to content

Commit 39b59d2

Browse files
author
Luiz Capitulino
committed
Monitor: Return before exiting with 'quit'
This is a new version of the (now reverted) following commit: 0e8d2b5 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 making do_quit() use qemu_system_shutdown_request(), so that we exit gracefully. Thanks to Paolo Bonzini <[email protected]> for suggesting this solution. Signed-off-by: Luiz Capitulino <[email protected]>
1 parent a691d41 commit 39b59d2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

monitor.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,10 @@ static void do_info_cpu_stats(Monitor *mon)
10201020
*/
10211021
static int do_quit(Monitor *mon, const QDict *qdict, QObject **ret_data)
10221022
{
1023-
exit(0);
1023+
monitor_suspend(mon);
1024+
no_shutdown = 0;
1025+
qemu_system_shutdown_request();
1026+
10241027
return 0;
10251028
}
10261029

0 commit comments

Comments
 (0)