From patchwork Tue Feb 23 15:06:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 46065 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1B13FB7D0B for ; Wed, 24 Feb 2010 02:07:58 +1100 (EST) Received: from localhost ([127.0.0.1]:48942 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NjwMd-0001YT-GU for incoming@patchwork.ozlabs.org; Tue, 23 Feb 2010 10:07:55 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NjwLs-0001Y6-WF for qemu-devel@nongnu.org; Tue, 23 Feb 2010 10:07:09 -0500 Received: from [199.232.76.173] (port=42290 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NjwLs-0001Xs-GH for qemu-devel@nongnu.org; Tue, 23 Feb 2010 10:07:08 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NjwLr-0004ND-9i for qemu-devel@nongnu.org; Tue, 23 Feb 2010 10:07:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36526) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NjwLq-0004N1-TB for qemu-devel@nongnu.org; Tue, 23 Feb 2010 10:07:07 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1NF75d9009077 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 23 Feb 2010 10:07:06 -0500 Received: from localhost.localdomain (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1NF748M027139; Tue, 23 Feb 2010 10:07:05 -0500 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Tue, 23 Feb 2010 16:06:20 +0100 Message-Id: <1266937580-25915-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com Subject: [Qemu-devel] [PATCH] qcow2: Fix image creation regression X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When checking for errors, commit db89119d compares with the wrong values, failing image creation even when there was no error. Additionally, if an error has occured, we can't preallocate the image (it's likely broken). This unbreaks test 023 of qemu-iotests. Signed-off-by: Kevin Wolf Acked-by: Juan Quintela --- block/qcow2.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 6632e6d..0e4cd98 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -986,7 +986,7 @@ static int qcow_create2(const char *filename, int64_t total_size, lseek(fd, s->refcount_block_offset, SEEK_SET); ret = qemu_write_full(fd, s->refcount_block, ref_clusters * s->cluster_size); - if (ret != s->cluster_size) { + if (ret != ref_clusters * s->cluster_size) { ret = -1; goto exit; } @@ -998,7 +998,7 @@ exit: close(fd); /* Preallocate metadata */ - if (prealloc) { + if (ret == 0 && prealloc) { BlockDriverState *bs; bs = bdrv_new(""); bdrv_open(bs, filename, BDRV_O_CACHE_WB | BDRV_O_RDWR);