From patchwork Mon Jan 18 12:11:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 43069 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 78BFEB7C63 for ; Mon, 18 Jan 2010 23:33:14 +1100 (EST) Received: from localhost ([127.0.0.1]:36511 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NWqd5-0000gw-N3 for incoming@patchwork.ozlabs.org; Mon, 18 Jan 2010 07:22:47 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NWqTO-0006kA-0m for qemu-devel@nongnu.org; Mon, 18 Jan 2010 07:12:46 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NWqTI-0006hF-Mx for qemu-devel@nongnu.org; Mon, 18 Jan 2010 07:12:45 -0500 Received: from [199.232.76.173] (port=51040 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NWqTI-0006h9-EP for qemu-devel@nongnu.org; Mon, 18 Jan 2010 07:12:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:13646) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NWqTI-0001bi-3L for qemu-devel@nongnu.org; Mon, 18 Jan 2010 07:12:40 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0ICCd4A021660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 18 Jan 2010 07:12:39 -0500 Received: from localhost.localdomain (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o0ICCV9s011108; Mon, 18 Jan 2010 07:12:38 -0500 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Mon, 18 Jan 2010 13:11:32 +0100 Message-Id: <1263816696-24122-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1263816696-24122-1-git-send-email-kwolf@redhat.com> References: <1263816696-24122-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Kevin Wolf Subject: [Qemu-devel] [PATCH 06/10] qcow2: Fix error handling in grow_refcount_table 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 Return the appropriate error code instead of -EIO. Signed-off-by: Kevin Wolf Reviewed-by: Christoph Hellwig --- block/qcow2-refcount.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 3a2d44a..6f449c6 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -168,9 +168,12 @@ static int grow_refcount_table(BlockDriverState *bs, int min_size) cpu_to_be64w((uint64_t*)data, table_offset); cpu_to_be32w((uint32_t*)(data + 8), refcount_table_clusters); - if (bdrv_pwrite(s->hd, offsetof(QCowHeader, refcount_table_offset), - data, sizeof(data)) != sizeof(data)) + ret = bdrv_pwrite(s->hd, offsetof(QCowHeader, refcount_table_offset), + data, sizeof(data)); + if (ret != sizeof(data)) { goto fail; + } + qemu_free(s->refcount_table); old_table_offset = s->refcount_table_offset; old_table_size = s->refcount_table_size; @@ -183,7 +186,7 @@ static int grow_refcount_table(BlockDriverState *bs, int min_size) return 0; fail: qemu_free(new_table); - return -EIO; + return ret < 0 ? ret : -EIO; }