From patchwork Wed Jul 17 09:42:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 259676 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 463532C0095 for ; Wed, 17 Jul 2013 20:01:16 +1000 (EST) Received: from localhost ([::1]:53195 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzOJZ-0000Rw-Gu for incoming@patchwork.ozlabs.org; Wed, 17 Jul 2013 05:46:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzOGT-000498-I7 for qemu-devel@nongnu.org; Wed, 17 Jul 2013 05:43:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UzOGR-0007w7-1d for qemu-devel@nongnu.org; Wed, 17 Jul 2013 05:43:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59617) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzOGQ-0007vh-Iw for qemu-devel@nongnu.org; Wed, 17 Jul 2013 05:43:14 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r6H9hDGd007941 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 17 Jul 2013 05:43:13 -0400 Received: from T430s.nay.redhat.com ([10.66.6.13]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r6H9gVr0026351; Wed, 17 Jul 2013 05:43:10 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 17 Jul 2013 17:42:14 +0800 Message-Id: <1374054136-28741-10-git-send-email-famz@redhat.com> In-Reply-To: <1374054136-28741-1-git-send-email-famz@redhat.com> References: <1374054136-28741-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, famz@redhat.com, hbrock@redhat.com, rjones@redhat.com, imain@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH v2 09/11] block: add assertion to check refcount before deleting 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org If BDS is managed with refcnt, we should not call bdrv_delete() directly, instead bdrv_unref() should be used. Adding assertion to ensure this. Signed-off-by: Fam Zheng --- block.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block.c b/block.c index 499de22..147a448 100644 --- a/block.c +++ b/block.c @@ -1606,6 +1606,8 @@ void bdrv_delete(BlockDriverState *bs) { assert(!bs->dev); assert(!bs->job); + assert(!bs->refcnt_soft); + assert(!bs->refcnt_hard); /* remove from list, if necessary */ bdrv_make_anon(bs);