diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2013-01-11 16:41:27 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2013-01-14 10:06:56 +0100 |
commit | c53b1c5114bdf7fc945cbf11436da61789ca2267 (patch) | |
tree | 6d55f04d9eef3813ea35f326d0253d34266b0704 /block.c | |
parent | b608c8dc02c78ee95455a0989bdf1b41c768b2ef (diff) | |
download | qemu-c53b1c5114bdf7fc945cbf11436da61789ca2267.tar.gz qemu-c53b1c5114bdf7fc945cbf11436da61789ca2267.tar.bz2 qemu-c53b1c5114bdf7fc945cbf11436da61789ca2267.zip |
block: make qiov_is_aligned() public
The qiov_is_aligned() function checks whether a QEMUIOVector meets a
BlockDriverState's alignment requirements. This is needed by
virtio-blk-data-plane so:
1. Move the function from block/raw-posix.c to block/block.c.
2. Make it public in block/block.h.
3. Rename to bdrv_qiov_is_aligned().
4. Change return type from int to bool.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -4313,6 +4313,22 @@ void *qemu_blockalign(BlockDriverState *bs, size_t size) return qemu_memalign((bs && bs->buffer_alignment) ? bs->buffer_alignment : 512, size); } +/* + * Check if all memory in this vector is sector aligned. + */ +bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov) +{ + int i; + + for (i = 0; i < qiov->niov; i++) { + if ((uintptr_t) qiov->iov[i].iov_base % bs->buffer_alignment) { + return false; + } + } + + return true; +} + void bdrv_set_dirty_tracking(BlockDriverState *bs, int enable) { int64_t bitmap_size; |