diff options
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -106,13 +106,23 @@ int is_windows_drive(const char *filename) size_t bdrv_opt_mem_align(BlockDriverState *bs) { if (!bs || !bs->drv) { - /* 4k should be on the safe side */ - return 4096; + /* page size or 4k (hdd sector size) should be on the safe side */ + return MAX(4096, getpagesize()); } return bs->bl.opt_mem_alignment; } +size_t bdrv_min_mem_align(BlockDriverState *bs) +{ + if (!bs || !bs->drv) { + /* page size or 4k (hdd sector size) should be on the safe side */ + return MAX(4096, getpagesize()); + } + + return bs->bl.min_mem_alignment; +} + /* check if the path starts with "<protocol>:" */ 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; |