All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-2.6] vpc: fix return value check for blk_pwrite
@ 2016-04-07 14:52 Paolo Bonzini
  2016-04-08 11:55 ` Kevin Wolf
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Bonzini @ 2016-04-07 14:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf

bdrv_pwrite_sync used to return zero or negative error, while blk_pwrite returns
the number of written bytes when successful.  This caused VPC image creation
to fail spectacularly: it wrote the first 512 bytes, and then exited immediately
because of the non-zero answer from blk_pwrite.  But the truly spectacular part
is that it returns a positive value (the 512 that blk_pwrite returned) causing
everyone to believe that it succeeded.

This fixes qemu-iotests with vpc format.

Fixes: b8f45cdf7827e39f9a1e6cc446f5972cc6144237
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block/vpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/vpc.c b/block/vpc.c
index 8830b5b..3713ec3 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -775,7 +775,7 @@ static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf,
     num_bat_entries = (total_sectors + block_size / 512) / (block_size / 512);
 
     ret = blk_pwrite(blk, offset, buf, HEADER_SIZE);
-    if (ret) {
+    if (ret < 0) {
         goto fail;
     }
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.6] vpc: fix return value check for blk_pwrite
  2016-04-07 14:52 [Qemu-devel] [PATCH for-2.6] vpc: fix return value check for blk_pwrite Paolo Bonzini
@ 2016-04-08 11:55 ` Kevin Wolf
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Wolf @ 2016-04-08 11:55 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel

Am 07.04.2016 um 16:52 hat Paolo Bonzini geschrieben:
> bdrv_pwrite_sync used to return zero or negative error, while blk_pwrite returns
> the number of written bytes when successful.  This caused VPC image creation
> to fail spectacularly: it wrote the first 512 bytes, and then exited immediately
> because of the non-zero answer from blk_pwrite.  But the truly spectacular part
> is that it returns a positive value (the 512 that blk_pwrite returned) causing
> everyone to believe that it succeeded.
> 
> This fixes qemu-iotests with vpc format.
> 
> Fixes: b8f45cdf7827e39f9a1e6cc446f5972cc6144237
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Thanks, applied to the block branch.

Kevin

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-04-08 11:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-07 14:52 [Qemu-devel] [PATCH for-2.6] vpc: fix return value check for blk_pwrite Paolo Bonzini
2016-04-08 11:55 ` Kevin Wolf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.