aboutsummaryrefslogtreecommitdiff
path: root/block/io.c
diff options
context:
space:
mode:
authorAlberto Faria <afaria@redhat.com>2022-06-09 16:27:37 +0100
committerHanna Reitz <hreitz@redhat.com>2022-07-12 12:14:55 +0200
commit353a5d84b25c335b259f37c4f43dad96e6d60ba8 (patch)
tree2bad4cabb0ec9703ee289439ca877b00b5f07696 /block/io.c
parent32cc71def9e3885f9527af713e6d8dc7521ddc08 (diff)
downloadqemu-353a5d84b25c335b259f37c4f43dad96e6d60ba8.zip
qemu-353a5d84b25c335b259f37c4f43dad96e6d60ba8.tar.gz
qemu-353a5d84b25c335b259f37c4f43dad96e6d60ba8.tar.bz2
block: Make bdrv_{pread,pwrite}() return 0 on success
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 <afaria@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20220609152744.3891847-4-afaria@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Diffstat (limited to 'block/io.c')
-rw-r--r--block/io.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/block/io.c b/block/io.c
index d4a39b5..86b5e8b 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1100,7 +1100,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 = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes);
IO_CODE();
@@ -1108,9 +1107,7 @@ int bdrv_pread(BdrvChild *child, int64_t offset, int64_t bytes, void *buf,
return -EINVAL;
}
- ret = bdrv_preadv(child, offset, bytes, &qiov, flags);
-
- return ret < 0 ? ret : bytes;
+ return bdrv_preadv(child, offset, bytes, &qiov, flags);
}
/* Return no. of bytes on success or < 0 on error. Important errors are:
@@ -1122,7 +1119,6 @@ int bdrv_pread(BdrvChild *child, int64_t offset, int64_t bytes, void *buf,
int bdrv_pwrite(BdrvChild *child, int64_t offset, int64_t bytes,
const void *buf, BdrvRequestFlags flags)
{
- int ret;
QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes);
IO_CODE();
@@ -1130,9 +1126,7 @@ int bdrv_pwrite(BdrvChild *child, int64_t offset, int64_t bytes,
return -EINVAL;
}
- ret = bdrv_pwritev(child, offset, bytes, &qiov, flags);
-
- return ret < 0 ? ret : bytes;
+ return bdrv_pwritev(child, offset, bytes, &qiov, flags);
}
/*