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>
This commit is contained in:
Alberto Faria 2022-06-09 16:27:37 +01:00 committed by Hanna Reitz
parent 32cc71def9
commit 353a5d84b2
10 changed files with 19 additions and 31 deletions

View file

@ -89,7 +89,7 @@ static void test_sync_op_pread(BdrvChild *c)
/* Success */
ret = bdrv_pread(c, 0, sizeof(buf), buf, 0);
g_assert_cmpint(ret, ==, 512);
g_assert_cmpint(ret, ==, 0);
/* Early error: Negative offset */
ret = bdrv_pread(c, -2, sizeof(buf), buf, 0);
@ -103,7 +103,7 @@ static void test_sync_op_pwrite(BdrvChild *c)
/* Success */
ret = bdrv_pwrite(c, 0, sizeof(buf), buf, 0);
g_assert_cmpint(ret, ==, 512);
g_assert_cmpint(ret, ==, 0);
/* Early error: Negative offset */
ret = bdrv_pwrite(c, -2, sizeof(buf), buf, 0);