From patchwork Mon Jan 18 12:11:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 43067 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 7D39DB7C7E for ; Mon, 18 Jan 2010 23:30:23 +1100 (EST) Received: from localhost ([127.0.0.1]:42146 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NWqiD-0002Ts-K0 for incoming@patchwork.ozlabs.org; Mon, 18 Jan 2010 07:28:05 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NWqTP-0006lG-Rm for qemu-devel@nongnu.org; Mon, 18 Jan 2010 07:12:47 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NWqTL-0006iN-6i for qemu-devel@nongnu.org; Mon, 18 Jan 2010 07:12:47 -0500 Received: from [199.232.76.173] (port=51042 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NWqTK-0006iG-Op for qemu-devel@nongnu.org; Mon, 18 Jan 2010 07:12:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:28781) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NWqTK-0001c0-Cv for qemu-devel@nongnu.org; Mon, 18 Jan 2010 07:12:42 -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 o0ICCfoK001930 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 18 Jan 2010 07:12:41 -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 o0ICCV9u011108; Mon, 18 Jan 2010 07:12:40 -0500 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Mon, 18 Jan 2010 13:11:34 +0100 Message-Id: <1263816696-24122-9-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 08/10] qcow2: Allow updating no refcounts 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 There's absolutely no problem with updating the refcounts of 0 clusters. At least snapshot code is doing this and would fail once the result of update_refcount isn't ignored any more. Signed-off-by: Kevin Wolf --- block/qcow2-refcount.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index a84620f..3dfadf1 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -284,8 +284,10 @@ static int update_refcount(BlockDriverState *bs, printf("update_refcount: offset=%" PRId64 " size=%" PRId64 " addend=%d\n", offset, length, addend); #endif - if (length <= 0) + if (length < 0) { return -EINVAL; + } + start = offset & ~(s->cluster_size - 1); last = (offset + length - 1) & ~(s->cluster_size - 1); for(cluster_offset = start; cluster_offset <= last;