OSDN Git Service

Monitor: Return before exiting with 'quit'
authorLuiz Capitulino <lcapitulino@redhat.com>
Tue, 11 May 2010 21:08:20 +0000 (18:08 -0300)
committerLuiz Capitulino <lcapitulino@redhat.com>
Wed, 19 May 2010 15:45:54 +0000 (12:45 -0300)
This is a new version of the (now reverted) following commit:

0e8d2b5575938b8876a3c4bb66ee13c5d306fb6d

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 <pbonzini@redhat.com> for suggesting
this solution.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
monitor.c

index 2e202ff..ad50f12 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -1020,7 +1020,10 @@ static void do_info_cpu_stats(Monitor *mon)
  */
 static int do_quit(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
-    exit(0);
+    monitor_suspend(mon);
+    no_shutdown = 0;
+    qemu_system_shutdown_request();
+
     return 0;
 }