From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1Z8p-0000cZ-8d for qemu-devel@nongnu.org; Tue, 23 Jul 2013 05:44:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1Z8m-0004cZ-Ur for qemu-devel@nongnu.org; Tue, 23 Jul 2013 05:44:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30889) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1Z8m-0004cH-NY for qemu-devel@nongnu.org; Tue, 23 Jul 2013 05:44:20 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r6N9iKeD023671 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 23 Jul 2013 05:44:20 -0400 Date: Tue, 23 Jul 2013 11:44:17 +0200 From: Stefan Hajnoczi Message-ID: <20130723094417.GC20256@stefanha-thinkpad.redhat.com> References: <1374054136-28741-1-git-send-email-famz@redhat.com> <1374054136-28741-5-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1374054136-28741-5-git-send-email-famz@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 04/11] block: use refcnt for device attach/detach List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: kwolf@redhat.com, hbrock@redhat.com, qemu-devel@nongnu.org, rjones@redhat.com, imain@redhat.com, pbonzini@redhat.com On Wed, Jul 17, 2013 at 05:42:09PM +0800, Fam Zheng wrote: > Signed-off-by: Fam Zheng > --- > block.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/block.c b/block.c > index 7b46669..57a3876 100644 > --- a/block.c > +++ b/block.c > @@ -1622,6 +1622,7 @@ int bdrv_attach_dev(BlockDriverState *bs, void *dev) > return -EBUSY; > } > bs->dev = dev; > + bdrv_ref(bs, false); > bdrv_iostatus_reset(bs); > return 0; > } > @@ -1639,6 +1640,7 @@ void bdrv_detach_dev(BlockDriverState *bs, void *dev) > { > assert(bs->dev == dev); > bs->dev = NULL; > + bdrv_unref(bs, false); > bs->dev_ops = NULL; > bs->dev_opaque = NULL; > bs->buffer_alignment = 512; I'm not 100% sure about this. sd_init() and ide_init2_with_non_qdev_drives() call bdrv_attach_dev_nofail() but I don't see a bdrv_detach_dev() call. It may be necessary to audit the lifecycle of emulated storage controllers more closely before the refcounts work correctly.