diff mbox

[3/3] Monitor: Return before exiting with 'quit'

Message ID 1273686768-26561-4-git-send-email-lcapitulino@redhat.com
State New
Headers show

Commit Message

Luiz Capitulino May 12, 2010, 5:52 p.m. UTC
This is a new version of the (now reverted) following commit:


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 |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
diff mbox


diff --git a/monitor.c b/monitor.c
index e984122..15b53b9 100644
--- a/monitor.c
+++ b/monitor.c
@@ -942,7 +942,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;