From patchwork Fri Jul 5 12:03:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 257163 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 58DDE2C0090 for ; Fri, 5 Jul 2013 22:05:16 +1000 (EST) Received: from localhost ([::1]:39399 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uv4lG-0007sZ-3f for incoming@patchwork.ozlabs.org; Fri, 05 Jul 2013 08:05:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uv4kc-0007sA-6s for qemu-devel@nongnu.org; Fri, 05 Jul 2013 08:04:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uv4ka-0008G9-7P for qemu-devel@nongnu.org; Fri, 05 Jul 2013 08:04:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59341) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uv4kZ-0008G1-Sw for qemu-devel@nongnu.org; Fri, 05 Jul 2013 08:04:32 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r65C4V86011551 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 5 Jul 2013 08:04:31 -0400 Received: from dhcp-200-207.str.redhat.com (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r65C4PDF005068; Fri, 5 Jul 2013 08:04:29 -0400 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Fri, 5 Jul 2013 14:03:52 +0200 Message-Id: <1373025833-22859-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1373025833-22859-1-git-send-email-kwolf@redhat.com> References: <1373025833-22859-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@redhat.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH 2/3] cpus: Add return value for vm_stop() 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 If flushing the block devices fails, return an error. The VM is stopped anyway. Signed-off-by: Kevin Wolf --- cpus.c | 20 +++++++++++++------- include/sysemu/sysemu.h | 4 ++-- stubs/vm-stop.c | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/cpus.c b/cpus.c index 20958e5..e15fdcb 100644 --- a/cpus.c +++ b/cpus.c @@ -435,17 +435,21 @@ bool cpu_is_stopped(CPUState *cpu) return !runstate_is_running() || cpu->stopped; } -static void do_vm_stop(RunState state) +static int do_vm_stop(RunState state) { + int ret = 0; + if (runstate_is_running()) { cpu_disable_ticks(); pause_all_vcpus(); runstate_set(state); vm_state_notify(0, state); bdrv_drain_all(); - bdrv_flush_all(); + ret = bdrv_flush_all(); monitor_protocol_event(QEVENT_STOP, NULL); } + + return ret; } static bool cpu_can_run(CPUState *cpu) @@ -1078,7 +1082,7 @@ void cpu_stop_current(void) } } -void vm_stop(RunState state) +int vm_stop(RunState state) { if (qemu_in_vcpu_thread()) { qemu_system_vmstop_request(state); @@ -1087,19 +1091,21 @@ void vm_stop(RunState state) * vm_stop() has been requested. */ cpu_stop_current(); - return; + return 0; } - do_vm_stop(state); + + return do_vm_stop(state); } /* does a state transition even if the VM is already stopped, current state is forgotten forever */ -void vm_stop_force_state(RunState state) +int vm_stop_force_state(RunState state) { if (runstate_is_running()) { - vm_stop(state); + return vm_stop(state); } else { runstate_set(state); + return 0; } } diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 2fb71af..b5e1add 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -35,8 +35,8 @@ void vm_state_notify(int running, RunState state); #define VMRESET_REPORT true void vm_start(void); -void vm_stop(RunState state); -void vm_stop_force_state(RunState state); +int vm_stop(RunState state); +int vm_stop_force_state(RunState state); typedef enum WakeupReason { QEMU_WAKEUP_REASON_OTHER = 0, diff --git a/stubs/vm-stop.c b/stubs/vm-stop.c index 4568935..f82c897 100644 --- a/stubs/vm-stop.c +++ b/stubs/vm-stop.c @@ -1,7 +1,7 @@ #include "qemu-common.h" #include "sysemu/sysemu.h" -void vm_stop(RunState state) +int vm_stop(RunState state) { abort(); }