0a122b
From 3e92f885201f2ddf30d093f34a02630ca3324b0b Mon Sep 17 00:00:00 2001
0a122b
From: Kevin Wolf <kwolf@redhat.com>
0a122b
Date: Fri, 29 Nov 2013 21:29:17 +0100
0a122b
Subject: [PATCH 06/37] qemu_memalign: Allow small alignments
0a122b
MIME-Version: 1.0
0a122b
Content-Type: text/plain; charset=UTF-8
0a122b
Content-Transfer-Encoding: 8bit
0a122b
0a122b
Message-id: <1392117622-28812-7-git-send-email-kwolf@redhat.com>
0a122b
Patchwork-id: 57171
0a122b
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 06/37] qemu_memalign: Allow small alignments
0a122b
Bugzilla: 748906
0a122b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
0a122b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
RH-Acked-by: Max Reitz <mreitz@redhat.com>
0a122b
0a122b
The functions used by qemu_memalign() require an alignment that is at
0a122b
least sizeof(void*). Adjust it if it is too small.
0a122b
0a122b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0a122b
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
0a122b
Reviewed-by: Max Reitz <mreitz@redhat.com>
0a122b
Reviewed-by: BenoƮt Canet <benoit@irqsave.net>
0a122b
(cherry picked from commit e5354657a626b325c31888f33de88ac6d39e2fcb)
0a122b
0a122b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0a122b
---
0a122b
 util/oslib-posix.c | 5 +++++
0a122b
 1 file changed, 5 insertions(+)
0a122b
---
0a122b
 util/oslib-posix.c |    5 +++++
0a122b
 1 files changed, 5 insertions(+), 0 deletions(-)
0a122b
0a122b
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
0a122b
index 253bc3d..2c756c7 100644
0a122b
--- a/util/oslib-posix.c
0a122b
+++ b/util/oslib-posix.c
0a122b
@@ -85,6 +85,11 @@ void *qemu_oom_check(void *ptr)
0a122b
 void *qemu_memalign(size_t alignment, size_t size)
0a122b
 {
0a122b
     void *ptr;
0a122b
+
0a122b
+    if (alignment < sizeof(void*)) {
0a122b
+        alignment = sizeof(void*);
0a122b
+    }
0a122b
+
0a122b
 #if defined(_POSIX_C_SOURCE) && !defined(__sun__)
0a122b
     int ret;
0a122b
     ret = posix_memalign(&ptr, alignment, size);
0a122b
-- 
0a122b
1.7.1
0a122b