From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Kevin Wolf Date: Tue, 23 Feb 2010 16:06:20 +0100 Message-Id: <1266937580-25915-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH] qcow2: Fix image creation regression List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com 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 --- 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); -- 1.6.6.1