From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=49627 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OElk2-0003xl-GW for qemu-devel@nongnu.org; Wed, 19 May 2010 12:03:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OElk0-0005Vm-Ox for qemu-devel@nongnu.org; Wed, 19 May 2010 12:03:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52353) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OElk0-0005Vb-FW for qemu-devel@nongnu.org; Wed, 19 May 2010 12:03:28 -0400 From: Luiz Capitulino Date: Wed, 19 May 2010 13:03:01 -0300 Message-Id: <1274284982-15125-7-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1274284982-15125-1-git-send-email-lcapitulino@redhat.com> References: <1274284982-15125-1-git-send-email-lcapitulino@redhat.com> Subject: [Qemu-devel] [PATCH 6/7] Monitor: Return before exiting with 'quit' List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: aliguori@us.ibm.com Cc: qemu-devel@nongnu.org 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 for suggesting this solution. Signed-off-by: Luiz Capitulino --- monitor.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/monitor.c b/monitor.c index 2e202ff..ad50f12 100644 --- 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; } -- 1.7.1.86.g0e460