From nobody Fri Apr 26 16:52:25 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652399120870920.4320910314634; Thu, 12 May 2022 16:45:20 -0700 (PDT) Received: from localhost ([::1]:49058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npIUh-0005jo-7l for importer2@patchew.org; Thu, 12 May 2022 19:45:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npIQd-0000kI-2o for qemu-devel@nongnu.org; Thu, 12 May 2022 19:41:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43423) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npIQY-0004ET-Bz for qemu-devel@nongnu.org; Thu, 12 May 2022 19:41:06 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-191-DEDChJpwNh-J3u8TruY3TA-1; Thu, 12 May 2022 19:39:00 -0400 Received: by mail-wr1-f72.google.com with SMTP id u11-20020a056000038b00b0020c9ea8b64fso2504118wrf.2 for ; Thu, 12 May 2022 16:39:00 -0700 (PDT) Received: from DESKTOP-E7ACR7D.lan ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id r12-20020adfa14c000000b0020c5253d8c7sm749045wrr.19.2022.05.12.16.38.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 16:38:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652398861; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZTk4E2x1IU/ew3GtIGSfaZ37Bzge+6Vi5swAtlpRT9M=; b=G+Y+poC3s2Nl+i95Qh1ZQJVzjtIvwOnkemYeiqYQKKocelGM1i8I2Is/nHWKSayjggcS6q uwR9QzYXOb/66u5UK++Do9XLt5jHcKn2b3m8behaNiObTx+Zs6yude5oN8VFu7zydPBF7+ BRNvNaBgddtOmYzEGbakakABFHKZi9s= X-MC-Unique: DEDChJpwNh-J3u8TruY3TA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZTk4E2x1IU/ew3GtIGSfaZ37Bzge+6Vi5swAtlpRT9M=; b=1uK63dTx4hniOHb1FUEjVxKogvxZMR4wVdWzOZ+gPjiMv+IayshgK3JK4KIT+Q5HYR cvmJNZ72W3pHCRM58yn/lt/W2UtIEo1kyCO6xAJJrToICaMuE0C/064iihSp3mXlIlng +6oLC90hT7eIvxxFuRt4kkRJXRBYhIiUziHUOCZ5GSAz8zq8aIS3TFV1RbWNQOiqIVYi D3y7PJnIH5EAtWH+7hbXcuSNxk7+KoXkOjr5CJOi3T5y870J/86fHPtRbf3t9SoFmL2M aedMTB03pFkLJadTX2lUG8fAKPrkZu5ED8hfDCvqryaizI5fs6p7WA7ZBObUM9Y+BvXB yzqQ== X-Gm-Message-State: AOAM531TENFPdRCzd5Dv3SzC/hpE86aJzTK97Y1EKWPMxuvMTM72UTgK tAtewmlr00EYWDdiy0MSO5d/uZ+UslCJlnuhtbJD28kF5faUNrv9DOLKso0QZ8LjbQPpuyonqUV Ej0rSSMNw4vpv74GtC1rIop44ixLLCIyHP2ux5bGdNb+iki8yu3HAHTB294uFJa9h X-Received: by 2002:adf:ee90:0:b0:20a:de35:14b4 with SMTP id b16-20020adfee90000000b0020ade3514b4mr1637780wro.558.1652398737706; Thu, 12 May 2022 16:38:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYxU83n2305O0TGJ3LKyv9R1fG+1AIgFDmLn8AUZcGtyaTctszm3mxJzEeEpB7Ou2XcD+8SA== X-Received: by 2002:adf:ee90:0:b0:20a:de35:14b4 with SMTP id b16-20020adfee90000000b0020ade3514b4mr1637733wro.558.1652398736614; Thu, 12 May 2022 16:38:56 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Alberto Faria , Ari Sundholm , Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Fam Zheng , "Denis V. Lunev" , Vladimir Sementsov-Ogievskiy , Eric Blake , John Snow , Stefan Weil , Jeff Cody Subject: [PATCH 1/7] block: Add a 'flags' param to bdrv_{pread, pwrite, pwrite_sync}() Date: Fri, 13 May 2022 00:38:43 +0100 Message-Id: <20220512233849.2219275-2-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220512233849.2219275-1-afaria@redhat.com> References: <20220512233849.2219275-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1652399123085100001 Content-Type: text/plain; charset="utf-8" For consistency with other I/O functions, and in preparation to implement them using generated_co_wrapper. Callers were updated using this Coccinelle script: @@ expression child, offset, buf, bytes; @@ - bdrv_pread(child, offset, buf, bytes) + bdrv_pread(child, offset, buf, bytes, 0) @@ expression child, offset, buf, bytes; @@ - bdrv_pwrite(child, offset, buf, bytes) + bdrv_pwrite(child, offset, buf, bytes, 0) @@ expression child, offset, buf, bytes; @@ - bdrv_pwrite_sync(child, offset, buf, bytes) + bdrv_pwrite_sync(child, offset, buf, bytes, 0) Resulting overly-long lines were then fixed by hand. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini --- block/blklogwrites.c | 4 +-- block/bochs.c | 6 ++-- block/cloop.c | 10 +++--- block/crypto.c | 4 +-- block/dmg.c | 24 +++++++------- block/io.c | 13 ++++---- block/parallels-ext.c | 4 +-- block/parallels.c | 12 +++---- block/qcow.c | 27 ++++++++------- block/qcow2-bitmap.c | 14 ++++---- block/qcow2-cache.c | 7 ++-- block/qcow2-cluster.c | 21 ++++++------ block/qcow2-refcount.c | 42 +++++++++++------------ block/qcow2-snapshot.c | 39 +++++++++++----------- block/qcow2.c | 44 ++++++++++++------------ block/qed.c | 8 ++--- block/vdi.c | 10 +++--- block/vhdx-log.c | 19 +++++------ block/vhdx.c | 32 ++++++++++-------- block/vmdk.c | 57 ++++++++++++++------------------ block/vpc.c | 19 ++++++----- block/vvfat.c | 7 ++-- include/block/block-io.h | 7 ++-- tests/unit/test-block-iothread.c | 8 ++--- 24 files changed, 219 insertions(+), 219 deletions(-) diff --git a/block/blklogwrites.c b/block/blklogwrites.c index f7a251e91f..c5c021e6f8 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -108,7 +108,7 @@ static uint64_t blk_log_writes_find_cur_log_sector(Bdrv= Child *log, =20 while (cur_idx < nr_entries) { int read_ret =3D bdrv_pread(log, cur_sector << sector_bits, &cur_e= ntry, - sizeof(cur_entry)); + sizeof(cur_entry), 0); if (read_ret < 0) { error_setg_errno(errp, -read_ret, "Failed to read log entry %"PRIu64, cur_idx); @@ -190,7 +190,7 @@ static int blk_log_writes_open(BlockDriverState *bs, QD= ict *options, int flags, log_sb.nr_entries =3D cpu_to_le64(0); log_sb.sectorsize =3D cpu_to_le32(BDRV_SECTOR_SIZE); } else { - ret =3D bdrv_pread(s->log_file, 0, &log_sb, sizeof(log_sb)); + ret =3D bdrv_pread(s->log_file, 0, &log_sb, sizeof(log_sb), 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read log superbloc= k"); goto fail_log; diff --git a/block/bochs.c b/block/bochs.c index 4d68658087..46d0f6a693 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -116,7 +116,7 @@ static int bochs_open(BlockDriverState *bs, QDict *opti= ons, int flags, return -EINVAL; } =20 - ret =3D bdrv_pread(bs->file, 0, &bochs, sizeof(bochs)); + ret =3D bdrv_pread(bs->file, 0, &bochs, sizeof(bochs), 0); if (ret < 0) { return ret; } @@ -151,7 +151,7 @@ static int bochs_open(BlockDriverState *bs, QDict *opti= ons, int flags, } =20 ret =3D bdrv_pread(bs->file, le32_to_cpu(bochs.header), s->catalog_bit= map, - s->catalog_size * 4); + s->catalog_size * 4, 0); if (ret < 0) { goto fail; } @@ -225,7 +225,7 @@ static int64_t seek_to_sector(BlockDriverState *bs, int= 64_t sector_num) =20 /* read in bitmap for current extent */ ret =3D bdrv_pread(bs->file, bitmap_offset + (extent_offset / 8), - &bitmap_entry, 1); + &bitmap_entry, 1, 0); if (ret < 0) { return ret; } diff --git a/block/cloop.c b/block/cloop.c index b8c6d0eccd..208a58ebb1 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -78,7 +78,7 @@ static int cloop_open(BlockDriverState *bs, QDict *option= s, int flags, } =20 /* read header */ - ret =3D bdrv_pread(bs->file, 128, &s->block_size, 4); + ret =3D bdrv_pread(bs->file, 128, &s->block_size, 4, 0); if (ret < 0) { return ret; } @@ -104,7 +104,7 @@ static int cloop_open(BlockDriverState *bs, QDict *opti= ons, int flags, return -EINVAL; } =20 - ret =3D bdrv_pread(bs->file, 128 + 4, &s->n_blocks, 4); + ret =3D bdrv_pread(bs->file, 128 + 4, &s->n_blocks, 4, 0); if (ret < 0) { return ret; } @@ -135,7 +135,7 @@ static int cloop_open(BlockDriverState *bs, QDict *opti= ons, int flags, return -ENOMEM; } =20 - ret =3D bdrv_pread(bs->file, 128 + 4 + 4, s->offsets, offsets_size); + ret =3D bdrv_pread(bs->file, 128 + 4 + 4, s->offsets, offsets_size, 0); if (ret < 0) { goto fail; } @@ -220,8 +220,8 @@ static inline int cloop_read_block(BlockDriverState *bs= , int block_num) int ret; uint32_t bytes =3D s->offsets[block_num + 1] - s->offsets[block_nu= m]; =20 - ret =3D bdrv_pread(bs->file, s->offsets[block_num], - s->compressed_block, bytes); + ret =3D bdrv_pread(bs->file, s->offsets[block_num], s->compressed_= block, + bytes, 0); if (ret !=3D bytes) { return -1; } diff --git a/block/crypto.c b/block/crypto.c index 1ba82984ef..d0c22e9549 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -65,7 +65,7 @@ static ssize_t block_crypto_read_func(QCryptoBlock *block, BlockDriverState *bs =3D opaque; ssize_t ret; =20 - ret =3D bdrv_pread(bs->file, offset, buf, buflen); + ret =3D bdrv_pread(bs->file, offset, buf, buflen, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read encryption header"); return ret; @@ -83,7 +83,7 @@ static ssize_t block_crypto_write_func(QCryptoBlock *bloc= k, BlockDriverState *bs =3D opaque; ssize_t ret; =20 - ret =3D bdrv_pwrite(bs->file, offset, buf, buflen); + ret =3D bdrv_pwrite(bs->file, offset, buf, buflen, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not write encryption header"); return ret; diff --git a/block/dmg.c b/block/dmg.c index c626587f9c..ddd1d23005 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -77,7 +77,7 @@ static int read_uint64(BlockDriverState *bs, int64_t offs= et, uint64_t *result) uint64_t buffer; int ret; =20 - ret =3D bdrv_pread(bs->file, offset, &buffer, 8); + ret =3D bdrv_pread(bs->file, offset, &buffer, 8, 0); if (ret < 0) { return ret; } @@ -91,7 +91,7 @@ static int read_uint32(BlockDriverState *bs, int64_t offs= et, uint32_t *result) uint32_t buffer; int ret; =20 - ret =3D bdrv_pread(bs->file, offset, &buffer, 4); + ret =3D bdrv_pread(bs->file, offset, &buffer, 4, 0); if (ret < 0) { return ret; } @@ -172,7 +172,7 @@ static int64_t dmg_find_koly_offset(BdrvChild *file, Er= ror **errp) offset =3D length - 511 - 512; } length =3D length < 515 ? length : 515; - ret =3D bdrv_pread(file, offset, buffer, length); + ret =3D bdrv_pread(file, offset, buffer, length, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed while reading UDIF trailer"); return ret; @@ -352,7 +352,7 @@ static int dmg_read_resource_fork(BlockDriverState *bs,= DmgHeaderState *ds, offset +=3D 4; =20 buffer =3D g_realloc(buffer, count); - ret =3D bdrv_pread(bs->file, offset, buffer, count); + ret =3D bdrv_pread(bs->file, offset, buffer, count, 0); if (ret < 0) { goto fail; } @@ -389,7 +389,7 @@ static int dmg_read_plist_xml(BlockDriverState *bs, Dmg= HeaderState *ds, =20 buffer =3D g_malloc(info_length + 1); buffer[info_length] =3D '\0'; - ret =3D bdrv_pread(bs->file, info_begin, buffer, info_length); + ret =3D bdrv_pread(bs->file, info_begin, buffer, info_length, 0); if (ret !=3D info_length) { ret =3D -EINVAL; goto fail; @@ -609,8 +609,8 @@ static inline int dmg_read_chunk(BlockDriverState *bs, = uint64_t sector_num) case UDZO: { /* zlib compressed */ /* we need to buffer, because only the chunk as whole can be * inflated. */ - ret =3D bdrv_pread(bs->file, s->offsets[chunk], - s->compressed_chunk, s->lengths[chunk]); + ret =3D bdrv_pread(bs->file, s->offsets[chunk], s->compressed_= chunk, + s->lengths[chunk], 0); if (ret !=3D s->lengths[chunk]) { return -1; } @@ -635,8 +635,8 @@ static inline int dmg_read_chunk(BlockDriverState *bs, = uint64_t sector_num) } /* we need to buffer, because only the chunk as whole can be * inflated. */ - ret =3D bdrv_pread(bs->file, s->offsets[chunk], - s->compressed_chunk, s->lengths[chunk]); + ret =3D bdrv_pread(bs->file, s->offsets[chunk], s->compressed_= chunk, + s->lengths[chunk], 0); if (ret !=3D s->lengths[chunk]) { return -1; } @@ -656,8 +656,8 @@ static inline int dmg_read_chunk(BlockDriverState *bs, = uint64_t sector_num) } /* we need to buffer, because only the chunk as whole can be * inflated. */ - ret =3D bdrv_pread(bs->file, s->offsets[chunk], - s->compressed_chunk, s->lengths[chunk]); + ret =3D bdrv_pread(bs->file, s->offsets[chunk], s->compressed_= chunk, + s->lengths[chunk], 0); if (ret !=3D s->lengths[chunk]) { return -1; } @@ -673,7 +673,7 @@ static inline int dmg_read_chunk(BlockDriverState *bs, = uint64_t sector_num) break; case UDRW: /* copy */ ret =3D bdrv_pread(bs->file, s->offsets[chunk], - s->uncompressed_chunk, s->lengths[chunk]); + s->uncompressed_chunk, s->lengths[chunk], 0); if (ret !=3D s->lengths[chunk]) { return -1; } diff --git a/block/io.c b/block/io.c index 789e6373d5..008e5c90bf 100644 --- a/block/io.c +++ b/block/io.c @@ -1112,7 +1112,8 @@ int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags= flags) } =20 /* See bdrv_pwrite() for the return codes */ -int bdrv_pread(BdrvChild *child, int64_t offset, void *buf, int64_t bytes) +int bdrv_pread(BdrvChild *child, int64_t offset, void *buf, int64_t bytes, + BdrvRequestFlags flags) { int ret; QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); @@ -1122,7 +1123,7 @@ int bdrv_pread(BdrvChild *child, int64_t offset, void= *buf, int64_t bytes) return -EINVAL; } =20 - ret =3D bdrv_preadv(child, offset, bytes, &qiov, 0); + ret =3D bdrv_preadv(child, offset, bytes, &qiov, flags); =20 return ret < 0 ? ret : bytes; } @@ -1134,7 +1135,7 @@ int bdrv_pread(BdrvChild *child, int64_t offset, void= *buf, int64_t bytes) -EACCES Trying to write a read-only device */ int bdrv_pwrite(BdrvChild *child, int64_t offset, const void *buf, - int64_t bytes) + int64_t bytes, BdrvRequestFlags flags) { int ret; QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); @@ -1144,7 +1145,7 @@ int bdrv_pwrite(BdrvChild *child, int64_t offset, con= st void *buf, return -EINVAL; } =20 - ret =3D bdrv_pwritev(child, offset, bytes, &qiov, 0); + ret =3D bdrv_pwritev(child, offset, bytes, &qiov, flags); =20 return ret < 0 ? ret : bytes; } @@ -1156,12 +1157,12 @@ int bdrv_pwrite(BdrvChild *child, int64_t offset, c= onst void *buf, * Returns 0 on success, -errno in error cases. */ int bdrv_pwrite_sync(BdrvChild *child, int64_t offset, - const void *buf, int64_t count) + const void *buf, int64_t count, BdrvRequestFlags flag= s) { int ret; IO_CODE(); =20 - ret =3D bdrv_pwrite(child, offset, buf, count); + ret =3D bdrv_pwrite(child, offset, buf, count, flags); if (ret < 0) { return ret; } diff --git a/block/parallels-ext.c b/block/parallels-ext.c index 5122f67ac2..f737104d12 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -94,7 +94,7 @@ static int parallels_load_bitmap_data(BlockDriverState *b= s, bdrv_dirty_bitmap_deserialize_ones(bitmap, offset, count, fals= e); } else { ret =3D bdrv_pread(bs->file, entry << BDRV_SECTOR_BITS, buf, - s->cluster_size); + s->cluster_size, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read bitmap data cluster"); @@ -286,7 +286,7 @@ int parallels_read_format_extension(BlockDriverState *b= s, =20 assert(ext_off > 0); =20 - ret =3D bdrv_pread(bs->file, ext_off, ext_cluster, s->cluster_size); + ret =3D bdrv_pread(bs->file, ext_off, ext_cluster, s->cluster_size, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read Format Extension clus= ter"); goto out; diff --git a/block/parallels.c b/block/parallels.c index 8879b7027a..6ab82764b2 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -277,8 +277,8 @@ static coroutine_fn int parallels_co_flush_to_os(BlockD= riverState *bs) if (off + to_write > s->header_size) { to_write =3D s->header_size - off; } - ret =3D bdrv_pwrite(bs->file, off, (uint8_t *)s->header + off, - to_write); + ret =3D bdrv_pwrite(bs->file, off, (uint8_t *)s->header + off, to_= write, + 0); if (ret < 0) { qemu_co_mutex_unlock(&s->lock); return ret; @@ -481,7 +481,7 @@ static int coroutine_fn parallels_co_check(BlockDriverS= tate *bs, =20 ret =3D 0; if (flush_bat) { - ret =3D bdrv_pwrite_sync(bs->file, 0, s->header, s->header_size); + ret =3D bdrv_pwrite_sync(bs->file, 0, s->header, s->header_size, 0= ); if (ret < 0) { res->check_errors++; goto out; @@ -723,7 +723,7 @@ static int parallels_update_header(BlockDriverState *bs) if (size > s->header_size) { size =3D s->header_size; } - return bdrv_pwrite_sync(bs->file, 0, s->header, size); + return bdrv_pwrite_sync(bs->file, 0, s->header, size, 0); } =20 static int parallels_open(BlockDriverState *bs, QDict *options, int flags, @@ -742,7 +742,7 @@ static int parallels_open(BlockDriverState *bs, QDict *= options, int flags, return -EINVAL; } =20 - ret =3D bdrv_pread(bs->file, 0, &ph, sizeof(ph)); + ret =3D bdrv_pread(bs->file, 0, &ph, sizeof(ph), 0); if (ret < 0) { goto fail; } @@ -798,7 +798,7 @@ static int parallels_open(BlockDriverState *bs, QDict *= options, int flags, s->header_size =3D size; } =20 - ret =3D bdrv_pread(bs->file, 0, s->header, s->header_size); + ret =3D bdrv_pread(bs->file, 0, s->header, s->header_size, 0); if (ret < 0) { goto fail; } diff --git a/block/qcow.c b/block/qcow.c index 4fba1b9e36..20fb94c18b 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -128,7 +128,7 @@ static int qcow_open(BlockDriverState *bs, QDict *optio= ns, int flags, goto fail; } =20 - ret =3D bdrv_pread(bs->file, 0, &header, sizeof(header)); + ret =3D bdrv_pread(bs->file, 0, &header, sizeof(header), 0); if (ret < 0) { goto fail; } @@ -261,7 +261,7 @@ static int qcow_open(BlockDriverState *bs, QDict *optio= ns, int flags, } =20 ret =3D bdrv_pread(bs->file, s->l1_table_offset, s->l1_table, - s->l1_size * sizeof(uint64_t)); + s->l1_size * sizeof(uint64_t), 0); if (ret < 0) { goto fail; } @@ -292,7 +292,7 @@ static int qcow_open(BlockDriverState *bs, QDict *optio= ns, int flags, goto fail; } ret =3D bdrv_pread(bs->file, header.backing_file_offset, - bs->auto_backing_file, len); + bs->auto_backing_file, len, 0); if (ret < 0) { goto fail; } @@ -383,7 +383,7 @@ static int get_cluster_offset(BlockDriverState *bs, BLKDBG_EVENT(bs->file, BLKDBG_L1_UPDATE); ret =3D bdrv_pwrite_sync(bs->file, s->l1_table_offset + l1_index * sizeof(tmp), - &tmp, sizeof(tmp)); + &tmp, sizeof(tmp), 0); if (ret < 0) { return ret; } @@ -415,13 +415,13 @@ static int get_cluster_offset(BlockDriverState *bs, if (new_l2_table) { memset(l2_table, 0, s->l2_size * sizeof(uint64_t)); ret =3D bdrv_pwrite_sync(bs->file, l2_offset, l2_table, - s->l2_size * sizeof(uint64_t)); + s->l2_size * sizeof(uint64_t), 0); if (ret < 0) { return ret; } } else { ret =3D bdrv_pread(bs->file, l2_offset, l2_table, - s->l2_size * sizeof(uint64_t)); + s->l2_size * sizeof(uint64_t), 0); if (ret < 0) { return ret; } @@ -454,7 +454,7 @@ static int get_cluster_offset(BlockDriverState *bs, /* write the cluster content */ BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); ret =3D bdrv_pwrite(bs->file, cluster_offset, s->cluster_cache, - s->cluster_size); + s->cluster_size, 0); if (ret < 0) { return ret; } @@ -492,10 +492,9 @@ static int get_cluster_offset(BlockDriverState *bs, return -EIO; } BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); - ret =3D bdrv_pwrite(bs->file, - cluster_offset + i, + ret =3D bdrv_pwrite(bs->file, cluster_offset += i, s->cluster_data, - BDRV_SECTOR_SIZE); + BDRV_SECTOR_SIZE, 0); if (ret < 0) { return ret; } @@ -516,7 +515,7 @@ static int get_cluster_offset(BlockDriverState *bs, BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE); } ret =3D bdrv_pwrite_sync(bs->file, l2_offset + l2_index * sizeof(t= mp), - &tmp, sizeof(tmp)); + &tmp, sizeof(tmp), 0); if (ret < 0) { return ret; } @@ -597,7 +596,7 @@ static int decompress_cluster(BlockDriverState *bs, uin= t64_t cluster_offset) csize =3D cluster_offset >> (63 - s->cluster_bits); csize &=3D (s->cluster_size - 1); BLKDBG_EVENT(bs->file, BLKDBG_READ_COMPRESSED); - ret =3D bdrv_pread(bs->file, coffset, s->cluster_data, csize); + ret =3D bdrv_pread(bs->file, coffset, s->cluster_data, csize, 0); if (ret !=3D csize) return -1; if (decompress_buffer(s->cluster_cache, s->cluster_size, @@ -1030,8 +1029,8 @@ static int qcow_make_empty(BlockDriverState *bs) int ret; =20 memset(s->l1_table, 0, l1_length); - if (bdrv_pwrite_sync(bs->file, s->l1_table_offset, s->l1_table, - l1_length) < 0) + if (bdrv_pwrite_sync(bs->file, s->l1_table_offset, s->l1_table, l1_len= gth, + 0) < 0) return -1; ret =3D bdrv_truncate(bs->file, s->l1_table_offset + l1_length, false, PREALLOC_MODE_OFF, 0, NULL); diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index 8fb4731551..6aa4739820 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -234,8 +234,8 @@ static int bitmap_table_load(BlockDriverState *bs, Qcow= 2BitmapTable *tb, } =20 assert(tb->size <=3D BME_MAX_TABLE_SIZE); - ret =3D bdrv_pread(bs->file, tb->offset, - table, tb->size * BME_TABLE_ENTRY_SIZE); + ret =3D bdrv_pread(bs->file, tb->offset, table, + tb->size * BME_TABLE_ENTRY_SIZE, 0); if (ret < 0) { goto fail; } @@ -317,7 +317,7 @@ static int load_bitmap_data(BlockDriverState *bs, * already cleared */ } } else { - ret =3D bdrv_pread(bs->file, data_offset, buf, s->cluster_size= ); + ret =3D bdrv_pread(bs->file, data_offset, buf, s->cluster_size= , 0); if (ret < 0) { goto finish; } @@ -575,7 +575,7 @@ static Qcow2BitmapList *bitmap_list_load(BlockDriverSta= te *bs, uint64_t offset, } dir_end =3D dir + size; =20 - ret =3D bdrv_pread(bs->file, offset, dir, size); + ret =3D bdrv_pread(bs->file, offset, dir, size, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read bitmap directory"); goto fail; @@ -798,7 +798,7 @@ static int bitmap_list_store(BlockDriverState *bs, Qcow= 2BitmapList *bm_list, goto fail; } =20 - ret =3D bdrv_pwrite(bs->file, dir_offset, dir, dir_size); + ret =3D bdrv_pwrite(bs->file, dir_offset, dir, dir_size, 0); if (ret < 0) { goto fail; } @@ -1339,7 +1339,7 @@ static uint64_t *store_bitmap_data(BlockDriverState *= bs, goto fail; } =20 - ret =3D bdrv_pwrite(bs->file, off, buf, s->cluster_size); + ret =3D bdrv_pwrite(bs->file, off, buf, s->cluster_size, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to write bitmap '%s' to f= ile", bm_name); @@ -1402,7 +1402,7 @@ static int store_bitmap(BlockDriverState *bs, Qcow2Bi= tmap *bm, Error **errp) } =20 bitmap_table_to_be(tb, tb_size); - ret =3D bdrv_pwrite(bs->file, tb_offset, tb, tb_size * sizeof(tb[0])); + ret =3D bdrv_pwrite(bs->file, tb_offset, tb, tb_size * sizeof(tb[0]), = 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to write bitmap '%s' to file", bm_name); diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 539f9ca2d5..e562e00c5c 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -224,7 +224,7 @@ static int qcow2_cache_entry_flush(BlockDriverState *bs= , Qcow2Cache *c, int i) } =20 ret =3D bdrv_pwrite(bs->file, c->entries[i].offset, - qcow2_cache_get_table_addr(c, i), c->table_size); + qcow2_cache_get_table_addr(c, i), c->table_size, 0); if (ret < 0) { return ret; } @@ -379,9 +379,8 @@ static int qcow2_cache_do_get(BlockDriverState *bs, Qco= w2Cache *c, BLKDBG_EVENT(bs->file, BLKDBG_L2_LOAD); } =20 - ret =3D bdrv_pread(bs->file, offset, - qcow2_cache_get_table_addr(c, i), - c->table_size); + ret =3D bdrv_pread(bs->file, offset, qcow2_cache_get_table_addr(c,= i), + c->table_size, 0); if (ret < 0) { return ret; } diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 20a16ba6ee..ad7107a795 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -159,8 +159,8 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t = min_size, BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_WRITE_TABLE); for(i =3D 0; i < s->l1_size; i++) new_l1_table[i] =3D cpu_to_be64(new_l1_table[i]); - ret =3D bdrv_pwrite_sync(bs->file, new_l1_table_offset, - new_l1_table, new_l1_size2); + ret =3D bdrv_pwrite_sync(bs->file, new_l1_table_offset, new_l1_table, + new_l1_size2, 0); if (ret < 0) goto fail; for(i =3D 0; i < s->l1_size; i++) @@ -170,8 +170,8 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t = min_size, BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_ACTIVATE_TABLE); stl_be_p(data, new_l1_size); stq_be_p(data + 4, new_l1_table_offset); - ret =3D bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, l1_size), - data, sizeof(data)); + ret =3D bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, l1_size), data, + sizeof(data), 0); if (ret < 0) { goto fail; } @@ -249,7 +249,7 @@ int qcow2_write_l1_entry(BlockDriverState *bs, int l1_i= ndex) BLKDBG_EVENT(bs->file, BLKDBG_L1_UPDATE); ret =3D bdrv_pwrite_sync(bs->file, s->l1_table_offset + L1E_SIZE * l1_start_index, - buf, bufsize); + buf, bufsize, 0); if (ret < 0) { return ret; } @@ -2260,7 +2260,8 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, (void **)&l2_slice); } else { /* load inactive L2 tables from disk */ - ret =3D bdrv_pread(bs->file, slice_offset, l2_slice, slice= _size2); + ret =3D bdrv_pread(bs->file, slice_offset, l2_slice, + slice_size2, 0); } if (ret < 0) { goto fail; @@ -2376,8 +2377,8 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, goto fail; } =20 - ret =3D bdrv_pwrite(bs->file, slice_offset, - l2_slice, slice_size2); + ret =3D bdrv_pwrite(bs->file, slice_offset, l2_slice, + slice_size2, 0); if (ret < 0) { goto fail; } @@ -2470,8 +2471,8 @@ int qcow2_expand_zero_clusters(BlockDriverState *bs, =20 l1_table =3D new_l1_table; =20 - ret =3D bdrv_pread(bs->file, s->snapshots[i].l1_table_offset, - l1_table, l1_size2); + ret =3D bdrv_pread(bs->file, s->snapshots[i].l1_table_offset, l1_t= able, + l1_size2, 0); if (ret < 0) { goto fail; } diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index ed0ecfaa89..5aa2b61b6c 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -119,7 +119,7 @@ int qcow2_refcount_init(BlockDriverState *bs) } BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_LOAD); ret =3D bdrv_pread(bs->file, s->refcount_table_offset, - s->refcount_table, refcount_table_size2); + s->refcount_table, refcount_table_size2, 0); if (ret < 0) { goto fail; } @@ -439,7 +439,7 @@ static int alloc_refcount_block(BlockDriverState *bs, BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP); ret =3D bdrv_pwrite_sync(bs->file, s->refcount_table_offset + refcount_table_index * REFTABLE_ENTRY_SIZE, - &data64, sizeof(data64)); + &data64, sizeof(data64), 0); if (ret < 0) { goto fail; } @@ -685,7 +685,7 @@ int64_t qcow2_refcount_area(BlockDriverState *bs, uint6= 4_t start_offset, =20 BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE); ret =3D bdrv_pwrite_sync(bs->file, table_offset, new_table, - table_size * REFTABLE_ENTRY_SIZE); + table_size * REFTABLE_ENTRY_SIZE, 0); if (ret < 0) { goto fail; } @@ -703,8 +703,8 @@ int64_t qcow2_refcount_area(BlockDriverState *bs, uint6= 4_t start_offset, data.d32 =3D cpu_to_be32(table_clusters); BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE); ret =3D bdrv_pwrite_sync(bs->file, - offsetof(QCowHeader, refcount_table_offset), - &data, sizeof(data)); + offsetof(QCowHeader, refcount_table_offset), &d= ata, + sizeof(data), 0); if (ret < 0) { goto fail; } @@ -1274,7 +1274,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *= bs, } l1_allocated =3D true; =20 - ret =3D bdrv_pread(bs->file, l1_table_offset, l1_table, l1_size2); + ret =3D bdrv_pread(bs->file, l1_table_offset, l1_table, l1_size2, = 0); if (ret < 0) { goto fail; } @@ -1435,8 +1435,8 @@ fail: cpu_to_be64s(&l1_table[i]); } =20 - ret =3D bdrv_pwrite_sync(bs->file, l1_table_offset, - l1_table, l1_size2); + ret =3D bdrv_pwrite_sync(bs->file, l1_table_offset, l1_table, l1_s= ize2, + 0); =20 for (i =3D 0; i < l1_size; i++) { be64_to_cpus(&l1_table[i]); @@ -1634,7 +1634,7 @@ static int fix_l2_entry_by_zero(BlockDriverState *bs,= BdrvCheckResult *res, } =20 ret =3D bdrv_pwrite_sync(bs->file, l2e_offset, &l2_table[idx], - l2_entry_size(s)); + l2_entry_size(s), 0); if (ret < 0) { fprintf(stderr, "ERROR: Failed to overwrite L2 " "table entry: %s\n", strerror(-ret)); @@ -1672,7 +1672,7 @@ static int check_refcounts_l2(BlockDriverState *bs, B= drvCheckResult *res, bool metadata_overlap; =20 /* Read L2 table from disk */ - ret =3D bdrv_pread(bs->file, l2_offset, l2_table, l2_size_bytes); + ret =3D bdrv_pread(bs->file, l2_offset, l2_table, l2_size_bytes, 0); if (ret < 0) { fprintf(stderr, "ERROR: I/O error in check_refcounts_l2\n"); res->check_errors++; @@ -1888,7 +1888,7 @@ static int check_refcounts_l1(BlockDriverState *bs, } =20 /* Read L1 table entries from disk */ - ret =3D bdrv_pread(bs->file, l1_table_offset, l1_table, l1_size_bytes); + ret =3D bdrv_pread(bs->file, l1_table_offset, l1_table, l1_size_bytes,= 0); if (ret < 0) { fprintf(stderr, "ERROR: I/O error in check_refcounts_l1\n"); res->check_errors++; @@ -2005,7 +2005,7 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, } =20 ret =3D bdrv_pread(bs->file, l2_offset, l2_table, - s->l2_size * l2_entry_size(s)); + s->l2_size * l2_entry_size(s), 0); if (ret < 0) { fprintf(stderr, "ERROR: Could not read L2 table: %s\n", strerror(-ret)); @@ -2058,8 +2058,8 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, goto fail; } =20 - ret =3D bdrv_pwrite(bs->file, l2_offset, l2_table, - s->cluster_size); + ret =3D bdrv_pwrite(bs->file, l2_offset, l2_table, s->cluster_= size, + 0); if (ret < 0) { fprintf(stderr, "ERROR: Could not write L2 table: %s\n", strerror(-ret)); @@ -2578,7 +2578,7 @@ static int rebuild_refcounts_write_refblocks( refblock_index * s->cluster_size); =20 ret =3D bdrv_pwrite(bs->file, refblock_offset, on_disk_refblock, - s->cluster_size); + s->cluster_size, 0); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR writing refblock"); return ret; @@ -2734,7 +2734,7 @@ static int rebuild_refcount_structure(BlockDriverStat= e *bs, =20 assert(reftable_length < INT_MAX); ret =3D bdrv_pwrite(bs->file, reftable_offset, on_disk_reftable, - reftable_length); + reftable_length, 0); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR writing reftable"); goto fail; @@ -2747,7 +2747,7 @@ static int rebuild_refcount_structure(BlockDriverStat= e *bs, ret =3D bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, refcount_table_offset), &reftable_offset_and_clusters, - sizeof(reftable_offset_and_clusters)); + sizeof(reftable_offset_and_clusters), 0); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR setting reftable"); goto fail; @@ -3009,7 +3009,7 @@ int qcow2_check_metadata_overlap(BlockDriverState *bs= , int ign, int64_t offset, return -ENOMEM; } =20 - ret =3D bdrv_pread(bs->file, l1_ofs, l1, l1_sz2); + ret =3D bdrv_pread(bs->file, l1_ofs, l1, l1_sz2, 0); if (ret < 0) { g_free(l1); return ret; @@ -3180,7 +3180,7 @@ static int flush_refblock(BlockDriverState *bs, uint6= 4_t **reftable, return ret; } =20 - ret =3D bdrv_pwrite(bs->file, offset, refblock, s->cluster_size); + ret =3D bdrv_pwrite(bs->file, offset, refblock, s->cluster_size, 0= ); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to write refblock"); return ret; @@ -3453,7 +3453,7 @@ int qcow2_change_refcount_order(BlockDriverState *bs,= int refcount_order, } =20 ret =3D bdrv_pwrite(bs->file, new_reftable_offset, new_reftable, - new_reftable_size * REFTABLE_ENTRY_SIZE); + new_reftable_size * REFTABLE_ENTRY_SIZE, 0); =20 for (i =3D 0; i < new_reftable_size; i++) { be64_to_cpus(&new_reftable[i]); @@ -3657,7 +3657,7 @@ int qcow2_shrink_reftable(BlockDriverState *bs) } =20 ret =3D bdrv_pwrite_sync(bs->file, s->refcount_table_offset, reftable_= tmp, - s->refcount_table_size * REFTABLE_ENTRY_SIZE); + s->refcount_table_size * REFTABLE_ENTRY_SIZE, 0= ); /* * If the write in the reftable failed the image may contain a partial= ly * overwritten reftable. In this case it would be better to clear the diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index 075269a023..dc62b0197c 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -108,7 +108,7 @@ static int qcow2_do_read_snapshots(BlockDriverState *bs= , bool repair, =20 /* Read statically sized part of the snapshot header */ offset =3D ROUND_UP(offset, 8); - ret =3D bdrv_pread(bs->file, offset, &h, sizeof(h)); + ret =3D bdrv_pread(bs->file, offset, &h, sizeof(h), 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read snapshot table"); goto fail; @@ -147,7 +147,7 @@ static int qcow2_do_read_snapshots(BlockDriverState *bs= , bool repair, =20 /* Read known extra data */ ret =3D bdrv_pread(bs->file, offset, &extra, - MIN(sizeof(extra), sn->extra_data_size)); + MIN(sizeof(extra), sn->extra_data_size), 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read snapshot table"); goto fail; @@ -185,7 +185,7 @@ static int qcow2_do_read_snapshots(BlockDriverState *bs= , bool repair, unknown_extra_data_size =3D sn->extra_data_size - sizeof(extra= ); sn->unknown_extra_data =3D g_malloc(unknown_extra_data_size); ret =3D bdrv_pread(bs->file, offset, sn->unknown_extra_data, - unknown_extra_data_size); + unknown_extra_data_size, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read snapshot table"); @@ -196,7 +196,7 @@ static int qcow2_do_read_snapshots(BlockDriverState *bs= , bool repair, =20 /* Read snapshot ID */ sn->id_str =3D g_malloc(id_str_size + 1); - ret =3D bdrv_pread(bs->file, offset, sn->id_str, id_str_size); + ret =3D bdrv_pread(bs->file, offset, sn->id_str, id_str_size, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read snapshot table"); goto fail; @@ -206,7 +206,7 @@ static int qcow2_do_read_snapshots(BlockDriverState *bs= , bool repair, =20 /* Read snapshot name */ sn->name =3D g_malloc(name_size + 1); - ret =3D bdrv_pread(bs->file, offset, sn->name, name_size); + ret =3D bdrv_pread(bs->file, offset, sn->name, name_size, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read snapshot table"); goto fail; @@ -349,13 +349,13 @@ int qcow2_write_snapshots(BlockDriverState *bs) h.name_size =3D cpu_to_be16(name_size); offset =3D ROUND_UP(offset, 8); =20 - ret =3D bdrv_pwrite(bs->file, offset, &h, sizeof(h)); + ret =3D bdrv_pwrite(bs->file, offset, &h, sizeof(h), 0); if (ret < 0) { goto fail; } offset +=3D sizeof(h); =20 - ret =3D bdrv_pwrite(bs->file, offset, &extra, sizeof(extra)); + ret =3D bdrv_pwrite(bs->file, offset, &extra, sizeof(extra), 0); if (ret < 0) { goto fail; } @@ -370,20 +370,20 @@ int qcow2_write_snapshots(BlockDriverState *bs) assert(sn->unknown_extra_data); =20 ret =3D bdrv_pwrite(bs->file, offset, sn->unknown_extra_data, - unknown_extra_data_size); + unknown_extra_data_size, 0); if (ret < 0) { goto fail; } offset +=3D unknown_extra_data_size; } =20 - ret =3D bdrv_pwrite(bs->file, offset, sn->id_str, id_str_size); + ret =3D bdrv_pwrite(bs->file, offset, sn->id_str, id_str_size, 0); if (ret < 0) { goto fail; } offset +=3D id_str_size; =20 - ret =3D bdrv_pwrite(bs->file, offset, sn->name, name_size); + ret =3D bdrv_pwrite(bs->file, offset, sn->name, name_size, 0); if (ret < 0) { goto fail; } @@ -406,7 +406,7 @@ int qcow2_write_snapshots(BlockDriverState *bs) header_data.snapshots_offset =3D cpu_to_be64(snapshots_offset); =20 ret =3D bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, nb_snapshots), - &header_data, sizeof(header_data)); + &header_data, sizeof(header_data), 0); if (ret < 0) { goto fail; } @@ -442,7 +442,8 @@ int coroutine_fn qcow2_check_read_snapshot_table(BlockD= riverState *bs, =20 /* qcow2_do_open() discards this information in check mode */ ret =3D bdrv_pread(bs->file, offsetof(QCowHeader, nb_snapshots), - &snapshot_table_pointer, sizeof(snapshot_table_pointe= r)); + &snapshot_table_pointer, sizeof(snapshot_table_pointe= r), + 0); if (ret < 0) { result->check_errors++; fprintf(stderr, "ERROR failed to read the snapshot table pointer f= rom " @@ -513,7 +514,7 @@ int coroutine_fn qcow2_check_read_snapshot_table(BlockD= riverState *bs, snapshot_table_pointer.nb_snapshots =3D cpu_to_be32(s->nb_snapshot= s); ret =3D bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, nb_snapsho= ts), &snapshot_table_pointer.nb_snapshots, - sizeof(snapshot_table_pointer.nb_snapshots)= ); + sizeof(snapshot_table_pointer.nb_snapshots)= , 0); if (ret < 0) { result->check_errors++; fprintf(stderr, "ERROR failed to update the snapshot count in = the " @@ -694,7 +695,7 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSna= pshotInfo *sn_info) } =20 ret =3D bdrv_pwrite(bs->file, sn->l1_table_offset, l1_table, - s->l1_size * L1E_SIZE); + s->l1_size * L1E_SIZE, 0); if (ret < 0) { goto fail; } @@ -829,8 +830,8 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const cha= r *snapshot_id) goto fail; } =20 - ret =3D bdrv_pread(bs->file, sn->l1_table_offset, - sn_l1_table, sn_l1_bytes); + ret =3D bdrv_pread(bs->file, sn->l1_table_offset, sn_l1_table, sn_l1_b= ytes, + 0); if (ret < 0) { goto fail; } @@ -849,7 +850,7 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const cha= r *snapshot_id) } =20 ret =3D bdrv_pwrite_sync(bs->file, s->l1_table_offset, sn_l1_table, - cur_l1_bytes); + cur_l1_bytes, 0); if (ret < 0) { goto fail; } @@ -1051,8 +1052,8 @@ int qcow2_snapshot_load_tmp(BlockDriverState *bs, return -ENOMEM; } =20 - ret =3D bdrv_pread(bs->file, sn->l1_table_offset, - new_l1_table, new_l1_bytes); + ret =3D bdrv_pread(bs->file, sn->l1_table_offset, new_l1_table, + new_l1_bytes, 0); if (ret < 0) { error_setg(errp, "Failed to read l1 table for snapshot"); qemu_vfree(new_l1_table); diff --git a/block/qcow2.c b/block/qcow2.c index 4f5e6440fb..99192d1242 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -107,8 +107,8 @@ static ssize_t qcow2_crypto_hdr_read_func(QCryptoBlock = *block, size_t offset, return -1; } =20 - ret =3D bdrv_pread(bs->file, - s->crypto_header.offset + offset, buf, buflen); + ret =3D bdrv_pread(bs->file, s->crypto_header.offset + offset, buf, bu= flen, + 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read encryption header"); return -1; @@ -168,8 +168,8 @@ static ssize_t qcow2_crypto_hdr_write_func(QCryptoBlock= *block, size_t offset, return -1; } =20 - ret =3D bdrv_pwrite(bs->file, - s->crypto_header.offset + offset, buf, buflen); + ret =3D bdrv_pwrite(bs->file, s->crypto_header.offset + offset, buf, b= uflen, + 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read encryption header"); return -1; @@ -227,7 +227,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, = uint64_t start_offset, printf("attempting to read extended header in offset %lu\n", offse= t); #endif =20 - ret =3D bdrv_pread(bs->file, offset, &ext, sizeof(ext)); + ret =3D bdrv_pread(bs->file, offset, &ext, sizeof(ext), 0); if (ret < 0) { error_setg_errno(errp, -ret, "qcow2_read_extension: ERROR: " "pread fail from offset %" PRIu64, offset); @@ -255,7 +255,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, = uint64_t start_offset, sizeof(bs->backing_format)); return 2; } - ret =3D bdrv_pread(bs->file, offset, bs->backing_format, ext.l= en); + ret =3D bdrv_pread(bs->file, offset, bs->backing_format, ext.l= en, 0); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR: ext_backing_format: " "Could not read format name"); @@ -271,7 +271,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, = uint64_t start_offset, case QCOW2_EXT_MAGIC_FEATURE_TABLE: if (p_feature_table !=3D NULL) { void *feature_table =3D g_malloc0(ext.len + 2 * sizeof(Qco= w2Feature)); - ret =3D bdrv_pread(bs->file, offset , feature_table, ext.l= en); + ret =3D bdrv_pread(bs->file, offset, feature_table, ext.le= n, 0); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR: ext_feature_table= : " "Could not read table"); @@ -296,7 +296,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, = uint64_t start_offset, return -EINVAL; } =20 - ret =3D bdrv_pread(bs->file, offset, &s->crypto_header, ext.le= n); + ret =3D bdrv_pread(bs->file, offset, &s->crypto_header, ext.le= n, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Unable to read CRYPTO header extension"); @@ -352,7 +352,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, = uint64_t start_offset, break; } =20 - ret =3D bdrv_pread(bs->file, offset, &bitmaps_ext, ext.len); + ret =3D bdrv_pread(bs->file, offset, &bitmaps_ext, ext.len, 0); if (ret < 0) { error_setg_errno(errp, -ret, "bitmaps_ext: " "Could not read ext header"); @@ -416,7 +416,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, = uint64_t start_offset, case QCOW2_EXT_MAGIC_DATA_FILE: { s->image_data_file =3D g_malloc0(ext.len + 1); - ret =3D bdrv_pread(bs->file, offset, s->image_data_file, ext.l= en); + ret =3D bdrv_pread(bs->file, offset, s->image_data_file, ext.l= en, 0); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR: Could not read data file name"); @@ -440,7 +440,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, = uint64_t start_offset, uext->len =3D ext.len; QLIST_INSERT_HEAD(&s->unknown_header_ext, uext, next); =20 - ret =3D bdrv_pread(bs->file, offset , uext->data, uext->le= n); + ret =3D bdrv_pread(bs->file, offset, uext->data, uext->len= , 0); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR: unknown extension= : " "Could not read data"); @@ -517,7 +517,7 @@ int qcow2_mark_dirty(BlockDriverState *bs) =20 val =3D cpu_to_be64(s->incompatible_features | QCOW2_INCOMPAT_DIRTY); ret =3D bdrv_pwrite(bs->file, offsetof(QCowHeader, incompatible_featur= es), - &val, sizeof(val)); + &val, sizeof(val), 0); if (ret < 0) { return ret; } @@ -1308,7 +1308,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverStat= e *bs, QDict *options, uint64_t l1_vm_state_index; bool update_header =3D false; =20 - ret =3D bdrv_pread(bs->file, 0, &header, sizeof(header)); + ret =3D bdrv_pread(bs->file, 0, &header, sizeof(header), 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read qcow2 header"); goto fail; @@ -1385,7 +1385,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverStat= e *bs, QDict *options, s->unknown_header_fields_size =3D header.header_length - sizeof(he= ader); s->unknown_header_fields =3D g_malloc(s->unknown_header_fields_siz= e); ret =3D bdrv_pread(bs->file, sizeof(header), s->unknown_header_fie= lds, - s->unknown_header_fields_size); + s->unknown_header_fields_size, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read unknown qcow2 hea= der " "fields"); @@ -1581,7 +1581,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverStat= e *bs, QDict *options, goto fail; } ret =3D bdrv_pread(bs->file, s->l1_table_offset, s->l1_table, - s->l1_size * L1E_SIZE); + s->l1_size * L1E_SIZE, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read L1 table"); goto fail; @@ -1699,7 +1699,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverStat= e *bs, QDict *options, goto fail; } ret =3D bdrv_pread(bs->file, header.backing_file_offset, - bs->auto_backing_file, len); + bs->auto_backing_file, len, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read backing file name= "); goto fail; @@ -3081,7 +3081,7 @@ int qcow2_update_header(BlockDriverState *bs) } =20 /* Write the new header */ - ret =3D bdrv_pwrite(bs->file, 0, header, s->cluster_size); + ret =3D bdrv_pwrite(bs->file, 0, header, s->cluster_size, 0); if (ret < 0) { goto fail; } @@ -4550,8 +4550,8 @@ static int coroutine_fn qcow2_co_truncate(BlockDriver= State *bs, int64_t offset, =20 /* write updated header.size */ offset =3D cpu_to_be64(offset); - ret =3D bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, size), - &offset, sizeof(offset)); + ret =3D bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, size), &offset, + sizeof(offset), 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to update the image size"); goto fail; @@ -4828,7 +4828,7 @@ static int make_completely_empty(BlockDriverState *bs) l1_ofs_rt_ofs_cls.reftable_offset =3D cpu_to_be64(s->cluster_size); l1_ofs_rt_ofs_cls.reftable_clusters =3D cpu_to_be32(1); ret =3D bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, l1_table_offse= t), - &l1_ofs_rt_ofs_cls, sizeof(l1_ofs_rt_ofs_cls)); + &l1_ofs_rt_ofs_cls, sizeof(l1_ofs_rt_ofs_cls), = 0); if (ret < 0) { goto fail_broken_refcounts; } @@ -4859,8 +4859,8 @@ static int make_completely_empty(BlockDriverState *bs) =20 /* Enter the first refblock into the reftable */ rt_entry =3D cpu_to_be64(2 * s->cluster_size); - ret =3D bdrv_pwrite_sync(bs->file, s->cluster_size, - &rt_entry, sizeof(rt_entry)); + ret =3D bdrv_pwrite_sync(bs->file, s->cluster_size, &rt_entry, + sizeof(rt_entry), 0); if (ret < 0) { goto fail_broken_refcounts; } diff --git a/block/qed.c b/block/qed.c index f34d9a3ac1..ad86079941 100644 --- a/block/qed.c +++ b/block/qed.c @@ -90,7 +90,7 @@ int qed_write_header_sync(BDRVQEDState *s) int ret; =20 qed_header_cpu_to_le(&s->header, &le); - ret =3D bdrv_pwrite(s->bs->file, 0, &le, sizeof(le)); + ret =3D bdrv_pwrite(s->bs->file, 0, &le, sizeof(le), 0); if (ret !=3D sizeof(le)) { return ret; } @@ -207,7 +207,7 @@ static int qed_read_string(BdrvChild *file, uint64_t of= fset, size_t n, if (n >=3D buflen) { return -EINVAL; } - ret =3D bdrv_pread(file, offset, buf, n); + ret =3D bdrv_pread(file, offset, buf, n, 0); if (ret < 0) { return ret; } @@ -392,7 +392,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverSta= te *bs, QDict *options, int64_t file_size; int ret; =20 - ret =3D bdrv_pread(bs->file, 0, &le_header, sizeof(le_header)); + ret =3D bdrv_pread(bs->file, 0, &le_header, sizeof(le_header), 0); if (ret < 0) { error_setg(errp, "Failed to read QED header"); return ret; @@ -1545,7 +1545,7 @@ static int bdrv_qed_change_backing_file(BlockDriverSt= ate *bs, } =20 /* Write new header */ - ret =3D bdrv_pwrite_sync(bs->file, 0, buffer, buffer_len); + ret =3D bdrv_pwrite_sync(bs->file, 0, buffer, buffer_len, 0); g_free(buffer); if (ret =3D=3D 0) { memcpy(&s->header, &new_header, sizeof(new_header)); diff --git a/block/vdi.c b/block/vdi.c index cca3a3a356..76cec1b883 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -385,7 +385,7 @@ static int vdi_open(BlockDriverState *bs, QDict *option= s, int flags, =20 logout("\n"); =20 - ret =3D bdrv_pread(bs->file, 0, &header, sizeof(header)); + ret =3D bdrv_pread(bs->file, 0, &header, sizeof(header), 0); if (ret < 0) { goto fail; } @@ -486,7 +486,7 @@ static int vdi_open(BlockDriverState *bs, QDict *option= s, int flags, } =20 ret =3D bdrv_pread(bs->file, header.offset_bmap, s->bmap, - bmap_size * SECTOR_SIZE); + bmap_size * SECTOR_SIZE, 0); if (ret < 0) { goto fail_free_bmap; } @@ -664,7 +664,7 @@ vdi_co_pwritev(BlockDriverState *bs, int64_t offset, in= t64_t bytes, * so this full-cluster write does not overlap a partial write * of the same cluster, issued from the "else" branch. */ - ret =3D bdrv_pwrite(bs->file, data_offset, block, s->block_siz= e); + ret =3D bdrv_pwrite(bs->file, data_offset, block, s->block_siz= e, 0); qemu_co_rwlock_unlock(&s->bmap_lock); } else { nonallocating_write: @@ -709,7 +709,7 @@ nonallocating_write: assert(VDI_IS_ALLOCATED(bmap_first)); *header =3D s->header; vdi_header_to_le(header); - ret =3D bdrv_pwrite(bs->file, 0, header, sizeof(*header)); + ret =3D bdrv_pwrite(bs->file, 0, header, sizeof(*header), 0); g_free(header); =20 if (ret < 0) { @@ -727,7 +727,7 @@ nonallocating_write: logout("will write %u block map sectors starting from entry %u\n", n_sectors, bmap_first); ret =3D bdrv_pwrite(bs->file, offset * SECTOR_SIZE, base, - n_sectors * SECTOR_SIZE); + n_sectors * SECTOR_SIZE, 0); } =20 return ret < 0 ? ret : 0; diff --git a/block/vhdx-log.c b/block/vhdx-log.c index ff0d4e0da0..da0057000b 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -84,7 +84,7 @@ static int vhdx_log_peek_hdr(BlockDriverState *bs, VHDXLo= gEntries *log, =20 offset =3D log->offset + read; =20 - ret =3D bdrv_pread(bs->file, offset, hdr, sizeof(VHDXLogEntryHeader)); + ret =3D bdrv_pread(bs->file, offset, hdr, sizeof(VHDXLogEntryHeader), = 0); if (ret < 0) { goto exit; } @@ -144,7 +144,7 @@ static int vhdx_log_read_sectors(BlockDriverState *bs, = VHDXLogEntries *log, } offset =3D log->offset + read; =20 - ret =3D bdrv_pread(bs->file, offset, buffer, VHDX_LOG_SECTOR_SIZE); + ret =3D bdrv_pread(bs->file, offset, buffer, VHDX_LOG_SECTOR_SIZE,= 0); if (ret < 0) { goto exit; } @@ -194,8 +194,8 @@ static int vhdx_log_write_sectors(BlockDriverState *bs,= VHDXLogEntries *log, /* full */ break; } - ret =3D bdrv_pwrite(bs->file, offset, buffer_tmp, - VHDX_LOG_SECTOR_SIZE); + ret =3D bdrv_pwrite(bs->file, offset, buffer_tmp, VHDX_LOG_SECTOR_= SIZE, + 0); if (ret < 0) { goto exit; } @@ -467,7 +467,7 @@ static int vhdx_log_flush_desc(BlockDriverState *bs, VH= DXLogDescriptor *desc, /* count is only > 1 if we are writing zeroes */ for (i =3D 0; i < count; i++) { ret =3D bdrv_pwrite_sync(bs->file, file_offset, buffer, - VHDX_LOG_SECTOR_SIZE); + VHDX_LOG_SECTOR_SIZE, 0); if (ret < 0) { goto exit; } @@ -971,7 +971,7 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVHD= XState *s, if (i =3D=3D 0 && leading_length) { /* partial sector at the front of the buffer */ ret =3D bdrv_pread(bs->file, file_offset, merged_sector, - VHDX_LOG_SECTOR_SIZE); + VHDX_LOG_SECTOR_SIZE, 0); if (ret < 0) { goto exit; } @@ -980,10 +980,9 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVH= DXState *s, sector_write =3D merged_sector; } else if (i =3D=3D sectors - 1 && trailing_length) { /* partial sector at the end of the buffer */ - ret =3D bdrv_pread(bs->file, - file_offset, - merged_sector + trailing_length, - VHDX_LOG_SECTOR_SIZE - trailing_length); + ret =3D bdrv_pread(bs->file, file_offset, + merged_sector + trailing_length, + VHDX_LOG_SECTOR_SIZE - trailing_length, 0); if (ret < 0) { goto exit; } diff --git a/block/vhdx.c b/block/vhdx.c index 410c6f9610..f5c812c9cf 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -326,7 +326,7 @@ static int vhdx_write_header(BdrvChild *file, VHDXHeade= r *hdr, buffer =3D qemu_blockalign(bs_file, VHDX_HEADER_SIZE); if (read) { /* if true, we can't assume the extra reserved bytes are 0 */ - ret =3D bdrv_pread(file, offset, buffer, VHDX_HEADER_SIZE); + ret =3D bdrv_pread(file, offset, buffer, VHDX_HEADER_SIZE, 0); if (ret < 0) { goto exit; } @@ -340,7 +340,7 @@ static int vhdx_write_header(BdrvChild *file, VHDXHeade= r *hdr, vhdx_header_le_export(hdr, header_le); vhdx_update_checksum(buffer, VHDX_HEADER_SIZE, offsetof(VHDXHeader, checksum)); - ret =3D bdrv_pwrite_sync(file, offset, header_le, sizeof(VHDXHeader)); + ret =3D bdrv_pwrite_sync(file, offset, header_le, sizeof(VHDXHeader), = 0); =20 exit: qemu_vfree(buffer); @@ -440,8 +440,8 @@ static void vhdx_parse_header(BlockDriverState *bs, BDR= VVHDXState *s, /* We have to read the whole VHDX_HEADER_SIZE instead of * sizeof(VHDXHeader), because the checksum is over the whole * region */ - ret =3D bdrv_pread(bs->file, VHDX_HEADER1_OFFSET, buffer, - VHDX_HEADER_SIZE); + ret =3D bdrv_pread(bs->file, VHDX_HEADER1_OFFSET, buffer, VHDX_HEADER_= SIZE, + 0); if (ret < 0) { goto fail; } @@ -457,8 +457,8 @@ static void vhdx_parse_header(BlockDriverState *bs, BDR= VVHDXState *s, } } =20 - ret =3D bdrv_pread(bs->file, VHDX_HEADER2_OFFSET, buffer, - VHDX_HEADER_SIZE); + ret =3D bdrv_pread(bs->file, VHDX_HEADER2_OFFSET, buffer, VHDX_HEADER_= SIZE, + 0); if (ret < 0) { goto fail; } @@ -532,7 +532,7 @@ static int vhdx_open_region_tables(BlockDriverState *bs= , BDRVVHDXState *s) buffer =3D qemu_blockalign(bs, VHDX_HEADER_BLOCK_SIZE); =20 ret =3D bdrv_pread(bs->file, VHDX_REGION_TABLE_OFFSET, buffer, - VHDX_HEADER_BLOCK_SIZE); + VHDX_HEADER_BLOCK_SIZE, 0); if (ret < 0) { goto fail; } @@ -645,7 +645,7 @@ static int vhdx_parse_metadata(BlockDriverState *bs, BD= RVVHDXState *s) buffer =3D qemu_blockalign(bs, VHDX_METADATA_TABLE_MAX_SIZE); =20 ret =3D bdrv_pread(bs->file, s->metadata_rt.file_offset, buffer, - VHDX_METADATA_TABLE_MAX_SIZE); + VHDX_METADATA_TABLE_MAX_SIZE, 0); if (ret < 0) { goto exit; } @@ -751,7 +751,8 @@ static int vhdx_parse_metadata(BlockDriverState *bs, BD= RVVHDXState *s) s->metadata_entries.file_parameters_entry.offset + s->metadata_rt.file_offset, &s->params, - sizeof(s->params)); + sizeof(s->params), + 0); =20 if (ret < 0) { goto exit; @@ -786,7 +787,8 @@ static int vhdx_parse_metadata(BlockDriverState *bs, BD= RVVHDXState *s) s->metadata_entries.virtual_disk_size_entry.offset + s->metadata_rt.file_offset, &s->virtual_disk_size, - sizeof(uint64_t)); + sizeof(uint64_t), + 0); if (ret < 0) { goto exit; } @@ -794,7 +796,8 @@ static int vhdx_parse_metadata(BlockDriverState *bs, BD= RVVHDXState *s) s->metadata_entries.logical_sector_size_entry.offset + s->metadata_rt.file_offset, &s->logical_sector_size, - sizeof(uint32_t)); + sizeof(uint32_t), + 0); if (ret < 0) { goto exit; } @@ -802,7 +805,8 @@ static int vhdx_parse_metadata(BlockDriverState *bs, BD= RVVHDXState *s) s->metadata_entries.phys_sector_size_entry.offset + s->metadata_rt.file_offset, &s->physical_sector_size, - sizeof(uint32_t)); + sizeof(uint32_t), + 0); if (ret < 0) { goto exit; } @@ -1010,7 +1014,7 @@ static int vhdx_open(BlockDriverState *bs, QDict *opt= ions, int flags, QLIST_INIT(&s->regions); =20 /* validate the file signature */ - ret =3D bdrv_pread(bs->file, 0, &signature, sizeof(uint64_t)); + ret =3D bdrv_pread(bs->file, 0, &signature, sizeof(uint64_t), 0); if (ret < 0) { goto fail; } @@ -1069,7 +1073,7 @@ static int vhdx_open(BlockDriverState *bs, QDict *opt= ions, int flags, goto fail; } =20 - ret =3D bdrv_pread(bs->file, s->bat_offset, s->bat, s->bat_rt.length); + ret =3D bdrv_pread(bs->file, s->bat_offset, s->bat, s->bat_rt.length, = 0); if (ret < 0) { goto fail; } diff --git a/block/vmdk.c b/block/vmdk.c index 38e5ab3806..4ad09ca07b 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -307,7 +307,7 @@ static int vmdk_read_cid(BlockDriverState *bs, int pare= nt, uint32_t *pcid) int ret; =20 desc =3D g_malloc0(DESC_SIZE); - ret =3D bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE); + ret =3D bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE, 0); if (ret < 0) { goto out; } @@ -348,7 +348,7 @@ static int vmdk_write_cid(BlockDriverState *bs, uint32_= t cid) =20 desc =3D g_malloc0(DESC_SIZE); tmp_desc =3D g_malloc0(DESC_SIZE); - ret =3D bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE); + ret =3D bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE, 0); if (ret < 0) { goto out; } @@ -368,7 +368,7 @@ static int vmdk_write_cid(BlockDriverState *bs, uint32_= t cid) pstrcat(desc, DESC_SIZE, tmp_desc); } =20 - ret =3D bdrv_pwrite_sync(bs->file, s->desc_offset, desc, DESC_SIZE); + ret =3D bdrv_pwrite_sync(bs->file, s->desc_offset, desc, DESC_SIZE, 0); =20 out: g_free(desc); @@ -469,7 +469,7 @@ static int vmdk_parent_open(BlockDriverState *bs) int ret; =20 desc =3D g_malloc0(DESC_SIZE + 1); - ret =3D bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE); + ret =3D bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE, 0); if (ret < 0) { goto out; } @@ -589,10 +589,8 @@ static int vmdk_init_tables(BlockDriverState *bs, Vmdk= Extent *extent, return -ENOMEM; } =20 - ret =3D bdrv_pread(extent->file, - extent->l1_table_offset, - extent->l1_table, - l1_size); + ret =3D bdrv_pread(extent->file, extent->l1_table_offset, extent->l1_t= able, + l1_size, 0); if (ret < 0) { bdrv_refresh_filename(extent->file->bs); error_setg_errno(errp, -ret, @@ -616,10 +614,8 @@ static int vmdk_init_tables(BlockDriverState *bs, Vmdk= Extent *extent, ret =3D -ENOMEM; goto fail_l1; } - ret =3D bdrv_pread(extent->file, - extent->l1_backup_table_offset, - extent->l1_backup_table, - l1_size); + ret =3D bdrv_pread(extent->file, extent->l1_backup_table_offset, + extent->l1_backup_table, l1_size, 0); if (ret < 0) { bdrv_refresh_filename(extent->file->bs); error_setg_errno(errp, -ret, @@ -651,7 +647,7 @@ static int vmdk_open_vmfs_sparse(BlockDriverState *bs, VMDK3Header header; VmdkExtent *extent =3D NULL; =20 - ret =3D bdrv_pread(file, sizeof(magic), &header, sizeof(header)); + ret =3D bdrv_pread(file, sizeof(magic), &header, sizeof(header), 0); if (ret < 0) { bdrv_refresh_filename(file->bs); error_setg_errno(errp, -ret, @@ -815,7 +811,7 @@ static int vmdk_open_se_sparse(BlockDriverState *bs, =20 assert(sizeof(const_header) =3D=3D SECTOR_SIZE); =20 - ret =3D bdrv_pread(file, 0, &const_header, sizeof(const_header)); + ret =3D bdrv_pread(file, 0, &const_header, sizeof(const_header), 0); if (ret < 0) { bdrv_refresh_filename(file->bs); error_setg_errno(errp, -ret, @@ -832,9 +828,8 @@ static int vmdk_open_se_sparse(BlockDriverState *bs, =20 assert(sizeof(volatile_header) =3D=3D SECTOR_SIZE); =20 - ret =3D bdrv_pread(file, - const_header.volatile_header_offset * SECTOR_SIZE, - &volatile_header, sizeof(volatile_header)); + ret =3D bdrv_pread(file, const_header.volatile_header_offset * SECTOR_= SIZE, + &volatile_header, sizeof(volatile_header), 0); if (ret < 0) { bdrv_refresh_filename(file->bs); error_setg_errno(errp, -ret, @@ -904,7 +899,7 @@ static char *vmdk_read_desc(BdrvChild *file, uint64_t d= esc_offset, Error **errp) size =3D MIN(size, (1 << 20) - 1); /* avoid unbounded allocation */ buf =3D g_malloc(size + 1); =20 - ret =3D bdrv_pread(file, desc_offset, buf, size); + ret =3D bdrv_pread(file, desc_offset, buf, size, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read from file"); g_free(buf); @@ -928,7 +923,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs, int64_t l1_backup_offset =3D 0; bool compressed; =20 - ret =3D bdrv_pread(file, sizeof(magic), &header, sizeof(header)); + ret =3D bdrv_pread(file, sizeof(magic), &header, sizeof(header), 0); if (ret < 0) { bdrv_refresh_filename(file->bs); error_setg_errno(errp, -ret, @@ -979,9 +974,8 @@ static int vmdk_open_vmdk4(BlockDriverState *bs, } QEMU_PACKED eos_marker; } QEMU_PACKED footer; =20 - ret =3D bdrv_pread(file, - bs->file->bs->total_sectors * 512 - 1536, - &footer, sizeof(footer)); + ret =3D bdrv_pread(file, bs->file->bs->total_sectors * 512 - 1536, + &footer, sizeof(footer), 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read footer"); return ret; @@ -1449,7 +1443,7 @@ static int get_whole_cluster(BlockDriverState *bs, /* qcow2 emits this on bs->file instead of bs->backing */ BLKDBG_EVENT(extent->file, BLKDBG_COW_READ); ret =3D bdrv_pread(bs->backing, offset, whole_grain, - skip_start_bytes); + skip_start_bytes, 0); if (ret < 0) { ret =3D VMDK_ERROR; goto exit; @@ -1457,7 +1451,7 @@ static int get_whole_cluster(BlockDriverState *bs, } BLKDBG_EVENT(extent->file, BLKDBG_COW_WRITE); ret =3D bdrv_pwrite(extent->file, cluster_offset, whole_grain, - skip_start_bytes); + skip_start_bytes, 0); if (ret < 0) { ret =3D VMDK_ERROR; goto exit; @@ -1470,7 +1464,7 @@ static int get_whole_cluster(BlockDriverState *bs, BLKDBG_EVENT(extent->file, BLKDBG_COW_READ); ret =3D bdrv_pread(bs->backing, offset + skip_end_bytes, whole_grain + skip_end_bytes, - cluster_bytes - skip_end_bytes); + cluster_bytes - skip_end_bytes, 0); if (ret < 0) { ret =3D VMDK_ERROR; goto exit; @@ -1479,7 +1473,7 @@ static int get_whole_cluster(BlockDriverState *bs, BLKDBG_EVENT(extent->file, BLKDBG_COW_WRITE); ret =3D bdrv_pwrite(extent->file, cluster_offset + skip_end_bytes, whole_grain + skip_end_bytes, - cluster_bytes - skip_end_bytes); + cluster_bytes - skip_end_bytes, 0); if (ret < 0) { ret =3D VMDK_ERROR; goto exit; @@ -1501,7 +1495,7 @@ static int vmdk_L2update(VmdkExtent *extent, VmdkMeta= Data *m_data, if (bdrv_pwrite(extent->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(offset)), - &offset, sizeof(offset)) < 0) { + &offset, sizeof(offset), 0) < 0) { return VMDK_ERROR; } /* update backup L2 table */ @@ -1510,7 +1504,7 @@ static int vmdk_L2update(VmdkExtent *extent, VmdkMeta= Data *m_data, if (bdrv_pwrite(extent->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(offset)), - &offset, sizeof(offset)) < 0) { + &offset, sizeof(offset), 0) < 0) { return VMDK_ERROR; } } @@ -1634,7 +1628,8 @@ static int get_cluster_offset(BlockDriverState *bs, if (bdrv_pread(extent->file, (int64_t)l2_offset * 512, l2_table, - l2_size_bytes + l2_size_bytes, + 0 ) !=3D l2_size_bytes) { return VMDK_ERROR; } @@ -1903,9 +1898,7 @@ static int vmdk_read_extent(VmdkExtent *extent, int64= _t cluster_offset, cluster_buf =3D g_malloc(buf_bytes); uncomp_buf =3D g_malloc(cluster_bytes); BLKDBG_EVENT(extent->file, BLKDBG_READ_COMPRESSED); - ret =3D bdrv_pread(extent->file, - cluster_offset, - cluster_buf, buf_bytes); + ret =3D bdrv_pread(extent->file, cluster_offset, cluster_buf, buf_byte= s, 0); if (ret < 0) { goto out; } diff --git a/block/vpc.c b/block/vpc.c index 4d8f16e199..1ccdfb0557 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -252,7 +252,7 @@ static int vpc_open(BlockDriverState *bs, QDict *option= s, int flags, goto fail; } =20 - ret =3D bdrv_pread(bs->file, 0, &s->footer, sizeof(s->footer)); + ret =3D bdrv_pread(bs->file, 0, &s->footer, sizeof(s->footer), 0); if (ret < 0) { error_setg(errp, "Unable to read VHD header"); goto fail; @@ -272,8 +272,8 @@ static int vpc_open(BlockDriverState *bs, QDict *option= s, int flags, } =20 /* If a fixed disk, the footer is found only at the end of the fil= e */ - ret =3D bdrv_pread(bs->file, offset - sizeof(*footer), - footer, sizeof(*footer)); + ret =3D bdrv_pread(bs->file, offset - sizeof(*footer), footer, + sizeof(*footer), 0); if (ret < 0) { goto fail; } @@ -347,7 +347,7 @@ static int vpc_open(BlockDriverState *bs, QDict *option= s, int flags, =20 if (disk_type =3D=3D VHD_DYNAMIC) { ret =3D bdrv_pread(bs->file, be64_to_cpu(footer->data_offset), - &dyndisk_header, sizeof(dyndisk_header)); + &dyndisk_header, sizeof(dyndisk_header), 0); if (ret < 0) { error_setg(errp, "Error reading dynamic VHD header"); goto fail; @@ -402,7 +402,7 @@ static int vpc_open(BlockDriverState *bs, QDict *option= s, int flags, s->bat_offset =3D be64_to_cpu(dyndisk_header.table_offset); =20 ret =3D bdrv_pread(bs->file, s->bat_offset, s->pagetable, - pagetable_size); + pagetable_size, 0); if (ret < 0) { error_setg(errp, "Error reading pagetable"); goto fail; @@ -516,7 +516,8 @@ static inline int64_t get_image_offset(BlockDriverState= *bs, uint64_t offset, =20 s->last_bitmap_offset =3D bitmap_offset; memset(bitmap, 0xff, s->bitmap_size); - r =3D bdrv_pwrite_sync(bs->file, bitmap_offset, bitmap, s->bitmap_= size); + r =3D bdrv_pwrite_sync(bs->file, bitmap_offset, bitmap, s->bitmap_= size, + 0); if (r < 0) { *err =3D r; return -2; @@ -538,7 +539,7 @@ static int rewrite_footer(BlockDriverState *bs) BDRVVPCState *s =3D bs->opaque; int64_t offset =3D s->free_data_block_offset; =20 - ret =3D bdrv_pwrite_sync(bs->file, offset, &s->footer, sizeof(s->foote= r)); + ret =3D bdrv_pwrite_sync(bs->file, offset, &s->footer, sizeof(s->foote= r), 0); if (ret < 0) return ret; =20 @@ -573,7 +574,7 @@ static int64_t alloc_block(BlockDriverState *bs, int64_= t offset) /* Initialize the block's bitmap */ memset(bitmap, 0xff, s->bitmap_size); ret =3D bdrv_pwrite_sync(bs->file, s->free_data_block_offset, bitmap, - s->bitmap_size); + s->bitmap_size, 0); if (ret < 0) { return ret; } @@ -587,7 +588,7 @@ static int64_t alloc_block(BlockDriverState *bs, int64_= t offset) /* Write BAT entry to disk */ bat_offset =3D s->bat_offset + (4 * index); bat_value =3D cpu_to_be32(s->pagetable[index]); - ret =3D bdrv_pwrite_sync(bs->file, bat_offset, &bat_value, 4); + ret =3D bdrv_pwrite_sync(bs->file, bat_offset, &bat_value, 4, 0); if (ret < 0) goto fail; =20 diff --git a/block/vvfat.c b/block/vvfat.c index b2b58d93b8..87595dfc69 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1489,7 +1489,7 @@ static int vvfat_read(BlockDriverState *bs, int64_t s= ector_num, " allocated\n", sector_num, n >> BDRV_SECTOR_BITS)); if (bdrv_pread(s->qcow, sector_num * BDRV_SECTOR_SIZE, - buf + i * 0x200, n) < 0) { + buf + i * 0x200, n, 0) < 0) { return -1; } i +=3D (n >> BDRV_SECTOR_BITS) - 1; @@ -1978,7 +1978,8 @@ static uint32_t get_cluster_count_for_direntry(BDRVVV= FATState* s, return -1; } res =3D bdrv_pwrite(s->qcow, offset * BDRV_SECTOR_= SIZE, - s->cluster_buffer, BDRV_SECTOR_S= IZE); + s->cluster_buffer, BDRV_SECTOR_S= IZE, + 0); if (res < 0) { return -2; } @@ -3063,7 +3064,7 @@ DLOG(checkpoint()); */ DLOG(fprintf(stderr, "Write to qcow backend: %d + %d\n", (int)sector_num, = nb_sectors)); ret =3D bdrv_pwrite(s->qcow, sector_num * BDRV_SECTOR_SIZE, buf, - nb_sectors * BDRV_SECTOR_SIZE); + nb_sectors * BDRV_SECTOR_SIZE, 0); if (ret < 0) { fprintf(stderr, "Error writing to qcow backend\n"); return ret; diff --git a/include/block/block-io.h b/include/block/block-io.h index 62c84f0519..900ab19545 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -42,11 +42,12 @@ int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset, int64_t bytes, BdrvRequestFlags flags); int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags flags); -int bdrv_pread(BdrvChild *child, int64_t offset, void *buf, int64_t bytes); +int bdrv_pread(BdrvChild *child, int64_t offset, void *buf, int64_t bytes, + BdrvRequestFlags flags); int bdrv_pwrite(BdrvChild *child, int64_t offset, const void *buf, - int64_t bytes); + int64_t bytes, BdrvRequestFlags flags); int bdrv_pwrite_sync(BdrvChild *child, int64_t offset, - const void *buf, int64_t bytes); + const void *buf, int64_t bytes, BdrvRequestFlags flag= s); /* * Efficiently zero a region of the disk image. Note that this is a regul= ar * I/O request like read or write and should have a reasonable size. This diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index 94718c9319..4db1ad5dfe 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -88,11 +88,11 @@ static void test_sync_op_pread(BdrvChild *c) int ret; =20 /* Success */ - ret =3D bdrv_pread(c, 0, buf, sizeof(buf)); + ret =3D bdrv_pread(c, 0, buf, sizeof(buf), 0); g_assert_cmpint(ret, =3D=3D, 512); =20 /* Early error: Negative offset */ - ret =3D bdrv_pread(c, -2, buf, sizeof(buf)); + ret =3D bdrv_pread(c, -2, buf, sizeof(buf), 0); g_assert_cmpint(ret, =3D=3D, -EIO); } =20 @@ -102,11 +102,11 @@ static void test_sync_op_pwrite(BdrvChild *c) int ret; =20 /* Success */ - ret =3D bdrv_pwrite(c, 0, buf, sizeof(buf)); + ret =3D bdrv_pwrite(c, 0, buf, sizeof(buf), 0); g_assert_cmpint(ret, =3D=3D, 512); =20 /* Early error: Negative offset */ - ret =3D bdrv_pwrite(c, -2, buf, sizeof(buf)); + ret =3D bdrv_pwrite(c, -2, buf, sizeof(buf), 0); g_assert_cmpint(ret, =3D=3D, -EIO); } =20 --=20 2.35.3 From nobody Fri Apr 26 16:52:25 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652399057477213.1533870624247; Thu, 12 May 2022 16:44:17 -0700 (PDT) Received: from localhost ([::1]:46078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npITg-0003is-Bj for importer2@patchew.org; Thu, 12 May 2022 19:44:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npIQc-0000kF-Um for qemu-devel@nongnu.org; Thu, 12 May 2022 19:41:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:40973) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npIQY-0004EV-BP for qemu-devel@nongnu.org; Thu, 12 May 2022 19:41:06 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-212-POGCvhEEM5uBBHLgEpxE-Q-1; Thu, 12 May 2022 19:39:04 -0400 Received: by mail-wm1-f70.google.com with SMTP id c125-20020a1c3583000000b0038e3f6e871aso2159079wma.8 for ; Thu, 12 May 2022 16:39:04 -0700 (PDT) Received: from DESKTOP-E7ACR7D.lan ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id r12-20020adfa14c000000b0020c5253d8c7sm749045wrr.19.2022.05.12.16.38.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 16:38:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652398861; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RMdRxYAMkIACK69Rg4TwVlJsXjcAvi4QcguNQgJyHyw=; b=Ioe4j13yHr1wLN7BNEY+HpfTgwUWHB0BSreq1dOi+KbPt2k7rLBYowUuquE6ZJmqzYmwpA JIZgKQxDEDIHfFw5wOLxhPHwFHy6NFNBw55wF0svBGK77hkBd+14jkTeRtSPKrGTP/+D/k JQURQIMw9STg0iF7ijThWv+dWnRPVxU= X-MC-Unique: POGCvhEEM5uBBHLgEpxE-Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RMdRxYAMkIACK69Rg4TwVlJsXjcAvi4QcguNQgJyHyw=; b=roqtjQpiEEN+b+2sta9afiWwjT88psdZqfDkkmugcCg/YoNZO84/oKWmkcAn5LRTUd vqtw2gOV1iBlXY3cMS4Bw4aUUnpy/mSdj+XKITUJde6Lp5o2kuASxh405D/2IClUTAby NuG0KPOpcc0m68P38tgb6UIW/aZYLV/lq/vXIzQRP9aJz9KWLvQVQ8raOWRqsGj7HBp2 Q3bmjAtnrtFa9cgzut30OciHy5QzgjyqFSEnu3cY5mWvyKhdKdatyVi8kWjxXG1/C3j1 lNur9jT74zr58LwPizG8JmzMHeX6taFQHOOvyvlrG3DdkhAMmiiyeEgPZ+X1/uCWTPUj o7ow== X-Gm-Message-State: AOAM532w6h5nYeeQNumifwRqb7Udm8bFzXb7Zh4X25LLToIHL2RA5Sxz JFqurLchtBlFTPEUBTt2vj2+/YiTmDhcBgRn3ltkIp582cChhO+nCvrNiCE5LJOPQrQiWYdNpEx 1PVHKhhdnwIwKkaTa0k0yea1lXlRdhv0KfQ1vhbEuh3C7OQYn39C0IyKaBEWneCI1 X-Received: by 2002:a5d:64ec:0:b0:20c:62d4:3917 with SMTP id g12-20020a5d64ec000000b0020c62d43917mr1562460wri.480.1652398740957; Thu, 12 May 2022 16:39:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmSJ0RtflV/j8T6Y3dF/WtXd6+Z6I7iPYIxzo63OBh9TBcvMuYs9Tu7dDXT7rLE+m8HtiN5Q== X-Received: by 2002:a5d:64ec:0:b0:20c:62d4:3917 with SMTP id g12-20020a5d64ec000000b0020c62d43917mr1562408wri.480.1652398739878; Thu, 12 May 2022 16:38:59 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Alberto Faria , Ari Sundholm , Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Fam Zheng , "Denis V. Lunev" , Vladimir Sementsov-Ogievskiy , Eric Blake , John Snow , Stefan Weil , Jeff Cody Subject: [PATCH 2/7] block: Change bdrv_{pread, pwrite, pwrite_sync}() param order Date: Fri, 13 May 2022 00:38:44 +0100 Message-Id: <20220512233849.2219275-3-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220512233849.2219275-1-afaria@redhat.com> References: <20220512233849.2219275-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1652399059744100001 Content-Type: text/plain; charset="utf-8" Swap 'buf' and 'bytes' around for consistency with bdrv_co_{pread,pwrite}(), and in preparation to implement these functions using generated_co_wrapper. Callers were updated using this Coccinelle script: @@ expression child, offset, buf, bytes, flags; @@ - bdrv_pread(child, offset, buf, bytes, flags) + bdrv_pread(child, offset, bytes, buf, flags) @@ expression child, offset, buf, bytes, flags; @@ - bdrv_pwrite(child, offset, buf, bytes, flags) + bdrv_pwrite(child, offset, bytes, buf, flags) @@ expression child, offset, buf, bytes, flags; @@ - bdrv_pwrite_sync(child, offset, buf, bytes, flags) + bdrv_pwrite_sync(child, offset, bytes, buf, flags) Resulting overly-long lines were then fixed by hand. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini --- block/blklogwrites.c | 6 ++-- block/bochs.c | 10 +++--- block/cloop.c | 10 +++--- block/crypto.c | 4 +-- block/dmg.c | 26 +++++++-------- block/io.c | 12 +++---- block/parallels-ext.c | 6 ++-- block/parallels.c | 10 +++--- block/qcow.c | 34 +++++++++---------- block/qcow2-bitmap.c | 14 ++++---- block/qcow2-cache.c | 8 ++--- block/qcow2-cluster.c | 22 ++++++------- block/qcow2-refcount.c | 56 +++++++++++++++++--------------- block/qcow2-snapshot.c | 48 +++++++++++++-------------- block/qcow2.c | 47 ++++++++++++++------------- block/qed.c | 8 ++--- block/vdi.c | 14 ++++---- block/vhdx-log.c | 18 +++++----- block/vhdx.c | 28 ++++++++-------- block/vmdk.c | 50 ++++++++++++++-------------- block/vpc.c | 22 ++++++------- block/vvfat.c | 10 +++--- include/block/block-io.h | 10 +++--- tests/unit/test-block-iothread.c | 8 ++--- 24 files changed, 242 insertions(+), 239 deletions(-) diff --git a/block/blklogwrites.c b/block/blklogwrites.c index c5c021e6f8..e3c6c4039c 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -107,8 +107,8 @@ static uint64_t blk_log_writes_find_cur_log_sector(Bdrv= Child *log, struct log_write_entry cur_entry; =20 while (cur_idx < nr_entries) { - int read_ret =3D bdrv_pread(log, cur_sector << sector_bits, &cur_e= ntry, - sizeof(cur_entry), 0); + int read_ret =3D bdrv_pread(log, cur_sector << sector_bits, + sizeof(cur_entry), &cur_entry, 0); if (read_ret < 0) { error_setg_errno(errp, -read_ret, "Failed to read log entry %"PRIu64, cur_idx); @@ -190,7 +190,7 @@ static int blk_log_writes_open(BlockDriverState *bs, QD= ict *options, int flags, log_sb.nr_entries =3D cpu_to_le64(0); log_sb.sectorsize =3D cpu_to_le32(BDRV_SECTOR_SIZE); } else { - ret =3D bdrv_pread(s->log_file, 0, &log_sb, sizeof(log_sb), 0); + ret =3D bdrv_pread(s->log_file, 0, sizeof(log_sb), &log_sb, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read log superbloc= k"); goto fail_log; diff --git a/block/bochs.c b/block/bochs.c index 46d0f6a693..b76f34fe03 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -116,7 +116,7 @@ static int bochs_open(BlockDriverState *bs, QDict *opti= ons, int flags, return -EINVAL; } =20 - ret =3D bdrv_pread(bs->file, 0, &bochs, sizeof(bochs), 0); + ret =3D bdrv_pread(bs->file, 0, sizeof(bochs), &bochs, 0); if (ret < 0) { return ret; } @@ -150,8 +150,8 @@ static int bochs_open(BlockDriverState *bs, QDict *opti= ons, int flags, return -ENOMEM; } =20 - ret =3D bdrv_pread(bs->file, le32_to_cpu(bochs.header), s->catalog_bit= map, - s->catalog_size * 4, 0); + ret =3D bdrv_pread(bs->file, le32_to_cpu(bochs.header), s->catalog_siz= e * 4, + s->catalog_bitmap, 0); if (ret < 0) { goto fail; } @@ -224,8 +224,8 @@ static int64_t seek_to_sector(BlockDriverState *bs, int= 64_t sector_num) (s->extent_blocks + s->bitmap_blocks)); =20 /* read in bitmap for current extent */ - ret =3D bdrv_pread(bs->file, bitmap_offset + (extent_offset / 8), - &bitmap_entry, 1, 0); + ret =3D bdrv_pread(bs->file, bitmap_offset + (extent_offset / 8), 1, + &bitmap_entry, 0); if (ret < 0) { return ret; } diff --git a/block/cloop.c b/block/cloop.c index 208a58ebb1..9a2334495e 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -78,7 +78,7 @@ static int cloop_open(BlockDriverState *bs, QDict *option= s, int flags, } =20 /* read header */ - ret =3D bdrv_pread(bs->file, 128, &s->block_size, 4, 0); + ret =3D bdrv_pread(bs->file, 128, 4, &s->block_size, 0); if (ret < 0) { return ret; } @@ -104,7 +104,7 @@ static int cloop_open(BlockDriverState *bs, QDict *opti= ons, int flags, return -EINVAL; } =20 - ret =3D bdrv_pread(bs->file, 128 + 4, &s->n_blocks, 4, 0); + ret =3D bdrv_pread(bs->file, 128 + 4, 4, &s->n_blocks, 0); if (ret < 0) { return ret; } @@ -135,7 +135,7 @@ static int cloop_open(BlockDriverState *bs, QDict *opti= ons, int flags, return -ENOMEM; } =20 - ret =3D bdrv_pread(bs->file, 128 + 4 + 4, s->offsets, offsets_size, 0); + ret =3D bdrv_pread(bs->file, 128 + 4 + 4, offsets_size, s->offsets, 0); if (ret < 0) { goto fail; } @@ -220,8 +220,8 @@ static inline int cloop_read_block(BlockDriverState *bs= , int block_num) int ret; uint32_t bytes =3D s->offsets[block_num + 1] - s->offsets[block_nu= m]; =20 - ret =3D bdrv_pread(bs->file, s->offsets[block_num], s->compressed_= block, - bytes, 0); + ret =3D bdrv_pread(bs->file, s->offsets[block_num], bytes, + s->compressed_block, 0); if (ret !=3D bytes) { return -1; } diff --git a/block/crypto.c b/block/crypto.c index d0c22e9549..deec7fae2f 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -65,7 +65,7 @@ static ssize_t block_crypto_read_func(QCryptoBlock *block, BlockDriverState *bs =3D opaque; ssize_t ret; =20 - ret =3D bdrv_pread(bs->file, offset, buf, buflen, 0); + ret =3D bdrv_pread(bs->file, offset, buflen, buf, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read encryption header"); return ret; @@ -83,7 +83,7 @@ static ssize_t block_crypto_write_func(QCryptoBlock *bloc= k, BlockDriverState *bs =3D opaque; ssize_t ret; =20 - ret =3D bdrv_pwrite(bs->file, offset, buf, buflen, 0); + ret =3D bdrv_pwrite(bs->file, offset, buflen, buf, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not write encryption header"); return ret; diff --git a/block/dmg.c b/block/dmg.c index ddd1d23005..5a460c3eb1 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -77,7 +77,7 @@ static int read_uint64(BlockDriverState *bs, int64_t offs= et, uint64_t *result) uint64_t buffer; int ret; =20 - ret =3D bdrv_pread(bs->file, offset, &buffer, 8, 0); + ret =3D bdrv_pread(bs->file, offset, 8, &buffer, 0); if (ret < 0) { return ret; } @@ -91,7 +91,7 @@ static int read_uint32(BlockDriverState *bs, int64_t offs= et, uint32_t *result) uint32_t buffer; int ret; =20 - ret =3D bdrv_pread(bs->file, offset, &buffer, 4, 0); + ret =3D bdrv_pread(bs->file, offset, 4, &buffer, 0); if (ret < 0) { return ret; } @@ -172,7 +172,7 @@ static int64_t dmg_find_koly_offset(BdrvChild *file, Er= ror **errp) offset =3D length - 511 - 512; } length =3D length < 515 ? length : 515; - ret =3D bdrv_pread(file, offset, buffer, length, 0); + ret =3D bdrv_pread(file, offset, length, buffer, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed while reading UDIF trailer"); return ret; @@ -352,7 +352,7 @@ static int dmg_read_resource_fork(BlockDriverState *bs,= DmgHeaderState *ds, offset +=3D 4; =20 buffer =3D g_realloc(buffer, count); - ret =3D bdrv_pread(bs->file, offset, buffer, count, 0); + ret =3D bdrv_pread(bs->file, offset, count, buffer, 0); if (ret < 0) { goto fail; } @@ -389,7 +389,7 @@ static int dmg_read_plist_xml(BlockDriverState *bs, Dmg= HeaderState *ds, =20 buffer =3D g_malloc(info_length + 1); buffer[info_length] =3D '\0'; - ret =3D bdrv_pread(bs->file, info_begin, buffer, info_length, 0); + ret =3D bdrv_pread(bs->file, info_begin, info_length, buffer, 0); if (ret !=3D info_length) { ret =3D -EINVAL; goto fail; @@ -609,8 +609,8 @@ static inline int dmg_read_chunk(BlockDriverState *bs, = uint64_t sector_num) case UDZO: { /* zlib compressed */ /* we need to buffer, because only the chunk as whole can be * inflated. */ - ret =3D bdrv_pread(bs->file, s->offsets[chunk], s->compressed_= chunk, - s->lengths[chunk], 0); + ret =3D bdrv_pread(bs->file, s->offsets[chunk], s->lengths[chu= nk], + s->compressed_chunk, 0); if (ret !=3D s->lengths[chunk]) { return -1; } @@ -635,8 +635,8 @@ static inline int dmg_read_chunk(BlockDriverState *bs, = uint64_t sector_num) } /* we need to buffer, because only the chunk as whole can be * inflated. */ - ret =3D bdrv_pread(bs->file, s->offsets[chunk], s->compressed_= chunk, - s->lengths[chunk], 0); + ret =3D bdrv_pread(bs->file, s->offsets[chunk], s->lengths[chu= nk], + s->compressed_chunk, 0); if (ret !=3D s->lengths[chunk]) { return -1; } @@ -656,8 +656,8 @@ static inline int dmg_read_chunk(BlockDriverState *bs, = uint64_t sector_num) } /* we need to buffer, because only the chunk as whole can be * inflated. */ - ret =3D bdrv_pread(bs->file, s->offsets[chunk], s->compressed_= chunk, - s->lengths[chunk], 0); + ret =3D bdrv_pread(bs->file, s->offsets[chunk], s->lengths[chu= nk], + s->compressed_chunk, 0); if (ret !=3D s->lengths[chunk]) { return -1; } @@ -672,8 +672,8 @@ static inline int dmg_read_chunk(BlockDriverState *bs, = uint64_t sector_num) } break; case UDRW: /* copy */ - ret =3D bdrv_pread(bs->file, s->offsets[chunk], - s->uncompressed_chunk, s->lengths[chunk], 0); + ret =3D bdrv_pread(bs->file, s->offsets[chunk], s->lengths[chu= nk], + s->uncompressed_chunk, 0); if (ret !=3D s->lengths[chunk]) { return -1; } diff --git a/block/io.c b/block/io.c index 008e5c90bf..2ed963d9e0 100644 --- a/block/io.c +++ b/block/io.c @@ -1112,7 +1112,7 @@ int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags= flags) } =20 /* See bdrv_pwrite() for the return codes */ -int bdrv_pread(BdrvChild *child, int64_t offset, void *buf, int64_t bytes, +int bdrv_pread(BdrvChild *child, int64_t offset, int64_t bytes, void *buf, BdrvRequestFlags flags) { int ret; @@ -1134,8 +1134,8 @@ int bdrv_pread(BdrvChild *child, int64_t offset, void= *buf, int64_t bytes, -EINVAL Invalid offset or number of bytes -EACCES Trying to write a read-only device */ -int bdrv_pwrite(BdrvChild *child, int64_t offset, const void *buf, - int64_t bytes, BdrvRequestFlags flags) +int bdrv_pwrite(BdrvChild *child, int64_t offset, int64_t bytes, + const void *buf, BdrvRequestFlags flags) { int ret; QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); @@ -1156,13 +1156,13 @@ int bdrv_pwrite(BdrvChild *child, int64_t offset, c= onst void *buf, * * Returns 0 on success, -errno in error cases. */ -int bdrv_pwrite_sync(BdrvChild *child, int64_t offset, - const void *buf, int64_t count, BdrvRequestFlags flag= s) +int bdrv_pwrite_sync(BdrvChild *child, int64_t offset, int64_t bytes, + const void *buf, BdrvRequestFlags flags) { int ret; IO_CODE(); =20 - ret =3D bdrv_pwrite(child, offset, buf, count, flags); + ret =3D bdrv_pwrite(child, offset, bytes, buf, flags); if (ret < 0) { return ret; } diff --git a/block/parallels-ext.c b/block/parallels-ext.c index f737104d12..c9dbbf5089 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -93,8 +93,8 @@ static int parallels_load_bitmap_data(BlockDriverState *b= s, if (entry =3D=3D 1) { bdrv_dirty_bitmap_deserialize_ones(bitmap, offset, count, fals= e); } else { - ret =3D bdrv_pread(bs->file, entry << BDRV_SECTOR_BITS, buf, - s->cluster_size, 0); + ret =3D bdrv_pread(bs->file, entry << BDRV_SECTOR_BITS, + s->cluster_size, buf, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read bitmap data cluster"); @@ -286,7 +286,7 @@ int parallels_read_format_extension(BlockDriverState *b= s, =20 assert(ext_off > 0); =20 - ret =3D bdrv_pread(bs->file, ext_off, ext_cluster, s->cluster_size, 0); + ret =3D bdrv_pread(bs->file, ext_off, s->cluster_size, ext_cluster, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read Format Extension clus= ter"); goto out; diff --git a/block/parallels.c b/block/parallels.c index 6ab82764b2..f22444efff 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -277,7 +277,7 @@ static coroutine_fn int parallels_co_flush_to_os(BlockD= riverState *bs) if (off + to_write > s->header_size) { to_write =3D s->header_size - off; } - ret =3D bdrv_pwrite(bs->file, off, (uint8_t *)s->header + off, to_= write, + ret =3D bdrv_pwrite(bs->file, off, to_write, (uint8_t *)s->header = + off, 0); if (ret < 0) { qemu_co_mutex_unlock(&s->lock); @@ -481,7 +481,7 @@ static int coroutine_fn parallels_co_check(BlockDriverS= tate *bs, =20 ret =3D 0; if (flush_bat) { - ret =3D bdrv_pwrite_sync(bs->file, 0, s->header, s->header_size, 0= ); + ret =3D bdrv_pwrite_sync(bs->file, 0, s->header_size, s->header, 0= ); if (ret < 0) { res->check_errors++; goto out; @@ -723,7 +723,7 @@ static int parallels_update_header(BlockDriverState *bs) if (size > s->header_size) { size =3D s->header_size; } - return bdrv_pwrite_sync(bs->file, 0, s->header, size, 0); + return bdrv_pwrite_sync(bs->file, 0, size, s->header, 0); } =20 static int parallels_open(BlockDriverState *bs, QDict *options, int flags, @@ -742,7 +742,7 @@ static int parallels_open(BlockDriverState *bs, QDict *= options, int flags, return -EINVAL; } =20 - ret =3D bdrv_pread(bs->file, 0, &ph, sizeof(ph), 0); + ret =3D bdrv_pread(bs->file, 0, sizeof(ph), &ph, 0); if (ret < 0) { goto fail; } @@ -798,7 +798,7 @@ static int parallels_open(BlockDriverState *bs, QDict *= options, int flags, s->header_size =3D size; } =20 - ret =3D bdrv_pread(bs->file, 0, s->header, s->header_size, 0); + ret =3D bdrv_pread(bs->file, 0, s->header_size, s->header, 0); if (ret < 0) { goto fail; } diff --git a/block/qcow.c b/block/qcow.c index 20fb94c18b..c94524b814 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -128,7 +128,7 @@ static int qcow_open(BlockDriverState *bs, QDict *optio= ns, int flags, goto fail; } =20 - ret =3D bdrv_pread(bs->file, 0, &header, sizeof(header), 0); + ret =3D bdrv_pread(bs->file, 0, sizeof(header), &header, 0); if (ret < 0) { goto fail; } @@ -260,8 +260,8 @@ static int qcow_open(BlockDriverState *bs, QDict *optio= ns, int flags, goto fail; } =20 - ret =3D bdrv_pread(bs->file, s->l1_table_offset, s->l1_table, - s->l1_size * sizeof(uint64_t), 0); + ret =3D bdrv_pread(bs->file, s->l1_table_offset, + s->l1_size * sizeof(uint64_t), s->l1_table, 0); if (ret < 0) { goto fail; } @@ -291,8 +291,8 @@ static int qcow_open(BlockDriverState *bs, QDict *optio= ns, int flags, ret =3D -EINVAL; goto fail; } - ret =3D bdrv_pread(bs->file, header.backing_file_offset, - bs->auto_backing_file, len, 0); + ret =3D bdrv_pread(bs->file, header.backing_file_offset, len, + bs->auto_backing_file, 0); if (ret < 0) { goto fail; } @@ -383,7 +383,7 @@ static int get_cluster_offset(BlockDriverState *bs, BLKDBG_EVENT(bs->file, BLKDBG_L1_UPDATE); ret =3D bdrv_pwrite_sync(bs->file, s->l1_table_offset + l1_index * sizeof(tmp), - &tmp, sizeof(tmp), 0); + sizeof(tmp), &tmp, 0); if (ret < 0) { return ret; } @@ -414,14 +414,14 @@ static int get_cluster_offset(BlockDriverState *bs, BLKDBG_EVENT(bs->file, BLKDBG_L2_LOAD); if (new_l2_table) { memset(l2_table, 0, s->l2_size * sizeof(uint64_t)); - ret =3D bdrv_pwrite_sync(bs->file, l2_offset, l2_table, - s->l2_size * sizeof(uint64_t), 0); + ret =3D bdrv_pwrite_sync(bs->file, l2_offset, + s->l2_size * sizeof(uint64_t), l2_table, 0); if (ret < 0) { return ret; } } else { - ret =3D bdrv_pread(bs->file, l2_offset, l2_table, - s->l2_size * sizeof(uint64_t), 0); + ret =3D bdrv_pread(bs->file, l2_offset, s->l2_size * sizeof(uint64= _t), + l2_table, 0); if (ret < 0) { return ret; } @@ -453,8 +453,8 @@ static int get_cluster_offset(BlockDriverState *bs, cluster_offset =3D QEMU_ALIGN_UP(cluster_offset, s->cluster_si= ze); /* write the cluster content */ BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); - ret =3D bdrv_pwrite(bs->file, cluster_offset, s->cluster_cache, - s->cluster_size, 0); + ret =3D bdrv_pwrite(bs->file, cluster_offset, s->cluster_size, + s->cluster_cache, 0); if (ret < 0) { return ret; } @@ -493,8 +493,8 @@ static int get_cluster_offset(BlockDriverState *bs, } BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); ret =3D bdrv_pwrite(bs->file, cluster_offset += i, - s->cluster_data, - BDRV_SECTOR_SIZE, 0); + BDRV_SECTOR_SIZE, + s->cluster_data, 0); if (ret < 0) { return ret; } @@ -515,7 +515,7 @@ static int get_cluster_offset(BlockDriverState *bs, BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE); } ret =3D bdrv_pwrite_sync(bs->file, l2_offset + l2_index * sizeof(t= mp), - &tmp, sizeof(tmp), 0); + sizeof(tmp), &tmp, 0); if (ret < 0) { return ret; } @@ -596,7 +596,7 @@ static int decompress_cluster(BlockDriverState *bs, uin= t64_t cluster_offset) csize =3D cluster_offset >> (63 - s->cluster_bits); csize &=3D (s->cluster_size - 1); BLKDBG_EVENT(bs->file, BLKDBG_READ_COMPRESSED); - ret =3D bdrv_pread(bs->file, coffset, s->cluster_data, csize, 0); + ret =3D bdrv_pread(bs->file, coffset, csize, s->cluster_data, 0); if (ret !=3D csize) return -1; if (decompress_buffer(s->cluster_cache, s->cluster_size, @@ -1029,7 +1029,7 @@ static int qcow_make_empty(BlockDriverState *bs) int ret; =20 memset(s->l1_table, 0, l1_length); - if (bdrv_pwrite_sync(bs->file, s->l1_table_offset, s->l1_table, l1_len= gth, + if (bdrv_pwrite_sync(bs->file, s->l1_table_offset, l1_length, s->l1_ta= ble, 0) < 0) return -1; ret =3D bdrv_truncate(bs->file, s->l1_table_offset + l1_length, false, diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index 6aa4739820..e98bafe0f4 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -234,8 +234,8 @@ static int bitmap_table_load(BlockDriverState *bs, Qcow= 2BitmapTable *tb, } =20 assert(tb->size <=3D BME_MAX_TABLE_SIZE); - ret =3D bdrv_pread(bs->file, tb->offset, table, - tb->size * BME_TABLE_ENTRY_SIZE, 0); + ret =3D bdrv_pread(bs->file, tb->offset, tb->size * BME_TABLE_ENTRY_SI= ZE, + table, 0); if (ret < 0) { goto fail; } @@ -317,7 +317,7 @@ static int load_bitmap_data(BlockDriverState *bs, * already cleared */ } } else { - ret =3D bdrv_pread(bs->file, data_offset, buf, s->cluster_size= , 0); + ret =3D bdrv_pread(bs->file, data_offset, s->cluster_size, buf= , 0); if (ret < 0) { goto finish; } @@ -575,7 +575,7 @@ static Qcow2BitmapList *bitmap_list_load(BlockDriverSta= te *bs, uint64_t offset, } dir_end =3D dir + size; =20 - ret =3D bdrv_pread(bs->file, offset, dir, size, 0); + ret =3D bdrv_pread(bs->file, offset, size, dir, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read bitmap directory"); goto fail; @@ -798,7 +798,7 @@ static int bitmap_list_store(BlockDriverState *bs, Qcow= 2BitmapList *bm_list, goto fail; } =20 - ret =3D bdrv_pwrite(bs->file, dir_offset, dir, dir_size, 0); + ret =3D bdrv_pwrite(bs->file, dir_offset, dir_size, dir, 0); if (ret < 0) { goto fail; } @@ -1339,7 +1339,7 @@ static uint64_t *store_bitmap_data(BlockDriverState *= bs, goto fail; } =20 - ret =3D bdrv_pwrite(bs->file, off, buf, s->cluster_size, 0); + ret =3D bdrv_pwrite(bs->file, off, s->cluster_size, buf, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to write bitmap '%s' to f= ile", bm_name); @@ -1402,7 +1402,7 @@ static int store_bitmap(BlockDriverState *bs, Qcow2Bi= tmap *bm, Error **errp) } =20 bitmap_table_to_be(tb, tb_size); - ret =3D bdrv_pwrite(bs->file, tb_offset, tb, tb_size * sizeof(tb[0]), = 0); + ret =3D bdrv_pwrite(bs->file, tb_offset, tb_size * sizeof(tb[0]), tb, = 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to write bitmap '%s' to file", bm_name); diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index e562e00c5c..54b2d5f4de 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -223,8 +223,8 @@ static int qcow2_cache_entry_flush(BlockDriverState *bs= , Qcow2Cache *c, int i) BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE); } =20 - ret =3D bdrv_pwrite(bs->file, c->entries[i].offset, - qcow2_cache_get_table_addr(c, i), c->table_size, 0); + ret =3D bdrv_pwrite(bs->file, c->entries[i].offset, c->table_size, + qcow2_cache_get_table_addr(c, i), 0); if (ret < 0) { return ret; } @@ -379,8 +379,8 @@ static int qcow2_cache_do_get(BlockDriverState *bs, Qco= w2Cache *c, BLKDBG_EVENT(bs->file, BLKDBG_L2_LOAD); } =20 - ret =3D bdrv_pread(bs->file, offset, qcow2_cache_get_table_addr(c,= i), - c->table_size, 0); + ret =3D bdrv_pread(bs->file, offset, c->table_size, + qcow2_cache_get_table_addr(c, i), 0); if (ret < 0) { return ret; } diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index ad7107a795..fd32316d6f 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -159,8 +159,8 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t = min_size, BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_WRITE_TABLE); for(i =3D 0; i < s->l1_size; i++) new_l1_table[i] =3D cpu_to_be64(new_l1_table[i]); - ret =3D bdrv_pwrite_sync(bs->file, new_l1_table_offset, new_l1_table, - new_l1_size2, 0); + ret =3D bdrv_pwrite_sync(bs->file, new_l1_table_offset, new_l1_size2, + new_l1_table, 0); if (ret < 0) goto fail; for(i =3D 0; i < s->l1_size; i++) @@ -170,8 +170,8 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t = min_size, BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_ACTIVATE_TABLE); stl_be_p(data, new_l1_size); stq_be_p(data + 4, new_l1_table_offset); - ret =3D bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, l1_size), data, - sizeof(data), 0); + ret =3D bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, l1_size), + sizeof(data), data, 0); if (ret < 0) { goto fail; } @@ -249,7 +249,7 @@ int qcow2_write_l1_entry(BlockDriverState *bs, int l1_i= ndex) BLKDBG_EVENT(bs->file, BLKDBG_L1_UPDATE); ret =3D bdrv_pwrite_sync(bs->file, s->l1_table_offset + L1E_SIZE * l1_start_index, - buf, bufsize, 0); + bufsize, buf, 0); if (ret < 0) { return ret; } @@ -2260,8 +2260,8 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, (void **)&l2_slice); } else { /* load inactive L2 tables from disk */ - ret =3D bdrv_pread(bs->file, slice_offset, l2_slice, - slice_size2, 0); + ret =3D bdrv_pread(bs->file, slice_offset, slice_size2, + l2_slice, 0); } if (ret < 0) { goto fail; @@ -2377,8 +2377,8 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, goto fail; } =20 - ret =3D bdrv_pwrite(bs->file, slice_offset, l2_slice, - slice_size2, 0); + ret =3D bdrv_pwrite(bs->file, slice_offset, slice_size= 2, + l2_slice, 0); if (ret < 0) { goto fail; } @@ -2471,8 +2471,8 @@ int qcow2_expand_zero_clusters(BlockDriverState *bs, =20 l1_table =3D new_l1_table; =20 - ret =3D bdrv_pread(bs->file, s->snapshots[i].l1_table_offset, l1_t= able, - l1_size2, 0); + ret =3D bdrv_pread(bs->file, s->snapshots[i].l1_table_offset, l1_s= ize2, + l1_table, 0); if (ret < 0) { goto fail; } diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 5aa2b61b6c..c4d99817b6 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -119,7 +119,7 @@ int qcow2_refcount_init(BlockDriverState *bs) } BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_LOAD); ret =3D bdrv_pread(bs->file, s->refcount_table_offset, - s->refcount_table, refcount_table_size2, 0); + refcount_table_size2, s->refcount_table, 0); if (ret < 0) { goto fail; } @@ -439,7 +439,7 @@ static int alloc_refcount_block(BlockDriverState *bs, BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP); ret =3D bdrv_pwrite_sync(bs->file, s->refcount_table_offset + refcount_table_index * REFTABLE_ENTRY_SIZE, - &data64, sizeof(data64), 0); + sizeof(data64), &data64, 0); if (ret < 0) { goto fail; } @@ -684,8 +684,8 @@ int64_t qcow2_refcount_area(BlockDriverState *bs, uint6= 4_t start_offset, } =20 BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE); - ret =3D bdrv_pwrite_sync(bs->file, table_offset, new_table, - table_size * REFTABLE_ENTRY_SIZE, 0); + ret =3D bdrv_pwrite_sync(bs->file, table_offset, + table_size * REFTABLE_ENTRY_SIZE, new_table, 0); if (ret < 0) { goto fail; } @@ -703,8 +703,8 @@ int64_t qcow2_refcount_area(BlockDriverState *bs, uint6= 4_t start_offset, data.d32 =3D cpu_to_be32(table_clusters); BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE); ret =3D bdrv_pwrite_sync(bs->file, - offsetof(QCowHeader, refcount_table_offset), &d= ata, - sizeof(data), 0); + offsetof(QCowHeader, refcount_table_offset), + sizeof(data), &data, 0); if (ret < 0) { goto fail; } @@ -1274,7 +1274,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *= bs, } l1_allocated =3D true; =20 - ret =3D bdrv_pread(bs->file, l1_table_offset, l1_table, l1_size2, = 0); + ret =3D bdrv_pread(bs->file, l1_table_offset, l1_size2, l1_table, = 0); if (ret < 0) { goto fail; } @@ -1435,7 +1435,7 @@ fail: cpu_to_be64s(&l1_table[i]); } =20 - ret =3D bdrv_pwrite_sync(bs->file, l1_table_offset, l1_table, l1_s= ize2, + ret =3D bdrv_pwrite_sync(bs->file, l1_table_offset, l1_size2, l1_t= able, 0); =20 for (i =3D 0; i < l1_size; i++) { @@ -1633,8 +1633,8 @@ static int fix_l2_entry_by_zero(BlockDriverState *bs,= BdrvCheckResult *res, goto fail; } =20 - ret =3D bdrv_pwrite_sync(bs->file, l2e_offset, &l2_table[idx], - l2_entry_size(s), 0); + ret =3D bdrv_pwrite_sync(bs->file, l2e_offset, l2_entry_size(s), + &l2_table[idx], 0); if (ret < 0) { fprintf(stderr, "ERROR: Failed to overwrite L2 " "table entry: %s\n", strerror(-ret)); @@ -1672,7 +1672,7 @@ static int check_refcounts_l2(BlockDriverState *bs, B= drvCheckResult *res, bool metadata_overlap; =20 /* Read L2 table from disk */ - ret =3D bdrv_pread(bs->file, l2_offset, l2_table, l2_size_bytes, 0); + ret =3D bdrv_pread(bs->file, l2_offset, l2_size_bytes, l2_table, 0); if (ret < 0) { fprintf(stderr, "ERROR: I/O error in check_refcounts_l2\n"); res->check_errors++; @@ -1888,7 +1888,7 @@ static int check_refcounts_l1(BlockDriverState *bs, } =20 /* Read L1 table entries from disk */ - ret =3D bdrv_pread(bs->file, l1_table_offset, l1_table, l1_size_bytes,= 0); + ret =3D bdrv_pread(bs->file, l1_table_offset, l1_size_bytes, l1_table,= 0); if (ret < 0) { fprintf(stderr, "ERROR: I/O error in check_refcounts_l1\n"); res->check_errors++; @@ -2004,8 +2004,8 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, } } =20 - ret =3D bdrv_pread(bs->file, l2_offset, l2_table, - s->l2_size * l2_entry_size(s), 0); + ret =3D bdrv_pread(bs->file, l2_offset, s->l2_size * l2_entry_size= (s), + l2_table, 0); if (ret < 0) { fprintf(stderr, "ERROR: Could not read L2 table: %s\n", strerror(-ret)); @@ -2058,7 +2058,7 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, goto fail; } =20 - ret =3D bdrv_pwrite(bs->file, l2_offset, l2_table, s->cluster_= size, + ret =3D bdrv_pwrite(bs->file, l2_offset, s->cluster_size, l2_t= able, 0); if (ret < 0) { fprintf(stderr, "ERROR: Could not write L2 table: %s\n", @@ -2577,8 +2577,8 @@ static int rebuild_refcounts_write_refblocks( on_disk_refblock =3D (void *)((char *) *refcount_table + refblock_index * s->cluster_size); =20 - ret =3D bdrv_pwrite(bs->file, refblock_offset, on_disk_refblock, - s->cluster_size, 0); + ret =3D bdrv_pwrite(bs->file, refblock_offset, s->cluster_size, + on_disk_refblock, 0); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR writing refblock"); return ret; @@ -2733,8 +2733,8 @@ static int rebuild_refcount_structure(BlockDriverStat= e *bs, } =20 assert(reftable_length < INT_MAX); - ret =3D bdrv_pwrite(bs->file, reftable_offset, on_disk_reftable, - reftable_length, 0); + ret =3D bdrv_pwrite(bs->file, reftable_offset, reftable_length, + on_disk_reftable, 0); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR writing reftable"); goto fail; @@ -2746,8 +2746,8 @@ static int rebuild_refcount_structure(BlockDriverStat= e *bs, cpu_to_be32(reftable_clusters); ret =3D bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, refcount_table_offset), - &reftable_offset_and_clusters, - sizeof(reftable_offset_and_clusters), 0); + sizeof(reftable_offset_and_clusters), + &reftable_offset_and_clusters, 0); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR setting reftable"); goto fail; @@ -3009,7 +3009,7 @@ int qcow2_check_metadata_overlap(BlockDriverState *bs= , int ign, int64_t offset, return -ENOMEM; } =20 - ret =3D bdrv_pread(bs->file, l1_ofs, l1, l1_sz2, 0); + ret =3D bdrv_pread(bs->file, l1_ofs, l1_sz2, l1, 0); if (ret < 0) { g_free(l1); return ret; @@ -3180,7 +3180,7 @@ static int flush_refblock(BlockDriverState *bs, uint6= 4_t **reftable, return ret; } =20 - ret =3D bdrv_pwrite(bs->file, offset, refblock, s->cluster_size, 0= ); + ret =3D bdrv_pwrite(bs->file, offset, s->cluster_size, refblock, 0= ); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to write refblock"); return ret; @@ -3452,8 +3452,9 @@ int qcow2_change_refcount_order(BlockDriverState *bs,= int refcount_order, cpu_to_be64s(&new_reftable[i]); } =20 - ret =3D bdrv_pwrite(bs->file, new_reftable_offset, new_reftable, - new_reftable_size * REFTABLE_ENTRY_SIZE, 0); + ret =3D bdrv_pwrite(bs->file, new_reftable_offset, + new_reftable_size * REFTABLE_ENTRY_SIZE, new_reftabl= e, + 0); =20 for (i =3D 0; i < new_reftable_size; i++) { be64_to_cpus(&new_reftable[i]); @@ -3656,8 +3657,9 @@ int qcow2_shrink_reftable(BlockDriverState *bs) reftable_tmp[i] =3D unused_block ? 0 : cpu_to_be64(s->refcount_tab= le[i]); } =20 - ret =3D bdrv_pwrite_sync(bs->file, s->refcount_table_offset, reftable_= tmp, - s->refcount_table_size * REFTABLE_ENTRY_SIZE, 0= ); + ret =3D bdrv_pwrite_sync(bs->file, s->refcount_table_offset, + s->refcount_table_size * REFTABLE_ENTRY_SIZE, + reftable_tmp, 0); /* * If the write in the reftable failed the image may contain a partial= ly * overwritten reftable. In this case it would be better to clear the diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index dc62b0197c..60e0461632 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -108,7 +108,7 @@ static int qcow2_do_read_snapshots(BlockDriverState *bs= , bool repair, =20 /* Read statically sized part of the snapshot header */ offset =3D ROUND_UP(offset, 8); - ret =3D bdrv_pread(bs->file, offset, &h, sizeof(h), 0); + ret =3D bdrv_pread(bs->file, offset, sizeof(h), &h, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read snapshot table"); goto fail; @@ -146,8 +146,8 @@ static int qcow2_do_read_snapshots(BlockDriverState *bs= , bool repair, } =20 /* Read known extra data */ - ret =3D bdrv_pread(bs->file, offset, &extra, - MIN(sizeof(extra), sn->extra_data_size), 0); + ret =3D bdrv_pread(bs->file, offset, + MIN(sizeof(extra), sn->extra_data_size), &extra, = 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read snapshot table"); goto fail; @@ -184,8 +184,8 @@ static int qcow2_do_read_snapshots(BlockDriverState *bs= , bool repair, /* Store unknown extra data */ unknown_extra_data_size =3D sn->extra_data_size - sizeof(extra= ); sn->unknown_extra_data =3D g_malloc(unknown_extra_data_size); - ret =3D bdrv_pread(bs->file, offset, sn->unknown_extra_data, - unknown_extra_data_size, 0); + ret =3D bdrv_pread(bs->file, offset, unknown_extra_data_size, + sn->unknown_extra_data, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read snapshot table"); @@ -196,7 +196,7 @@ static int qcow2_do_read_snapshots(BlockDriverState *bs= , bool repair, =20 /* Read snapshot ID */ sn->id_str =3D g_malloc(id_str_size + 1); - ret =3D bdrv_pread(bs->file, offset, sn->id_str, id_str_size, 0); + ret =3D bdrv_pread(bs->file, offset, id_str_size, sn->id_str, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read snapshot table"); goto fail; @@ -206,7 +206,7 @@ static int qcow2_do_read_snapshots(BlockDriverState *bs= , bool repair, =20 /* Read snapshot name */ sn->name =3D g_malloc(name_size + 1); - ret =3D bdrv_pread(bs->file, offset, sn->name, name_size, 0); + ret =3D bdrv_pread(bs->file, offset, name_size, sn->name, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read snapshot table"); goto fail; @@ -349,13 +349,13 @@ int qcow2_write_snapshots(BlockDriverState *bs) h.name_size =3D cpu_to_be16(name_size); offset =3D ROUND_UP(offset, 8); =20 - ret =3D bdrv_pwrite(bs->file, offset, &h, sizeof(h), 0); + ret =3D bdrv_pwrite(bs->file, offset, sizeof(h), &h, 0); if (ret < 0) { goto fail; } offset +=3D sizeof(h); =20 - ret =3D bdrv_pwrite(bs->file, offset, &extra, sizeof(extra), 0); + ret =3D bdrv_pwrite(bs->file, offset, sizeof(extra), &extra, 0); if (ret < 0) { goto fail; } @@ -369,21 +369,21 @@ int qcow2_write_snapshots(BlockDriverState *bs) assert(unknown_extra_data_size <=3D BDRV_REQUEST_MAX_BYTES); assert(sn->unknown_extra_data); =20 - ret =3D bdrv_pwrite(bs->file, offset, sn->unknown_extra_data, - unknown_extra_data_size, 0); + ret =3D bdrv_pwrite(bs->file, offset, unknown_extra_data_size, + sn->unknown_extra_data, 0); if (ret < 0) { goto fail; } offset +=3D unknown_extra_data_size; } =20 - ret =3D bdrv_pwrite(bs->file, offset, sn->id_str, id_str_size, 0); + ret =3D bdrv_pwrite(bs->file, offset, id_str_size, sn->id_str, 0); if (ret < 0) { goto fail; } offset +=3D id_str_size; =20 - ret =3D bdrv_pwrite(bs->file, offset, sn->name, name_size, 0); + ret =3D bdrv_pwrite(bs->file, offset, name_size, sn->name, 0); if (ret < 0) { goto fail; } @@ -406,7 +406,7 @@ int qcow2_write_snapshots(BlockDriverState *bs) header_data.snapshots_offset =3D cpu_to_be64(snapshots_offset); =20 ret =3D bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, nb_snapshots), - &header_data, sizeof(header_data), 0); + sizeof(header_data), &header_data, 0); if (ret < 0) { goto fail; } @@ -442,7 +442,7 @@ int coroutine_fn qcow2_check_read_snapshot_table(BlockD= riverState *bs, =20 /* qcow2_do_open() discards this information in check mode */ ret =3D bdrv_pread(bs->file, offsetof(QCowHeader, nb_snapshots), - &snapshot_table_pointer, sizeof(snapshot_table_pointe= r), + sizeof(snapshot_table_pointer), &snapshot_table_point= er, 0); if (ret < 0) { result->check_errors++; @@ -513,8 +513,8 @@ int coroutine_fn qcow2_check_read_snapshot_table(BlockD= riverState *bs, =20 snapshot_table_pointer.nb_snapshots =3D cpu_to_be32(s->nb_snapshot= s); ret =3D bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, nb_snapsho= ts), - &snapshot_table_pointer.nb_snapshots, - sizeof(snapshot_table_pointer.nb_snapshots)= , 0); + sizeof(snapshot_table_pointer.nb_snapshots), + &snapshot_table_pointer.nb_snapshots, 0); if (ret < 0) { result->check_errors++; fprintf(stderr, "ERROR failed to update the snapshot count in = the " @@ -694,8 +694,8 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSna= pshotInfo *sn_info) goto fail; } =20 - ret =3D bdrv_pwrite(bs->file, sn->l1_table_offset, l1_table, - s->l1_size * L1E_SIZE, 0); + ret =3D bdrv_pwrite(bs->file, sn->l1_table_offset, s->l1_size * L1E_SI= ZE, + l1_table, 0); if (ret < 0) { goto fail; } @@ -830,7 +830,7 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const cha= r *snapshot_id) goto fail; } =20 - ret =3D bdrv_pread(bs->file, sn->l1_table_offset, sn_l1_table, sn_l1_b= ytes, + ret =3D bdrv_pread(bs->file, sn->l1_table_offset, sn_l1_bytes, sn_l1_t= able, 0); if (ret < 0) { goto fail; @@ -849,8 +849,8 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const cha= r *snapshot_id) goto fail; } =20 - ret =3D bdrv_pwrite_sync(bs->file, s->l1_table_offset, sn_l1_table, - cur_l1_bytes, 0); + ret =3D bdrv_pwrite_sync(bs->file, s->l1_table_offset, cur_l1_bytes, + sn_l1_table, 0); if (ret < 0) { goto fail; } @@ -1052,8 +1052,8 @@ int qcow2_snapshot_load_tmp(BlockDriverState *bs, return -ENOMEM; } =20 - ret =3D bdrv_pread(bs->file, sn->l1_table_offset, new_l1_table, - new_l1_bytes, 0); + ret =3D bdrv_pread(bs->file, sn->l1_table_offset, new_l1_bytes, + new_l1_table, 0); if (ret < 0) { error_setg(errp, "Failed to read l1 table for snapshot"); qemu_vfree(new_l1_table); diff --git a/block/qcow2.c b/block/qcow2.c index 99192d1242..5493e6b847 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -107,7 +107,7 @@ static ssize_t qcow2_crypto_hdr_read_func(QCryptoBlock = *block, size_t offset, return -1; } =20 - ret =3D bdrv_pread(bs->file, s->crypto_header.offset + offset, buf, bu= flen, + ret =3D bdrv_pread(bs->file, s->crypto_header.offset + offset, buflen,= buf, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read encryption header"); @@ -168,7 +168,7 @@ static ssize_t qcow2_crypto_hdr_write_func(QCryptoBlock= *block, size_t offset, return -1; } =20 - ret =3D bdrv_pwrite(bs->file, s->crypto_header.offset + offset, buf, b= uflen, + ret =3D bdrv_pwrite(bs->file, s->crypto_header.offset + offset, buflen= , buf, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read encryption header"); @@ -227,7 +227,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, = uint64_t start_offset, printf("attempting to read extended header in offset %lu\n", offse= t); #endif =20 - ret =3D bdrv_pread(bs->file, offset, &ext, sizeof(ext), 0); + ret =3D bdrv_pread(bs->file, offset, sizeof(ext), &ext, 0); if (ret < 0) { error_setg_errno(errp, -ret, "qcow2_read_extension: ERROR: " "pread fail from offset %" PRIu64, offset); @@ -255,7 +255,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, = uint64_t start_offset, sizeof(bs->backing_format)); return 2; } - ret =3D bdrv_pread(bs->file, offset, bs->backing_format, ext.l= en, 0); + ret =3D bdrv_pread(bs->file, offset, ext.len, bs->backing_form= at, 0); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR: ext_backing_format: " "Could not read format name"); @@ -271,7 +271,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, = uint64_t start_offset, case QCOW2_EXT_MAGIC_FEATURE_TABLE: if (p_feature_table !=3D NULL) { void *feature_table =3D g_malloc0(ext.len + 2 * sizeof(Qco= w2Feature)); - ret =3D bdrv_pread(bs->file, offset, feature_table, ext.le= n, 0); + ret =3D bdrv_pread(bs->file, offset, ext.len, feature_tabl= e, 0); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR: ext_feature_table= : " "Could not read table"); @@ -296,7 +296,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, = uint64_t start_offset, return -EINVAL; } =20 - ret =3D bdrv_pread(bs->file, offset, &s->crypto_header, ext.le= n, 0); + ret =3D bdrv_pread(bs->file, offset, ext.len, &s->crypto_heade= r, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Unable to read CRYPTO header extension"); @@ -352,7 +352,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, = uint64_t start_offset, break; } =20 - ret =3D bdrv_pread(bs->file, offset, &bitmaps_ext, ext.len, 0); + ret =3D bdrv_pread(bs->file, offset, ext.len, &bitmaps_ext, 0); if (ret < 0) { error_setg_errno(errp, -ret, "bitmaps_ext: " "Could not read ext header"); @@ -416,7 +416,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, = uint64_t start_offset, case QCOW2_EXT_MAGIC_DATA_FILE: { s->image_data_file =3D g_malloc0(ext.len + 1); - ret =3D bdrv_pread(bs->file, offset, s->image_data_file, ext.l= en, 0); + ret =3D bdrv_pread(bs->file, offset, ext.len, s->image_data_fi= le, 0); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR: Could not read data file name"); @@ -440,7 +440,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, = uint64_t start_offset, uext->len =3D ext.len; QLIST_INSERT_HEAD(&s->unknown_header_ext, uext, next); =20 - ret =3D bdrv_pread(bs->file, offset, uext->data, uext->len= , 0); + ret =3D bdrv_pread(bs->file, offset, uext->len, uext->data= , 0); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR: unknown extension= : " "Could not read data"); @@ -517,7 +517,7 @@ int qcow2_mark_dirty(BlockDriverState *bs) =20 val =3D cpu_to_be64(s->incompatible_features | QCOW2_INCOMPAT_DIRTY); ret =3D bdrv_pwrite(bs->file, offsetof(QCowHeader, incompatible_featur= es), - &val, sizeof(val), 0); + sizeof(val), &val, 0); if (ret < 0) { return ret; } @@ -1308,7 +1308,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverStat= e *bs, QDict *options, uint64_t l1_vm_state_index; bool update_header =3D false; =20 - ret =3D bdrv_pread(bs->file, 0, &header, sizeof(header), 0); + ret =3D bdrv_pread(bs->file, 0, sizeof(header), &header, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read qcow2 header"); goto fail; @@ -1384,8 +1384,9 @@ static int coroutine_fn qcow2_do_open(BlockDriverStat= e *bs, QDict *options, if (header.header_length > sizeof(header)) { s->unknown_header_fields_size =3D header.header_length - sizeof(he= ader); s->unknown_header_fields =3D g_malloc(s->unknown_header_fields_siz= e); - ret =3D bdrv_pread(bs->file, sizeof(header), s->unknown_header_fie= lds, - s->unknown_header_fields_size, 0); + ret =3D bdrv_pread(bs->file, sizeof(header), + s->unknown_header_fields_size, + s->unknown_header_fields, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read unknown qcow2 hea= der " "fields"); @@ -1580,8 +1581,8 @@ static int coroutine_fn qcow2_do_open(BlockDriverStat= e *bs, QDict *options, ret =3D -ENOMEM; goto fail; } - ret =3D bdrv_pread(bs->file, s->l1_table_offset, s->l1_table, - s->l1_size * L1E_SIZE, 0); + ret =3D bdrv_pread(bs->file, s->l1_table_offset, s->l1_size * L1E_= SIZE, + s->l1_table, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read L1 table"); goto fail; @@ -1698,8 +1699,8 @@ static int coroutine_fn qcow2_do_open(BlockDriverStat= e *bs, QDict *options, ret =3D -EINVAL; goto fail; } - ret =3D bdrv_pread(bs->file, header.backing_file_offset, - bs->auto_backing_file, len, 0); + ret =3D bdrv_pread(bs->file, header.backing_file_offset, len, + bs->auto_backing_file, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read backing file name= "); goto fail; @@ -3081,7 +3082,7 @@ int qcow2_update_header(BlockDriverState *bs) } =20 /* Write the new header */ - ret =3D bdrv_pwrite(bs->file, 0, header, s->cluster_size, 0); + ret =3D bdrv_pwrite(bs->file, 0, s->cluster_size, header, 0); if (ret < 0) { goto fail; } @@ -4550,8 +4551,8 @@ static int coroutine_fn qcow2_co_truncate(BlockDriver= State *bs, int64_t offset, =20 /* write updated header.size */ offset =3D cpu_to_be64(offset); - ret =3D bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, size), &offset, - sizeof(offset), 0); + ret =3D bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, size), + sizeof(offset), &offset, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to update the image size"); goto fail; @@ -4828,7 +4829,7 @@ static int make_completely_empty(BlockDriverState *bs) l1_ofs_rt_ofs_cls.reftable_offset =3D cpu_to_be64(s->cluster_size); l1_ofs_rt_ofs_cls.reftable_clusters =3D cpu_to_be32(1); ret =3D bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, l1_table_offse= t), - &l1_ofs_rt_ofs_cls, sizeof(l1_ofs_rt_ofs_cls), = 0); + sizeof(l1_ofs_rt_ofs_cls), &l1_ofs_rt_ofs_cls, = 0); if (ret < 0) { goto fail_broken_refcounts; } @@ -4859,8 +4860,8 @@ static int make_completely_empty(BlockDriverState *bs) =20 /* Enter the first refblock into the reftable */ rt_entry =3D cpu_to_be64(2 * s->cluster_size); - ret =3D bdrv_pwrite_sync(bs->file, s->cluster_size, &rt_entry, - sizeof(rt_entry), 0); + ret =3D bdrv_pwrite_sync(bs->file, s->cluster_size, sizeof(rt_entry), + &rt_entry, 0); if (ret < 0) { goto fail_broken_refcounts; } diff --git a/block/qed.c b/block/qed.c index ad86079941..ba93e99570 100644 --- a/block/qed.c +++ b/block/qed.c @@ -90,7 +90,7 @@ int qed_write_header_sync(BDRVQEDState *s) int ret; =20 qed_header_cpu_to_le(&s->header, &le); - ret =3D bdrv_pwrite(s->bs->file, 0, &le, sizeof(le), 0); + ret =3D bdrv_pwrite(s->bs->file, 0, sizeof(le), &le, 0); if (ret !=3D sizeof(le)) { return ret; } @@ -207,7 +207,7 @@ static int qed_read_string(BdrvChild *file, uint64_t of= fset, size_t n, if (n >=3D buflen) { return -EINVAL; } - ret =3D bdrv_pread(file, offset, buf, n, 0); + ret =3D bdrv_pread(file, offset, n, buf, 0); if (ret < 0) { return ret; } @@ -392,7 +392,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverSta= te *bs, QDict *options, int64_t file_size; int ret; =20 - ret =3D bdrv_pread(bs->file, 0, &le_header, sizeof(le_header), 0); + ret =3D bdrv_pread(bs->file, 0, sizeof(le_header), &le_header, 0); if (ret < 0) { error_setg(errp, "Failed to read QED header"); return ret; @@ -1545,7 +1545,7 @@ static int bdrv_qed_change_backing_file(BlockDriverSt= ate *bs, } =20 /* Write new header */ - ret =3D bdrv_pwrite_sync(bs->file, 0, buffer, buffer_len, 0); + ret =3D bdrv_pwrite_sync(bs->file, 0, buffer_len, buffer, 0); g_free(buffer); if (ret =3D=3D 0) { memcpy(&s->header, &new_header, sizeof(new_header)); diff --git a/block/vdi.c b/block/vdi.c index 76cec1b883..9ef55a117a 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -385,7 +385,7 @@ static int vdi_open(BlockDriverState *bs, QDict *option= s, int flags, =20 logout("\n"); =20 - ret =3D bdrv_pread(bs->file, 0, &header, sizeof(header), 0); + ret =3D bdrv_pread(bs->file, 0, sizeof(header), &header, 0); if (ret < 0) { goto fail; } @@ -485,8 +485,8 @@ static int vdi_open(BlockDriverState *bs, QDict *option= s, int flags, goto fail; } =20 - ret =3D bdrv_pread(bs->file, header.offset_bmap, s->bmap, - bmap_size * SECTOR_SIZE, 0); + ret =3D bdrv_pread(bs->file, header.offset_bmap, bmap_size * SECTOR_SI= ZE, + s->bmap, 0); if (ret < 0) { goto fail_free_bmap; } @@ -664,7 +664,7 @@ vdi_co_pwritev(BlockDriverState *bs, int64_t offset, in= t64_t bytes, * so this full-cluster write does not overlap a partial write * of the same cluster, issued from the "else" branch. */ - ret =3D bdrv_pwrite(bs->file, data_offset, block, s->block_siz= e, 0); + ret =3D bdrv_pwrite(bs->file, data_offset, s->block_size, bloc= k, 0); qemu_co_rwlock_unlock(&s->bmap_lock); } else { nonallocating_write: @@ -709,7 +709,7 @@ nonallocating_write: assert(VDI_IS_ALLOCATED(bmap_first)); *header =3D s->header; vdi_header_to_le(header); - ret =3D bdrv_pwrite(bs->file, 0, header, sizeof(*header), 0); + ret =3D bdrv_pwrite(bs->file, 0, sizeof(*header), header, 0); g_free(header); =20 if (ret < 0) { @@ -726,8 +726,8 @@ nonallocating_write: base =3D ((uint8_t *)&s->bmap[0]) + bmap_first * SECTOR_SIZE; logout("will write %u block map sectors starting from entry %u\n", n_sectors, bmap_first); - ret =3D bdrv_pwrite(bs->file, offset * SECTOR_SIZE, base, - n_sectors * SECTOR_SIZE, 0); + ret =3D bdrv_pwrite(bs->file, offset * SECTOR_SIZE, + n_sectors * SECTOR_SIZE, base, 0); } =20 return ret < 0 ? ret : 0; diff --git a/block/vhdx-log.c b/block/vhdx-log.c index da0057000b..572582b87b 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -84,7 +84,7 @@ static int vhdx_log_peek_hdr(BlockDriverState *bs, VHDXLo= gEntries *log, =20 offset =3D log->offset + read; =20 - ret =3D bdrv_pread(bs->file, offset, hdr, sizeof(VHDXLogEntryHeader), = 0); + ret =3D bdrv_pread(bs->file, offset, sizeof(VHDXLogEntryHeader), hdr, = 0); if (ret < 0) { goto exit; } @@ -144,7 +144,7 @@ static int vhdx_log_read_sectors(BlockDriverState *bs, = VHDXLogEntries *log, } offset =3D log->offset + read; =20 - ret =3D bdrv_pread(bs->file, offset, buffer, VHDX_LOG_SECTOR_SIZE,= 0); + ret =3D bdrv_pread(bs->file, offset, VHDX_LOG_SECTOR_SIZE, buffer,= 0); if (ret < 0) { goto exit; } @@ -194,7 +194,7 @@ static int vhdx_log_write_sectors(BlockDriverState *bs,= VHDXLogEntries *log, /* full */ break; } - ret =3D bdrv_pwrite(bs->file, offset, buffer_tmp, VHDX_LOG_SECTOR_= SIZE, + ret =3D bdrv_pwrite(bs->file, offset, VHDX_LOG_SECTOR_SIZE, buffer= _tmp, 0); if (ret < 0) { goto exit; @@ -466,8 +466,8 @@ static int vhdx_log_flush_desc(BlockDriverState *bs, VH= DXLogDescriptor *desc, =20 /* count is only > 1 if we are writing zeroes */ for (i =3D 0; i < count; i++) { - ret =3D bdrv_pwrite_sync(bs->file, file_offset, buffer, - VHDX_LOG_SECTOR_SIZE, 0); + ret =3D bdrv_pwrite_sync(bs->file, file_offset, VHDX_LOG_SECTOR_SI= ZE, + buffer, 0); if (ret < 0) { goto exit; } @@ -970,8 +970,8 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVHD= XState *s, =20 if (i =3D=3D 0 && leading_length) { /* partial sector at the front of the buffer */ - ret =3D bdrv_pread(bs->file, file_offset, merged_sector, - VHDX_LOG_SECTOR_SIZE, 0); + ret =3D bdrv_pread(bs->file, file_offset, VHDX_LOG_SECTOR_SIZE, + merged_sector, 0); if (ret < 0) { goto exit; } @@ -981,8 +981,8 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVHD= XState *s, } else if (i =3D=3D sectors - 1 && trailing_length) { /* partial sector at the end of the buffer */ ret =3D bdrv_pread(bs->file, file_offset, - merged_sector + trailing_length, - VHDX_LOG_SECTOR_SIZE - trailing_length, 0); + VHDX_LOG_SECTOR_SIZE - trailing_length, + merged_sector + trailing_length, 0); if (ret < 0) { goto exit; } diff --git a/block/vhdx.c b/block/vhdx.c index f5c812c9cf..12f5261f80 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -326,7 +326,7 @@ static int vhdx_write_header(BdrvChild *file, VHDXHeade= r *hdr, buffer =3D qemu_blockalign(bs_file, VHDX_HEADER_SIZE); if (read) { /* if true, we can't assume the extra reserved bytes are 0 */ - ret =3D bdrv_pread(file, offset, buffer, VHDX_HEADER_SIZE, 0); + ret =3D bdrv_pread(file, offset, VHDX_HEADER_SIZE, buffer, 0); if (ret < 0) { goto exit; } @@ -340,7 +340,7 @@ static int vhdx_write_header(BdrvChild *file, VHDXHeade= r *hdr, vhdx_header_le_export(hdr, header_le); vhdx_update_checksum(buffer, VHDX_HEADER_SIZE, offsetof(VHDXHeader, checksum)); - ret =3D bdrv_pwrite_sync(file, offset, header_le, sizeof(VHDXHeader), = 0); + ret =3D bdrv_pwrite_sync(file, offset, sizeof(VHDXHeader), header_le, = 0); =20 exit: qemu_vfree(buffer); @@ -440,7 +440,7 @@ static void vhdx_parse_header(BlockDriverState *bs, BDR= VVHDXState *s, /* We have to read the whole VHDX_HEADER_SIZE instead of * sizeof(VHDXHeader), because the checksum is over the whole * region */ - ret =3D bdrv_pread(bs->file, VHDX_HEADER1_OFFSET, buffer, VHDX_HEADER_= SIZE, + ret =3D bdrv_pread(bs->file, VHDX_HEADER1_OFFSET, VHDX_HEADER_SIZE, bu= ffer, 0); if (ret < 0) { goto fail; @@ -457,7 +457,7 @@ static void vhdx_parse_header(BlockDriverState *bs, BDR= VVHDXState *s, } } =20 - ret =3D bdrv_pread(bs->file, VHDX_HEADER2_OFFSET, buffer, VHDX_HEADER_= SIZE, + ret =3D bdrv_pread(bs->file, VHDX_HEADER2_OFFSET, VHDX_HEADER_SIZE, bu= ffer, 0); if (ret < 0) { goto fail; @@ -531,8 +531,8 @@ static int vhdx_open_region_tables(BlockDriverState *bs= , BDRVVHDXState *s) * whole block */ buffer =3D qemu_blockalign(bs, VHDX_HEADER_BLOCK_SIZE); =20 - ret =3D bdrv_pread(bs->file, VHDX_REGION_TABLE_OFFSET, buffer, - VHDX_HEADER_BLOCK_SIZE, 0); + ret =3D bdrv_pread(bs->file, VHDX_REGION_TABLE_OFFSET, + VHDX_HEADER_BLOCK_SIZE, buffer, 0); if (ret < 0) { goto fail; } @@ -644,8 +644,8 @@ static int vhdx_parse_metadata(BlockDriverState *bs, BD= RVVHDXState *s) =20 buffer =3D qemu_blockalign(bs, VHDX_METADATA_TABLE_MAX_SIZE); =20 - ret =3D bdrv_pread(bs->file, s->metadata_rt.file_offset, buffer, - VHDX_METADATA_TABLE_MAX_SIZE, 0); + ret =3D bdrv_pread(bs->file, s->metadata_rt.file_offset, + VHDX_METADATA_TABLE_MAX_SIZE, buffer, 0); if (ret < 0) { goto exit; } @@ -750,8 +750,8 @@ static int vhdx_parse_metadata(BlockDriverState *bs, BD= RVVHDXState *s) ret =3D bdrv_pread(bs->file, s->metadata_entries.file_parameters_entry.offset + s->metadata_rt.file_offset, - &s->params, sizeof(s->params), + &s->params, 0); =20 if (ret < 0) { @@ -786,8 +786,8 @@ static int vhdx_parse_metadata(BlockDriverState *bs, BD= RVVHDXState *s) ret =3D bdrv_pread(bs->file, s->metadata_entries.virtual_disk_size_entry.offset + s->metadata_rt.file_offset, - &s->virtual_disk_size, sizeof(uint64_t), + &s->virtual_disk_size, 0); if (ret < 0) { goto exit; @@ -795,8 +795,8 @@ static int vhdx_parse_metadata(BlockDriverState *bs, BD= RVVHDXState *s) ret =3D bdrv_pread(bs->file, s->metadata_entries.logical_sector_size_entry.offset + s->metadata_rt.file_offset, - &s->logical_sector_size, sizeof(uint32_t), + &s->logical_sector_size, 0); if (ret < 0) { goto exit; @@ -804,8 +804,8 @@ static int vhdx_parse_metadata(BlockDriverState *bs, BD= RVVHDXState *s) ret =3D bdrv_pread(bs->file, s->metadata_entries.phys_sector_size_entry.offset + s->metadata_rt.file_offset, - &s->physical_sector_size, sizeof(uint32_t), + &s->physical_sector_size, 0); if (ret < 0) { goto exit; @@ -1014,7 +1014,7 @@ static int vhdx_open(BlockDriverState *bs, QDict *opt= ions, int flags, QLIST_INIT(&s->regions); =20 /* validate the file signature */ - ret =3D bdrv_pread(bs->file, 0, &signature, sizeof(uint64_t), 0); + ret =3D bdrv_pread(bs->file, 0, sizeof(uint64_t), &signature, 0); if (ret < 0) { goto fail; } @@ -1073,7 +1073,7 @@ static int vhdx_open(BlockDriverState *bs, QDict *opt= ions, int flags, goto fail; } =20 - ret =3D bdrv_pread(bs->file, s->bat_offset, s->bat, s->bat_rt.length, = 0); + ret =3D bdrv_pread(bs->file, s->bat_offset, s->bat_rt.length, s->bat, = 0); if (ret < 0) { goto fail; } diff --git a/block/vmdk.c b/block/vmdk.c index 4ad09ca07b..aacea1095f 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -307,7 +307,7 @@ static int vmdk_read_cid(BlockDriverState *bs, int pare= nt, uint32_t *pcid) int ret; =20 desc =3D g_malloc0(DESC_SIZE); - ret =3D bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE, 0); + ret =3D bdrv_pread(bs->file, s->desc_offset, DESC_SIZE, desc, 0); if (ret < 0) { goto out; } @@ -348,7 +348,7 @@ static int vmdk_write_cid(BlockDriverState *bs, uint32_= t cid) =20 desc =3D g_malloc0(DESC_SIZE); tmp_desc =3D g_malloc0(DESC_SIZE); - ret =3D bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE, 0); + ret =3D bdrv_pread(bs->file, s->desc_offset, DESC_SIZE, desc, 0); if (ret < 0) { goto out; } @@ -368,7 +368,7 @@ static int vmdk_write_cid(BlockDriverState *bs, uint32_= t cid) pstrcat(desc, DESC_SIZE, tmp_desc); } =20 - ret =3D bdrv_pwrite_sync(bs->file, s->desc_offset, desc, DESC_SIZE, 0); + ret =3D bdrv_pwrite_sync(bs->file, s->desc_offset, DESC_SIZE, desc, 0); =20 out: g_free(desc); @@ -469,7 +469,7 @@ static int vmdk_parent_open(BlockDriverState *bs) int ret; =20 desc =3D g_malloc0(DESC_SIZE + 1); - ret =3D bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE, 0); + ret =3D bdrv_pread(bs->file, s->desc_offset, DESC_SIZE, desc, 0); if (ret < 0) { goto out; } @@ -589,8 +589,8 @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkE= xtent *extent, return -ENOMEM; } =20 - ret =3D bdrv_pread(extent->file, extent->l1_table_offset, extent->l1_t= able, - l1_size, 0); + ret =3D bdrv_pread(extent->file, extent->l1_table_offset, l1_size, + extent->l1_table, 0); if (ret < 0) { bdrv_refresh_filename(extent->file->bs); error_setg_errno(errp, -ret, @@ -615,7 +615,7 @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkE= xtent *extent, goto fail_l1; } ret =3D bdrv_pread(extent->file, extent->l1_backup_table_offset, - extent->l1_backup_table, l1_size, 0); + l1_size, extent->l1_backup_table, 0); if (ret < 0) { bdrv_refresh_filename(extent->file->bs); error_setg_errno(errp, -ret, @@ -647,7 +647,7 @@ static int vmdk_open_vmfs_sparse(BlockDriverState *bs, VMDK3Header header; VmdkExtent *extent =3D NULL; =20 - ret =3D bdrv_pread(file, sizeof(magic), &header, sizeof(header), 0); + ret =3D bdrv_pread(file, sizeof(magic), sizeof(header), &header, 0); if (ret < 0) { bdrv_refresh_filename(file->bs); error_setg_errno(errp, -ret, @@ -811,7 +811,7 @@ static int vmdk_open_se_sparse(BlockDriverState *bs, =20 assert(sizeof(const_header) =3D=3D SECTOR_SIZE); =20 - ret =3D bdrv_pread(file, 0, &const_header, sizeof(const_header), 0); + ret =3D bdrv_pread(file, 0, sizeof(const_header), &const_header, 0); if (ret < 0) { bdrv_refresh_filename(file->bs); error_setg_errno(errp, -ret, @@ -829,7 +829,7 @@ static int vmdk_open_se_sparse(BlockDriverState *bs, assert(sizeof(volatile_header) =3D=3D SECTOR_SIZE); =20 ret =3D bdrv_pread(file, const_header.volatile_header_offset * SECTOR_= SIZE, - &volatile_header, sizeof(volatile_header), 0); + sizeof(volatile_header), &volatile_header, 0); if (ret < 0) { bdrv_refresh_filename(file->bs); error_setg_errno(errp, -ret, @@ -899,7 +899,7 @@ static char *vmdk_read_desc(BdrvChild *file, uint64_t d= esc_offset, Error **errp) size =3D MIN(size, (1 << 20) - 1); /* avoid unbounded allocation */ buf =3D g_malloc(size + 1); =20 - ret =3D bdrv_pread(file, desc_offset, buf, size, 0); + ret =3D bdrv_pread(file, desc_offset, size, buf, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read from file"); g_free(buf); @@ -923,7 +923,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs, int64_t l1_backup_offset =3D 0; bool compressed; =20 - ret =3D bdrv_pread(file, sizeof(magic), &header, sizeof(header), 0); + ret =3D bdrv_pread(file, sizeof(magic), sizeof(header), &header, 0); if (ret < 0) { bdrv_refresh_filename(file->bs); error_setg_errno(errp, -ret, @@ -975,7 +975,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs, } QEMU_PACKED footer; =20 ret =3D bdrv_pread(file, bs->file->bs->total_sectors * 512 - 1536, - &footer, sizeof(footer), 0); + sizeof(footer), &footer, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read footer"); return ret; @@ -1442,16 +1442,16 @@ static int get_whole_cluster(BlockDriverState *bs, if (copy_from_backing) { /* qcow2 emits this on bs->file instead of bs->backing */ BLKDBG_EVENT(extent->file, BLKDBG_COW_READ); - ret =3D bdrv_pread(bs->backing, offset, whole_grain, - skip_start_bytes, 0); + ret =3D bdrv_pread(bs->backing, offset, skip_start_bytes, + whole_grain, 0); if (ret < 0) { ret =3D VMDK_ERROR; goto exit; } } BLKDBG_EVENT(extent->file, BLKDBG_COW_WRITE); - ret =3D bdrv_pwrite(extent->file, cluster_offset, whole_grain, - skip_start_bytes, 0); + ret =3D bdrv_pwrite(extent->file, cluster_offset, skip_start_bytes, + whole_grain, 0); if (ret < 0) { ret =3D VMDK_ERROR; goto exit; @@ -1463,8 +1463,8 @@ static int get_whole_cluster(BlockDriverState *bs, /* qcow2 emits this on bs->file instead of bs->backing */ BLKDBG_EVENT(extent->file, BLKDBG_COW_READ); ret =3D bdrv_pread(bs->backing, offset + skip_end_bytes, - whole_grain + skip_end_bytes, - cluster_bytes - skip_end_bytes, 0); + cluster_bytes - skip_end_bytes, + whole_grain + skip_end_bytes, 0); if (ret < 0) { ret =3D VMDK_ERROR; goto exit; @@ -1472,8 +1472,8 @@ static int get_whole_cluster(BlockDriverState *bs, } BLKDBG_EVENT(extent->file, BLKDBG_COW_WRITE); ret =3D bdrv_pwrite(extent->file, cluster_offset + skip_end_bytes, - whole_grain + skip_end_bytes, - cluster_bytes - skip_end_bytes, 0); + cluster_bytes - skip_end_bytes, + whole_grain + skip_end_bytes, 0); if (ret < 0) { ret =3D VMDK_ERROR; goto exit; @@ -1495,7 +1495,7 @@ static int vmdk_L2update(VmdkExtent *extent, VmdkMeta= Data *m_data, if (bdrv_pwrite(extent->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(offset)), - &offset, sizeof(offset), 0) < 0) { + sizeof(offset), &offset, 0) < 0) { return VMDK_ERROR; } /* update backup L2 table */ @@ -1504,7 +1504,7 @@ static int vmdk_L2update(VmdkExtent *extent, VmdkMeta= Data *m_data, if (bdrv_pwrite(extent->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(offset)), - &offset, sizeof(offset), 0) < 0) { + sizeof(offset), &offset, 0) < 0) { return VMDK_ERROR; } } @@ -1627,8 +1627,8 @@ static int get_cluster_offset(BlockDriverState *bs, BLKDBG_EVENT(extent->file, BLKDBG_L2_LOAD); if (bdrv_pread(extent->file, (int64_t)l2_offset * 512, - l2_table, l2_size_bytes, + l2_table, 0 ) !=3D l2_size_bytes) { return VMDK_ERROR; @@ -1898,7 +1898,7 @@ static int vmdk_read_extent(VmdkExtent *extent, int64= _t cluster_offset, cluster_buf =3D g_malloc(buf_bytes); uncomp_buf =3D g_malloc(cluster_bytes); BLKDBG_EVENT(extent->file, BLKDBG_READ_COMPRESSED); - ret =3D bdrv_pread(extent->file, cluster_offset, cluster_buf, buf_byte= s, 0); + ret =3D bdrv_pread(extent->file, cluster_offset, buf_bytes, cluster_bu= f, 0); if (ret < 0) { goto out; } diff --git a/block/vpc.c b/block/vpc.c index 1ccdfb0557..7f20820193 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -252,7 +252,7 @@ static int vpc_open(BlockDriverState *bs, QDict *option= s, int flags, goto fail; } =20 - ret =3D bdrv_pread(bs->file, 0, &s->footer, sizeof(s->footer), 0); + ret =3D bdrv_pread(bs->file, 0, sizeof(s->footer), &s->footer, 0); if (ret < 0) { error_setg(errp, "Unable to read VHD header"); goto fail; @@ -272,8 +272,8 @@ static int vpc_open(BlockDriverState *bs, QDict *option= s, int flags, } =20 /* If a fixed disk, the footer is found only at the end of the fil= e */ - ret =3D bdrv_pread(bs->file, offset - sizeof(*footer), footer, - sizeof(*footer), 0); + ret =3D bdrv_pread(bs->file, offset - sizeof(*footer), sizeof(*foo= ter), + footer, 0); if (ret < 0) { goto fail; } @@ -347,7 +347,7 @@ static int vpc_open(BlockDriverState *bs, QDict *option= s, int flags, =20 if (disk_type =3D=3D VHD_DYNAMIC) { ret =3D bdrv_pread(bs->file, be64_to_cpu(footer->data_offset), - &dyndisk_header, sizeof(dyndisk_header), 0); + sizeof(dyndisk_header), &dyndisk_header, 0); if (ret < 0) { error_setg(errp, "Error reading dynamic VHD header"); goto fail; @@ -401,8 +401,8 @@ static int vpc_open(BlockDriverState *bs, QDict *option= s, int flags, =20 s->bat_offset =3D be64_to_cpu(dyndisk_header.table_offset); =20 - ret =3D bdrv_pread(bs->file, s->bat_offset, s->pagetable, - pagetable_size, 0); + ret =3D bdrv_pread(bs->file, s->bat_offset, pagetable_size, + s->pagetable, 0); if (ret < 0) { error_setg(errp, "Error reading pagetable"); goto fail; @@ -516,7 +516,7 @@ static inline int64_t get_image_offset(BlockDriverState= *bs, uint64_t offset, =20 s->last_bitmap_offset =3D bitmap_offset; memset(bitmap, 0xff, s->bitmap_size); - r =3D bdrv_pwrite_sync(bs->file, bitmap_offset, bitmap, s->bitmap_= size, + r =3D bdrv_pwrite_sync(bs->file, bitmap_offset, s->bitmap_size, bi= tmap, 0); if (r < 0) { *err =3D r; @@ -539,7 +539,7 @@ static int rewrite_footer(BlockDriverState *bs) BDRVVPCState *s =3D bs->opaque; int64_t offset =3D s->free_data_block_offset; =20 - ret =3D bdrv_pwrite_sync(bs->file, offset, &s->footer, sizeof(s->foote= r), 0); + ret =3D bdrv_pwrite_sync(bs->file, offset, sizeof(s->footer), &s->foot= er, 0); if (ret < 0) return ret; =20 @@ -573,8 +573,8 @@ static int64_t alloc_block(BlockDriverState *bs, int64_= t offset) =20 /* Initialize the block's bitmap */ memset(bitmap, 0xff, s->bitmap_size); - ret =3D bdrv_pwrite_sync(bs->file, s->free_data_block_offset, bitmap, - s->bitmap_size, 0); + ret =3D bdrv_pwrite_sync(bs->file, s->free_data_block_offset, + s->bitmap_size, bitmap, 0); if (ret < 0) { return ret; } @@ -588,7 +588,7 @@ static int64_t alloc_block(BlockDriverState *bs, int64_= t offset) /* Write BAT entry to disk */ bat_offset =3D s->bat_offset + (4 * index); bat_value =3D cpu_to_be32(s->pagetable[index]); - ret =3D bdrv_pwrite_sync(bs->file, bat_offset, &bat_value, 4, 0); + ret =3D bdrv_pwrite_sync(bs->file, bat_offset, 4, &bat_value, 0); if (ret < 0) goto fail; =20 diff --git a/block/vvfat.c b/block/vvfat.c index 87595dfc69..d6dd919683 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1488,8 +1488,8 @@ static int vvfat_read(BlockDriverState *bs, int64_t s= ector_num, DLOG(fprintf(stderr, "sectors %" PRId64 "+%" PRId64 " allocated\n", sector_num, n >> BDRV_SECTOR_BITS)); - if (bdrv_pread(s->qcow, sector_num * BDRV_SECTOR_SIZE, - buf + i * 0x200, n, 0) < 0) { + if (bdrv_pread(s->qcow, sector_num * BDRV_SECTOR_SIZE, n, + buf + i * 0x200, 0) < 0) { return -1; } i +=3D (n >> BDRV_SECTOR_BITS) - 1; @@ -1978,7 +1978,7 @@ static uint32_t get_cluster_count_for_direntry(BDRVVV= FATState* s, return -1; } res =3D bdrv_pwrite(s->qcow, offset * BDRV_SECTOR_= SIZE, - s->cluster_buffer, BDRV_SECTOR_S= IZE, + BDRV_SECTOR_SIZE, s->cluster_buf= fer, 0); if (res < 0) { return -2; @@ -3063,8 +3063,8 @@ DLOG(checkpoint()); * Use qcow backend. Commit later. */ DLOG(fprintf(stderr, "Write to qcow backend: %d + %d\n", (int)sector_num, = nb_sectors)); - ret =3D bdrv_pwrite(s->qcow, sector_num * BDRV_SECTOR_SIZE, buf, - nb_sectors * BDRV_SECTOR_SIZE, 0); + ret =3D bdrv_pwrite(s->qcow, sector_num * BDRV_SECTOR_SIZE, + nb_sectors * BDRV_SECTOR_SIZE, buf, 0); if (ret < 0) { fprintf(stderr, "Error writing to qcow backend\n"); return ret; diff --git a/include/block/block-io.h b/include/block/block-io.h index 900ab19545..879221cebe 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -42,12 +42,12 @@ int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset, int64_t bytes, BdrvRequestFlags flags); int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags flags); -int bdrv_pread(BdrvChild *child, int64_t offset, void *buf, int64_t bytes, +int bdrv_pread(BdrvChild *child, int64_t offset, int64_t bytes, void *buf, BdrvRequestFlags flags); -int bdrv_pwrite(BdrvChild *child, int64_t offset, const void *buf, - int64_t bytes, BdrvRequestFlags flags); -int bdrv_pwrite_sync(BdrvChild *child, int64_t offset, - const void *buf, int64_t bytes, BdrvRequestFlags flag= s); +int bdrv_pwrite(BdrvChild *child, int64_t offset, int64_t bytes, + const void *buf, BdrvRequestFlags flags); +int bdrv_pwrite_sync(BdrvChild *child, int64_t offset, int64_t bytes, + const void *buf, BdrvRequestFlags flags); /* * Efficiently zero a region of the disk image. Note that this is a regul= ar * I/O request like read or write and should have a reasonable size. This diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index 4db1ad5dfe..49fb1ef1ea 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -88,11 +88,11 @@ static void test_sync_op_pread(BdrvChild *c) int ret; =20 /* Success */ - ret =3D bdrv_pread(c, 0, buf, sizeof(buf), 0); + ret =3D bdrv_pread(c, 0, sizeof(buf), buf, 0); g_assert_cmpint(ret, =3D=3D, 512); =20 /* Early error: Negative offset */ - ret =3D bdrv_pread(c, -2, buf, sizeof(buf), 0); + ret =3D bdrv_pread(c, -2, sizeof(buf), buf, 0); g_assert_cmpint(ret, =3D=3D, -EIO); } =20 @@ -102,11 +102,11 @@ static void test_sync_op_pwrite(BdrvChild *c) int ret; =20 /* Success */ - ret =3D bdrv_pwrite(c, 0, buf, sizeof(buf), 0); + ret =3D bdrv_pwrite(c, 0, sizeof(buf), buf, 0); g_assert_cmpint(ret, =3D=3D, 512); =20 /* Early error: Negative offset */ - ret =3D bdrv_pwrite(c, -2, buf, sizeof(buf), 0); + ret =3D bdrv_pwrite(c, -2, sizeof(buf), buf, 0); g_assert_cmpint(ret, =3D=3D, -EIO); } =20 --=20 2.35.3 From nobody Fri Apr 26 16:52:25 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652398996; cv=none; d=zohomail.com; s=zohoarc; b=SA3gPfS4rX9o2ysvjRXuDnRYgnqQMhfAQpZoSRXKySzqfh49UPoKczNOjDdkCosPWyMxu9zoK3fdMjAyn7ARFRJ/V3FxiZxqBimh4EUo1puoJj5jd+D2fKMvEgCOPg1v6o7N2PntEmiAjg2h9JwggaVNo7haRMGD+ubTRuDNico= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652398996; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2i3J4nsvNSczAXb0CsedMqrL/LqxMntP1NW/SiHLTLg=; b=H9HaIenwZ8ULOqjkDJmQJHnq/67v0v6QnAMLf4Dw+XnGchk7SnhzQrYVSH0gtZZz+qNYVq0T5V8swADBxHY1Z0uOW5Q6KeDBIiNlHreLwf304VwmRJ0LltKvMxZ3PIIrlgiLJcKCI4euyLfzzfNG69HCWlTwVIas+7YV2NqdDdI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652398996651896.2089411937118; Thu, 12 May 2022 16:43:16 -0700 (PDT) Received: from localhost ([::1]:43264 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npISh-0001n1-J7 for importer2@patchew.org; Thu, 12 May 2022 19:43:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52774) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npIPk-0007v3-Q3 for qemu-devel@nongnu.org; Thu, 12 May 2022 19:40:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24049) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npIPi-00046s-Ch for qemu-devel@nongnu.org; Thu, 12 May 2022 19:40:12 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-441-cpSxagDCNCyczmiTx65-NQ-1; Thu, 12 May 2022 19:39:03 -0400 Received: by mail-wm1-f69.google.com with SMTP id m124-20020a1c2682000000b00393fcd2722dso2243925wmm.4 for ; Thu, 12 May 2022 16:39:03 -0700 (PDT) Received: from DESKTOP-E7ACR7D.lan ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id r12-20020adfa14c000000b0020c5253d8c7sm749045wrr.19.2022.05.12.16.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 16:39:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652398809; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2i3J4nsvNSczAXb0CsedMqrL/LqxMntP1NW/SiHLTLg=; b=E3ZaKkNKoEij3y0yqrLOpLEoZ7FEPIYMg3OD1oQiVxzuCCLfoQJnis+nYprW5wTAyx/EwG uDxtN1QPW8U0BrBdX6hBmEIR8BOYLnZA5Rl4iwy1+UH2WoNP6RTzimdIdepAnH8EXO2eVN 2yLShyGebhvxyfvQr9aedyBsKlAtXK8= X-MC-Unique: cpSxagDCNCyczmiTx65-NQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2i3J4nsvNSczAXb0CsedMqrL/LqxMntP1NW/SiHLTLg=; b=s5PCTKa43sCRsKAPB+PA1xUdryIuRrjiqd12sadpPS7x0AXBYNUu3j4i+CQQuSNrW+ Ge2idTfYl6b3c8wUY6C2vbiWtOE+lTeX1lqh1KfIS8q85ntY39MzBD3zPEQI5pDhLTp2 f1i6eYjc6t0qT0vfaf3I3ngwAgdQJrJJQw8orG5ANCWfo+PLYYvILvXu/Pgu2BV1Aoth EnVLsNEKx49+Jhpd5yDE7+EDgWaoqrKPc+rXwGze9/r9dIpSYPlJg7LL5UeHb6NAfx50 A/oSkkTaBmNUM/Kf+c0a8j1eiUJfsCQxxFo1pTA9W4w9Rh3VR9cQx8oRro/o6+m8dsY4 RObg== X-Gm-Message-State: AOAM530AEhgX/P0y7ysF57DqItGq9I3E/OzhZsNIC6kQ5IsG1InezUo+ sRAI+LD9WfXkWksPpTIkrdNC17l3v+CAm0uVcuBTqzE+y5Jr7y37XgrTKKTWJGvWSwRHdUv/5cH qZ+8BrGteDrkaeAhlAhvQ945BUMB9spnyKlz4UMDIohtpxPkFVdAnefvKz+xgfNl7 X-Received: by 2002:adf:f210:0:b0:20c:dd8b:7e8f with SMTP id p16-20020adff210000000b0020cdd8b7e8fmr1523580wro.411.1652398741451; Thu, 12 May 2022 16:39:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkkTGwrsPSBCIVFuuQYgLl0I0bJtSXBCX740d7fvD1v8Wa0BNCxmzK9lwrtcXRQSfHRFRcAw== X-Received: by 2002:adf:f210:0:b0:20c:dd8b:7e8f with SMTP id p16-20020adff210000000b0020cdd8b7e8fmr1523561wro.411.1652398741097; Thu, 12 May 2022 16:39:01 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Alberto Faria , Stefan Hajnoczi , Kevin Wolf , Hanna Reitz , Fam Zheng , Jeff Cody Subject: [PATCH 3/7] block: Make bdrv_{pread,pwrite}() return 0 on success Date: Fri, 13 May 2022 00:38:45 +0100 Message-Id: <20220512233849.2219275-4-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220512233849.2219275-1-afaria@redhat.com> References: <20220512233849.2219275-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652398998497100001 Content-Type: text/plain; charset="utf-8" They currently return the value of their 'bytes' parameter on success. Make them return 0 instead, for consistency with other I/O functions and in preparation to implement them using generated_co_wrapper. This also makes it clear that short reads/writes are not possible. The few callers that rely on the previous behavior are adjusted accordingly by hand. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini --- block/cloop.c | 2 +- block/crypto.c | 4 ++-- block/dmg.c | 10 +++++----- block/io.c | 10 ++-------- block/qcow.c | 2 +- block/qcow2.c | 4 ++-- block/qed.c | 7 +------ block/vhdx-log.c | 3 +++ block/vmdk.c | 5 ++--- tests/unit/test-block-iothread.c | 4 ++-- 10 files changed, 21 insertions(+), 30 deletions(-) diff --git a/block/cloop.c b/block/cloop.c index 9a2334495e..40b146e714 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -222,7 +222,7 @@ static inline int cloop_read_block(BlockDriverState *bs= , int block_num) =20 ret =3D bdrv_pread(bs->file, s->offsets[block_num], bytes, s->compressed_block, 0); - if (ret !=3D bytes) { + if (ret < 0) { return -1; } =20 diff --git a/block/crypto.c b/block/crypto.c index deec7fae2f..e7f5c4e31a 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -70,7 +70,7 @@ static ssize_t block_crypto_read_func(QCryptoBlock *block, error_setg_errno(errp, -ret, "Could not read encryption header"); return ret; } - return ret; + return buflen; } =20 static ssize_t block_crypto_write_func(QCryptoBlock *block, @@ -88,7 +88,7 @@ static ssize_t block_crypto_write_func(QCryptoBlock *bloc= k, error_setg_errno(errp, -ret, "Could not write encryption header"); return ret; } - return ret; + return buflen; } =20 =20 diff --git a/block/dmg.c b/block/dmg.c index 5a460c3eb1..98db18d82a 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -390,7 +390,7 @@ static int dmg_read_plist_xml(BlockDriverState *bs, Dmg= HeaderState *ds, buffer =3D g_malloc(info_length + 1); buffer[info_length] =3D '\0'; ret =3D bdrv_pread(bs->file, info_begin, info_length, buffer, 0); - if (ret !=3D info_length) { + if (ret < 0) { ret =3D -EINVAL; goto fail; } @@ -611,7 +611,7 @@ static inline int dmg_read_chunk(BlockDriverState *bs, = uint64_t sector_num) * inflated. */ ret =3D bdrv_pread(bs->file, s->offsets[chunk], s->lengths[chu= nk], s->compressed_chunk, 0); - if (ret !=3D s->lengths[chunk]) { + if (ret < 0) { return -1; } =20 @@ -637,7 +637,7 @@ static inline int dmg_read_chunk(BlockDriverState *bs, = uint64_t sector_num) * inflated. */ ret =3D bdrv_pread(bs->file, s->offsets[chunk], s->lengths[chu= nk], s->compressed_chunk, 0); - if (ret !=3D s->lengths[chunk]) { + if (ret < 0) { return -1; } =20 @@ -658,7 +658,7 @@ static inline int dmg_read_chunk(BlockDriverState *bs, = uint64_t sector_num) * inflated. */ ret =3D bdrv_pread(bs->file, s->offsets[chunk], s->lengths[chu= nk], s->compressed_chunk, 0); - if (ret !=3D s->lengths[chunk]) { + if (ret < 0) { return -1; } =20 @@ -674,7 +674,7 @@ static inline int dmg_read_chunk(BlockDriverState *bs, = uint64_t sector_num) case UDRW: /* copy */ ret =3D bdrv_pread(bs->file, s->offsets[chunk], s->lengths[chu= nk], s->uncompressed_chunk, 0); - if (ret !=3D s->lengths[chunk]) { + if (ret < 0) { return -1; } break; diff --git a/block/io.c b/block/io.c index 2ed963d9e0..78a289192e 100644 --- a/block/io.c +++ b/block/io.c @@ -1115,7 +1115,6 @@ int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags= flags) int bdrv_pread(BdrvChild *child, int64_t offset, int64_t bytes, void *buf, BdrvRequestFlags flags) { - int ret; QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); IO_CODE(); =20 @@ -1123,9 +1122,7 @@ int bdrv_pread(BdrvChild *child, int64_t offset, int6= 4_t bytes, void *buf, return -EINVAL; } =20 - ret =3D bdrv_preadv(child, offset, bytes, &qiov, flags); - - return ret < 0 ? ret : bytes; + return bdrv_preadv(child, offset, bytes, &qiov, flags); } =20 /* Return no. of bytes on success or < 0 on error. Important errors are: @@ -1137,7 +1134,6 @@ int bdrv_pread(BdrvChild *child, int64_t offset, int6= 4_t bytes, void *buf, int bdrv_pwrite(BdrvChild *child, int64_t offset, int64_t bytes, const void *buf, BdrvRequestFlags flags) { - int ret; QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); IO_CODE(); =20 @@ -1145,9 +1141,7 @@ int bdrv_pwrite(BdrvChild *child, int64_t offset, int= 64_t bytes, return -EINVAL; } =20 - ret =3D bdrv_pwritev(child, offset, bytes, &qiov, flags); - - return ret < 0 ? ret : bytes; + return bdrv_pwritev(child, offset, bytes, &qiov, flags); } =20 /* diff --git a/block/qcow.c b/block/qcow.c index c94524b814..c646d6b16d 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -597,7 +597,7 @@ static int decompress_cluster(BlockDriverState *bs, uin= t64_t cluster_offset) csize &=3D (s->cluster_size - 1); BLKDBG_EVENT(bs->file, BLKDBG_READ_COMPRESSED); ret =3D bdrv_pread(bs->file, coffset, csize, s->cluster_data, 0); - if (ret !=3D csize) + if (ret < 0) return -1; if (decompress_buffer(s->cluster_cache, s->cluster_size, s->cluster_data, csize) < 0) { diff --git a/block/qcow2.c b/block/qcow2.c index 5493e6b847..d5a1e8bc43 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -113,7 +113,7 @@ static ssize_t qcow2_crypto_hdr_read_func(QCryptoBlock = *block, size_t offset, error_setg_errno(errp, -ret, "Could not read encryption header"); return -1; } - return ret; + return buflen; } =20 =20 @@ -174,7 +174,7 @@ static ssize_t qcow2_crypto_hdr_write_func(QCryptoBlock= *block, size_t offset, error_setg_errno(errp, -ret, "Could not read encryption header"); return -1; } - return ret; + return buflen; } =20 static QDict* diff --git a/block/qed.c b/block/qed.c index ba93e99570..55da91eb72 100644 --- a/block/qed.c +++ b/block/qed.c @@ -87,14 +87,9 @@ static void qed_header_cpu_to_le(const QEDHeader *cpu, Q= EDHeader *le) int qed_write_header_sync(BDRVQEDState *s) { QEDHeader le; - int ret; =20 qed_header_cpu_to_le(&s->header, &le); - ret =3D bdrv_pwrite(s->bs->file, 0, sizeof(le), &le, 0); - if (ret !=3D sizeof(le)) { - return ret; - } - return 0; + return bdrv_pwrite(s->bs->file, 0, sizeof(le), &le, 0); } =20 /** diff --git a/block/vhdx-log.c b/block/vhdx-log.c index 572582b87b..33a7786631 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -88,6 +88,7 @@ static int vhdx_log_peek_hdr(BlockDriverState *bs, VHDXLo= gEntries *log, if (ret < 0) { goto exit; } + ret =3D sizeof(VHDXLogEntryHeader); vhdx_log_entry_hdr_le_import(hdr); =20 exit: @@ -148,6 +149,7 @@ static int vhdx_log_read_sectors(BlockDriverState *bs, = VHDXLogEntries *log, if (ret < 0) { goto exit; } + ret =3D VHDX_LOG_SECTOR_SIZE; read =3D vhdx_log_inc_idx(read, log->length); =20 *sectors_read =3D *sectors_read + 1; @@ -199,6 +201,7 @@ static int vhdx_log_write_sectors(BlockDriverState *bs,= VHDXLogEntries *log, if (ret < 0) { goto exit; } + ret =3D VHDX_LOG_SECTOR_SIZE; buffer_tmp +=3D VHDX_LOG_SECTOR_SIZE; =20 log->write =3D write; diff --git a/block/vmdk.c b/block/vmdk.c index aacea1095f..332565c80f 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -473,7 +473,6 @@ static int vmdk_parent_open(BlockDriverState *bs) if (ret < 0) { goto out; } - ret =3D 0; =20 p_name =3D strstr(desc, "parentFileNameHint"); if (p_name !=3D NULL) { @@ -905,7 +904,7 @@ static char *vmdk_read_desc(BdrvChild *file, uint64_t d= esc_offset, Error **errp) g_free(buf); return NULL; } - buf[ret] =3D 0; + buf[size] =3D 0; =20 return buf; } @@ -1630,7 +1629,7 @@ static int get_cluster_offset(BlockDriverState *bs, l2_size_bytes, l2_table, 0 - ) !=3D l2_size_bytes) { + ) < 0) { return VMDK_ERROR; } =20 diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index 49fb1ef1ea..a5c163af7e 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -89,7 +89,7 @@ static void test_sync_op_pread(BdrvChild *c) =20 /* Success */ ret =3D bdrv_pread(c, 0, sizeof(buf), buf, 0); - g_assert_cmpint(ret, =3D=3D, 512); + g_assert_cmpint(ret, =3D=3D, 0); =20 /* Early error: Negative offset */ ret =3D bdrv_pread(c, -2, sizeof(buf), buf, 0); @@ -103,7 +103,7 @@ static void test_sync_op_pwrite(BdrvChild *c) =20 /* Success */ ret =3D bdrv_pwrite(c, 0, sizeof(buf), buf, 0); - g_assert_cmpint(ret, =3D=3D, 512); + g_assert_cmpint(ret, =3D=3D, 0); =20 /* Early error: Negative offset */ ret =3D bdrv_pwrite(c, -2, sizeof(buf), buf, 0); --=20 2.35.3 From nobody Fri Apr 26 16:52:25 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652399688; cv=none; d=zohomail.com; s=zohoarc; b=LEi3w7xXrWAscpgCfF9+Jr4hJfQ+ExNRkLZDtJwUrqEWhQ+EbBlSewmSWLNMWNaZQ5Y8MvWWynv34CRRX6lx8vJLpNxjkMKoy0W9effI4RzwbvNJTcJq6zi71FULBGZDc+Z7VurZQu+dO1+8D0MqCE3MrXxSd3q3hlJS+4rCqp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652399688; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=juphkoDYaBAl4VcdnicBmMRCWBXv/XQ424qePsr/oS8=; b=mB5ao0EXqhpsjgmKQzsOzZsFmK2ySs9YIXH1PejtESZcyg55tyPX8tvx7SpbnS2cBCwtv1F23ankazkogDdAkGQ1g8452PbgDPP2MpDM0tCzJFI4wx5pPA348H/XfWQlgujHWNNL/rOn1DpJz0/5EVK5nBFqO3n5iKFxnaS1kB4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165239968821919.644574563722358; Thu, 12 May 2022 16:54:48 -0700 (PDT) Received: from localhost ([::1]:59500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npIdr-0004jB-7i for importer2@patchew.org; Thu, 12 May 2022 19:54:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npIaR-0007DC-Bd for qemu-devel@nongnu.org; Thu, 12 May 2022 19:51:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56478) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npIaN-0005gW-Hz for qemu-devel@nongnu.org; Thu, 12 May 2022 19:51:14 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-660-IOFprhpANDyKDXVCPUpZqw-1; Thu, 12 May 2022 19:51:08 -0400 Received: by mail-wm1-f71.google.com with SMTP id k5-20020a05600c0b4500b003941ca130f9so2174682wmr.0 for ; Thu, 12 May 2022 16:51:08 -0700 (PDT) Received: from DESKTOP-E7ACR7D.lan ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id a25-20020adfb519000000b0020c5253d90asm678577wrd.86.2022.05.12.16.51.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 16:51:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652399470; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=juphkoDYaBAl4VcdnicBmMRCWBXv/XQ424qePsr/oS8=; b=UlcOEgpNmoIALvswR1+HbwpUk1/wpyGKa5dFA2j2XbcCS919Gt+zqPyKozRQcDmF1KiUs4 lfr7q2GAE3qBkVrKeP5ehCCogTVz7Lpi85NuB06GSGbEAR0tPIWFVUUN7nbAsY65p3uIk4 yt4yvwaHP/9mC010yWL5iIO9GXF+IQA= X-MC-Unique: IOFprhpANDyKDXVCPUpZqw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=juphkoDYaBAl4VcdnicBmMRCWBXv/XQ424qePsr/oS8=; b=LMbrTzRBZl4uf2vDm7BiG9GsubIqOlR5BbCF5W7IygU+113BYd+hciqOIseA0mcMyu SVGrf7L6h4bbYP63YEoctGD6RptlSBc/SDoFSP7z0Xz2E39gLQPhBk1NnG3bJ5UV8A+e /qbZz9QK8+5eFCw5UVrIJ6YRGY7KSyB+hnnCSxiGULExIBqmVFLAQLhMgII29hImhBo/ DERHZtY6trAJEjY4hs8q/aZWfyhqi5EnHmMX66NBgNL1nCkZ+omnK2/Wm3bU1xeHaYcf nCHsiRWpue87aJOg2I4S0rPR7rnYT0efrIl7rY0Pm5jZgTlioPBeNae2zq5hup4qX4Gk W2bQ== X-Gm-Message-State: AOAM532/TeulC+T4R2h4kiZac35cBDGMlaEIedIX1yYvLN06RHGMh2ng 0oznnHl+c+fYOEs+4z2HoWdg5oZUQmkVIGtwpvgCdMK+20mlm3BO2tN6QAmBUTMu5Sbg9/T4pmB 3T5yJwBhG7p0CkFatLbI01NW8eOUfZxC4ilvhHOLBvR/N7eeLsw9lIUrDYBjVHkc1 X-Received: by 2002:a05:600c:48b:b0:394:2ee9:5847 with SMTP id d11-20020a05600c048b00b003942ee95847mr12846373wme.117.1652399467119; Thu, 12 May 2022 16:51:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzb9NPGpXBB9CqN550Rzp3OqlSH0hFVAixAC+gcA9vKqd471m7shjwMReUO7rzrJ0ZEEq+jbw== X-Received: by 2002:a05:600c:48b:b0:394:2ee9:5847 with SMTP id d11-20020a05600c048b00b003942ee95847mr12846354wme.117.1652399466661; Thu, 12 May 2022 16:51:06 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Alberto Faria , Kevin Wolf , Hanna Reitz Subject: [PATCH 4/7] block: Make bdrv_co_pwrite() take a const buffer Date: Fri, 13 May 2022 00:51:00 +0100 Message-Id: <20220512235103.2224817-1-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220512233849.2219275-1-afaria@redhat.com> References: <20220512233849.2219275-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652399689933100001 Content-Type: text/plain; charset="utf-8" It does not mutate the buffer. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini --- include/block/block_int-io.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h index bb454200e5..d4d3bed783 100644 --- a/include/block/block_int-io.h +++ b/include/block/block_int-io.h @@ -65,7 +65,7 @@ static inline int coroutine_fn bdrv_co_pread(BdrvChild *c= hild, } =20 static inline int coroutine_fn bdrv_co_pwrite(BdrvChild *child, - int64_t offset, unsigned int bytes, void *buf, BdrvRequestFlags flags) + int64_t offset, unsigned int bytes, const void *buf, BdrvRequestFlags = flags) { QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); IO_CODE(); --=20 2.35.3 From nobody Fri Apr 26 16:52:25 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652399588544722.7636346146146; Thu, 12 May 2022 16:53:08 -0700 (PDT) Received: from localhost ([::1]:53930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npIcF-0000zO-7T for importer2@patchew.org; Thu, 12 May 2022 19:53:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54186) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npIaR-0007DB-Bj for qemu-devel@nongnu.org; Thu, 12 May 2022 19:51:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:34394) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npIaN-0005gZ-Fe for qemu-devel@nongnu.org; Thu, 12 May 2022 19:51:13 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-115-atoQMOiPP5y6MyJyMSXwXg-1; Thu, 12 May 2022 19:51:09 -0400 Received: by mail-wm1-f69.google.com with SMTP id bi5-20020a05600c3d8500b0039489e1d18dso5102733wmb.5 for ; Thu, 12 May 2022 16:51:09 -0700 (PDT) Received: from DESKTOP-E7ACR7D.lan ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id a25-20020adfb519000000b0020c5253d90asm678577wrd.86.2022.05.12.16.51.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 16:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652399470; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eFUmwFuRAQEB3IhuBD+mCfJNDp2124QaArTjCqmbDa0=; b=MpXSscV2kS6ndZrBYzy3J/HIn5cY5FB5St6pMLVP6nDZEqi9UjIMQ/Z0cwrfLXWrpDLJgU 6/u20M9y48FgUGZ+/lKnjD5P5AcAr8c2JXPn5k68NFrc20yHrdQVoYftQig7GP1VcnqpZf DgdahN6LD+yrHaSMZrTlTo+7kPrhtfk= X-MC-Unique: atoQMOiPP5y6MyJyMSXwXg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eFUmwFuRAQEB3IhuBD+mCfJNDp2124QaArTjCqmbDa0=; b=Kv/13ALfMjfqyvLIbJdgBxfKMzS8oBhRl/sJ/MvqMoABBQ43ZtyJ4YSz8EA9n1kTnD i7BTg0GrxDqDJqfZBqryPI4EDcWw0KLEPisuA+8Lz5TmgXc55nmlijKax7FzyyvT+Kk1 TXxwIhrBeVQjMrBfqERrYOSHEwpiQueNVgrwwL9q/a0Etjk7nnfzo2M43m3rJvSdVoUz 0etWihg9uhQ5QhISieVotplZYjvVPf19LIe4uyJ0K9d1v3GkJcloak9vA3xp/Z9IflOE kbl4cowPoo6AqlbJbClTTJRLYbCr8qOcyB9YthRFC61JXWMBOyNWyaH8n626oof8ZEz4 wa4w== X-Gm-Message-State: AOAM531e9RCZ64jK1MkAVkJAPV/yb0gbP889/S2lD0Qx6zbJe/+s8m5Q 3DTkeHQbBRduPo8jdZNwyiWL1oOWtRIQpP6/n6g5ry6h4/155ZKU45Urf5pPcndtWeftohXRt8z JKSKkNUHy3v9EKa3PTtHrScgb1mKQulSncji5rQokR3A0BjOfu13HGdbnppg08kR/ X-Received: by 2002:a05:600c:1e89:b0:394:9587:cbe0 with SMTP id be9-20020a05600c1e8900b003949587cbe0mr12368756wmb.89.1652399468013; Thu, 12 May 2022 16:51:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxskdtdbx2qaYQ5TcREKuhzh3reYvEQKA/39U7MdO08OB4W2F53o1LqO41y8ky8j6Bi7rgsfQ== X-Received: by 2002:a05:600c:1e89:b0:394:9587:cbe0 with SMTP id be9-20020a05600c1e8900b003949587cbe0mr12368744wmb.89.1652399467783; Thu, 12 May 2022 16:51:07 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Alberto Faria , Kevin Wolf , Hanna Reitz Subject: [PATCH 5/7] block: Make 'bytes' param of bdrv_co_{pread, pwrite, preadv, pwritev}() an int64_t Date: Fri, 13 May 2022 00:51:01 +0100 Message-Id: <20220512235103.2224817-2-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220512233849.2219275-1-afaria@redhat.com> References: <20220512233849.2219275-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1652399589475100003 Content-Type: text/plain; charset="utf-8" For consistency with other I/O functions, and in preparation to implement bdrv_{pread,pwrite}() using generated_co_wrapper. unsigned int fits in int64_t, so all callers remain correct. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini --- block/coroutines.h | 4 ++-- include/block/block_int-io.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/block/coroutines.h b/block/coroutines.h index 830ecaa733..3f41238b33 100644 --- a/block/coroutines.h +++ b/block/coroutines.h @@ -91,11 +91,11 @@ int coroutine_fn blk_co_do_flush(BlockBackend *blk); */ =20 int generated_co_wrapper -bdrv_preadv(BdrvChild *child, int64_t offset, unsigned int bytes, +bdrv_preadv(BdrvChild *child, int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); =20 int generated_co_wrapper -bdrv_pwritev(BdrvChild *child, int64_t offset, unsigned int bytes, +bdrv_pwritev(BdrvChild *child, int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); =20 int generated_co_wrapper diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h index d4d3bed783..d1a6970dc6 100644 --- a/include/block/block_int-io.h +++ b/include/block/block_int-io.h @@ -56,7 +56,7 @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child, QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags); =20 static inline int coroutine_fn bdrv_co_pread(BdrvChild *child, - int64_t offset, unsigned int bytes, void *buf, BdrvRequestFlags flags) + int64_t offset, int64_t bytes, void *buf, BdrvRequestFlags flags) { QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); IO_CODE(); @@ -65,7 +65,7 @@ static inline int coroutine_fn bdrv_co_pread(BdrvChild *c= hild, } =20 static inline int coroutine_fn bdrv_co_pwrite(BdrvChild *child, - int64_t offset, unsigned int bytes, const void *buf, BdrvRequestFlags = flags) + int64_t offset, int64_t bytes, const void *buf, BdrvRequestFlags flags) { QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); IO_CODE(); --=20 2.35.3 From nobody Fri Apr 26 16:52:25 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652399591750830.1064256392488; Thu, 12 May 2022 16:53:11 -0700 (PDT) Received: from localhost ([::1]:54114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npIcI-000170-AF for importer2@patchew.org; Thu, 12 May 2022 19:53:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npIaR-0007Db-PB for qemu-devel@nongnu.org; Thu, 12 May 2022 19:51:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47508) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npIaO-0005hD-Ko for qemu-devel@nongnu.org; Thu, 12 May 2022 19:51:15 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-616-caRKUYtQPK6DgWBglqUtQQ-1; Thu, 12 May 2022 19:51:10 -0400 Received: by mail-wr1-f69.google.com with SMTP id j27-20020adfb31b000000b0020c4ca11566so2493000wrd.14 for ; Thu, 12 May 2022 16:51:10 -0700 (PDT) Received: from DESKTOP-E7ACR7D.lan ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id a25-20020adfb519000000b0020c5253d90asm678577wrd.86.2022.05.12.16.51.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 16:51:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652399471; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R50B4D9e4LU1l+ZBd6FIpWVVtqdYSRIaWclScqEgXO8=; b=P/IJPbRovNg2oVjzzdAL9e0FZwkuUtsDhDbG/1fHdXYqjR/GLqvrbSsI3b7jXK1NfCh4GD KoDFB/29P4PbDPfPi26WG0Ji2qFHEfTgnSpryViYDd+aFgyviKT+g556unnSmbWkJWPXob 9MazNlbvINBs3WTRpSf6vFHV8fj9w2w= X-MC-Unique: caRKUYtQPK6DgWBglqUtQQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R50B4D9e4LU1l+ZBd6FIpWVVtqdYSRIaWclScqEgXO8=; b=omoBXy6Fnk4mukgRXIB2/MmZ1Qxb8AI+cM7uLfL2H/SQZg5u0VtYgvbDRG50a48+VJ IkqIqzBhNdb4PP8LjrdJsz9btFP6gl79TY3VSajLLiAVmqY54vSrJbdebCDGj0W6wPTX 3fRudROBqQWN9iJpCLHaZn57NzqDE+VedHE7MH/2KKD/fBjVKHE7YD1nqpwh3SiDdOIj uLrCw932MjxktReUDsnPJWZj1eM5S+H+VIEc28y0dkBMhrXE/++w07mX9wMcxiwN0fkX OUe9E9y83T/Fq8UXAoi/iKEeFyXuD4+7It52jQ9GYMBzWJ1j+cy4KIA8KivwzWw7Db6t f9sA== X-Gm-Message-State: AOAM530IfKQNG9IgiZhsdbkug8aNwaMWQRxxuK2RmLmM+2DUaWGmVS91 cmFthUPpOXINdQVIOFwmZNSYZXFtej/SOmXPlaC1+KRUqTASLsxcRF0vGfHtmK1IqoVCLaC/pmr f30GK5XoiGLCesbszJfdQHxcaxOaD6Tn2BCBcYXi37w6e5/BABX0vVTakFrBDb9lp X-Received: by 2002:a5d:5966:0:b0:20a:e810:5e9d with SMTP id e38-20020a5d5966000000b0020ae8105e9dmr1614326wri.240.1652399469340; Thu, 12 May 2022 16:51:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhIwQt23qNOwHZxMZe9Qbbx/KXAPzFAF3MdWnFcVhkhPsnHTcCjNndTkEx739ZDnMRrM6lvA== X-Received: by 2002:a5d:5966:0:b0:20a:e810:5e9d with SMTP id e38-20020a5d5966000000b0020ae8105e9dmr1614310wri.240.1652399469063; Thu, 12 May 2022 16:51:09 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Alberto Faria , Stefan Hajnoczi , Fam Zheng , Kevin Wolf , Hanna Reitz Subject: [PATCH 6/7] block: Implement bdrv_{pread, pwrite, pwrite_zeroes}() using generated_co_wrapper Date: Fri, 13 May 2022 00:51:02 +0100 Message-Id: <20220512235103.2224817-3-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220512233849.2219275-1-afaria@redhat.com> References: <20220512233849.2219275-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1652399593463100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini --- block/io.c | 41 ---------------------------------------- include/block/block-io.h | 15 +++++++++------ 2 files changed, 9 insertions(+), 47 deletions(-) diff --git a/block/io.c b/block/io.c index 78a289192e..ecd1c2a53c 100644 --- a/block/io.c +++ b/block/io.c @@ -1061,14 +1061,6 @@ static int bdrv_check_request32(int64_t offset, int6= 4_t bytes, return 0; } =20 -int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset, - int64_t bytes, BdrvRequestFlags flags) -{ - IO_CODE(); - return bdrv_pwritev(child, offset, bytes, NULL, - BDRV_REQ_ZERO_WRITE | flags); -} - /* * Completely zero out a block device with the help of bdrv_pwrite_zeroes. * The operation is sped up by checking the block status and only writing @@ -1111,39 +1103,6 @@ int bdrv_make_zero(BdrvChild *child, BdrvRequestFlag= s flags) } } =20 -/* See bdrv_pwrite() for the return codes */ -int bdrv_pread(BdrvChild *child, int64_t offset, int64_t bytes, void *buf, - BdrvRequestFlags flags) -{ - QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); - IO_CODE(); - - if (bytes < 0) { - return -EINVAL; - } - - return bdrv_preadv(child, offset, bytes, &qiov, flags); -} - -/* Return no. of bytes on success or < 0 on error. Important errors are: - -EIO generic I/O error (may happen for all errors) - -ENOMEDIUM No media inserted. - -EINVAL Invalid offset or number of bytes - -EACCES Trying to write a read-only device -*/ -int bdrv_pwrite(BdrvChild *child, int64_t offset, int64_t bytes, - const void *buf, BdrvRequestFlags flags) -{ - QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); - IO_CODE(); - - if (bytes < 0) { - return -EINVAL; - } - - return bdrv_pwritev(child, offset, bytes, &qiov, flags); -} - /* * Writes to the file and ensures that no writes are reordered across this * request (acts as a barrier) diff --git a/include/block/block-io.h b/include/block/block-io.h index 879221cebe..c81739ad16 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -39,13 +39,16 @@ * to catch when they are accidentally called by the wrong API. */ =20 -int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset, - int64_t bytes, BdrvRequestFlags flags); +int generated_co_wrapper bdrv_pwrite_zeroes(BdrvChild *child, int64_t offs= et, + int64_t bytes, + BdrvRequestFlags flags); int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags flags); -int bdrv_pread(BdrvChild *child, int64_t offset, int64_t bytes, void *buf, - BdrvRequestFlags flags); -int bdrv_pwrite(BdrvChild *child, int64_t offset, int64_t bytes, - const void *buf, BdrvRequestFlags flags); +int generated_co_wrapper bdrv_pread(BdrvChild *child, int64_t offset, + int64_t bytes, void *buf, + BdrvRequestFlags flags); +int generated_co_wrapper bdrv_pwrite(BdrvChild *child, int64_t offset, + int64_t bytes, const void *buf, + BdrvRequestFlags flags); int bdrv_pwrite_sync(BdrvChild *child, int64_t offset, int64_t bytes, const void *buf, BdrvRequestFlags flags); /* --=20 2.35.3 From nobody Fri Apr 26 16:52:25 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652399596; cv=none; d=zohomail.com; s=zohoarc; b=kuUQaw+4SKnkXYTPbUEehazsJ7t6emiudkwazeaFP/Hax+8c9uQzGSF2QC7oVSh9J1kcU5qe5rpviUCbsuYH8NoCiU5cerdQgntveoiLZbu42zmvtEW2lZ7q5shUp/0+FbXB0CGbt/ci+Y/RQusX9n5FH0eq8R7/Bo1klcUyvqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652399596; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=d4CdPiovWolhzsauxg3NFy4KndJJVIMVPi4RXbreQrI=; b=bj0QSr/LoP74KylbcpJTbJqoVf4SJtAHKs76AGjJ1wA6VwQxVigEhzdZL4sX9yN5gnmUJeUjr9aoQ9SWlOMoYDHOokG6K7R7abFf3gZEdjbcjvfahCgQe4tkQJVZYiPFCeWD1QUTQCUSkuynrGyobuOPavYxHIDFj+0JR1RQrys= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652399596950867.9460519298099; Thu, 12 May 2022 16:53:16 -0700 (PDT) Received: from localhost ([::1]:54536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npIcN-0001OR-GT for importer2@patchew.org; Thu, 12 May 2022 19:53:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npIaU-0007Fx-1O for qemu-devel@nongnu.org; Thu, 12 May 2022 19:51:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34760) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npIaR-0005io-3R for qemu-devel@nongnu.org; Thu, 12 May 2022 19:51:16 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-132-DkxDJcmLNV6gMADwdvTgfA-1; Thu, 12 May 2022 19:51:12 -0400 Received: by mail-wm1-f71.google.com with SMTP id c125-20020a1c3583000000b0038e3f6e871aso2169981wma.8 for ; Thu, 12 May 2022 16:51:11 -0700 (PDT) Received: from DESKTOP-E7ACR7D.lan ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id a25-20020adfb519000000b0020c5253d90asm678577wrd.86.2022.05.12.16.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 16:51:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652399473; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d4CdPiovWolhzsauxg3NFy4KndJJVIMVPi4RXbreQrI=; b=APE+O5XZETPPWyiF5AsWTrSZd3sNttNlVbLNJZhc3HEb1qDRYojvnveglrgJU9huq060l/ AnQtrz1gg3HXY994QCIRoiuAoXo7KTxP9s+uOKNeuqPu9HGKNw2wS0QvPW2bD6kgmXNn13 4rcZaJutsXteNlRl/HZSjZOiQa7zJ8U= X-MC-Unique: DkxDJcmLNV6gMADwdvTgfA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d4CdPiovWolhzsauxg3NFy4KndJJVIMVPi4RXbreQrI=; b=C6DKRvzZX0e+qZQrp9mIw4e45hmdKVdJjthM85NcUG/wP/2LsBjBPS3Bp/27X1Eh9f R+9Itbt76HordmUowwphg2gfJFBH5TY9O7qKBfQQzp6xXTc2gTn71B0KwKUVCykZZR/3 MZKAdMJBUOevdR8Qg3PQMjr0VEl43YmKClpJ6Fg2BNlcm6e/uJ1kJM8VTqzqg3jK1+mP W0Vx+UV0k4NWADu+luKXMTU+S3O/RkbpgI2G1BSfgwLIzqU6j5l+qk9FTvSvBiaug6CR RB7bDOBeoft9xyXZTxUIVQPbho4k5jfARpuXydGsCKESV/bEEa6Zs6AY0roTHFUb0Gpt 8gEQ== X-Gm-Message-State: AOAM530n85SXT92BrSwAxjZlBuA66IcERNzXfG4penzZQC7ZUWUHMmsU 6H3u19aEHJFj1DVstTQ81zRsd7DJA2ojqV93DQ3fEmK9qJkdr0ulK6pBXF4p18CCRhUGE9V+OFM RLsSOssLW+YC4YB0KjBbibiMjTDwmU/ST2t2Cwm3Mq9LGwZ9g+b/4mm8KZeWLlTAH X-Received: by 2002:a05:600c:4e8c:b0:394:8144:6836 with SMTP id f12-20020a05600c4e8c00b0039481446836mr12181153wmq.130.1652399470517; Thu, 12 May 2022 16:51:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIIBukiG8IElwiW5uH+O9Xvi+swpyP6SIyEIGwXkiaenaktKWN3Da22ThfQksKXG+rnPHVyw== X-Received: by 2002:a05:600c:4e8c:b0:394:8144:6836 with SMTP id f12-20020a05600c4e8c00b0039481446836mr12181136wmq.130.1652399470290; Thu, 12 May 2022 16:51:10 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Alberto Faria , Stefan Hajnoczi , Fam Zheng , Kevin Wolf , Hanna Reitz Subject: [PATCH 7/7] block: Add bdrv_co_pwrite_sync() Date: Fri, 13 May 2022 00:51:03 +0100 Message-Id: <20220512235103.2224817-4-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220512233849.2219275-1-afaria@redhat.com> References: <20220512233849.2219275-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652399597538100001 Content-Type: text/plain; charset="utf-8" Also convert bdrv_pwrite_sync() to being implemented using generated_co_wrapper. Signed-off-by: Alberto Faria --- block/io.c | 5 +++-- include/block/block-io.h | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/block/io.c b/block/io.c index ecd1c2a53c..19f9251c11 100644 --- a/block/io.c +++ b/block/io.c @@ -1109,8 +1109,9 @@ int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags= flags) * * Returns 0 on success, -errno in error cases. */ -int bdrv_pwrite_sync(BdrvChild *child, int64_t offset, int64_t bytes, - const void *buf, BdrvRequestFlags flags) +int coroutine_fn bdrv_co_pwrite_sync(BdrvChild *child, int64_t offset, + int64_t bytes, const void *buf, + BdrvRequestFlags flags) { int ret; IO_CODE(); diff --git a/include/block/block-io.h b/include/block/block-io.h index c81739ad16..ae90d1e588 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -49,8 +49,12 @@ int generated_co_wrapper bdrv_pread(BdrvChild *child, in= t64_t offset, int generated_co_wrapper bdrv_pwrite(BdrvChild *child, int64_t offset, int64_t bytes, const void *buf, BdrvRequestFlags flags); -int bdrv_pwrite_sync(BdrvChild *child, int64_t offset, int64_t bytes, - const void *buf, BdrvRequestFlags flags); +int generated_co_wrapper bdrv_pwrite_sync(BdrvChild *child, int64_t offset, + int64_t bytes, const void *buf, + BdrvRequestFlags flags); +int coroutine_fn bdrv_co_pwrite_sync(BdrvChild *child, int64_t offset, + int64_t bytes, const void *buf, + BdrvRequestFlags flags); /* * Efficiently zero a region of the disk image. Note that this is a regul= ar * I/O request like read or write and should have a reasonable size. This --=20 2.35.3