thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
Blob Blame History Raw
From 3e92f885201f2ddf30d093f34a02630ca3324b0b Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Fri, 29 Nov 2013 21:29:17 +0100
Subject: [PATCH 06/37] qemu_memalign: Allow small alignments
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Message-id: <1392117622-28812-7-git-send-email-kwolf@redhat.com>
Patchwork-id: 57171
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 06/37] qemu_memalign: Allow small alignments
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>

The functions used by qemu_memalign() require an alignment that is at
least sizeof(void*). Adjust it if it is too small.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: BenoƮt Canet <benoit@irqsave.net>
(cherry picked from commit e5354657a626b325c31888f33de88ac6d39e2fcb)

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 util/oslib-posix.c | 5 +++++
 1 file changed, 5 insertions(+)
---
 util/oslib-posix.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 253bc3d..2c756c7 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -85,6 +85,11 @@ void *qemu_oom_check(void *ptr)
 void *qemu_memalign(size_t alignment, size_t size)
 {
     void *ptr;
+
+    if (alignment < sizeof(void*)) {
+        alignment = sizeof(void*);
+    }
+
 #if defined(_POSIX_C_SOURCE) && !defined(__sun__)
     int ret;
     ret = posix_memalign(&ptr, alignment, size);
-- 
1.7.1