]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
block: Add bdrv_parse_cache_mode()
authorKevin Wolf <kwolf@redhat.com>
Mon, 14 Mar 2016 10:40:23 +0000 (11:40 +0100)
committerKevin Wolf <kwolf@redhat.com>
Wed, 30 Mar 2016 10:16:00 +0000 (12:16 +0200)
It's like bdrv_parse_cache_flags(), except that writethrough mode isn't
included in the flags, but returned as a separate bool.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
block.c
include/block/block.h

diff --git a/block.c b/block.c
index af3584389de67bd668b8444d4bfa31c57866db3b..14d2ebc35ab3741afad4b838da8864928e8b3d02 100644 (file)
--- a/block.c
+++ b/block.c
@@ -667,6 +667,23 @@ int bdrv_parse_cache_flags(const char *mode, int *flags)
     return 0;
 }
 
+int bdrv_parse_cache_mode(const char *mode, int *flags, bool *writethrough)
+{
+    int ret = bdrv_parse_cache_flags(mode, flags);
+    if (ret < 0) {
+        return ret;
+    }
+
+    if (*flags & BDRV_O_CACHE_WB) {
+        *flags &= ~BDRV_O_CACHE_WB;
+        *writethrough = false;
+    } else {
+        *writethrough = true;
+    }
+
+    return 0;
+}
+
 /*
  * Returns the options and flags that a temporary snapshot should get, based on
  * the originally requested flags (the originally requested image will have
index b4b4650fd35c8c8fd371520feb02ebda83c33987..4fd6c050f060da82c911ed1121c890da295e6024 100644 (file)
@@ -208,6 +208,7 @@ void bdrv_replace_in_backing_chain(BlockDriverState *old,
                                    BlockDriverState *new);
 
 int bdrv_parse_cache_flags(const char *mode, int *flags);
+int bdrv_parse_cache_mode(const char *mode, int *flags, bool *writethrough);
 int bdrv_parse_discard_flags(const char *mode, int *flags);
 BdrvChild *bdrv_open_child(const char *filename,
                            QDict *options, const char *bdref_key,