summaryrefslogtreecommitdiffstats
path: root/block.c
diff options
context:
space:
mode:
authorPeter Maydell2015-05-22 14:25:40 +0200
committerPeter Maydell2015-05-22 14:25:40 +0200
commit8b6db32a4ec47d1171ccfa21d557096b99f4eef0 (patch)
treeeca89cb63571cd7c7c5806d8007928fdda63e9da /block.c
parentRevert "target-alpha: Add vector implementation for CMPBGE" (diff)
parentblock: get_block_status: use "else" when testing the opposite condition (diff)
downloadqemu-8b6db32a4ec47d1171ccfa21d557096b99f4eef0.tar.gz
qemu-8b6db32a4ec47d1171ccfa21d557096b99f4eef0.tar.xz
qemu-8b6db32a4ec47d1171ccfa21d557096b99f4eef0.zip
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
# gpg: Signature made Fri May 22 10:00:53 2015 BST using RSA key ID 81AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" * remotes/stefanha/tags/block-pull-request: (38 commits) block: get_block_status: use "else" when testing the opposite condition qemu-iotests: Test unaligned sub-block zero write block: Fix NULL deference for unaligned write if qiov is NULL Revert "block: Fix unaligned zero write" block: align bounce buffers to page block: minimal bounce buffer alignment block: return EPERM on writes or discards to read-only devices configure: Add workaround for ccache and clang configure: silence glib unknown attribute __alloc_size__ configure: factor out supported flag check configure: handle clang -nopie argument warning block/parallels: improve image writing performance further block/parallels: optimize linear image expansion block/parallels: add prealloc-mode and prealloc-size open paramemets block/parallels: delay writing to BAT till bdrv_co_flush_to_os block/parallels: create bat_entry_off helper block/parallels: improve image reading performance iotests, parallels: check for incorrectly closed image in tests block/parallels: implement incorrect close detection block/parallels: implement parallels_check method of block driver ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'block.c')
-rw-r--r--block.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/block.c b/block.c
index 7904098c64..325f7272fe 100644
--- a/block.c
+++ b/block.c
@@ -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;