aboutsummaryrefslogtreecommitdiff
path: root/block/qapi.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2016-03-03 11:37:48 +0100
committerKevin Wolf <kwolf@redhat.com>2016-03-30 12:16:02 +0200
commitc83f9fba2a4ae3f07a7ac8ff8c021f539a08b6ce (patch)
tree3415e706dcd6ccca77ac108551e139c7c95e067d /block/qapi.c
parentbfd18d1e0b06608226fcef1982c3a439c49c3366 (diff)
block/qapi: Use blk_enable_write_cache()
Now that WCE is handled on the BlockBackend level, the flag is meaningless for BDSes. As the schema requires us to fill the field, we return an enabled write cache for them. Note that this means that querying the BlockBackend name may return writethrough as the cache information, whereas querying the node-name of the root of that same BlockBackend will return writeback. This may appear odd at first, but it actually makes sense because it correctly repesents the layer that implements the WCE handling. This becomes more apparent when you consider nodes that are the root node of multiple BlockBackends, where each BB can have its own WCE setting. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block/qapi.c')
-rw-r--r--block/qapi.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/block/qapi.c b/block/qapi.c
index 351676175b..c5f6ba643c 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -34,7 +34,8 @@
#include "sysemu/block-backend.h"
#include "qemu/cutils.h"
-BlockDeviceInfo *bdrv_block_device_info(BlockDriverState *bs, Error **errp)
+BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
+ BlockDriverState *bs, Error **errp)
{
ImageInfo **p_image_info;
BlockDriverState *bs0;
@@ -48,7 +49,7 @@ BlockDeviceInfo *bdrv_block_device_info(BlockDriverState *bs, Error **errp)
info->cache = g_new(BlockdevCacheInfo, 1);
*info->cache = (BlockdevCacheInfo) {
- .writeback = bdrv_enable_write_cache(bs),
+ .writeback = blk ? blk_enable_write_cache(blk) : true,
.direct = !!(bs->open_flags & BDRV_O_NOCACHE),
.no_flush = !!(bs->open_flags & BDRV_O_NO_FLUSH),
};
@@ -343,7 +344,7 @@ static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info,
if (bs && bs->drv) {
info->has_inserted = true;
- info->inserted = bdrv_block_device_info(bs, errp);
+ info->inserted = bdrv_block_device_info(blk, bs, errp);
if (info->inserted == NULL) {
goto err;
}