qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PULL 5/8] block: Add return value for bdrv_flush_all()


From: Kevin Wolf
Subject: [Qemu-devel] [PULL 5/8] block: Add return value for bdrv_flush_all()
Date: Mon, 15 Jul 2013 13:16:37 +0200

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 <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
 block.c               | 10 ++++++++--
 include/block/block.h |  2 +-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/block.c b/block.c
index 2df65c8..b560241 100644
--- a/block.c
+++ b/block.c
@@ -2910,13 +2910,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_1(BlockDriverState *bs)
diff --git a/include/block/block.h b/include/block/block.h
index eeb4816..b6b9014 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -267,7 +267,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);
 
-- 
1.8.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]