From 4196d2f0308cb1ae13ed450424ab7dfe154acda9 Mon Sep 17 00:00:00 2001 From: "Denis V. Lunev" Date: Tue, 12 May 2015 17:30:55 +0300 Subject: block: minimal bounce buffer alignment The patch introduces new concept: minimal memory alignment for bounce buffers. Original so called "optimal" value is actually minimal required value for aligment. It should be used for validation that the IOVec is properly aligned and bounce buffer is not required. Though, from the performance point of view, it would be better if bounce buffer or IOVec allocated by QEMU will be aligned stricter. The patch does not change any alignment value yet. Signed-off-by: Denis V. Lunev Reviewed-by: Kevin Wolf Message-id: 1431441056-26198-2-git-send-email-den@openvz.org CC: Paolo Bonzini Reviewed-by: Kevin Wolf CC: Stefan Hajnoczi Signed-off-by: Stefan Hajnoczi --- block.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'block.c') diff --git a/block.c b/block.c index 7904098c64..e293907c2b 100644 --- a/block.c +++ b/block.c @@ -113,6 +113,16 @@ size_t bdrv_opt_mem_align(BlockDriverState *bs) return bs->bl.opt_mem_alignment; } +size_t bdrv_min_mem_align(BlockDriverState *bs) +{ + if (!bs || !bs->drv) { + /* 4k should be on the safe side */ + return 4096; + } + + return bs->bl.min_mem_alignment; +} + /* check if the path starts with ":" */ int path_has_protocol(const char *path) { @@ -890,6 +900,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file, } assert(bdrv_opt_mem_align(bs) != 0); + assert(bdrv_min_mem_align(bs) != 0); assert((bs->request_alignment != 0) || bs->sg); return 0; -- cgit v1.2.3