From nobody Wed Apr 24 23:40:10 2024 Delivered-To: importer@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+importer=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 16524574714041023.7174847654701; Fri, 13 May 2022 08:57:51 -0700 (PDT) Received: from localhost ([::1]:45306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npXfp-0008Nd-QS for importer@patchew.org; Fri, 13 May 2022 11:57:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npXci-0005Wj-6N for qemu-devel@nongnu.org; Fri, 13 May 2022 11:54:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:48594) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npXce-0001d5-2U for qemu-devel@nongnu.org; Fri, 13 May 2022 11:54:35 -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-145-c9vBWckqNS6KUlSs1RtuUA-1; Fri, 13 May 2022 11:54:29 -0400 Received: by mail-wm1-f70.google.com with SMTP id c62-20020a1c3541000000b0038ec265155fso6123959wma.6 for ; Fri, 13 May 2022 08:54:29 -0700 (PDT) Received: from DESKTOP-E7ACR7D.lan ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id bg12-20020a05600c3c8c00b003942a244ecbsm2791262wmb.16.2022.05.13.08.54.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 08:54:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652457271; 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=flYQHso69wgM6aio5nmywU7lSiBeBT61YFZwCFGH+k8=; b=VBjgjmfFLBS2QibXPlzZSL2lDx8vWrJyw+JrDfKvz0xrKuVOnry1AXk4ABv9hxufRCXQ1S Vw0lyA1hky5ZmGfCA2iU0Z0gKzOIvZtOgeydbnsTGjK4cVQDAhJHxgnKTTR5hOqE4H9jo+ 9C3SPSRYRQf3EEEZmL+VmKInJ//9TDY= X-MC-Unique: c9vBWckqNS6KUlSs1RtuUA-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=flYQHso69wgM6aio5nmywU7lSiBeBT61YFZwCFGH+k8=; b=hV3sKZ1pVYjggwyeW2cDZ//UM2YtPF09KGW96kE3yNmwIMkX+/bmViV267rtjXeGFc gv7d9/hnCID1rSy00723tJFHaVVFSJWNpwma5wYbUpMMu48XMh09MYAo9lyH3LWobGCO 0d7c5Jkg95ec3ESdPy97KRDw4KuTqGkeore6b4vb9K26ofj8eQYXbhNQukgcMeKfbI8A GPCHFloZWmtqSJd7lZQIdv5RVMyAuCMvEUr5fC0KMGv5qnfeHpubI5wr63GKOLHDC3oY blF/EvXvB6KDu4gFWUaxEaUkVYPdU8nOV3LoPuSJ6fOSXUX/csFK6M5esik9IaT12a5d D7Qg== X-Gm-Message-State: AOAM533sS7o4ugUvoGATUw1RLIKEawS8JsQ4fEqeO6eY+RaretOSSDBH OMx900ptRylf5x82Yq7PYF/DDdV1e7/9Jro8bi2aBwnjiGwJCpBer6uE/XwsgrkV6PKaYWWmGgV dN1j/OIRKhG9Fzs+DuBjJLPkqLSv3D9cbh6pyWOPE3D+rLqhRJoX4+KsKuJbmgVKE X-Received: by 2002:a05:600c:1f19:b0:396:e98e:35e1 with SMTP id bd25-20020a05600c1f1900b00396e98e35e1mr2377008wmb.84.1652457266407; Fri, 13 May 2022 08:54:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyafH4EV+SpbQRYY1SiNZE6PXnYVU5X0Nskywl0VZmRZiZQ0RiAdW3EaKS2KjCH7GqYf3RPYw== X-Received: by 2002:a05:600c:1f19:b0:396:e98e:35e1 with SMTP id bd25-20020a05600c1f1900b00396e98e35e1mr2376917wmb.84.1652457265287; Fri, 13 May 2022 08:54:25 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Alberto Faria , Paolo Bonzini , 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 v2 01/10] block: Add a 'flags' param to bdrv_{pread, pwrite, pwrite_sync}() Date: Fri, 13 May 2022 16:54:09 +0100 Message-Id: <20220513155418.2486450-2-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220513155418.2486450-1-afaria@redhat.com> References: <20220513155418.2486450-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+importer=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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1652457473118100001 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 Wed Apr 24 23:40:10 2024 Delivered-To: importer@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+importer=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 1652457887428427.1370277438027; Fri, 13 May 2022 09:04:47 -0700 (PDT) Received: from localhost ([::1]:57120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npXmX-0008IJ-Qd for importer@patchew.org; Fri, 13 May 2022 12:04:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npXcj-0005cB-PT for qemu-devel@nongnu.org; Fri, 13 May 2022 11:54:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25314) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npXcf-0001dE-OV for qemu-devel@nongnu.org; Fri, 13 May 2022 11:54:37 -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-580-uqgsXEOdNXaSN4hO1L8MdQ-1; Fri, 13 May 2022 11:54:31 -0400 Received: by mail-wm1-f71.google.com with SMTP id bg7-20020a05600c3c8700b0039468585269so3075945wmb.3 for ; Fri, 13 May 2022 08:54:31 -0700 (PDT) Received: from DESKTOP-E7ACR7D.lan ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id bg12-20020a05600c3c8c00b003942a244ecbsm2791262wmb.16.2022.05.13.08.54.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 08:54:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652457273; 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=aOOcsxkUdjw8nV1yLW8EydVksEhxm/cM2ulWbW6fH5s=; b=GXPL09o5Xwm87cP/NS1imZif84U411YMVqYFTLTVSTvXLLRTkA+YCD0wzyM/F9PtKp+ERO 8A1EX+hN3h3juW4GNVleA+C1jmhxu3EyYGHSxev5LEZb7yW0zBmEqSKVO/KMo29TxRitO1 235bF4MYeeCajO1zJDTz6e2Cu0W+hKQ= X-MC-Unique: uqgsXEOdNXaSN4hO1L8MdQ-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=aOOcsxkUdjw8nV1yLW8EydVksEhxm/cM2ulWbW6fH5s=; b=S6qhEJCFzcZM0dZhJ8BL2gN0MLrlxeY9zWgigNHH+vOcjDfan0FhPrT0Bqi3FwJ3oa 4q9+zmicBWr4ZBsy6pWU61Wfj3eTzSts6EwhusUx3++74m+yoGR6SntEDbWXVBPT9/Rd Xc7iHvRaQOZHxyRyjzDcQsLpfUk1u4vRyL8G+3hb4EAEaN97EtHp6v0jVpfSjTX49J43 pJEYTNlDCwQywsUxPI3zkhKHn2xWWRCulcngvwcgrKkhiRqkuB7IUz3aI9g4tT+/HUDv 2SsTUC10NUqpL+CvHy408lyaRH1ZeVGTUvTRina9e6wMyxuelYrnRpJBvqevMM3hnX50 QDzQ== X-Gm-Message-State: AOAM5313HKMpqeMnqB55LC6A3HzMsC0ss/XIRASyxHDPz3iJXN/AHeKj tmyUKZH91XQ/Ytulqo9SUFcHhU1RM6gMPDzsvlHjg5OoqfRU0S/VLwuvvr9CsOXD8wydMrnM+2A N6rLEsnragY2TPspIBqQI30yBq/ARmpFKDEzNGOrOkJBMv6fpR9IP9lu3vRDg/kIg X-Received: by 2002:a5d:6d8c:0:b0:20c:599a:4f7e with SMTP id l12-20020a5d6d8c000000b0020c599a4f7emr4573922wrs.324.1652457268304; Fri, 13 May 2022 08:54:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVdbqwaeBx9UTrBirTeQYzqNndaVV8Xrf5OOQPdglVJ2N/J0IdMY9LE18/pQeGTt5qk9FtKw== X-Received: by 2002:a5d:6d8c:0:b0:20c:599a:4f7e with SMTP id l12-20020a5d6d8c000000b0020c599a4f7emr4573841wrs.324.1652457267069; Fri, 13 May 2022 08:54:27 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Alberto Faria , Paolo Bonzini , 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 v2 02/10] block: Change bdrv_{pread, pwrite, pwrite_sync}() param order Date: Fri, 13 May 2022 16:54:10 +0100 Message-Id: <20220513155418.2486450-3-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220513155418.2486450-1-afaria@redhat.com> References: <20220513155418.2486450-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+importer=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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1652457888045100001 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 Wed Apr 24 23:40:10 2024 Delivered-To: importer@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+importer=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 1652458642562180.60358888586745; Fri, 13 May 2022 09:17:22 -0700 (PDT) Received: from localhost ([::1]:58286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npXyi-0004Qn-Ks for importer@patchew.org; Fri, 13 May 2022 12:17:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npXfx-0001KZ-BG for qemu-devel@nongnu.org; Fri, 13 May 2022 11:57:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49920) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npXfv-0002I6-A8 for qemu-devel@nongnu.org; Fri, 13 May 2022 11:57:57 -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-114-PbQIvnFDPB6l5sdlCBW2iw-1; Fri, 13 May 2022 11:57:53 -0400 Received: by mail-wm1-f71.google.com with SMTP id v191-20020a1cacc8000000b0038ce818d2efso3081028wme.1 for ; Fri, 13 May 2022 08:57:53 -0700 (PDT) Received: from DESKTOP-E7ACR7D.lan ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id l5-20020adfc785000000b0020cdcb0efa2sm2558758wrg.34.2022.05.13.08.57.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 08:57:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652457474; 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=2dSrVcjvWGbPjvKOoFvwRPiMAoMY8ZsrRmMQ4iX5vOA=; b=az6b3x3oRxFi/sAgKdtw+8pQrmzbW2UepsVQXRX1L5Ko/ouWkvIPjKeOF6FokuvxRSuBrn GsM01LbYkudoiFDRkjWbI+zLX1c2eZg67x43uPE5eoWe6uISqolDtsWmEcOBbZjqls8xEA 49Py1EA2/74exXsIfVz0nB7Aeu0zef8= X-MC-Unique: PbQIvnFDPB6l5sdlCBW2iw-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=2dSrVcjvWGbPjvKOoFvwRPiMAoMY8ZsrRmMQ4iX5vOA=; b=796gtLoTBBevwg3JvgfdLAKunD01RNj0vj0on94EXJhXbRS4slvcf0gO1oIll3/J1G 2QDSwlmQ0pHMFOQLaLiITo0OJYt/NDVem+gqimC38VsgRrJpX9CBMvFN25rsw9Mf0lwl LTMpnsztjBHpKO3Z/icF17RAHv5Qx7yd3l14F01ct4/vAq3OguZA0pDGsUdAbDMag6Ak Rpc39OVRp0jo3bXyqjYsV/f50TvZHZ88l05mc2ze3iGJgT+Hl05F1mdf8vPhmTNRLC2v xRdpcleb/xTeutvrUPfcUVI3IBvfkrAEHu8VRm02ghv+lsThIuea24eheYeIQArHbSs1 ta0Q== X-Gm-Message-State: AOAM5310brjIl3/xrqcnOrFgF1njROCzFVnv81Cb9nUTua8RhRYf4UZN jivVJuXrbmueQDkUWR71NZxmKh8dgM+s6ho0bKpDg3Nq0WMkVVuw8NUk2fXy4U67jrL/EvctX1F gDkxgs+HzpnpQpDdzcjGeix7jbmv6O+UxOEwa0XSRsg4jldgbW4AkrLVfdzg8+NSF X-Received: by 2002:a05:6000:12d1:b0:20a:d901:3828 with SMTP id l17-20020a05600012d100b0020ad9013828mr4460024wrx.313.1652457471957; Fri, 13 May 2022 08:57:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFdmCYCVhzfdxeFFKn09uIbB+82DoFaLlw4LIyFyY7bsHOkPI2zVSk7yoyT443H2DjZ0ZnIQ== X-Received: by 2002:a05:6000:12d1:b0:20a:d901:3828 with SMTP id l17-20020a05600012d100b0020ad9013828mr4459990wrx.313.1652457471503; Fri, 13 May 2022 08:57:51 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Alberto Faria , Paolo Bonzini , Stefan Hajnoczi , Kevin Wolf , Hanna Reitz , Fam Zheng , Stefan Weil Subject: [PATCH v2 03/10] block: Make bdrv_{pread, pwrite}() return 0 on success Date: Fri, 13 May 2022 16:57:42 +0100 Message-Id: <20220513155749.2488070-1-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220513155418.2486450-1-afaria@redhat.com> References: <20220513155418.2486450-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+importer=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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1652458643478100001 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/vdi.c | 2 +- block/vmdk.c | 5 ++--- tests/unit/test-block-iothread.c | 4 ++-- 10 files changed, 19 insertions(+), 31 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/vdi.c b/block/vdi.c index 9ef55a117a..a0be2a23b9 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -730,7 +730,7 @@ nonallocating_write: n_sectors * SECTOR_SIZE, base, 0); } =20 - return ret < 0 ? ret : 0; + return ret; } =20 static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_opt= ions, 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 Wed Apr 24 23:40:10 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652458805; cv=none; d=zohomail.com; s=zohoarc; b=JtdzmXMIsjH8DIJ1VfKbVAgcOCz2cvB9TxG4soimRkVisJsCQ1SAKMFG46lUrCTCSm6DJfo5q8fbuOxiTHx0sqWzLWvx4bgEUjpVZ0Gl+3AYG98jHkkR+2sadkwB8O0cQyxxcfXHjgVmCf1f49LbpsaYa7XZEOd3QejzHW2y/ss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652458805; 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=Dm3IvBwJxua9KEizHdCf2c1cG8CX9z66n84uAYu2smA=; b=LjiabGrtEqDlcF/XV5BJ6Y3oxvHlr22IV8NFzNjKYMWTIcQ9s1MRlxMOUyV5GkR1Fxz0zo1uh++5Dpyl7yl2GdCHELYz/hbQtieramvE/uzysobZcg+rSiQ4Tn5IAu1CBBDvlY0W3dHrzLjfZZ7oiOvdUzA8DW8LzWdtW76nkek= 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+importer=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 1652458805487620.5563095337653; Fri, 13 May 2022 09:20:05 -0700 (PDT) Received: from localhost ([::1]:38550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npY1M-0001uQ-3J for importer@patchew.org; Fri, 13 May 2022 12:20:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npXfy-0001NG-Q6 for qemu-devel@nongnu.org; Fri, 13 May 2022 11:57:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56568) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npXfw-0002IE-Bi for qemu-devel@nongnu.org; Fri, 13 May 2022 11:57:58 -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-172-mATz9dMrM96gMSg3wpAn3A-1; Fri, 13 May 2022 11:57:54 -0400 Received: by mail-wm1-f70.google.com with SMTP id k5-20020a05600c0b4500b003941ca130f9so3083518wmr.0 for ; Fri, 13 May 2022 08:57:54 -0700 (PDT) Received: from DESKTOP-E7ACR7D.lan ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id l5-20020adfc785000000b0020cdcb0efa2sm2558758wrg.34.2022.05.13.08.57.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 08:57:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652457475; 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=Dm3IvBwJxua9KEizHdCf2c1cG8CX9z66n84uAYu2smA=; b=KkUYp0p5Uitv3dgvotVlc6Ke+JtDVdKly9tGGF9DdGwTIUwUSbQ1QeMOI5DHmOZonWtl4C Jc8sEsQbESRmp2qFPqRd95kAW1sF5rdBnE/zXk8FzkDO46KWN6OiT5sdGG7BFUXkAfnKsT Yt1pANurjE74o25LlkFyAnaEoU8xkIw= X-MC-Unique: mATz9dMrM96gMSg3wpAn3A-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=Dm3IvBwJxua9KEizHdCf2c1cG8CX9z66n84uAYu2smA=; b=O9YX5uQpYkYIbspaHOIYq6PCo6FCoN8IKQq3egEXKLq/WTtn6wzHxyqAvtx8tKY80I HKWDdwt8Yfm22yjSm/ns0lsjHU8oJqVB5EZOq50FZ8uziOyygkb33SDoQbza5AXhMqFS 4N5xhZUlWCQ9uF/lnSmyAi+f7AAwxB3pMbVmwgumFoZnRw4SYayh+gJ9fSzoRwJ7IlwR m+crHcB2fUMGQnMeW0Uhck2368ffeM0e8HzByaZTwRjIiPLjapaZdF3azNMUZOKjoYN5 rehMhOHgf4USguEFniXTQWj/paD/Me8gyhmpJM5LTHnZOMspt8O3NS7rypq4rcVs1oUe itlw== X-Gm-Message-State: AOAM5332kkVDF9OG2AeTkNiTFnxXAZgPZGg2jB80vF+Oma9WVte8zEhk 2zmnP79VBapyPhvwANhF8WuEnIaQM1hv1Y9RBV12iUeVuA+DgnJTBZilIZfgJhSjVPujUPe/ARo cwxo+jZ6YpeVqH2DNp9sFIfX45wQGxRFcIk91WCDhQK7LQdJJIsV0KR3uA4faeOYX X-Received: by 2002:a05:600c:1d8f:b0:394:8be3:a81e with SMTP id p15-20020a05600c1d8f00b003948be3a81emr15741176wms.97.1652457473202; Fri, 13 May 2022 08:57:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBOBZjth5vprurrBe7ZFCW0X+lJ1AaXP0rsYa/07L+bR/dlPRLyCkJzsfo99jr9QGzlzJvOw== X-Received: by 2002:a05:600c:1d8f:b0:394:8be3:a81e with SMTP id p15-20020a05600c1d8f00b003948be3a81emr15741145wms.97.1652457472791; Fri, 13 May 2022 08:57:52 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Alberto Faria , Kevin Wolf , Hanna Reitz , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v2 04/10] crypto: Make block callbacks return 0 on success Date: Fri, 13 May 2022 16:57:43 +0100 Message-Id: <20220513155749.2488070-2-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220513155418.2486450-1-afaria@redhat.com> References: <20220513155418.2486450-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+importer=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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652458806975100001 Content-Type: text/plain; charset="utf-8" They currently return the value of their headerlen/buflen parameter on success. Returning 0 instead makes it clear that short reads/writes are not possible. Signed-off-by: Alberto Faria Reviewed-by: Eric Blake --- block/crypto.c | 52 +++++++++++++++++----------------- block/qcow2.c | 22 +++++++------- crypto/block-luks.c | 8 +++--- crypto/block.c | 6 ++-- include/crypto/block.h | 32 ++++++++++----------- tests/unit/test-crypto-block.c | 38 ++++++++++++------------- 6 files changed, 79 insertions(+), 79 deletions(-) diff --git a/block/crypto.c b/block/crypto.c index e7f5c4e31a..11c3ddbc73 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -55,12 +55,12 @@ static int block_crypto_probe_generic(QCryptoBlockForma= t format, } =20 =20 -static ssize_t block_crypto_read_func(QCryptoBlock *block, - size_t offset, - uint8_t *buf, - size_t buflen, - void *opaque, - Error **errp) +static int block_crypto_read_func(QCryptoBlock *block, + size_t offset, + uint8_t *buf, + size_t buflen, + void *opaque, + Error **errp) { BlockDriverState *bs =3D opaque; ssize_t ret; @@ -70,15 +70,15 @@ static ssize_t block_crypto_read_func(QCryptoBlock *blo= ck, error_setg_errno(errp, -ret, "Could not read encryption header"); return ret; } - return buflen; + return 0; } =20 -static ssize_t block_crypto_write_func(QCryptoBlock *block, - size_t offset, - const uint8_t *buf, - size_t buflen, - void *opaque, - Error **errp) +static int block_crypto_write_func(QCryptoBlock *block, + size_t offset, + const uint8_t *buf, + size_t buflen, + void *opaque, + Error **errp) { BlockDriverState *bs =3D opaque; ssize_t ret; @@ -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 buflen; + return 0; } =20 =20 @@ -99,12 +99,12 @@ struct BlockCryptoCreateData { }; =20 =20 -static ssize_t block_crypto_create_write_func(QCryptoBlock *block, - size_t offset, - const uint8_t *buf, - size_t buflen, - void *opaque, - Error **errp) +static int block_crypto_create_write_func(QCryptoBlock *block, + size_t offset, + const uint8_t *buf, + size_t buflen, + void *opaque, + Error **errp) { struct BlockCryptoCreateData *data =3D opaque; ssize_t ret; @@ -114,13 +114,13 @@ static ssize_t block_crypto_create_write_func(QCrypto= Block *block, error_setg_errno(errp, -ret, "Could not write encryption header"); return ret; } - return ret; + return 0; } =20 -static ssize_t block_crypto_create_init_func(QCryptoBlock *block, - size_t headerlen, - void *opaque, - Error **errp) +static int block_crypto_create_init_func(QCryptoBlock *block, + size_t headerlen, + void *opaque, + Error **errp) { struct BlockCryptoCreateData *data =3D opaque; Error *local_error =3D NULL; @@ -139,7 +139,7 @@ static ssize_t block_crypto_create_init_func(QCryptoBlo= ck *block, data->prealloc, 0, &local_error); =20 if (ret >=3D 0) { - return ret; + return 0; } =20 error: diff --git a/block/qcow2.c b/block/qcow2.c index d5a1e8bc43..c43238a006 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -94,9 +94,9 @@ static int qcow2_probe(const uint8_t *buf, int buf_size, = const char *filename) } =20 =20 -static ssize_t qcow2_crypto_hdr_read_func(QCryptoBlock *block, size_t offs= et, - uint8_t *buf, size_t buflen, - void *opaque, Error **errp) +static int qcow2_crypto_hdr_read_func(QCryptoBlock *block, size_t offset, + uint8_t *buf, size_t buflen, + void *opaque, Error **errp) { BlockDriverState *bs =3D opaque; BDRVQcow2State *s =3D bs->opaque; @@ -113,12 +113,12 @@ static ssize_t qcow2_crypto_hdr_read_func(QCryptoBloc= k *block, size_t offset, error_setg_errno(errp, -ret, "Could not read encryption header"); return -1; } - return buflen; + return 0; } =20 =20 -static ssize_t qcow2_crypto_hdr_init_func(QCryptoBlock *block, size_t head= erlen, - void *opaque, Error **errp) +static int qcow2_crypto_hdr_init_func(QCryptoBlock *block, size_t headerle= n, + void *opaque, Error **errp) { BlockDriverState *bs =3D opaque; BDRVQcow2State *s =3D bs->opaque; @@ -151,13 +151,13 @@ static ssize_t qcow2_crypto_hdr_init_func(QCryptoBloc= k *block, size_t headerlen, return -1; } =20 - return ret; + return 0; } =20 =20 -static ssize_t qcow2_crypto_hdr_write_func(QCryptoBlock *block, size_t off= set, - const uint8_t *buf, size_t bufl= en, - void *opaque, Error **errp) +static int qcow2_crypto_hdr_write_func(QCryptoBlock *block, size_t offset, + const uint8_t *buf, size_t buflen, + void *opaque, Error **errp) { BlockDriverState *bs =3D opaque; BDRVQcow2State *s =3D bs->opaque; @@ -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 buflen; + return 0; } =20 static QDict* diff --git a/crypto/block-luks.c b/crypto/block-luks.c index fe8f04ffb2..f62be6836b 100644 --- a/crypto/block-luks.c +++ b/crypto/block-luks.c @@ -495,7 +495,7 @@ qcrypto_block_luks_load_header(QCryptoBlock *block, void *opaque, Error **errp) { - ssize_t rv; + int rv; size_t i; QCryptoBlockLUKS *luks =3D block->opaque; =20 @@ -856,7 +856,7 @@ qcrypto_block_luks_store_key(QCryptoBlock *block, QCRYPTO_BLOCK_LUKS_SECTOR_SIZE, splitkey, splitkeylen, opaque, - errp) !=3D splitkeylen) { + errp) < 0) { goto cleanup; } =20 @@ -903,7 +903,7 @@ qcrypto_block_luks_load_key(QCryptoBlock *block, g_autofree uint8_t *splitkey =3D NULL; size_t splitkeylen; g_autofree uint8_t *possiblekey =3D NULL; - ssize_t rv; + int rv; g_autoptr(QCryptoCipher) cipher =3D NULL; uint8_t keydigest[QCRYPTO_BLOCK_LUKS_DIGEST_LEN]; g_autoptr(QCryptoIVGen) ivgen =3D NULL; @@ -1193,7 +1193,7 @@ qcrypto_block_luks_erase_key(QCryptoBlock *block, garbagesplitkey, splitkeylen, opaque, - &local_err) !=3D splitkeylen) { + &local_err) < 0) { error_propagate(errp, local_err); return -1; } diff --git a/crypto/block.c b/crypto/block.c index eb057948b5..7bb4b74a37 100644 --- a/crypto/block.c +++ b/crypto/block.c @@ -115,7 +115,7 @@ QCryptoBlock *qcrypto_block_create(QCryptoBlockCreateOp= tions *options, } =20 =20 -static ssize_t qcrypto_block_headerlen_hdr_init_func(QCryptoBlock *block, +static int qcrypto_block_headerlen_hdr_init_func(QCryptoBlock *block, size_t headerlen, void *opaque, Error **errp) { size_t *headerlenp =3D opaque; @@ -126,12 +126,12 @@ static ssize_t qcrypto_block_headerlen_hdr_init_func(= QCryptoBlock *block, } =20 =20 -static ssize_t qcrypto_block_headerlen_hdr_write_func(QCryptoBlock *block, +static int qcrypto_block_headerlen_hdr_write_func(QCryptoBlock *block, size_t offset, const uint8_t *buf, size_t buflen, void *opaque, Error **errp) { /* Discard the bytes, we're not actually writing to an image */ - return buflen; + return 0; } =20 =20 diff --git a/include/crypto/block.h b/include/crypto/block.h index 7a65e8e402..4f63a37872 100644 --- a/include/crypto/block.h +++ b/include/crypto/block.h @@ -29,24 +29,24 @@ typedef struct QCryptoBlock QCryptoBlock; /* See also QCryptoBlockFormat, QCryptoBlockCreateOptions * and QCryptoBlockOpenOptions in qapi/crypto.json */ =20 -typedef ssize_t (*QCryptoBlockReadFunc)(QCryptoBlock *block, - size_t offset, - uint8_t *buf, - size_t buflen, - void *opaque, - Error **errp); +typedef int (*QCryptoBlockReadFunc)(QCryptoBlock *block, + size_t offset, + uint8_t *buf, + size_t buflen, + void *opaque, + Error **errp); =20 -typedef ssize_t (*QCryptoBlockInitFunc)(QCryptoBlock *block, - size_t headerlen, - void *opaque, - Error **errp); +typedef int (*QCryptoBlockInitFunc)(QCryptoBlock *block, + size_t headerlen, + void *opaque, + Error **errp); =20 -typedef ssize_t (*QCryptoBlockWriteFunc)(QCryptoBlock *block, - size_t offset, - const uint8_t *buf, - size_t buflen, - void *opaque, - Error **errp); +typedef int (*QCryptoBlockWriteFunc)(QCryptoBlock *block, + size_t offset, + const uint8_t *buf, + size_t buflen, + void *opaque, + Error **errp); =20 /** * qcrypto_block_has_format: diff --git a/tests/unit/test-crypto-block.c b/tests/unit/test-crypto-block.c index 3b1f0d509f..3417b67be5 100644 --- a/tests/unit/test-crypto-block.c +++ b/tests/unit/test-crypto-block.c @@ -188,12 +188,12 @@ static struct QCryptoBlockTestData { }; =20 =20 -static ssize_t test_block_read_func(QCryptoBlock *block, - size_t offset, - uint8_t *buf, - size_t buflen, - void *opaque, - Error **errp) +static int test_block_read_func(QCryptoBlock *block, + size_t offset, + uint8_t *buf, + size_t buflen, + void *opaque, + Error **errp) { Buffer *header =3D opaque; =20 @@ -201,14 +201,14 @@ static ssize_t test_block_read_func(QCryptoBlock *blo= ck, =20 memcpy(buf, header->buffer + offset, buflen); =20 - return buflen; + return 0; } =20 =20 -static ssize_t test_block_init_func(QCryptoBlock *block, - size_t headerlen, - void *opaque, - Error **errp) +static int test_block_init_func(QCryptoBlock *block, + size_t headerlen, + void *opaque, + Error **errp) { Buffer *header =3D opaque; =20 @@ -216,16 +216,16 @@ static ssize_t test_block_init_func(QCryptoBlock *blo= ck, =20 buffer_reserve(header, headerlen); =20 - return headerlen; + return 0; } =20 =20 -static ssize_t test_block_write_func(QCryptoBlock *block, - size_t offset, - const uint8_t *buf, - size_t buflen, - void *opaque, - Error **errp) +static int test_block_write_func(QCryptoBlock *block, + size_t offset, + const uint8_t *buf, + size_t buflen, + void *opaque, + Error **errp) { Buffer *header =3D opaque; =20 @@ -234,7 +234,7 @@ static ssize_t test_block_write_func(QCryptoBlock *bloc= k, memcpy(header->buffer + offset, buf, buflen); header->offset =3D offset + buflen; =20 - return buflen; + return 0; } =20 =20 --=20 2.35.3 From nobody Wed Apr 24 23:40:10 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652458251; cv=none; d=zohomail.com; s=zohoarc; b=T7yDtzjfOKg0nPNDGCKyI8B/8BnjsXBvdDTu4omVg02i5Xb7CYz+wRrc/GIgYW18kIItwZXjcZuTSNPd5tCS/sz/SlzBrYIgjZinoeUa/SubUtytbtZd8HonPxIe6sjXWllMyg4sXx9R73DH3Zu8cScGcVBIWRBHIybpFbjQgZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652458251; 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=GpampNajM5UgtrwDmiLk0bVq9KGYx4aWYW3nYWLwC4w=; b=mcPCzBnrVUGUeKDwN+pC3kaxWXAzK49yb4OvU9yxXzFU0Hi8r4EXyW4x61KxdTwFG9S/E7bu+It1xYjpRh50GyvIk5PVi9oKZXsE7e3oGPUiJNnmP6X85hffjeGB8rSDLQlphYybkPFKvp205WMzpPxNY0D2iDoMiN0YUTHUYlU= 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+importer=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 165245825125599.81731978883397; Fri, 13 May 2022 09:10:51 -0700 (PDT) Received: from localhost ([::1]:39144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npXsQ-0007c5-6Q for importer@patchew.org; Fri, 13 May 2022 12:10:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npXfz-0001Pw-9V for qemu-devel@nongnu.org; Fri, 13 May 2022 11:58:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:52547) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npXfx-0002IZ-LH for qemu-devel@nongnu.org; Fri, 13 May 2022 11:57:58 -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-663-7z7Zg8ffOWuq-at06ogtCA-1; Fri, 13 May 2022 11:57:55 -0400 Received: by mail-wm1-f69.google.com with SMTP id h6-20020a7bc926000000b0039470bcb9easo3180360wml.1 for ; Fri, 13 May 2022 08:57:55 -0700 (PDT) Received: from DESKTOP-E7ACR7D.lan ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id l5-20020adfc785000000b0020cdcb0efa2sm2558758wrg.34.2022.05.13.08.57.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 08:57:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652457477; 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=GpampNajM5UgtrwDmiLk0bVq9KGYx4aWYW3nYWLwC4w=; b=YWJBnCXz3k6kyY0g3mL+2hLhteTfws6wlbvtZL3qIDTfD6BZQ5k9u/BEEpis/YVhBH+CjL ZKQY6W8zScohUGCxzg4l6t7m5jb0LlPwXsjA/Cw/RQRgv467cB3b1qHYom7/ZARZiy5Yon H1ollL85Yyz7cCu/JVECn7/+54vD0S8= X-MC-Unique: 7z7Zg8ffOWuq-at06ogtCA-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=GpampNajM5UgtrwDmiLk0bVq9KGYx4aWYW3nYWLwC4w=; b=Juvw+r4JAEO9PNzIMpiASfYtyoCsJkb1SPu9N538Ogmy7Z4fwxovEya2xc8wWFeWzT mQETaOpk2vMAGY1Iz+CHwKGxNBkkaI/n982voLT/ezSk5UStm8e23r23IgP9BdqDjhRc 2Qa2vnR4PU0rbcxWt1T3sJRkSwKJRTUY/GghN1hLkbUu1Ph+Kk3w5OYrnPmOE9+147ud XHt69HSRvDpgUVyPEH9slWbl9oexnxkKEty6jPL76FfOB4ywtFmW/cs2RbXmJZW72N19 amE6Xjmd7xNFQkNlN9flATNOKVIRGxbwtmvso54oazZJxA6Kbamgka62qqY80l2jlTwC IQvA== X-Gm-Message-State: AOAM532VvDSaaKKZhuNiAxYe8Twyk6jmYC2GzcStl1jluOC9PixG6uqO N0LLL1e3IC8GaQcBbPyMejAhC4iXlaWsuVTbe0m0lgAZukNhrXAiPK/23NPCszAATvrBPHHnSUz +mSg17hCNGQ3aWlR8haBW7q27cYeuq6A7AS+BWixDCZh3SkOuu1BPFAvpXV4AW9v2 X-Received: by 2002:adf:fc52:0:b0:20c:4c8a:e370 with SMTP id e18-20020adffc52000000b0020c4c8ae370mr4560447wrs.161.1652457474377; Fri, 13 May 2022 08:57:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJAE0fGtJv3gUO91O/W1T/M67GYszbpgHbSgm+d3Adw4uqut1VMHW98oJzbfo26FQxSM3BXQ== X-Received: by 2002:adf:fc52:0:b0:20c:4c8a:e370 with SMTP id e18-20020adffc52000000b0020c4c8ae370mr4560426wrs.161.1652457474192; Fri, 13 May 2022 08:57:54 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Alberto Faria , Paolo Bonzini , Kevin Wolf , Hanna Reitz Subject: [PATCH v2 05/10] block: Make bdrv_co_pwrite() take a const buffer Date: Fri, 13 May 2022 16:57:44 +0100 Message-Id: <20220513155749.2488070-3-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220513155418.2486450-1-afaria@redhat.com> References: <20220513155418.2486450-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+importer=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=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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652458253339100001 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 Wed Apr 24 23:40:10 2024 Delivered-To: importer@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+importer=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 1652457659059531.5111765296994; Fri, 13 May 2022 09:00:59 -0700 (PDT) Received: from localhost ([::1]:54464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npXir-0006Le-Vv for importer@patchew.org; Fri, 13 May 2022 12:00:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npXg0-0001R3-9l for qemu-devel@nongnu.org; Fri, 13 May 2022 11:58:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:58974) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npXfy-0002Ij-JL for qemu-devel@nongnu.org; Fri, 13 May 2022 11:58:00 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-629-T2mR9CLGMu6MLzkSWPTfqA-1; Fri, 13 May 2022 11:57:56 -0400 Received: by mail-wm1-f72.google.com with SMTP id t184-20020a1c46c1000000b00394209f54f1so3078139wma.4 for ; Fri, 13 May 2022 08:57:56 -0700 (PDT) Received: from DESKTOP-E7ACR7D.lan ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id l5-20020adfc785000000b0020cdcb0efa2sm2558758wrg.34.2022.05.13.08.57.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 08:57:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652457477; 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=mr9baOup5pIFh95eY4zB+Hxx/05d8EL0oqEFRJE8hT4=; b=Rgqa7CdleQgTZqGfi6UtV3NgkraMnCm5qA1xeb4oezcytJXAYR6Du2WmBBlUk0OgFyUJKv PsD7QZixQVHvXoq/PKHyDM2ZZcARZjc4VuDku4VF8/z8EFMk/vZZXaa7TEtJBLfsskbypI FEh9GCMck68uhcumXATgyK/2Y6HpEdg= X-MC-Unique: T2mR9CLGMu6MLzkSWPTfqA-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=mr9baOup5pIFh95eY4zB+Hxx/05d8EL0oqEFRJE8hT4=; b=bzYkq8fs3pJb/icGaiubnYxS5Gsear+2K2bIRttaQXkMc/zZHx5H5pOsJ0ujlDC9MP Yjf6UjFFZnvnQTDwTunb4tk+L/woq62mgIQNIaaKT3PMghxu4/ct3pMtQcHBqlp0xWFd QvAnPZPp2bLk0VgEePjD2+sTEyFP0NLVFRq99sr+hwouX94l92kMr1cYBt+nml9mmYdX 20KpVlDcM92btlXJ7D1+zY7sqZ7uNtUhAjjXdYhtXHp+Yl/P7aOUjERHc42IBq/FaMlj s1GlJLdPwqBLRwS1nqFmeZO+zmAjlSEvTH5NB68A8TXEhZjUSibl4qFoRgs1PLWoJwpA CnsA== X-Gm-Message-State: AOAM530ruepWVZ8Ljh8nxU7Aj1khcCvtoTrGmmPK8kaXqG4VEVxp1Lfh s84bGplvZhezJitxc2nXjPMWSHQf0fBgeHKJS3RdsDCmRl3kuohZFFBRrdF/FQSPKu5EvfbvsEF 5Bgi+OJQvL8JsmhP370bOxIhCrCYU+ANmV6zQEjKyYPP8pA2ymOmbLvlQaxNOMcmE X-Received: by 2002:a5d:64c8:0:b0:20c:6969:b277 with SMTP id f8-20020a5d64c8000000b0020c6969b277mr4544267wri.354.1652457475402; Fri, 13 May 2022 08:57:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKtE+HmIr+t9VOZKIRlHRErC4XceC5ZvjFpKn+tzqHDYFd5oAsFlUofki8fB6OU0ppRl25Ow== X-Received: by 2002:a5d:64c8:0:b0:20c:6969:b277 with SMTP id f8-20020a5d64c8000000b0020c6969b277mr4544251wri.354.1652457475203; Fri, 13 May 2022 08:57:55 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Alberto Faria , Paolo Bonzini , Kevin Wolf , Hanna Reitz Subject: [PATCH v2 06/10] block: Make 'bytes' param of bdrv_co_{pread, pwrite, preadv, pwritev}() an int64_t Date: Fri, 13 May 2022 16:57:45 +0100 Message-Id: <20220513155749.2488070-4-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220513155418.2486450-1-afaria@redhat.com> References: <20220513155418.2486450-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+importer=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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1652457661021100003 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 Wed Apr 24 23:40:10 2024 Delivered-To: importer@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+importer=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 1652457577172697.1141174799492; Fri, 13 May 2022 08:59:37 -0700 (PDT) Received: from localhost ([::1]:51638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npXhY-0004RK-3S for importer@patchew.org; Fri, 13 May 2022 11:59:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npXg2-0001Ts-3M for qemu-devel@nongnu.org; Fri, 13 May 2022 11:58:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23931) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npXfz-0002JG-O1 for qemu-devel@nongnu.org; Fri, 13 May 2022 11:58:01 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-124-y3bLlB0fN5SAeMcExbRLjQ-1; Fri, 13 May 2022 11:57:58 -0400 Received: by mail-wr1-f71.google.com with SMTP id j27-20020adfb31b000000b0020c4ca11566so3053371wrd.14 for ; Fri, 13 May 2022 08:57:57 -0700 (PDT) Received: from DESKTOP-E7ACR7D.lan ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id l5-20020adfc785000000b0020cdcb0efa2sm2558758wrg.34.2022.05.13.08.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 08:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652457479; 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=FcGvu50RtmqWJCfgzl9A9RBDNayfR1zOdU9lDxkj9RI=; b=Iaef3fKIimUJ87QUGCfsVaid9o+y5AnRZVno/7xFu3zgkyLXcLxj8qrYPk1mWYt4QDJphi gQEIcncQ8lY2+PgO8ryoxt0OwveRbDPqboihdEPLGn5mjbybp6YYgLQbZNcnz6BCpZcI7+ Ea41WnSxYO2IlDGjWpod0EnonwcUfvo= X-MC-Unique: y3bLlB0fN5SAeMcExbRLjQ-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=FcGvu50RtmqWJCfgzl9A9RBDNayfR1zOdU9lDxkj9RI=; b=hBJHxMgAUzCrYlW3zEdrDklvZz+n0t9rWBu7vHg1n5mmo9bU5NXzEqLTbUvW4HqGNs lBH0pJ3z4qs5xky+XKzHs+Qn3moiIf6CGhGQSnhEKaU3pJKSy2LsqmD3bmYSeHsiwEcj qnSVMSqL8JRJu3TBkItTuU578LgwTVRcBiBjk1/mi0xd+eQAUONgesjJ7a4pimXXbiV0 5IW+WyZrCE8L+UZQsdeWIDZA4m0UAZKZx6jbwXZ+LMYfYk8cKtnoRQtFQ9CEwDnibUQl 4Z1gPC0CTnjwMuLO7yw5D5XA1kZ4nTF1eYEhx66GkW0LB7GhYfonDeRevOsVQDKRioTd jzKg== X-Gm-Message-State: AOAM532sIeMAnLqUqEOkvrd1jqP2RVwmaJ2swcJUm3QqYruAs6Mg90gR /nOfqwTdjWT/uj4HwYKLUOzoijMlU8NLMozi1LtDEDADY0RzP55Td2zco2P08Pq0IJGB2Cd8Qil BbybOMrKlkf/73/pjgUUZTu4TNctrQI3NS2FZ/uRkuvd4XEjiYkdB5VxWDsBTLUF2 X-Received: by 2002:a05:6000:1788:b0:20c:a43c:10fa with SMTP id e8-20020a056000178800b0020ca43c10famr4478259wrg.511.1652457476706; Fri, 13 May 2022 08:57:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZ81a5mjtwbV1D/xZOYvYpqvDCVHWpHT9JurHo4h7g8JZOYKfeQYyhpdDTlmZWf1r3QM3t9w== X-Received: by 2002:a05:6000:1788:b0:20c:a43c:10fa with SMTP id e8-20020a056000178800b0020ca43c10famr4478233wrg.511.1652457476392; Fri, 13 May 2022 08:57:56 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Alberto Faria , Paolo Bonzini , Stefan Hajnoczi , Fam Zheng , Kevin Wolf , Hanna Reitz Subject: [PATCH v2 07/10] block: Implement bdrv_{pread, pwrite, pwrite_zeroes}() using generated_co_wrapper Date: Fri, 13 May 2022 16:57:46 +0100 Message-Id: <20220513155749.2488070-5-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220513155418.2486450-1-afaria@redhat.com> References: <20220513155418.2486450-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+importer=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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1652457577739100001 Content-Type: text/plain; charset="utf-8" bdrv_pwrite_zeroes() now also calls trace_bdrv_co_pwrite_zeroes() and clears the BDRV_REQ_MAY_UNMAP flag when appropriate, which it didn't previously. 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 Wed Apr 24 23:40:10 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652458463; cv=none; d=zohomail.com; s=zohoarc; b=I85S/DZVv9yU1lxsSJex09ZsXhrknc0HbAVnulBUAKbCI0gRAxutiss9apSH+ETb78cSon9hieHdX/Xj/rCe6h68FzRQ9rTrdg+Zsazg32Sg/cv+WFuThbCXtPlKRxgMEdEbsZR09JTQDuqCjPxIeHFY7pXKSc8SW2MeGHy6Fj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652458463; 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=UgbMHkWhsgJPf5WPgAeMbIGGOvJpYk05MGY0Cz6qJn0=; b=ex5PoTnEmOoskcTk7C9hCR/BPwfEGOkWA6K1+fmiboARQWmCRVvDSIGwLdp6FLAEtIsBMvWduzqIxZOOGQ4SLRuwzz6sWeYbniNtTce03Z1PyBqQjq1aiarF4mRbKj7Kp/TfnPf2GyEq4EolYnewCKosxTdqNdjwqdiEkmou3w4= 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+importer=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 1652458463577618.3493929644696; Fri, 13 May 2022 09:14:23 -0700 (PDT) Received: from localhost ([::1]:48486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npXvq-0005Yv-GP for importer@patchew.org; Fri, 13 May 2022 12:14:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50300) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npXg4-0001Uj-4j for qemu-devel@nongnu.org; Fri, 13 May 2022 11:58:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27333) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npXg1-0002JZ-Oq for qemu-devel@nongnu.org; Fri, 13 May 2022 11:58:03 -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-510-l7VYWu8fNM-702U49bFYZw-1; Fri, 13 May 2022 11:57:59 -0400 Received: by mail-wm1-f70.google.com with SMTP id n26-20020a1c721a000000b003941ea1ced7so3165511wmc.7 for ; Fri, 13 May 2022 08:57:59 -0700 (PDT) Received: from DESKTOP-E7ACR7D.lan ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id l5-20020adfc785000000b0020cdcb0efa2sm2558758wrg.34.2022.05.13.08.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 08:57:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652457480; 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=UgbMHkWhsgJPf5WPgAeMbIGGOvJpYk05MGY0Cz6qJn0=; b=PDQQbfqAB1iYPgdo37ZLXtZLn/IQosjYRlkvQ17NP4xYj8VmpbR8Dj0qbBOQvxP9YbIMoe bG3aSFnEI5o7c8vgCIctyPiUd0C825wRa5CARx3kEBK09Y7hd3SaKkwjuiE4ch1+leFD77 fY2V1hVD7q9K8a7kaQn7VEdjHEswkg8= X-MC-Unique: l7VYWu8fNM-702U49bFYZw-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=UgbMHkWhsgJPf5WPgAeMbIGGOvJpYk05MGY0Cz6qJn0=; b=sPWniUKRKAXp0YC+cbz4LY2AYtAw1rv2hz9D87vgdo3SlZE+HVLI/Y8iupP13U5dH4 2GuqiC2g+wnOMowEQTpP5C3ln/EkJwM4Q/GoHXQET758/lseVKdEgwc9+Li/O2F8gMQr nNMbBfAnsZpPKO9ZijkQyvyxDyOLntx79Vo3XEVPY48rp+mFYmDpfQGTeepWLd8Q+9AI fI99k0uCxnBpw61ar3UarI/UnbE/MQ6mbzXNYFDcZp5Bd1l3UkpFXM9yhVT8lYhu+hIk E64hgylIPYS+s8rp+NGU8ok0HWsTPI5yuyEom5Lv7OkH1gnRgbotYRiCqc1HOUfcb2jO VKmw== X-Gm-Message-State: AOAM5328P5E6aBi59fPquhJPcCn3INa0FrlvYQjSU4PoUS3JiYEq8Kpn mdorHJ+7KBIZKiMK424HNVNYSaYJVcJnmaEHyn5GpdCAEuKkKg5IIYFuuxtpg4WbddF4tIu33ax sI3OLkDa4wt6zIkYf31Dz57+bU9OEu79sHvktYtlyEF7SwhP6CdkVDDtF0zPEET5f X-Received: by 2002:a05:600c:a03:b0:395:bc75:61eb with SMTP id z3-20020a05600c0a0300b00395bc7561ebmr5225979wmp.46.1652457477986; Fri, 13 May 2022 08:57:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhSjLiBeu8C9cbejCf0e2s04VteJm25k6E5s2VvfUx/QI66fbFTKirMdtJQKtd/dtYpunGng== X-Received: by 2002:a05:600c:a03:b0:395:bc75:61eb with SMTP id z3-20020a05600c0a0300b00395bc7561ebmr5225951wmp.46.1652457477698; Fri, 13 May 2022 08:57:57 -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 v2 08/10] block: Add bdrv_co_pwrite_sync() Date: Fri, 13 May 2022 16:57:47 +0100 Message-Id: <20220513155749.2488070-6-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220513155418.2486450-1-afaria@redhat.com> References: <20220513155418.2486450-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+importer=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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652458464256100001 Content-Type: text/plain; charset="utf-8" Also convert bdrv_pwrite_sync() to being implemented using generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Eric Blake --- block/io.c | 9 +++++---- include/block/block-io.h | 8 ++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/block/io.c b/block/io.c index ecd1c2a53c..b2e35dbe23 100644 --- a/block/io.c +++ b/block/io.c @@ -1109,18 +1109,19 @@ int bdrv_make_zero(BdrvChild *child, BdrvRequestFla= gs 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(); =20 - ret =3D bdrv_pwrite(child, offset, bytes, buf, flags); + ret =3D bdrv_co_pwrite(child, offset, bytes, buf, flags); if (ret < 0) { return ret; } =20 - ret =3D bdrv_flush(child->bs); + ret =3D bdrv_co_flush(child->bs); if (ret < 0) { return ret; } 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 From nobody Wed Apr 24 23:40:10 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652458985; cv=none; d=zohomail.com; s=zohoarc; b=HG1lDY1sFZaHTQ1Y27udHZQePJRqms+PLNkFq1e+on950+0KxtPLIpRHgZzXoxA53vrFf/owbxFMuHxJF+1M0h0cnw+1ZvaECv3NxOMJTv8GG37Do+5Rw904EzSufkvoCdbN0Jhk4baIdhwiEECDzgdmDF1zgUhT59ioElRcDgc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652458985; 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=0ZiTTpsuZ33TDZjs3UGEEKFA0+EFT2f97t9Chg4BjWk=; b=CGyiJsWSXdgJkGKUMozJMXW7tyvib64qsBDpuoAMecU/SpCuDXua0yAO0TNLynJACUUpojjNGsKHIB5AGJpUCSY3jgZeoJXLu5T7CavxYylnNPTyC/EKcubG6EXp6EDQIP/1bk8sqp/j+VAqOo0GwgwSP3YEzl4oyEYW7uukZW4= 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+importer=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 1652458985024268.16222360153506; Fri, 13 May 2022 09:23:05 -0700 (PDT) Received: from localhost ([::1]:48950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npY4F-0000dL-F7 for importer@patchew.org; Fri, 13 May 2022 12:23:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50364) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npXg8-0001eJ-Hn for qemu-devel@nongnu.org; Fri, 13 May 2022 11:58:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:27345) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npXg5-0002KK-MO for qemu-devel@nongnu.org; Fri, 13 May 2022 11:58:08 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-269-oZnF6NlMMCa3ulMJiaiOrA-1; Fri, 13 May 2022 11:58:00 -0400 Received: by mail-wr1-f71.google.com with SMTP id w20-20020adfd1b4000000b0020cbb4347e6so3086791wrc.17 for ; Fri, 13 May 2022 08:58:00 -0700 (PDT) Received: from DESKTOP-E7ACR7D.lan ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id l5-20020adfc785000000b0020cdcb0efa2sm2558758wrg.34.2022.05.13.08.57.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 08:57:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652457484; 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=0ZiTTpsuZ33TDZjs3UGEEKFA0+EFT2f97t9Chg4BjWk=; b=h/876NfCVGahzp+3gAvXxA93Y5UYsY79Kfa2dbWAk9Xw2FCxLA6ARQealHfDou0OJbES7f EIC4NVCAXWYeCtcJ2VeXwVjRqsYSCIXV90bDW882s06XzMP56HLcok2hS17s8RKJKiubfX OeUqpaj0JlOzHQqKi8YcbM+jTx73K/s= X-MC-Unique: oZnF6NlMMCa3ulMJiaiOrA-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=0ZiTTpsuZ33TDZjs3UGEEKFA0+EFT2f97t9Chg4BjWk=; b=xlgTaIrGpNtjaa3B6cuyRRk+6uDggkMEt7GBIDDsf+J6rGOv0ftR9hnj9Vo/CwA+nT yN8kLwCnpK2X+V8ATckUKMQBSg0A3/Zp+uEA7xMwhVofLlkcy1v8MjapsXK9iyVr0mrE NtbBwM54EddRJasT4jJBFoIXJXrIrbFlvm52J4Kj0cKdNOkTdwLUNrMcoGR2QawwYGq/ S1AWOfBugbKzfEw51+33OZw2D+SiZHdF4A0rfZJQZ7PO0R/3UYHzz0UgYe9y+kW9Cy5f WQCzPE0qUHwKNk7LP0i+RZKJMZqAmoEGPMEZTzJkaGbns8uaoaGBiIeopBNjY0FBAvTZ fQyw== X-Gm-Message-State: AOAM532nI+KQNl3EZwNU5Aa2319v6ebPRu0gZudgio1Pwq1gCxDY7Zsg KldnLg1OUtDMAPi6NWZ4KFpFDP4LfGgsGj7fWxtpbE+cfYAv+6/JMVRuAXxhba6BlHp0YoF/QkG OQpJzFZz2Pmr49jNSdf3lxRH8ovcgVN9IWhZ0DARmY5fwk3OGbVot0WYx7aAe8+KN X-Received: by 2002:a05:600c:4f0f:b0:394:54c1:f5b3 with SMTP id l15-20020a05600c4f0f00b0039454c1f5b3mr16045955wmq.33.1652457479482; Fri, 13 May 2022 08:57:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaiITMnGmxDTx4yh24kd7XAX+ekpwI1aiEwDdqW8y+768s//RDPTd35b/+iXaRs40i46hnkA== X-Received: by 2002:a05:600c:4f0f:b0:394:54c1:f5b3 with SMTP id l15-20020a05600c4f0f00b0039454c1f5b3mr16045936wmq.33.1652457479278; Fri, 13 May 2022 08:57:59 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Alberto Faria , Stefan Hajnoczi , "Denis V. Lunev" , Vladimir Sementsov-Ogievskiy , Kevin Wolf , Hanna Reitz Subject: [PATCH v2 09/10] block: Use bdrv_co_pwrite_sync() when caller is coroutine_fn Date: Fri, 13 May 2022 16:57:48 +0100 Message-Id: <20220513155749.2488070-7-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220513155418.2486450-1-afaria@redhat.com> References: <20220513155418.2486450-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+importer=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=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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652458986252100001 Content-Type: text/plain; charset="utf-8" Convert uses of bdrv_pwrite_sync() into bdrv_co_pwrite_sync() when the callers are already coroutine_fn. Signed-off-by: Alberto Faria Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 2 +- block/qcow2-snapshot.c | 6 +++--- block/qcow2.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index f22444efff..8b23b9580d 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -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_size, s->header, 0= ); + ret =3D bdrv_co_pwrite_sync(bs->file, 0, s->header_size, s->header= , 0); if (ret < 0) { res->check_errors++; goto out; diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index 60e0461632..d1d46facbf 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -512,9 +512,9 @@ int coroutine_fn qcow2_check_read_snapshot_table(BlockD= riverState *bs, assert(fix & BDRV_FIX_ERRORS); =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), - sizeof(snapshot_table_pointer.nb_snapshots), - &snapshot_table_pointer.nb_snapshots, 0); + ret =3D bdrv_co_pwrite_sync(bs->file, offsetof(QCowHeader, nb_snap= shots), + sizeof(snapshot_table_pointer.nb_snapsho= ts), + &snapshot_table_pointer.nb_snapshots, 0); if (ret < 0) { result->check_errors++; fprintf(stderr, "ERROR failed to update the snapshot count in = the " diff --git a/block/qcow2.c b/block/qcow2.c index c43238a006..f2fb54c51f 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -4551,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), - sizeof(offset), &offset, 0); + ret =3D bdrv_co_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; --=20 2.35.3 From nobody Wed Apr 24 23:40:10 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652458139; cv=none; d=zohomail.com; s=zohoarc; b=MRbVBr+MxAzZgHyKju+XtSyYPNUQNi1DtsA/2SJ4XJJXV8toOoQvti3NFUJqeLWZzyG4AcV8aZa3GJkOWM+x0Z2seV8IzpJertaH73yK8OWB/w7scXk4dMmRLCwGEWRWLpFYuvOWgVcRLFVhJFO+bzhZFuLZ8jfk2GFTcfqw3Gg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652458139; 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=04vgAW3zSUgCkAoZ/zalDsggthLXpY/1atnq79b/gK4=; b=Zh4DJ7RyWM2Iae8kCF2TIFg542yOSr1gr06hfKWHRHY5OIGsydirWB8jDBXHzvMokZjraw9VOq5gE5WSN4WwFdVbuGoyZCsRQHDDcTdxBRtCgezMlgng6693efTmOCOzUC5Ypn3p/PJ1UZHjYT4hEM7llvY5rfPIWJceEbGr+f8= 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+importer=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 1652458139911569.6770531526006; Fri, 13 May 2022 09:08:59 -0700 (PDT) Received: from localhost ([::1]:34880 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npXqc-0004dz-MW for importer@patchew.org; Fri, 13 May 2022 12:08:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npXg8-0001dm-By for qemu-devel@nongnu.org; Fri, 13 May 2022 11:58:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:21953) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npXg3-0002K4-Qm for qemu-devel@nongnu.org; Fri, 13 May 2022 11:58:08 -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-41-qp82yJxPNYSK-5geCs0u5Q-1; Fri, 13 May 2022 11:58:01 -0400 Received: by mail-wm1-f70.google.com with SMTP id i18-20020a1c5412000000b0039491a8298cso3171474wmb.5 for ; Fri, 13 May 2022 08:58:01 -0700 (PDT) Received: from DESKTOP-E7ACR7D.lan ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id l5-20020adfc785000000b0020cdcb0efa2sm2558758wrg.34.2022.05.13.08.57.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 08:57:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652457483; 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=04vgAW3zSUgCkAoZ/zalDsggthLXpY/1atnq79b/gK4=; b=G/YpIji+sHphwSWP8ErNQ0Wyuze9N3AEL2EZ394pjkSpbcPqp9ZeQ4KSdFf2Qv0fSw0lU2 aEZCZNct1XemawFqOxahFpKhU3MMS36fl/ENdwmPgy0BU1zNAxF+qZKE0mWpnW1PwDbC8R iZoyeAupLxVm3ibuQMYksgpI49Hu3/w= X-MC-Unique: qp82yJxPNYSK-5geCs0u5Q-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=04vgAW3zSUgCkAoZ/zalDsggthLXpY/1atnq79b/gK4=; b=ME8UH6XZ/jiEgwFTeOT60xZXM2LfGfgERn8WBU+P1JYdNNlycOulr1JJPrJCvx4bK/ B0kzzjNqF3gYf3Y730n6bOBA4rftvNf/5+U2Y3Ha79hY/mSy/feD8Q/77IMcjw5xw8NL uGB31repV4mKWW5/q+iqulTvQntjWgaUOeTiny4YUJWcPlw9jzspwfrSwOfyPKtweTMb i8QSQ5dmKrSZKCRQ9Puibd3yscvczxCi2vDjHTNRLBgvLSkcE793wdaXhr2VtQGA0d/f h8uABvrz623yDnZg78iqHNvhXti1XUTcBtRW0UfNZz052rkE4JKe1Zlyf8fyD/0LG8S6 prAA== X-Gm-Message-State: AOAM5336F0HXhb5gpJ2tIBN7PbYo6S5ULecOOXzzZpn7nBce7IKS545K SLTfRF6DJ2hwt3Sn81h5l/DXdXiPkMYR2VfhI2ZIJzij4Qd5w2hiyiWEM+FDg2TENl2vTHeeSVa 6QOnm0cha+YlzqXlAuph6wrzwkfTcjrK/uACe7JWJxfEP5LqoB6WE1qryfKHozvqT X-Received: by 2002:a7b:c3cb:0:b0:394:3533:c712 with SMTP id t11-20020a7bc3cb000000b003943533c712mr5305970wmj.141.1652457480548; Fri, 13 May 2022 08:58:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyS7WxYqrF3HhjxJh7Gko+iyWsYUulrLRf6kW4vYJm53Gqv9vS8uqweVY75VGln0rIPDWZ9kg== X-Received: by 2002:a7b:c3cb:0:b0:394:3533:c712 with SMTP id t11-20020a7bc3cb000000b003943533c712mr5305950wmj.141.1652457480362; Fri, 13 May 2022 08:58:00 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Alberto Faria , Kevin Wolf , Hanna Reitz Subject: [PATCH v2 10/10] block/qcow2: Use bdrv_pwrite_sync() in qcow2_mark_dirty() Date: Fri, 13 May 2022 16:57:49 +0100 Message-Id: <20220513155749.2488070-8-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220513155418.2486450-1-afaria@redhat.com> References: <20220513155418.2486450-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+importer=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=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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652458141596100001 Content-Type: text/plain; charset="utf-8" Use bdrv_pwrite_sync() instead of calling bdrv_pwrite() and bdrv_flush() separately. Signed-off-by: Alberto Faria Reviewed-by: Eric Blake --- block/qcow2.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index f2fb54c51f..90a2dd406b 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -516,12 +516,9 @@ 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), - sizeof(val), &val, 0); - if (ret < 0) { - return ret; - } - ret =3D bdrv_flush(bs->file->bs); + ret =3D bdrv_pwrite_sync(bs->file, + offsetof(QCowHeader, incompatible_features), + sizeof(val), &val, 0); if (ret < 0) { return ret; } --=20 2.35.3