From nobody Sat Nov 8 03:22:16 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 154953564051775.00672972339964; Thu, 7 Feb 2019 02:34:00 -0800 (PST) Received: from localhost ([127.0.0.1]:37382 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grh0I-0001AV-D1 for importer@patchew.org; Thu, 07 Feb 2019 05:33:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37037) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgru-0002z6-Ko for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1grgrt-00025M-O3 for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:18 -0500 Received: from relay.sw.ru ([185.231.240.75]:43058) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grgrt-0001dX-FO; Thu, 07 Feb 2019 05:25:17 -0500 Received: from [10.28.8.145] (helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1grgrO-0005bY-GD; Thu, 07 Feb 2019 13:24:46 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 7 Feb 2019 13:24:29 +0300 Message-Id: <20190207102445.71998-2-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 01/17] block: enhance QEMUIOVector structure 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" Add a possibility of embedded iovec, for cases when we need only one local iov. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- include/qemu/iov.h | 64 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/include/qemu/iov.h b/include/qemu/iov.h index 5f433c7768..034b9ae080 100644 --- a/include/qemu/iov.h +++ b/include/qemu/iov.h @@ -133,10 +133,70 @@ size_t iov_discard_back(struct iovec *iov, unsigned i= nt *iov_cnt, typedef struct QEMUIOVector { struct iovec *iov; int niov; - int nalloc; - size_t size; + + /* + * For external @iov (qemu_iovec_init_external()) or allocated @iov + * (qemu_iovec_init()), @size is the cumulative size of iovecs and + * @local_iov is invalid and unused. + * + * For embedded @iov (QEMU_IOVEC_INIT_BUF() or qemu_iovec_init_buf()), + * @iov is equal to &@local_iov, and @size is valid, as it has same + * offset and type as @local_iov.iov_len, which is guaranteed by + * static assertion below. + * + * @nalloc is always valid and is -1 both for embedded and external + * cases. It is included in the union only to ensure the padding prior + * to the @size field will not result in a 0-length array. + */ + union { + struct { + int nalloc; + struct iovec local_iov; + }; + struct { + char __pad[sizeof(int) + offsetof(struct iovec, iov_len)]; + size_t size; + }; + }; } QEMUIOVector; =20 +QEMU_BUILD_BUG_ON(offsetof(QEMUIOVector, size) !=3D + offsetof(QEMUIOVector, local_iov.iov_len)); + +#define QEMU_IOVEC_INIT_BUF(self, buf, len) \ +{ \ + .iov =3D &(self).local_iov, \ + .niov =3D 1, \ + .nalloc =3D -1, \ + .local_iov =3D { \ + .iov_base =3D (void *)(buf), /* cast away const */ \ + .iov_len =3D (len), \ + }, \ +} + +/* + * qemu_iovec_init_buf + * + * Initialize embedded QEMUIOVector. + * + * Note: "const" is used over @buf pointer to make it simple to pass + * const pointers, appearing in read functions. Then this "const" is + * casted away by QEMU_IOVEC_INIT_BUF(). + */ +static inline void qemu_iovec_init_buf(QEMUIOVector *qiov, + const void *buf, size_t len) +{ + *qiov =3D (QEMUIOVector) QEMU_IOVEC_INIT_BUF(*qiov, buf, len); +} + +static inline void *qemu_iovec_get_buf(QEMUIOVector *qiov) +{ + /* Only supports embedded iov */ + assert(qiov->niov =3D=3D -1 && qiov->iov =3D=3D &(qiov->local_iov)); + + return qiov->local_iov.iov_base; +} + void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint); void qemu_iovec_init_external(QEMUIOVector *qiov, struct iovec *iov, int n= iov); void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len); --=20 2.18.0 From nobody Sat Nov 8 03:22:16 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 1549535944876226.18089645722375; Thu, 7 Feb 2019 02:39:04 -0800 (PST) Received: from localhost ([127.0.0.1]:37485 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grh58-00054m-I1 for importer@patchew.org; Thu, 07 Feb 2019 05:38:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgrv-0002zB-3h for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1grgrt-00025f-QQ for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:19 -0500 Received: from relay.sw.ru ([185.231.240.75]:43032) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grgrt-0001dP-HX; Thu, 07 Feb 2019 05:25:17 -0500 Received: from [10.28.8.145] (helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1grgrO-0005bY-L4; Thu, 07 Feb 2019 13:24:46 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 7 Feb 2019 13:24:30 +0300 Message-Id: <20190207102445.71998-3-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 02/17] block/io: 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. While being here, use qemu_try_blockalign0 as well. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- block/io.c | 89 ++++++++++++------------------------------------------ 1 file changed, 20 insertions(+), 69 deletions(-) diff --git a/block/io.c b/block/io.c index 213ca03d8d..2ba603c7bc 100644 --- a/block/io.c +++ b/block/io.c @@ -843,17 +843,13 @@ static int bdrv_prwv_co(BdrvChild *child, int64_t off= set, static int bdrv_rw_co(BdrvChild *child, int64_t sector_num, uint8_t *buf, int nb_sectors, bool is_write, BdrvRequestFlags flag= s) { - QEMUIOVector qiov; - struct iovec iov =3D { - .iov_base =3D (void *)buf, - .iov_len =3D nb_sectors * BDRV_SECTOR_SIZE, - }; + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, + nb_sectors * BDRV_SECTOR_SIZE); =20 if (nb_sectors < 0 || nb_sectors > BDRV_REQUEST_MAX_SECTORS) { return -EINVAL; } =20 - qemu_iovec_init_external(&qiov, &iov, 1); return bdrv_prwv_co(child, sector_num << BDRV_SECTOR_BITS, &qiov, is_write, flags); } @@ -880,13 +876,8 @@ int bdrv_write(BdrvChild *child, int64_t sector_num, int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset, int bytes, BdrvRequestFlags flags) { - QEMUIOVector qiov; - struct iovec iov =3D { - .iov_base =3D NULL, - .iov_len =3D bytes, - }; + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, NULL, bytes); =20 - qemu_iovec_init_external(&qiov, &iov, 1); return bdrv_prwv_co(child, offset, &qiov, true, BDRV_REQ_ZERO_WRITE | flags); } @@ -950,17 +941,12 @@ int bdrv_preadv(BdrvChild *child, int64_t offset, QEM= UIOVector *qiov) =20 int bdrv_pread(BdrvChild *child, int64_t offset, void *buf, int bytes) { - QEMUIOVector qiov; - struct iovec iov =3D { - .iov_base =3D (void *)buf, - .iov_len =3D bytes, - }; + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); =20 if (bytes < 0) { return -EINVAL; } =20 - qemu_iovec_init_external(&qiov, &iov, 1); return bdrv_preadv(child, offset, &qiov); } =20 @@ -978,17 +964,12 @@ int bdrv_pwritev(BdrvChild *child, int64_t offset, QE= MUIOVector *qiov) =20 int bdrv_pwrite(BdrvChild *child, int64_t offset, const void *buf, int byt= es) { - QEMUIOVector qiov; - struct iovec iov =3D { - .iov_base =3D (void *) buf, - .iov_len =3D bytes, - }; + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); =20 if (bytes < 0) { return -EINVAL; } =20 - qemu_iovec_init_external(&qiov, &iov, 1); return bdrv_pwritev(child, offset, &qiov); } =20 @@ -1165,7 +1146,6 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(Bdrv= Child *child, void *bounce_buffer; =20 BlockDriver *drv =3D bs->drv; - struct iovec iov; QEMUIOVector local_qiov; int64_t cluster_offset; int64_t cluster_bytes; @@ -1230,9 +1210,8 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(Bdrv= Child *child, =20 if (ret <=3D 0) { /* Must copy-on-read; use the bounce buffer */ - iov.iov_base =3D bounce_buffer; - iov.iov_len =3D pnum =3D MIN(pnum, MAX_BOUNCE_BUFFER); - qemu_iovec_init_external(&local_qiov, &iov, 1); + pnum =3D MIN(pnum, MAX_BOUNCE_BUFFER); + qemu_iovec_init_buf(&local_qiov, bounce_buffer, pnum); =20 ret =3D bdrv_driver_preadv(bs, cluster_offset, pnum, &local_qiov, 0); @@ -1477,7 +1456,7 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(Bloc= kDriverState *bs, { BlockDriver *drv =3D bs->drv; QEMUIOVector qiov; - struct iovec iov =3D {0}; + void *buf =3D NULL; int ret =3D 0; bool need_flush =3D false; int head =3D 0; @@ -1547,16 +1526,14 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(Bl= ockDriverState *bs, need_flush =3D true; } num =3D MIN(num, max_transfer); - iov.iov_len =3D num; - if (iov.iov_base =3D=3D NULL) { - iov.iov_base =3D qemu_try_blockalign(bs, num); - if (iov.iov_base =3D=3D NULL) { + if (buf =3D=3D NULL) { + buf =3D qemu_try_blockalign0(bs, num); + if (buf =3D=3D NULL) { ret =3D -ENOMEM; goto fail; } - memset(iov.iov_base, 0, num); } - qemu_iovec_init_external(&qiov, &iov, 1); + qemu_iovec_init_buf(&qiov, buf, num); =20 ret =3D bdrv_driver_pwritev(bs, offset, num, &qiov, write_flag= s); =20 @@ -1564,8 +1541,8 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(Bloc= kDriverState *bs, * all future requests. */ if (num < max_transfer) { - qemu_vfree(iov.iov_base); - iov.iov_base =3D NULL; + qemu_vfree(buf); + buf =3D NULL; } } =20 @@ -1577,7 +1554,7 @@ fail: if (ret =3D=3D 0 && need_flush) { ret =3D bdrv_co_flush(bs); } - qemu_vfree(iov.iov_base); + qemu_vfree(buf); return ret; } =20 @@ -1763,7 +1740,6 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvC= hild *child, BlockDriverState *bs =3D child->bs; uint8_t *buf =3D NULL; QEMUIOVector local_qiov; - struct iovec iov; uint64_t align =3D bs->bl.request_alignment; unsigned int head_padding_bytes, tail_padding_bytes; int ret =3D 0; @@ -1775,11 +1751,7 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(Bdrv= Child *child, assert(flags & BDRV_REQ_ZERO_WRITE); if (head_padding_bytes || tail_padding_bytes) { buf =3D qemu_blockalign(bs, align); - iov =3D (struct iovec) { - .iov_base =3D buf, - .iov_len =3D align, - }; - qemu_iovec_init_external(&local_qiov, &iov, 1); + qemu_iovec_init_buf(&local_qiov, buf, align); } if (head_padding_bytes) { uint64_t zero_bytes =3D MIN(bytes, align - head_padding_bytes); @@ -1885,17 +1857,12 @@ int coroutine_fn bdrv_co_pwritev(BdrvChild *child, =20 if (offset & (align - 1)) { QEMUIOVector head_qiov; - struct iovec head_iov; =20 mark_request_serialising(&req, align); wait_serialising_requests(&req); =20 head_buf =3D qemu_blockalign(bs, align); - head_iov =3D (struct iovec) { - .iov_base =3D head_buf, - .iov_len =3D align, - }; - qemu_iovec_init_external(&head_qiov, &head_iov, 1); + qemu_iovec_init_buf(&head_qiov, head_buf, align); =20 bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_HEAD); ret =3D bdrv_aligned_preadv(child, &req, offset & ~(align - 1), al= ign, @@ -1924,7 +1891,6 @@ int coroutine_fn bdrv_co_pwritev(BdrvChild *child, =20 if ((offset + bytes) & (align - 1)) { QEMUIOVector tail_qiov; - struct iovec tail_iov; size_t tail_bytes; bool waited; =20 @@ -1933,11 +1899,7 @@ int coroutine_fn bdrv_co_pwritev(BdrvChild *child, assert(!waited || !use_local_qiov); =20 tail_buf =3D qemu_blockalign(bs, align); - tail_iov =3D (struct iovec) { - .iov_base =3D tail_buf, - .iov_len =3D align, - }; - qemu_iovec_init_external(&tail_qiov, &tail_iov, 1); + qemu_iovec_init_buf(&tail_qiov, tail_buf, align); =20 bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_TAIL); ret =3D bdrv_aligned_preadv(child, &req, (offset + bytes) & ~(alig= n - 1), @@ -2468,15 +2430,9 @@ bdrv_rw_vmstate(BlockDriverState *bs, QEMUIOVector *= qiov, int64_t pos, int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf, int64_t pos, int size) { - QEMUIOVector qiov; - struct iovec iov =3D { - .iov_base =3D (void *) buf, - .iov_len =3D size, - }; + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, size); int ret; =20 - qemu_iovec_init_external(&qiov, &iov, 1); - ret =3D bdrv_writev_vmstate(bs, &qiov, pos); if (ret < 0) { return ret; @@ -2493,14 +2449,9 @@ int bdrv_writev_vmstate(BlockDriverState *bs, QEMUIO= Vector *qiov, int64_t pos) int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf, int64_t pos, int size) { - QEMUIOVector qiov; - struct iovec iov =3D { - .iov_base =3D buf, - .iov_len =3D size, - }; + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, size); int ret; =20 - qemu_iovec_init_external(&qiov, &iov, 1); ret =3D bdrv_readv_vmstate(bs, &qiov, pos); if (ret < 0) { return ret; --=20 2.18.0 From nobody Sat Nov 8 03:22:16 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 1549535592887506.0826147759486; Thu, 7 Feb 2019 02:33:12 -0800 (PST) Received: from localhost ([127.0.0.1]:37378 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgzR-0000Th-MC for importer@patchew.org; Thu, 07 Feb 2019 05:33:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgrb-0002iW-JV 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-0001k1-8F for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:24:59 -0500 Received: from relay.sw.ru ([185.231.240.75]:43034) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grgrZ-0001dQ-Sz; Thu, 07 Feb 2019 05:24:58 -0500 Received: from [10.28.8.145] (helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1grgrO-0005bY-P1; Thu, 07 Feb 2019 13:24:46 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 7 Feb 2019 13:24:31 +0300 Message-Id: <20190207102445.71998-4-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 03/17] block/block-backend: 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 Reviewed-by: Stefan Hajnoczi --- block/block-backend.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index f6ea824308..6cc25569ef 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1204,17 +1204,8 @@ static int blk_prw(BlockBackend *blk, int64_t offset= , uint8_t *buf, int64_t bytes, CoroutineEntry co_entry, BdrvRequestFlags flags) { - QEMUIOVector qiov; - struct iovec iov; - BlkRwCo rwco; - - iov =3D (struct iovec) { - .iov_base =3D buf, - .iov_len =3D bytes, - }; - qemu_iovec_init_external(&qiov, &iov, 1); - - rwco =3D (BlkRwCo) { + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); + BlkRwCo rwco =3D { .blk =3D blk, .offset =3D offset, .iobuf =3D &qiov, --=20 2.18.0 From nobody Sat Nov 8 03:22:16 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 154953593841019.502556245871233; Thu, 7 Feb 2019 02:38:58 -0800 (PST) Received: from localhost ([127.0.0.1]:37483 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grh56-000529-7h for importer@patchew.org; Thu, 07 Feb 2019 05:38:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgru-0002z5-KV for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1grgrt-00025m-R1 for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:18 -0500 Received: from relay.sw.ru ([185.231.240.75]:43020) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grgrt-0001dR-IB; Thu, 07 Feb 2019 05:25:17 -0500 Received: from [10.28.8.145] (helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1grgrO-0005bY-SM; Thu, 07 Feb 2019 13:24:46 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 7 Feb 2019 13:24:32 +0300 Message-Id: <20190207102445.71998-5-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 04/17] block/backup: 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 Reviewed-by: Stefan Hajnoczi --- block/backup.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/block/backup.c b/block/backup.c index 435414e964..9988753249 100644 --- a/block/backup.c +++ b/block/backup.c @@ -107,7 +107,6 @@ static int coroutine_fn backup_cow_with_bounce_buffer(B= ackupBlockJob *job, void **bounce_buffer) { int ret; - struct iovec iov; QEMUIOVector qiov; BlockBackend *blk =3D job->common.blk; int nbytes; @@ -119,9 +118,7 @@ static int coroutine_fn backup_cow_with_bounce_buffer(B= ackupBlockJob *job, if (!*bounce_buffer) { *bounce_buffer =3D blk_blockalign(blk, job->cluster_size); } - iov.iov_base =3D *bounce_buffer; - iov.iov_len =3D nbytes; - qemu_iovec_init_external(&qiov, &iov, 1); + qemu_iovec_init_buf(&qiov, *bounce_buffer, nbytes); =20 ret =3D blk_co_preadv(blk, start, qiov.size, &qiov, read_flags); if (ret < 0) { --=20 2.18.0 From nobody Sat Nov 8 03:22:16 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 1549535408175171.33976275294845; Thu, 7 Feb 2019 02:30:08 -0800 (PST) Received: from localhost ([127.0.0.1]:37317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgwS-0006X8-1j for importer@patchew.org; Thu, 07 Feb 2019 05:30:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgrb-0002iV-Gg 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-0001jw-7m for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:24:59 -0500 Received: from relay.sw.ru ([185.231.240.75]:43052) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grgrZ-0001db-RN; Thu, 07 Feb 2019 05:24:58 -0500 Received: from [10.28.8.145] (helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1grgrO-0005bY-Vt; 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:33 +0300 Message-Id: <20190207102445.71998-6-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 05/17] block/commit: 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 Reviewed-by: Stefan Hajnoczi --- block/commit.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/block/commit.c b/block/commit.c index 53148e610b..d500a93068 100644 --- a/block/commit.c +++ b/block/commit.c @@ -47,14 +47,9 @@ static int coroutine_fn commit_populate(BlockBackend *bs= , BlockBackend *base, void *buf) { int ret =3D 0; - QEMUIOVector qiov; - struct iovec iov =3D { - .iov_base =3D buf, - .iov_len =3D bytes, - }; + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); =20 assert(bytes < SIZE_MAX); - qemu_iovec_init_external(&qiov, &iov, 1); =20 ret =3D blk_co_preadv(bs, offset, qiov.size, &qiov, 0); if (ret < 0) { --=20 2.18.0 From nobody Sat Nov 8 03:22:16 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 1549535233400993.631681329668; Thu, 7 Feb 2019 02:27:13 -0800 (PST) Received: from localhost ([127.0.0.1]:37295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgtd-00049A-8h for importer@patchew.org; Thu, 07 Feb 2019 05:27:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36661) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgrc-0002iY-3G for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1grgra-0001kD-Ar for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:24:59 -0500 Received: from relay.sw.ru ([185.231.240.75]:43026) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grgrZ-0001dW-Uj; Thu, 07 Feb 2019 05:24:58 -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-3u; 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:34 +0300 Message-Id: <20190207102445.71998-7-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 06/17] block/stream: 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 Reviewed-by: Stefan Hajnoczi --- block/stream.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/block/stream.c b/block/stream.c index 7a49ac0992..e14579ff80 100644 --- a/block/stream.c +++ b/block/stream.c @@ -41,14 +41,9 @@ static int coroutine_fn stream_populate(BlockBackend *bl= k, int64_t offset, uint64_t bytes, void *buf) { - struct iovec iov =3D { - .iov_base =3D buf, - .iov_len =3D bytes, - }; - QEMUIOVector qiov; + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); =20 assert(bytes < SIZE_MAX); - qemu_iovec_init_external(&qiov, &iov, 1); =20 /* Copy-on-read the unallocated clusters */ return blk_co_preadv(blk, offset, qiov.size, &qiov, BDRV_REQ_COPY_ON_R= EAD); --=20 2.18.0 From nobody Sat Nov 8 03:22:16 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 1549535791633925.4044905657299; Thu, 7 Feb 2019 02:36:31 -0800 (PST) Received: from localhost ([127.0.0.1]:37457 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grh2h-0003F9-Lw for importer@patchew.org; Thu, 07 Feb 2019 05:36:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgru-0002z4-Cv for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1grgrt-00025S-OV for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:18 -0500 Received: from relay.sw.ru ([185.231.240.75]:43040) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grgrt-0001dZ-Go; Thu, 07 Feb 2019 05:25:17 -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-6u; 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:35 +0300 Message-Id: <20190207102445.71998-8-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 07/17] block/parallels: 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 Reviewed-by: Stefan Hajnoczi --- block/parallels.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index cc9445879d..6d24ee6d8e 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -220,23 +220,20 @@ static int64_t allocate_clusters(BlockDriverState *bs= , int64_t sector_num, if (bs->backing) { int64_t nb_cow_sectors =3D to_allocate * s->tracks; int64_t nb_cow_bytes =3D nb_cow_sectors << BDRV_SECTOR_BITS; - QEMUIOVector qiov; - struct iovec iov =3D { - .iov_len =3D nb_cow_bytes, - .iov_base =3D qemu_blockalign(bs, nb_cow_bytes) - }; - qemu_iovec_init_external(&qiov, &iov, 1); + QEMUIOVector qiov =3D + QEMU_IOVEC_INIT_BUF(qiov, qemu_blockalign(bs, nb_cow_bytes), + nb_cow_bytes); =20 ret =3D bdrv_co_preadv(bs->backing, idx * s->tracks * BDRV_SECTOR_= SIZE, nb_cow_bytes, &qiov, 0); if (ret < 0) { - qemu_vfree(iov.iov_base); + qemu_vfree(qemu_iovec_get_buf(&qiov)); return ret; } =20 ret =3D bdrv_co_pwritev(bs->file, s->data_end * BDRV_SECTOR_SIZE, nb_cow_bytes, &qiov, 0); - qemu_vfree(iov.iov_base); + qemu_vfree(qemu_iovec_get_buf(&qiov)); if (ret < 0) { return ret; } --=20 2.18.0 From nobody Sat Nov 8 03:22:16 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 Reviewed-by: Stefan Hajnoczi --- 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 From nobody Sat Nov 8 03:22:16 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 1549536256101219.86969848287333; Thu, 7 Feb 2019 02:44:16 -0800 (PST) Received: from localhost ([127.0.0.1]:37576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grhAA-0000QF-2q for importer@patchew.org; Thu, 07 Feb 2019 05:44:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgru-0002z9-QG for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1grgru-000260-3w for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:18 -0500 Received: from relay.sw.ru ([185.231.240.75]:43014) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grgrt-0001dT-T1; Thu, 07 Feb 2019 05:25:18 -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-ET; 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:37 +0300 Message-Id: <20190207102445.71998-10-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 09/17] block/qcow2: 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 Reviewed-by: Stefan Hajnoczi --- block/qcow2.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 8c91b92865..1f413a75bf 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3894,7 +3894,6 @@ qcow2_co_pwritev_compressed(BlockDriverState *bs, uin= t64_t offset, { BDRVQcow2State *s =3D bs->opaque; QEMUIOVector hd_qiov; - struct iovec iov; int ret; size_t out_len; uint8_t *buf, *out_buf; @@ -3960,11 +3959,7 @@ qcow2_co_pwritev_compressed(BlockDriverState *bs, ui= nt64_t offset, goto fail; } =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); =20 BLKDBG_EVENT(bs->file, BLKDBG_WRITE_COMPRESSED); ret =3D bdrv_co_pwritev(bs->file, cluster_offset, out_len, &hd_qiov, 0= ); @@ -3990,7 +3985,6 @@ qcow2_co_preadv_compressed(BlockDriverState *bs, int ret =3D 0, csize, nb_csectors; uint64_t coffset; uint8_t *buf, *out_buf; - struct iovec iov; QEMUIOVector local_qiov; int offset_in_cluster =3D offset_into_cluster(s, offset); =20 @@ -4002,9 +3996,7 @@ qcow2_co_preadv_compressed(BlockDriverState *bs, if (!buf) { return -ENOMEM; } - iov.iov_base =3D buf; - iov.iov_len =3D csize; - qemu_iovec_init_external(&local_qiov, &iov, 1); + qemu_iovec_init_buf(&local_qiov, buf, csize); =20 out_buf =3D qemu_blockalign(bs, s->cluster_size); =20 --=20 2.18.0 From nobody Sat Nov 8 03:22:16 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549536165693946.829719308224; Thu, 7 Feb 2019 02:42:45 -0800 (PST) Received: from localhost ([127.0.0.1]:37564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grh8k-0007pI-PA for importer@patchew.org; Thu, 07 Feb 2019 05:42:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgru-0002zA-Sd for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1grgrt-00025Y-PD for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:18 -0500 Received: from relay.sw.ru ([185.231.240.75]:43076) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grgrt-0001gV-G9; Thu, 07 Feb 2019 05:25:17 -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-GO; 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:38 +0300 Message-Id: <20190207102445.71998-11-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 10/17] block/qed: 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 Reviewed-by: Stefan Hajnoczi --- block/qed-table.c | 16 +++------------- block/qed.c | 31 +++++++++---------------------- 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/block/qed-table.c b/block/qed-table.c index 7df5680adb..c497bd4aec 100644 --- a/block/qed-table.c +++ b/block/qed-table.c @@ -21,16 +21,11 @@ /* Called with table_lock held. */ static int qed_read_table(BDRVQEDState *s, uint64_t offset, QEDTable *tabl= e) { - QEMUIOVector qiov; + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF( + qiov, table->offsets, s->header.cluster_size * s->header.table_siz= e); int noffsets; int i, ret; =20 - struct iovec iov =3D { - .iov_base =3D table->offsets, - .iov_len =3D s->header.cluster_size * s->header.table_size, - }; - qemu_iovec_init_external(&qiov, &iov, 1); - trace_qed_read_table(s, offset, table); =20 qemu_co_mutex_unlock(&s->table_lock); @@ -71,7 +66,6 @@ static int qed_write_table(BDRVQEDState *s, uint64_t offs= et, QEDTable *table, unsigned int sector_mask =3D BDRV_SECTOR_SIZE / sizeof(uint64_t) - 1; unsigned int start, end, i; QEDTable *new_table; - struct iovec iov; QEMUIOVector qiov; size_t len_bytes; int ret; @@ -85,11 +79,7 @@ static int qed_write_table(BDRVQEDState *s, uint64_t off= set, QEDTable *table, len_bytes =3D (end - start) * sizeof(uint64_t); =20 new_table =3D qemu_blockalign(s->bs, len_bytes); - iov =3D (struct iovec) { - .iov_base =3D new_table->offsets, - .iov_len =3D len_bytes, - }; - qemu_iovec_init_external(&qiov, &iov, 1); + qemu_iovec_init_buf(&qiov, new_table->offsets, len_bytes); =20 /* Byteswap table */ for (i =3D start; i < end; i++) { diff --git a/block/qed.c b/block/qed.c index 1280870024..a010e5b349 100644 --- a/block/qed.c +++ b/block/qed.c @@ -113,18 +113,13 @@ static int coroutine_fn qed_write_header(BDRVQEDState= *s) int nsectors =3D DIV_ROUND_UP(sizeof(QEDHeader), BDRV_SECTOR_SIZE); size_t len =3D nsectors * BDRV_SECTOR_SIZE; uint8_t *buf; - struct iovec iov; QEMUIOVector qiov; int ret; =20 assert(s->allocating_acb || s->allocating_write_reqs_plugged); =20 buf =3D qemu_blockalign(s->bs, len); - iov =3D (struct iovec) { - .iov_base =3D buf, - .iov_len =3D len, - }; - qemu_iovec_init_external(&qiov, &iov, 1); + qemu_iovec_init_buf(&qiov, buf, len); =20 ret =3D bdrv_co_preadv(s->bs->file, 0, qiov.size, &qiov, 0); if (ret < 0) { @@ -913,7 +908,6 @@ static int coroutine_fn qed_copy_from_backing_file(BDRV= QEDState *s, { QEMUIOVector qiov; QEMUIOVector *backing_qiov =3D NULL; - struct iovec iov; int ret; =20 /* Skip copy entirely if there is no work to do */ @@ -921,11 +915,7 @@ static int coroutine_fn qed_copy_from_backing_file(BDR= VQEDState *s, return 0; } =20 - iov =3D (struct iovec) { - .iov_base =3D qemu_blockalign(s->bs, len), - .iov_len =3D len, - }; - qemu_iovec_init_external(&qiov, &iov, 1); + qemu_iovec_init_buf(&qiov, qemu_blockalign(s->bs, len), len); =20 ret =3D qed_read_backing_file(s, pos, &qiov, &backing_qiov); =20 @@ -946,7 +936,7 @@ static int coroutine_fn qed_copy_from_backing_file(BDRV= QEDState *s, } ret =3D 0; out: - qemu_vfree(iov.iov_base); + qemu_vfree(qemu_iovec_get_buf(&qiov)); return ret; } =20 @@ -1447,8 +1437,12 @@ static int coroutine_fn bdrv_qed_co_pwrite_zeroes(Bl= ockDriverState *bs, BdrvRequestFlags flags) { BDRVQEDState *s =3D bs->opaque; - QEMUIOVector qiov; - struct iovec iov; + + /* + * Zero writes start without an I/O buffer. If a buffer becomes neces= sary + * then it will be allocated during request processing. + */ + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, NULL, bytes); =20 /* Fall back if the request is not aligned */ if (qed_offset_into_cluster(s, offset) || @@ -1456,13 +1450,6 @@ static int coroutine_fn bdrv_qed_co_pwrite_zeroes(Bl= ockDriverState *bs, return -ENOTSUP; } =20 - /* Zero writes start without an I/O buffer. If a buffer becomes neces= sary - * then it will be allocated during request processing. - */ - iov.iov_base =3D NULL; - iov.iov_len =3D bytes; - - qemu_iovec_init_external(&qiov, &iov, 1); return qed_co_request(bs, offset >> BDRV_SECTOR_BITS, &qiov, bytes >> BDRV_SECTOR_BITS, QED_AIOCB_WRITE | QED_AIOCB_ZERO); --=20 2.18.0 From nobody Sat Nov 8 03:22:16 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 1549535233850506.3104183189166; Thu, 7 Feb 2019 02:27:13 -0800 (PST) Received: from localhost ([127.0.0.1]:37291 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgtd-00048N-PS for importer@patchew.org; Thu, 07 Feb 2019 05:27:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgre-0002iy-LG 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-0001lU-N9 for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:02 -0500 Received: from relay.sw.ru ([185.231.240.75]:43072) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grgra-0001gT-BT; Thu, 07 Feb 2019 05:24:58 -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-Kd; 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:39 +0300 Message-Id: <20190207102445.71998-12-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 11/17] block/vmdk: 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 Reviewed-by: Stefan Hajnoczi --- block/vmdk.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 682ad93aa1..4e331832df 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1371,7 +1371,6 @@ static int vmdk_write_extent(VmdkExtent *extent, int6= 4_t cluster_offset, VmdkGrainMarker *data =3D NULL; uLongf buf_len; QEMUIOVector local_qiov; - struct iovec iov; int64_t write_offset; int64_t write_end_sector; =20 @@ -1399,11 +1398,7 @@ static int vmdk_write_extent(VmdkExtent *extent, int= 64_t cluster_offset, data->size =3D cpu_to_le32(buf_len); =20 n_bytes =3D buf_len + sizeof(VmdkGrainMarker); - iov =3D (struct iovec) { - .iov_base =3D data, - .iov_len =3D n_bytes, - }; - qemu_iovec_init_external(&local_qiov, &iov, 1); + qemu_iovec_init_buf(&local_qiov, data, n_bytes); =20 BLKDBG_EVENT(extent->file, BLKDBG_WRITE_COMPRESSED); } else { --=20 2.18.0 From nobody Sat Nov 8 03:22:16 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1549535590262410.51047817777226; Thu, 7 Feb 2019 02:33:10 -0800 (PST) Received: from localhost ([127.0.0.1]:37376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgzQ-0000SS-3f for importer@patchew.org; Thu, 07 Feb 2019 05:33:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgrb-0002iS-8l for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1grgra-0001jN-13 for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:24:59 -0500 Received: from relay.sw.ru ([185.231.240.75]:43068) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grgrZ-0001gU-Mo; 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-Nw; 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:40 +0300 Message-Id: <20190207102445.71998-13-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 12/17] qemu-img: 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 Reviewed-by: Stefan Hajnoczi --- qemu-img.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 25288c4d18..7853935049 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1670,7 +1670,6 @@ static int coroutine_fn convert_co_read(ImgConvertSta= te *s, int64_t sector_num, { int n, ret; QEMUIOVector qiov; - struct iovec iov; =20 assert(nb_sectors <=3D s->buf_sectors); while (nb_sectors > 0) { @@ -1686,9 +1685,7 @@ static int coroutine_fn convert_co_read(ImgConvertSta= te *s, int64_t sector_num, bs_sectors =3D s->src_sectors[src_cur]; =20 n =3D MIN(nb_sectors, bs_sectors - (sector_num - src_cur_offset)); - iov.iov_base =3D buf; - iov.iov_len =3D n << BDRV_SECTOR_BITS; - qemu_iovec_init_external(&qiov, &iov, 1); + qemu_iovec_init_buf(&qiov, buf, n << BDRV_SECTOR_BITS); =20 ret =3D blk_co_preadv( blk, (sector_num - src_cur_offset) << BDRV_SECTOR_BITS, @@ -1712,7 +1709,6 @@ static int coroutine_fn convert_co_write(ImgConvertSt= ate *s, int64_t sector_num, { int ret; QEMUIOVector qiov; - struct iovec iov; =20 while (nb_sectors > 0) { int n =3D nb_sectors; @@ -1740,9 +1736,7 @@ static int coroutine_fn convert_co_write(ImgConvertSt= ate *s, int64_t sector_num, (s->compressed && !buffer_is_zero(buf, n * BDRV_SECTOR_SIZE))) { - iov.iov_base =3D buf; - iov.iov_len =3D n << BDRV_SECTOR_BITS; - qemu_iovec_init_external(&qiov, &iov, 1); + qemu_iovec_init_buf(&qiov, buf, n << BDRV_SECTOR_BITS); =20 ret =3D blk_co_pwritev(s->target, sector_num << BDRV_SECTO= R_BITS, n << BDRV_SECTOR_BITS, &qiov, flags); --=20 2.18.0 From nobody Sat Nov 8 03:22:16 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1549535591803264.48769677440566; Thu, 7 Feb 2019 02:33:11 -0800 (PST) Received: from localhost ([127.0.0.1]:37380 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgzR-0000UD-NH for importer@patchew.org; Thu, 07 Feb 2019 05:33:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgrd-0002il-Cs for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1grgra-0001kO-BJ for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:01 -0500 Received: from relay.sw.ru ([185.231.240.75]:43016) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grgrZ-0001dS-UG; Thu, 07 Feb 2019 05:24:58 -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-Pn; 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:41 +0300 Message-Id: <20190207102445.71998-14-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 13/17] migration/block: 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 Reviewed-by: Stefan Hajnoczi --- migration/block.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/migration/block.c b/migration/block.c index 0e24e18d13..83c633fb3f 100644 --- a/migration/block.c +++ b/migration/block.c @@ -83,7 +83,6 @@ typedef struct BlkMigBlock { BlkMigDevState *bmds; int64_t sector; int nr_sectors; - struct iovec iov; QEMUIOVector qiov; BlockAIOCB *aiocb; =20 @@ -314,9 +313,7 @@ static int mig_save_device_bulk(QEMUFile *f, BlkMigDevS= tate *bmds) blk->sector =3D cur_sector; blk->nr_sectors =3D nr_sectors; =20 - blk->iov.iov_base =3D blk->buf; - blk->iov.iov_len =3D nr_sectors * BDRV_SECTOR_SIZE; - qemu_iovec_init_external(&blk->qiov, &blk->iov, 1); + qemu_iovec_init_buf(&blk->qiov, blk->buf, nr_sectors * BDRV_SECTOR_SIZ= E); =20 blk_mig_lock(); block_mig_state.submitted++; @@ -556,9 +553,8 @@ static int mig_save_device_dirty(QEMUFile *f, BlkMigDev= State *bmds, blk->nr_sectors =3D nr_sectors; =20 if (is_async) { - blk->iov.iov_base =3D blk->buf; - blk->iov.iov_len =3D nr_sectors * BDRV_SECTOR_SIZE; - qemu_iovec_init_external(&blk->qiov, &blk->iov, 1); + qemu_iovec_init_buf(&blk->qiov, blk->buf, + nr_sectors * BDRV_SECTOR_SIZE); =20 blk->aiocb =3D blk_aio_preadv(bmds->blk, sector * BDRV_SECTOR_SIZE, --=20 2.18.0 From nobody Sat Nov 8 03:22:16 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549536053221168.9072029967316; Thu, 7 Feb 2019 02:40:53 -0800 (PST) Received: from localhost ([127.0.0.1]:37544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grh6w-0006WN-A4 for importer@patchew.org; Thu, 07 Feb 2019 05:40:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37044) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgru-0002z8-PW for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1grgrt-00025t-Sq for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:18 -0500 Received: from relay.sw.ru ([185.231.240.75]:43012) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grgrt-0001dV-KY; Thu, 07 Feb 2019 05:25:17 -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-SG; 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:42 +0300 Message-Id: <20190207102445.71998-15-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 14/17] tests/test-bdrv-drain: 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 Reviewed-by: Stefan Hajnoczi --- tests/test-bdrv-drain.c | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index ee1740ff06..821be405f0 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -204,12 +204,7 @@ static void test_drv_cb_common(enum drain_type drain_t= ype, bool recursive) BlockAIOCB *acb; int aio_ret; =20 - QEMUIOVector qiov; - struct iovec iov =3D { - .iov_base =3D NULL, - .iov_len =3D 0, - }; - qemu_iovec_init_external(&qiov, &iov, 1); + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, NULL, 0); =20 blk =3D blk_new(BLK_PERM_ALL, BLK_PERM_ALL); bs =3D bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR, @@ -670,12 +665,7 @@ static void test_iothread_common(enum drain_type drain= _type, int drain_thread) AioContext *ctx_a =3D iothread_get_aio_context(a); AioContext *ctx_b =3D iothread_get_aio_context(b); =20 - QEMUIOVector qiov; - struct iovec iov =3D { - .iov_base =3D NULL, - .iov_len =3D 0, - }; - qemu_iovec_init_external(&qiov, &iov, 1); + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, NULL, 0); =20 /* bdrv_drain_all() may only be called from the main loop thread */ if (drain_type =3D=3D BDRV_DRAIN_ALL && drain_thread !=3D 0) { @@ -1148,13 +1138,7 @@ static void coroutine_fn test_co_delete_by_drain(voi= d *opaque) BlockDriverState *bs =3D blk_bs(blk); BDRVTestTopState *tts =3D bs->opaque; void *buffer =3D g_malloc(65536); - QEMUIOVector qiov; - struct iovec iov =3D { - .iov_base =3D buffer, - .iov_len =3D 65536, - }; - - qemu_iovec_init_external(&qiov, &iov, 1); + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buffer, 65536); =20 /* Pretend some internal write operation from parent to child. * Important: We have to read from the child, not from the parent! @@ -1365,12 +1349,7 @@ static void test_detach_indirect(bool by_parent_cb) BdrvChild *child_a, *child_b; BlockAIOCB *acb; =20 - QEMUIOVector qiov; - struct iovec iov =3D { - .iov_base =3D NULL, - .iov_len =3D 0, - }; - qemu_iovec_init_external(&qiov, &iov, 1); + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, NULL, 0); =20 if (!by_parent_cb) { detach_by_driver_cb_role =3D child_file; --=20 2.18.0 From nobody Sat Nov 8 03:22:16 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 1549535226511851.9388062710017; Thu, 7 Feb 2019 02:27:06 -0800 (PST) Received: from localhost ([127.0.0.1]:37289 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgtY-00045I-1Z for importer@patchew.org; Thu, 07 Feb 2019 05:27:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgrb-0002iR-2p for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1grgrZ-0001j5-Tm for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:24:59 -0500 Received: from relay.sw.ru ([185.231.240.75]:43004) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grgrZ-0001dO-KM; 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-VT; Thu, 07 Feb 2019 13:24:48 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 7 Feb 2019 13:24:43 +0300 Message-Id: <20190207102445.71998-16-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 15/17] hw/ide: drop iov field from IDEState 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" @iov is used only to initialize @qiov. Let's use new qemu_iovec_init_buf() instead, which simplifies the code. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- include/hw/ide/internal.h | 1 - hw/ide/atapi.c | 9 ++++----- hw/ide/core.c | 8 ++------ 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/include/hw/ide/internal.h b/include/hw/ide/internal.h index 880413ddc7..fa99486d7a 100644 --- a/include/hw/ide/internal.h +++ b/include/hw/ide/internal.h @@ -405,7 +405,6 @@ struct IDEState { int atapi_dma; /* true if dma is requested for the packet cmd */ BlockAcctCookie acct; BlockAIOCB *pio_aiocb; - struct iovec iov; QEMUIOVector qiov; QLIST_HEAD(, IDEBufferedRequest) buffered_requests; /* ATA DMA state */ diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index 39e473f9c2..4de86555d9 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -174,16 +174,15 @@ static void cd_read_sector_cb(void *opaque, int ret) =20 static int cd_read_sector(IDEState *s) { + void *buf; + if (s->cd_sector_size !=3D 2048 && s->cd_sector_size !=3D 2352) { block_acct_invalid(blk_get_stats(s->blk), BLOCK_ACCT_READ); return -EINVAL; } =20 - s->iov.iov_base =3D (s->cd_sector_size =3D=3D 2352) ? - s->io_buffer + 16 : s->io_buffer; - - s->iov.iov_len =3D ATAPI_SECTOR_SIZE; - qemu_iovec_init_external(&s->qiov, &s->iov, 1); + buf =3D (s->cd_sector_size =3D=3D 2352) ? s->io_buffer + 16 : s->io_bu= ffer; + qemu_iovec_init_buf(&s->qiov, buf, ATAPI_SECTOR_SIZE); =20 trace_cd_read_sector(s->lba); =20 diff --git a/hw/ide/core.c b/hw/ide/core.c index c3d779db6e..e94ba8c488 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -774,9 +774,7 @@ static void ide_sector_read(IDEState *s) return; } =20 - s->iov.iov_base =3D s->io_buffer; - s->iov.iov_len =3D n * BDRV_SECTOR_SIZE; - qemu_iovec_init_external(&s->qiov, &s->iov, 1); + qemu_iovec_init_buf(&s->qiov, s->io_buffer, n * BDRV_SECTOR_SIZE); =20 block_acct_start(blk_get_stats(s->blk), &s->acct, n * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ); @@ -1045,9 +1043,7 @@ static void ide_sector_write(IDEState *s) return; } =20 - s->iov.iov_base =3D s->io_buffer; - s->iov.iov_len =3D n * BDRV_SECTOR_SIZE; - qemu_iovec_init_external(&s->qiov, &s->iov, 1); + qemu_iovec_init_buf(&s->qiov, s->io_buffer, n * BDRV_SECTOR_SIZE); =20 block_acct_start(blk_get_stats(s->blk), &s->acct, n * BDRV_SECTOR_SIZE, BLOCK_ACCT_WRITE); --=20 2.18.0 From nobody Sat Nov 8 03:22:16 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 1549535231683308.5515589304857; Thu, 7 Feb 2019 02:27:11 -0800 (PST) Received: from localhost ([127.0.0.1]:37293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgtd-000496-JN for importer@patchew.org; Thu, 07 Feb 2019 05:27:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgrb-0002iT-9u for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1grgra-0001je-1e for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:24:59 -0500 Received: from relay.sw.ru ([185.231.240.75]:43056) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grgrZ-0001dY-OE; 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 1grgrQ-0005bY-2S; Thu, 07 Feb 2019 13:24:48 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 7 Feb 2019 13:24:44 +0300 Message-Id: <20190207102445.71998-17-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 16/17] hw/ide: drop iov field from IDEBufferedRequest 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" @iov is used only to initialize @qiov. Let's use new qemu_iovec_init_buf() instead, which simplifies the code. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- include/hw/ide/internal.h | 1 - hw/ide/core.c | 11 ++++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/hw/ide/internal.h b/include/hw/ide/internal.h index fa99486d7a..1b02bb9151 100644 --- a/include/hw/ide/internal.h +++ b/include/hw/ide/internal.h @@ -346,7 +346,6 @@ extern const char *IDE_DMA_CMD_lookup[IDE_DMA__COUNT]; =20 typedef struct IDEBufferedRequest { QLIST_ENTRY(IDEBufferedRequest) list; - struct iovec iov; QEMUIOVector qiov; QEMUIOVector *original_qiov; BlockCompletionFunc *original_cb; diff --git a/hw/ide/core.c b/hw/ide/core.c index e94ba8c488..1cf87fdefe 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -629,13 +629,15 @@ static void ide_buffered_readv_cb(void *opaque, int r= et) IDEBufferedRequest *req =3D opaque; if (!req->orphaned) { if (!ret) { - qemu_iovec_from_buf(req->original_qiov, 0, req->iov.iov_base, + assert(req->qiov.size =3D=3D req->original_qiov->size); + qemu_iovec_from_buf(req->original_qiov, 0, + req->qiov.local_iov.iov_base, req->original_qiov->size); } req->original_cb(req->original_opaque, ret); } QLIST_REMOVE(req, list); - qemu_vfree(req->iov.iov_base); + qemu_vfree(qemu_iovec_get_buf(&req->qiov)); g_free(req); } =20 @@ -660,9 +662,8 @@ BlockAIOCB *ide_buffered_readv(IDEState *s, int64_t sec= tor_num, req->original_qiov =3D iov; req->original_cb =3D cb; req->original_opaque =3D opaque; - req->iov.iov_base =3D qemu_blockalign(blk_bs(s->blk), iov->size); - req->iov.iov_len =3D iov->size; - qemu_iovec_init_external(&req->qiov, &req->iov, 1); + qemu_iovec_init_buf(&req->qiov, blk_blockalign(s->blk, iov->size), + iov->size); =20 aioreq =3D blk_aio_preadv(s->blk, sector_num << BDRV_SECTOR_BITS, &req->qiov, 0, ide_buffered_readv_cb, req); --=20 2.18.0 From nobody Sat Nov 8 03:22:16 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549535404277104.44739826978923; Thu, 7 Feb 2019 02:30:04 -0800 (PST) Received: from localhost ([127.0.0.1]:37319 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgwT-0006Xs-7Z for importer@patchew.org; Thu, 07 Feb 2019 05:30:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grgrd-0002ic-95 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-0001kU-DE for qemu-devel@nongnu.org; Thu, 07 Feb 2019 05:25:01 -0500 Received: from relay.sw.ru ([185.231.240.75]:43060) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grgra-0001dc-0P; Thu, 07 Feb 2019 05:24:58 -0500 Received: from [10.28.8.145] (helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1grgrQ-0005bY-4M; Thu, 07 Feb 2019 13:24:48 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 7 Feb 2019 13:24:45 +0300 Message-Id: <20190207102445.71998-18-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 17/17] hw/ide: drop iov field from IDEDMA 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" @iov is used only to initialize @qiov. Let's use new qemu_iovec_init_buf() instead, which simplifies the code. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- include/hw/ide/internal.h | 1 - hw/ide/atapi.c | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/include/hw/ide/internal.h b/include/hw/ide/internal.h index 1b02bb9151..8efd03132b 100644 --- a/include/hw/ide/internal.h +++ b/include/hw/ide/internal.h @@ -455,7 +455,6 @@ struct IDEDMAOps { =20 struct IDEDMA { const struct IDEDMAOps *ops; - struct iovec iov; QEMUIOVector qiov; BlockAIOCB *aiocb; }; diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index 4de86555d9..1b0f66cc08 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -420,9 +420,8 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int= ret) data_offset =3D 0; } trace_ide_atapi_cmd_read_dma_cb_aio(s, s->lba, n); - s->bus->dma->iov.iov_base =3D (void *)(s->io_buffer + data_offset); - s->bus->dma->iov.iov_len =3D n * ATAPI_SECTOR_SIZE; - qemu_iovec_init_external(&s->bus->dma->qiov, &s->bus->dma->iov, 1); + qemu_iovec_init_buf(&s->bus->dma->qiov, s->io_buffer + data_offset, + n * ATAPI_SECTOR_SIZE); =20 s->bus->dma->aiocb =3D ide_buffered_readv(s, (int64_t)s->lba << 2, &s->bus->dma->qiov, n * 4, --=20 2.18.0