From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uznh6-0002tY-FZ for qemu-devel@nongnu.org; Thu, 18 Jul 2013 08:52:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uznh3-00013D-4W for qemu-devel@nongnu.org; Thu, 18 Jul 2013 08:52:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52263) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uznh2-000138-TJ for qemu-devel@nongnu.org; Thu, 18 Jul 2013 08:52:25 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r6ICqOT4019997 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 18 Jul 2013 08:52:24 -0400 From: Kevin Wolf Date: Thu, 18 Jul 2013 14:52:19 +0200 Message-Id: <1374151939-3883-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH] cpus: Let vm_stop[_force_state]() always flush block devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@redhat.com Even if the VM is already stopped, we cannot assume that all data has already been successfully flushed to disk. The flush during the previous vm_stop() could have failed. Run bdrv_flush_all() unconditionally so that we get an error each time if the block device isn't really flushed. Signed-off-by: Kevin Wolf --- cpus.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cpus.c b/cpus.c index 8062cdd..2509eb5 100644 --- a/cpus.c +++ b/cpus.c @@ -443,11 +443,12 @@ static int do_vm_stop(RunState state) pause_all_vcpus(); runstate_set(state); vm_state_notify(0, state); - bdrv_drain_all(); - ret = bdrv_flush_all(); monitor_protocol_event(QEVENT_STOP, NULL); } + bdrv_drain_all(); + ret = bdrv_flush_all(); + return ret; } @@ -1126,7 +1127,9 @@ int vm_stop_force_state(RunState state) return vm_stop(state); } else { runstate_set(state); - return 0; + /* Make sure to return an error if the flush in a previous vm_stop() + * failed. */ + return bdrv_flush_all(); } } -- 1.8.1.4