]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
cpus: Add return value for vm_stop()
authorKevin Wolf <kwolf@redhat.com>
Fri, 5 Jul 2013 11:49:54 +0000 (13:49 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 13 Aug 2013 14:30:49 +0000 (09:30 -0500)
If flushing the block devices fails, return an error. The VM is stopped
anyway.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
(cherry picked from commit 5698346391b306c2c84358c68ee897c095d714cc)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
cpus.c
include/sysemu/sysemu.h
stubs/vm-stop.c

diff --git a/cpus.c b/cpus.c
index c232265cd25245fae1983ed4e1c775709fc66908..2a2f633036de7b8b6db86eff91cd13b478690dc2 100644 (file)
--- a/cpus.c
+++ b/cpus.c
@@ -437,17 +437,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)
@@ -1093,7 +1097,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);
@@ -1102,19 +1106,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;
     }
 }
 
index 2fb71afa259acbcf075b92c4290ee9e6982a4614..b5e1add75a6b7b03a007530d8c7da3e6b3b2b0a1 100644 (file)
@@ -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,
index 45689354f663ca64695355c6c01b44a7535d3d37..f82c897dfe805496e34616f2ca36405125065cd8 100644 (file)
@@ -1,7 +1,7 @@
 #include "qemu-common.h"
 #include "sysemu/sysemu.h"
 
-void vm_stop(RunState state)
+int vm_stop(RunState state)
 {
     abort();
 }