From nobody Sat Nov 8 07:57:43 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549535770787594.1321156054278; Thu, 7 Feb 2019 02:36:10 -0800 (PST) Received: from localhost ([127.0.0.1]:37455 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grh2M-0002xc-QW for importer@patchew.org; Thu, 07 Feb 2019 05:36:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgrb-0002iX-Le for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1grgra-0001jO-1E for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:24:59 -0500 Received: from relay.sw.ru ([185.231.240.75]:43054) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grgrZ-0001da-Mm; Thu, 07 Feb 2019 05:24:57 -0500 Received: from [10.28.8.145] (helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1grgrP-0005bY-C2; Thu, 07 Feb 2019 13:24:47 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 7 Feb 2019 13:24:36 +0300 Message-Id: <20190207102445.71998-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190207102445.71998-1-vsementsov@virtuozzo.com> References: <20190207102445.71998-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v3 08/17] block/qcow: use qemu_iovec_init_buf X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, quintela@redhat.com, jcody@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use new qemu_iovec_init_buf() instead of qemu_iovec_init_external( ... , 1), which simplifies the code. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- 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 =3D 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 =3D (void *)buf; - hd_iov.iov_len =3D 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 =3D -EIO; break; } - hd_iov.iov_base =3D (void *)buf; - hd_iov.iov_len =3D 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 =3D bdrv_co_preadv(bs->file, cluster_offset + offset_in_cl= uster, @@ -733,7 +728,6 @@ static coroutine_fn int qcow_co_pwritev(BlockDriverStat= e *bs, uint64_t offset, int offset_in_cluster; uint64_t cluster_offset; int ret =3D 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(BlockDriverStat= e *bs, uint64_t offset, } } =20 - hd_iov.iov_base =3D (void *)buf; - hd_iov.iov_len =3D 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 =3D bdrv_co_pwritev(bs->file, cluster_offset + offset_in_clust= er, @@ -1062,7 +1054,6 @@ qcow_co_pwritev_compressed(BlockDriverState *bs, uint= 64_t offset, { BDRVQcowState *s =3D 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, uin= t64_t offset, } cluster_offset &=3D s->cluster_offset_mask; =20 - iov =3D (struct iovec) { - .iov_base =3D out_buf, - .iov_len =3D 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 =3D bdrv_co_pwritev(bs->file, cluster_offset, out_len, &hd_qiov, 0= ); if (ret < 0) { --=20 2.18.0