From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Subject: [Qemu-devel] [PULL 08/27] block/qcow: use qemu_iovec_init_buf
Date: Fri, 22 Feb 2019 14:07:37 +0000 [thread overview]
Message-ID: <20190222140756.29834-9-stefanha@redhat.com> (raw)
In-Reply-To: <20190222140756.29834-1-stefanha@redhat.com>
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Use new qemu_iovec_init_buf() instead of
qemu_iovec_init_external( ... , 1), which simplifies the code.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 20190218140926.333779-9-vsementsov@virtuozzo.com
Message-Id: <20190218140926.333779-9-vsementsov@virtuozzo.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/qcow.c | 21 ++++-----------------
1 file changed, 4 insertions(+), 17 deletions(-)
diff --git a/block/qcow.c b/block/qcow.c
index 0a235bf393..409c700d33 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -628,7 +628,6 @@ static coroutine_fn int qcow_co_preadv(BlockDriverState *bs, uint64_t offset,
int offset_in_cluster;
int ret = 0, n;
uint64_t cluster_offset;
- struct iovec hd_iov;
QEMUIOVector hd_qiov;
uint8_t *buf;
void *orig_buf;
@@ -661,9 +660,7 @@ static coroutine_fn int qcow_co_preadv(BlockDriverState *bs, uint64_t offset,
if (!cluster_offset) {
if (bs->backing) {
/* read from the base image */
- hd_iov.iov_base = (void *)buf;
- hd_iov.iov_len = n;
- qemu_iovec_init_external(&hd_qiov, &hd_iov, 1);
+ qemu_iovec_init_buf(&hd_qiov, buf, n);
qemu_co_mutex_unlock(&s->lock);
/* qcow2 emits this on bs->file instead of bs->backing */
BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO);
@@ -688,9 +685,7 @@ static coroutine_fn int qcow_co_preadv(BlockDriverState *bs, uint64_t offset,
ret = -EIO;
break;
}
- hd_iov.iov_base = (void *)buf;
- hd_iov.iov_len = n;
- qemu_iovec_init_external(&hd_qiov, &hd_iov, 1);
+ qemu_iovec_init_buf(&hd_qiov, buf, n);
qemu_co_mutex_unlock(&s->lock);
BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO);
ret = bdrv_co_preadv(bs->file, cluster_offset + offset_in_cluster,
@@ -733,7 +728,6 @@ static coroutine_fn int qcow_co_pwritev(BlockDriverState *bs, uint64_t offset,
int offset_in_cluster;
uint64_t cluster_offset;
int ret = 0, n;
- struct iovec hd_iov;
QEMUIOVector hd_qiov;
uint8_t *buf;
void *orig_buf;
@@ -779,9 +773,7 @@ static coroutine_fn int qcow_co_pwritev(BlockDriverState *bs, uint64_t offset,
}
}
- hd_iov.iov_base = (void *)buf;
- hd_iov.iov_len = n;
- qemu_iovec_init_external(&hd_qiov, &hd_iov, 1);
+ qemu_iovec_init_buf(&hd_qiov, buf, n);
qemu_co_mutex_unlock(&s->lock);
BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO);
ret = bdrv_co_pwritev(bs->file, cluster_offset + offset_in_cluster,
@@ -1062,7 +1054,6 @@ qcow_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset,
{
BDRVQcowState *s = bs->opaque;
QEMUIOVector hd_qiov;
- struct iovec iov;
z_stream strm;
int ret, out_len;
uint8_t *buf, *out_buf;
@@ -1128,11 +1119,7 @@ qcow_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset,
}
cluster_offset &= s->cluster_offset_mask;
- iov = (struct iovec) {
- .iov_base = out_buf,
- .iov_len = out_len,
- };
- qemu_iovec_init_external(&hd_qiov, &iov, 1);
+ qemu_iovec_init_buf(&hd_qiov, out_buf, out_len);
BLKDBG_EVENT(bs->file, BLKDBG_WRITE_COMPRESSED);
ret = bdrv_co_pwritev(bs->file, cluster_offset, out_len, &hd_qiov, 0);
if (ret < 0) {
--
2.20.1
next prev parent reply other threads:[~2019-02-22 14:08 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-22 14:07 [Qemu-devel] [PULL 00/27] Block patches Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 01/27] block: enhance QEMUIOVector structure Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 02/27] block/io: use qemu_iovec_init_buf Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 03/27] block/block-backend: use QEMU_IOVEC_INIT_BUF Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 04/27] block/backup: use qemu_iovec_init_buf Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 05/27] block/commit: use QEMU_IOVEC_INIT_BUF Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 06/27] block/stream: " Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 07/27] block/parallels: " Stefan Hajnoczi
2019-02-22 14:07 ` Stefan Hajnoczi [this message]
2019-02-22 14:07 ` [Qemu-devel] [PULL 09/27] block/qcow2: use qemu_iovec_init_buf Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 10/27] block/qed: " Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 11/27] block/vmdk: " Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 12/27] qemu-img: " Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 13/27] migration/block: " Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 14/27] tests/test-bdrv-drain: use QEMU_IOVEC_INIT_BUF Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 15/27] hw/ide: drop iov field from IDEState Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 16/27] hw/ide: drop iov field from IDEBufferedRequest Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 17/27] hw/ide: drop iov field from IDEDMA Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 18/27] virtio-blk: add acct_failed param to virtio_blk_handle_rw_error() Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 19/27] virtio-blk: add host_features field in VirtIOBlock Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 20/27] virtio-blk: add "discard" and "write-zeroes" properties Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 21/27] virtio-net: make VirtIOFeature usable for other virtio devices Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 22/27] virtio-blk: set config size depending on the features enabled Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 23/27] virtio-blk: add DISCARD and WRITE_ZEROES features Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 24/27] tests/virtio-blk: change assert on data_size in virtio_blk_request() Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 25/27] tests/virtio-blk: add virtio_blk_fix_dwz_hdr() function Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 26/27] tests/virtio-blk: add test for WRITE_ZEROES command Stefan Hajnoczi
2019-02-22 14:07 ` [Qemu-devel] [PULL 27/27] tests/virtio-blk: add test for DISCARD command Stefan Hajnoczi
2019-02-26 14:06 ` [Qemu-devel] [PULL 00/27] Block patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190222140756.29834-9-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).