[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 46/48] block/null-{co, aio}: Allow reading zeroes
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 46/48] block/null-{co, aio}: Allow reading zeroes |
Date: |
Tue, 29 Mar 2016 17:08:46 +0200 |
From: Max Reitz <address@hidden>
This is optional so that it does not impede the null block driver's
performance unless this behavior is desired.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Acked-by: Fam Zheng <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/null.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/block/null.c b/block/null.c
index d90165d..a7df386 100644
--- a/block/null.c
+++ b/block/null.c
@@ -14,10 +14,12 @@
#include "block/block_int.h"
#define NULL_OPT_LATENCY "latency-ns"
+#define NULL_OPT_ZEROES "read-zeroes"
typedef struct {
int64_t length;
int64_t latency_ns;
+ bool read_zeroes;
} BDRVNullState;
static QemuOptsList runtime_opts = {
@@ -40,6 +42,11 @@ static QemuOptsList runtime_opts = {
.help = "nanoseconds (approximated) to wait "
"before completing request",
},
+ {
+ .name = NULL_OPT_ZEROES,
+ .type = QEMU_OPT_BOOL,
+ .help = "return zeroes when read",
+ },
{ /* end of list */ }
},
};
@@ -61,6 +68,7 @@ static int null_file_open(BlockDriverState *bs, QDict
*options, int flags,
error_setg(errp, "latency-ns is invalid");
ret = -EINVAL;
}
+ s->read_zeroes = qemu_opt_get_bool(opts, NULL_OPT_ZEROES, false);
qemu_opts_del(opts);
return ret;
}
@@ -90,6 +98,12 @@ static coroutine_fn int null_co_readv(BlockDriverState *bs,
int64_t sector_num, int nb_sectors,
QEMUIOVector *qiov)
{
+ BDRVNullState *s = bs->opaque;
+
+ if (s->read_zeroes) {
+ qemu_iovec_memset(qiov, 0, 0, nb_sectors * BDRV_SECTOR_SIZE);
+ }
+
return null_co_common(bs);
}
@@ -159,6 +173,12 @@ static BlockAIOCB *null_aio_readv(BlockDriverState *bs,
BlockCompletionFunc *cb,
void *opaque)
{
+ BDRVNullState *s = bs->opaque;
+
+ if (s->read_zeroes) {
+ qemu_iovec_memset(qiov, 0, 0, nb_sectors * BDRV_SECTOR_SIZE);
+ }
+
return null_aio_common(bs, cb, opaque);
}
--
1.8.3.1
- [Qemu-devel] [PULL 32/48] block: Always set writeback mode in blk_new_open(), (continued)
- [Qemu-devel] [PULL 32/48] block: Always set writeback mode in blk_new_open(), Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 39/48] raw: Support BDRV_REQ_FUA, Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 36/48] block: Introduce bdrv_co_writev_flags(), Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 35/48] block/qapi: Use blk_enable_write_cache(), Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 38/48] nbd: Support BDRV_REQ_FUA, Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 41/48] qemu-io: Use bdrv_parse_cache_mode() in reopen_f(), Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 44/48] block: Remove bdrv_(set_)enable_write_cache(), Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 40/48] block: Use bdrv_parse_cache_mode() in drive_init(), Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 20/48] block: an interoperability test for luks vs dm-crypt/cryptsetup, Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 42/48] block: Remove bdrv_parse_cache_flags(), Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 46/48] block/null-{co, aio}: Allow reading zeroes,
Kevin Wolf <=
- [Qemu-devel] [PULL 43/48] block: Remove BDRV_O_CACHE_WB, Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 47/48] block/null-{co, aio}: Implement get_block_status(), Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 45/48] qemu-img: Fix preallocation with -S 0 for convert, Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 48/48] iotests: Test qemu-img convert -S 0 behavior, Kevin Wolf, 2016/03/29
- Re: [Qemu-devel] [PULL 00/48] Block layer patches, Peter Maydell, 2016/03/29