From baf5602ed92628067990abfa7a873f51586a4dc1 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Mon, 14 Mar 2016 11:40:23 +0100 Subject: 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 Reviewed-by: Max Reitz --- block.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'block.c') diff --git a/block.c b/block.c index af3584389d..14d2ebc35a 100644 --- 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 -- cgit v1.2.3-70-g09d2