yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
Blob Blame History Raw
From 3015984eb6778214d381cf7de32d8ab81e277728 Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Thu, 5 Dec 2013 13:01:46 +0100
Subject: [PATCH 07/37] block: Detect unaligned length in bdrv_qiov_is_aligned()

Message-id: <1392117622-28812-8-git-send-email-kwolf@redhat.com>
Patchwork-id: 57172
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 07/37] block: Detect unaligned length in bdrv_qiov_is_aligned()
Bugzilla: 748906
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>

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>
(cherry picked from commit 1ff735bdc417945bc6df1857861b127644b3f461)

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c | 3 +++
 1 file changed, 3 insertions(+)
---
 block.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/block.c b/block.c
index f62acbd..6c98ff7 100644
--- a/block.c
+++ b/block.c
@@ -4743,6 +4743,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;
-- 
1.7.1