]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
block: Add return value for bdrv_flush_all()
authorKevin Wolf <kwolf@redhat.com>
Fri, 5 Jul 2013 11:48:01 +0000 (13:48 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 13 Aug 2013 14:30:49 +0000 (09:30 -0500)
bdrv_flush() can fail, and bdrv_flush_all() should return an error as
well if this happens for a block device. It returns the first error
return now, but still at least tries to flush the remaining devices even
in error cases.

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

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
block.c
include/block/block.h

diff --git a/block.c b/block.c
index c7c3e06f83dbfe6deeef21a25216b8b4e8b15abf..d338a20d1091bf629ccd7afea87eae50bb42d748 100644 (file)
--- a/block.c
+++ b/block.c
@@ -2907,13 +2907,19 @@ int bdrv_get_flags(BlockDriverState *bs)
     return bs->open_flags;
 }
 
-void bdrv_flush_all(void)
+int bdrv_flush_all(void)
 {
     BlockDriverState *bs;
+    int result = 0;
 
     QTAILQ_FOREACH(bs, &bdrv_states, list) {
-        bdrv_flush(bs);
+        int ret = bdrv_flush(bs);
+        if (ret < 0 && !result) {
+            result = ret;
+        }
     }
+
+    return result;
 }
 
 int bdrv_has_zero_init(BlockDriverState *bs)
index 1251c5cf9f8f136704334cd35387d18e87844c47..4bc51d533be22eccd8dceccaa862e7d19303d906 100644 (file)
@@ -276,7 +276,7 @@ void bdrv_clear_incoming_migration_all(void);
 /* Ensure contents are flushed to disk.  */
 int bdrv_flush(BlockDriverState *bs);
 int coroutine_fn bdrv_co_flush(BlockDriverState *bs);
-void bdrv_flush_all(void);
+int bdrv_flush_all(void);
 void bdrv_close_all(void);
 void bdrv_drain_all(void);