From patchwork Wed Feb 20 15:32:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 222123 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EFBD12C007C for ; Thu, 21 Feb 2013 03:55:44 +1100 (EST) Received: from localhost ([::1]:44030 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8BgD-0000PR-Hv for incoming@patchwork.ozlabs.org; Wed, 20 Feb 2013 10:33:57 -0500 Received: from eggs.gnu.org ([208.118.235.92]:51947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8Bfc-0007P0-Ol for qemu-devel@nongnu.org; Wed, 20 Feb 2013 10:33:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U8BfV-0001hx-R2 for qemu-devel@nongnu.org; Wed, 20 Feb 2013 10:33:20 -0500 Received: from e28smtp08.in.ibm.com ([122.248.162.8]:43737) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8BfV-0001hW-9e for qemu-devel@nongnu.org; Wed, 20 Feb 2013 10:33:13 -0500 Received: from /spool/local by e28smtp08.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Feb 2013 20:59:47 +0530 Received: from d28dlp03.in.ibm.com (9.184.220.128) by e28smtp08.in.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 20 Feb 2013 20:59:45 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id CA7FF1258052 for ; Wed, 20 Feb 2013 21:03:55 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r1KFX4kk36831428 for ; Wed, 20 Feb 2013 21:03:04 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r1KFX7IT023995 for ; Thu, 21 Feb 2013 02:33:08 +1100 Received: from titi.austin.rr.com (sig-9-76-138-226.mts.ibm.com [9.76.138.226]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r1KFWpJN022744; Thu, 21 Feb 2013 02:33:05 +1100 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2013 09:32:44 -0600 Message-Id: <1361374369-19024-5-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1361374369-19024-1-git-send-email-aliguori@us.ibm.com> References: <1361374369-19024-1-git-send-email-aliguori@us.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13022015-2000-0000-0000-00000B056190 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.8 Cc: Paolo Bonzini , Anthony Liguori , Jan Kiszka , Stefano Stabellini Subject: [Qemu-devel] [PATCH 4/9] main-loop: refactor qemu_system_shutdown_request() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org There are two open coded versions of shutdown depending on whether the -no-shutdown flag is used or not. Refactor to just one. Signed-off-by: Anthony Liguori --- vl.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/vl.c b/vl.c index 705c7f1..4810178 100644 --- a/vl.c +++ b/vl.c @@ -1824,12 +1824,12 @@ void qemu_system_reset(bool report) void qemu_system_reset_request(void) { if (no_reboot) { - shutdown_requested = 1; + qemu_system_shutdown_request(); } else { reset_requested = 1; + cpu_stop_current(); + qemu_notify_event(); } - cpu_stop_current(); - qemu_notify_event(); } static gboolean qemu_system_suspend(gpointer unused) @@ -1891,9 +1891,21 @@ void qemu_system_killed(int signal, pid_t pid) qemu_system_shutdown_request(); } +static void qemu_system_shutdown(void) +{ + qemu_kill_report(); + monitor_protocol_event(QEVENT_SHUTDOWN, NULL); + if (no_shutdown) { + vm_stop(RUN_STATE_SHUTDOWN); + } else { + main_loop_quit(); + } +} + void qemu_system_shutdown_request(void) { shutdown_requested = 1; + cpu_stop_current(); qemu_notify_event(); } @@ -1935,14 +1947,7 @@ static void main_loop_junk(void) { RunState r; if (qemu_shutdown_requested()) { - qemu_kill_report(); - monitor_protocol_event(QEVENT_SHUTDOWN, NULL); - if (no_shutdown) { - vm_stop(RUN_STATE_SHUTDOWN); - } else { - main_loop_quit(); - return; - } + qemu_system_shutdown(); } if (qemu_reset_requested()) { pause_all_vcpus();