Received: from eggs.gnu.org ([2001:4830:134:3::10]:35701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoBIZ-0006PC-KY for qemu-devel@nongnu.org; Thu, 07 Apr 2016 10:52:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoBIU-0000tI-Hb for qemu-devel@nongnu.org; Thu, 07 Apr 2016 10:52:43 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:36036) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoBIU-0000tC-8k for qemu-devel@nongnu.org; Thu, 07 Apr 2016 10:52:38 -0400 Received: by mail-wm0-x241.google.com with SMTP id l6so4985782wml.3 for ; Thu, 07 Apr 2016 07:52:37 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 7 Apr 2016 16:52:34 +0200 Message-Id: <1460040754-108375-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH for-2.6] vpc: fix return value check for blk_pwrite List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com 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 --- 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