From patchwork Wed May 12 17:52:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 52398 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 925F5B7DF8 for ; Thu, 13 May 2010 04:07:33 +1000 (EST) Received: from localhost ([127.0.0.1]:43293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OCGBW-0008Oh-JP for incoming@patchwork.ozlabs.org; Wed, 12 May 2010 13:57:30 -0400 Received: from [140.186.70.92] (port=40386 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OCG7j-0006rG-75 for qemu-devel@nongnu.org; Wed, 12 May 2010 13:53:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OCG7M-0008V6-55 for qemu-devel@nongnu.org; Wed, 12 May 2010 13:53:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19488) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OCG7L-0008Uw-NX for qemu-devel@nongnu.org; Wed, 12 May 2010 13:53:12 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4CHrA0M007586 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 12 May 2010 13:53:11 -0400 Received: from localhost (vpn-10-238.rdu.redhat.com [10.11.10.238]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4CHr9sX028804; Wed, 12 May 2010 13:53:10 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Wed, 12 May 2010 14:52:48 -0300 Message-Id: <1273686768-26561-4-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1273686768-26561-1-git-send-email-lcapitulino@redhat.com> References: <1273686768-26561-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: pbonzini@redhat.com Subject: [Qemu-devel] [PATCH 3/3] Monitor: Return before exiting with 'quit' X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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 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; }