diff options
author | Kevin Wolf <kwolf@redhat.com> | 2016-03-14 11:40:23 +0100 |
---|---|---|
committer | Timothy Pearson <tpearson@raptorengineering.com> | 2019-11-29 20:01:34 -0600 |
commit | 5d3d40905568d147283df60424c04af051aa07d2 (patch) | |
tree | 2bab12cd7febb7b92bc14130fdd6c40aa1cab290 | |
parent | 6fc68b5064616e728bc9bb59763b261e7e7c1964 (diff) | |
download | hqemu-5d3d40905568d147283df60424c04af051aa07d2.zip hqemu-5d3d40905568d147283df60424c04af051aa07d2.tar.gz |
block: Add bdrv_parse_cache_mode()
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>
-rw-r--r-- | block.c | 17 | ||||
-rw-r--r-- | include/block/block.h | 1 |
2 files changed, 18 insertions, 0 deletions
@@ -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 diff --git a/include/block/block.h b/include/block/block.h index b4b4650..4fd6c05 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -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, |