aboutsummaryrefslogtreecommitdiff
path: root/block/qcow2.c
diff options
context:
space:
mode:
authorAlberto Faria <afaria@redhat.com>2022-06-09 16:27:35 +0100
committerHanna Reitz <hreitz@redhat.com>2022-07-12 12:14:55 +0200
commit53fb7844f03241a0e6de2c342c9e1b89df12da4d (patch)
tree917522c3ce90e4449ffa7fb2a430aa137c22391e /block/qcow2.c
parent9548cbeffffd4253e38570d29b8cff0bf77c998f (diff)
downloadqemu-53fb7844f03241a0e6de2c342c9e1b89df12da4d.zip
qemu-53fb7844f03241a0e6de2c342c9e1b89df12da4d.tar.gz
qemu-53fb7844f03241a0e6de2c342c9e1b89df12da4d.tar.bz2
block: Add a 'flags' param to bdrv_{pread,pwrite,pwrite_sync}()
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 <afaria@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Message-Id: <20220609152744.3891847-2-afaria@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Diffstat (limited to 'block/qcow2.c')
-rw-r--r--block/qcow2.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/block/qcow2.c b/block/qcow2.c
index 4f5e644..99192d1 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;
}
- ret = bdrv_pread(bs->file,
- s->crypto_header.offset + offset, buf, buflen);
+ ret = bdrv_pread(bs->file, s->crypto_header.offset + offset, buf, buflen,
+ 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;
}
- ret = bdrv_pwrite(bs->file,
- s->crypto_header.offset + offset, buf, buflen);
+ ret = bdrv_pwrite(bs->file, s->crypto_header.offset + offset, buf, buflen,
+ 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", offset);
#endif
- ret = bdrv_pread(bs->file, offset, &ext, sizeof(ext));
+ ret = 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 = bdrv_pread(bs->file, offset, bs->backing_format, ext.len);
+ ret = bdrv_pread(bs->file, offset, bs->backing_format, ext.len, 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 != NULL) {
void *feature_table = g_malloc0(ext.len + 2 * sizeof(Qcow2Feature));
- ret = bdrv_pread(bs->file, offset , feature_table, ext.len);
+ ret = bdrv_pread(bs->file, offset, feature_table, ext.len, 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;
}
- ret = bdrv_pread(bs->file, offset, &s->crypto_header, ext.len);
+ ret = bdrv_pread(bs->file, offset, &s->crypto_header, ext.len, 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;
}
- ret = bdrv_pread(bs->file, offset, &bitmaps_ext, ext.len);
+ ret = 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 = g_malloc0(ext.len + 1);
- ret = bdrv_pread(bs->file, offset, s->image_data_file, ext.len);
+ ret = bdrv_pread(bs->file, offset, s->image_data_file, ext.len, 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 = ext.len;
QLIST_INSERT_HEAD(&s->unknown_header_ext, uext, next);
- ret = bdrv_pread(bs->file, offset , uext->data, uext->len);
+ ret = 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)
val = cpu_to_be64(s->incompatible_features | QCOW2_INCOMPAT_DIRTY);
ret = bdrv_pwrite(bs->file, offsetof(QCowHeader, incompatible_features),
- &val, sizeof(val));
+ &val, sizeof(val), 0);
if (ret < 0) {
return ret;
}
@@ -1308,7 +1308,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
uint64_t l1_vm_state_index;
bool update_header = false;
- ret = bdrv_pread(bs->file, 0, &header, sizeof(header));
+ ret = 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(BlockDriverState *bs, QDict *options,
s->unknown_header_fields_size = header.header_length - sizeof(header);
s->unknown_header_fields = g_malloc(s->unknown_header_fields_size);
ret = bdrv_pread(bs->file, sizeof(header), s->unknown_header_fields,
- s->unknown_header_fields_size);
+ s->unknown_header_fields_size, 0);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read unknown qcow2 header "
"fields");
@@ -1581,7 +1581,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
goto fail;
}
ret = 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(BlockDriverState *bs, QDict *options,
goto fail;
}
ret = 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)
}
/* Write the new header */
- ret = bdrv_pwrite(bs->file, 0, header, s->cluster_size);
+ ret = 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(BlockDriverState *bs, int64_t offset,
/* write updated header.size */
offset = cpu_to_be64(offset);
- ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, size),
- &offset, sizeof(offset));
+ ret = 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 = cpu_to_be64(s->cluster_size);
l1_ofs_rt_ofs_cls.reftable_clusters = cpu_to_be32(1);
ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, l1_table_offset),
- &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)
/* Enter the first refblock into the reftable */
rt_entry = cpu_to_be64(2 * s->cluster_size);
- ret = bdrv_pwrite_sync(bs->file, s->cluster_size,
- &rt_entry, sizeof(rt_entry));
+ ret = bdrv_pwrite_sync(bs->file, s->cluster_size, &rt_entry,
+ sizeof(rt_entry), 0);
if (ret < 0) {
goto fail_broken_refcounts;
}