From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36141) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agz1r-0003eD-VZ for qemu-devel@nongnu.org; Fri, 18 Mar 2016 14:21:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agz1q-0006z0-VY for qemu-devel@nongnu.org; Fri, 18 Mar 2016 14:21:43 -0400 From: Kevin Wolf Date: Fri, 18 Mar 2016 19:21:10 +0100 Message-Id: <1458325289-17848-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1458325289-17848-1-git-send-email-kwolf@redhat.com> References: <1458325289-17848-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 01/20] block: Add bdrv_parse_cache_mode() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com 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 --- block.c | 17 +++++++++++++++++ include/block/block.h | 1 + 2 files changed, 18 insertions(+) diff --git a/block.c b/block.c index d319f86..172f865 100644 --- a/block.c +++ b/block.c @@ -661,6 +661,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 4adb1e9..823f4d7 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -206,6 +206,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, -- 1.8.3.1