aboutsummaryrefslogtreecommitdiff
path: root/qemu-img.c
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2018-01-16 14:08:58 +0800
committerFam Zheng <famz@redhat.com>2018-02-08 09:22:03 +0800
commit79d465839f6be12d614ee2bdf3514c5d645116ff (patch)
treeb521f60269ffb804e0fa8281a81e010bfea502ab /qemu-img.c
parent9ed616129ec6fa2a3011d324b2eb19f91cfb8547 (diff)
downloadqemu-79d465839f6be12d614ee2bdf3514c5d645116ff.zip
qemu-79d465839f6be12d614ee2bdf3514c5d645116ff.tar.gz
qemu-79d465839f6be12d614ee2bdf3514c5d645116ff.tar.bz2
qemu-img: Map bench buffer
Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20180116060901.17413-7-famz@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com>
Diffstat (limited to 'qemu-img.c')
-rw-r--r--qemu-img.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/qemu-img.c b/qemu-img.c
index 68b375f..28d0e4e 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -3862,6 +3862,7 @@ static int img_bench(int argc, char **argv)
struct timeval t1, t2;
int i;
bool force_share = false;
+ size_t buf_size;
for (;;) {
static const struct option long_options[] = {
@@ -4050,9 +4051,12 @@ static int img_bench(int argc, char **argv)
printf("Sending flush every %d requests\n", flush_interval);
}
- data.buf = blk_blockalign(blk, data.nrreq * data.bufsize);
+ buf_size = data.nrreq * data.bufsize;
+ data.buf = blk_blockalign(blk, buf_size);
memset(data.buf, pattern, data.nrreq * data.bufsize);
+ blk_register_buf(blk, data.buf, buf_size);
+
data.qiov = g_new(QEMUIOVector, data.nrreq);
for (i = 0; i < data.nrreq; i++) {
qemu_iovec_init(&data.qiov[i], 1);
@@ -4073,6 +4077,9 @@ static int img_bench(int argc, char **argv)
+ ((double)(t2.tv_usec - t1.tv_usec) / 1000000));
out:
+ if (data.buf) {
+ blk_unregister_buf(blk, data.buf);
+ }
qemu_vfree(data.buf);
blk_unref(blk);