diff options
author | Kevin Wolf <kwolf@redhat.com> | 2016-03-14 11:40:23 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2016-03-30 12:16:00 +0200 |
commit | baf5602ed92628067990abfa7a873f51586a4dc1 (patch) | |
tree | bc7326f58f367dc7c8675270351e2ad7af904fd7 /block.c | |
parent | 63785678f3941c84be01d3ab7867e2742ea9fe3e (diff) |
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>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 17 |
1 files changed, 17 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 |