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>
This commit is contained in:
parent
63785678f3
commit
baf5602ed9
17
block.c
17
block.c
@ -667,6 +667,23 @@ int bdrv_parse_cache_flags(const char *mode, int *flags)
|
|||||||
return 0;
|
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
|
* Returns the options and flags that a temporary snapshot should get, based on
|
||||||
* the originally requested flags (the originally requested image will have
|
* the originally requested flags (the originally requested image will have
|
||||||
|
@ -208,6 +208,7 @@ void bdrv_replace_in_backing_chain(BlockDriverState *old,
|
|||||||
BlockDriverState *new);
|
BlockDriverState *new);
|
||||||
|
|
||||||
int bdrv_parse_cache_flags(const char *mode, int *flags);
|
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);
|
int bdrv_parse_discard_flags(const char *mode, int *flags);
|
||||||
BdrvChild *bdrv_open_child(const char *filename,
|
BdrvChild *bdrv_open_child(const char *filename,
|
||||||
QDict *options, const char *bdref_key,
|
QDict *options, const char *bdref_key,
|
||||||
|
Loading…
Reference in New Issue
Block a user