|
|
9ae3a8 |
From ad8bc0d8901415eeea7bb27ef26f197918be0752 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
Date: Sat, 13 Jun 2015 16:22:09 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 15/42] block: Add qemu_{,try_}blockalign0()
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Message-id: <1434212556-3927-16-git-send-email-mreitz@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 66034
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.2 qemu-kvm PATCH 15/42] block: Add qemu_{,try_}blockalign0()
|
|
|
9ae3a8 |
Bugzilla: 1129893
|
|
|
9ae3a8 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
BZ: 1129893
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
These functions call their non-0-counterparts and then fill the
|
|
|
9ae3a8 |
allocated buffer with 0 (if the allocation has been successful).
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 9ebd84480583bb6d9a7666c079d99ff3266c423d)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block.c | 16 ++++++++++++++++
|
|
|
9ae3a8 |
include/block/block.h | 2 ++
|
|
|
9ae3a8 |
2 files changed, 18 insertions(+)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block.c b/block.c
|
|
|
9ae3a8 |
index 1afa544..22ab762 100644
|
|
|
9ae3a8 |
--- a/block.c
|
|
|
9ae3a8 |
+++ b/block.c
|
|
|
9ae3a8 |
@@ -5178,6 +5178,11 @@ void *qemu_blockalign(BlockDriverState *bs, size_t size)
|
|
|
9ae3a8 |
return qemu_memalign(bdrv_opt_mem_align(bs), size);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+void *qemu_blockalign0(BlockDriverState *bs, size_t size)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ return memset(qemu_blockalign(bs, size), 0, size);
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
void *qemu_try_blockalign(BlockDriverState *bs, size_t size)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
size_t align = bdrv_opt_mem_align(bs);
|
|
|
9ae3a8 |
@@ -5191,6 +5196,17 @@ void *qemu_try_blockalign(BlockDriverState *bs, size_t size)
|
|
|
9ae3a8 |
return qemu_try_memalign(align, size);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+void *qemu_try_blockalign0(BlockDriverState *bs, size_t size)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ void *mem = qemu_try_blockalign(bs, size);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ if (mem) {
|
|
|
9ae3a8 |
+ memset(mem, 0, size);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ return mem;
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
/*
|
|
|
9ae3a8 |
* Check if all memory in this vector is sector aligned.
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
diff --git a/include/block/block.h b/include/block/block.h
|
|
|
9ae3a8 |
index 7b538b7..8339cac 100644
|
|
|
9ae3a8 |
--- a/include/block/block.h
|
|
|
9ae3a8 |
+++ b/include/block/block.h
|
|
|
9ae3a8 |
@@ -417,7 +417,9 @@ void bdrv_img_create(const char *filename, const char *fmt,
|
|
|
9ae3a8 |
size_t bdrv_opt_mem_align(BlockDriverState *bs);
|
|
|
9ae3a8 |
void bdrv_set_guest_block_size(BlockDriverState *bs, int align);
|
|
|
9ae3a8 |
void *qemu_blockalign(BlockDriverState *bs, size_t size);
|
|
|
9ae3a8 |
+void *qemu_blockalign0(BlockDriverState *bs, size_t size);
|
|
|
9ae3a8 |
void *qemu_try_blockalign(BlockDriverState *bs, size_t size);
|
|
|
9ae3a8 |
+void *qemu_try_blockalign0(BlockDriverState *bs, size_t size);
|
|
|
9ae3a8 |
bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
struct HBitmapIter;
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|