]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block: Detect unaligned length in bdrv_qiov_is_aligned()
authorKevin Wolf <kwolf@redhat.com>
Thu, 5 Dec 2013 12:01:46 +0000 (13:01 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 24 Jan 2014 16:40:01 +0000 (17:40 +0100)
For an O_DIRECT request to succeed, it's not only necessary that all
base addresses in the qiov are aligned, but also that each length in it
is aligned.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
block.c

diff --git a/block.c b/block.c
index 9d0cfc46da3ca2221a10781e4c917e4b22e4b629..275d387354283c6cad930fc9a589348ab49d0037 100644 (file)
--- a/block.c
+++ b/block.c
@@ -4811,6 +4811,9 @@ bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov)
         if ((uintptr_t) qiov->iov[i].iov_base % bs->buffer_alignment) {
             return false;
         }
+        if (qiov->iov[i].iov_len % bs->buffer_alignment) {
+            return false;
+        }
     }
 
     return true;