From patchwork Thu Apr 7 14:52:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 8773731 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 05674C0553 for ; Thu, 7 Apr 2016 14:52:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6615920121 for ; Thu, 7 Apr 2016 14:52:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BD3172017E for ; Thu, 7 Apr 2016 14:52:52 +0000 (UTC) Received: from localhost ([::1]:50349 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoBIi-0006RF-7B for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Apr 2016 10:52:52 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=zPqUVJdKt8hnjs1PmAOzk5rBhF0ZUEaGgzsn2n+QutA=; b=0QfS156rLemJwLRPXDIfPer0TH+q7bwRUldpyzBWXCW14NfBZl6/ynuqv1h8TW5zY1 aOsR5ihQfClOERVp8k0X9ibMEnbiozUVFX4q/haYWOGnP5ltG8p+6939i8OOuoPM4fbl UeEUsnpWm3lWmwoUOzzGMn+iykZleCl1Rgxs7cqpTH5MY11RO/TGqshe6WO4Cmms8VWU dvQ8NdENrQ+dI2R6nsAHz9GEEo6JeR7b3UtxDWRA51d1pdzTGL0m/7X3Dg4IKQguhv3m +Y5/GnFscyONPbnpjj/a1OIBGXd4XIk8uRzBZl6tes8ux42lOwt51wwctQ4MY/X1yiNS NqTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=zPqUVJdKt8hnjs1PmAOzk5rBhF0ZUEaGgzsn2n+QutA=; b=mnlxCjY5mrUdcoeTNnrpH0tPgbPXM/YOClH+iSnuYLn6znBBvrYBEExS6ZSFZ8csRM VhWcb3b8POquYHiHPI9q1lNvylXckynWgc8r2HzzewX5NR60ffl57celuDfps9PveqY6 Vw9fzbFBKrpXr6FMV5JyIh/RN4VCHbibpNimL9ixNFLZAe6x4kRGqGlMO/9lUa76YgL8 QEMxutCmlEOLLhkPc8lr+pXwv92Mvp6TAlBnCH0kb0kgCvNpFDGL3RlSulH0sbRCn+uF wD0BaqeNRAUvn+2j/IUj4ft5HEJFj3eTgTCRVnBEu3j1Bsef2mZ0zcXAxHiY7cu1R+cJ P1yQ== X-Gm-Message-State: AD7BkJIoqsIkRZgtLOgSR91JhBX3ASgpOPr+Rs8PIWxEAOdkEJKy41qWl6IrshGEAozY9A== X-Received: by 10.28.126.21 with SMTP id z21mr12275384wmc.73.1460040757182; Thu, 07 Apr 2016 07:52:37 -0700 (PDT) Received: from 640k.lan (94-39-141-76.adsl-ull.clienti.tiscali.it. [94.39.141.76]) by smtp.gmail.com with ESMTPSA id u16sm9369845wmd.5.2016.04.07.07.52.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Apr 2016 07:52:36 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 7 Apr 2016 16:52:34 +0200 Message-Id: <1460040754-108375-1-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::241 Cc: kwolf@redhat.com Subject: [Qemu-devel] [PATCH for-2.6] vpc: fix return value check for blk_pwrite X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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; }