From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2Ww4-0003k9-JI for qemu-devel@nongnu.org; Thu, 25 Jul 2013 21:35:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V2Ww2-0002KT-8L for qemu-devel@nongnu.org; Thu, 25 Jul 2013 21:35:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4332) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2Wre-0000uP-Gw for qemu-devel@nongnu.org; Thu, 25 Jul 2013 21:30:38 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r6Q1UbVu004961 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 25 Jul 2013 21:30:38 -0400 Date: Thu, 25 Jul 2013 21:30:35 -0400 From: Jeff Cody Message-ID: <20130726013035.GB5445@localhost.localdomain> References: <1374742906-4489-1-git-send-email-famz@redhat.com> <1374742906-4489-8-git-send-email-famz@redhat.com> <20130725125641.GB19682@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130725125641.GB19682@localhost.localdomain> Subject: Re: [Qemu-devel] [PATCH 7/8] xen_disk: simplify blk_disconnect with refcnt List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com On Thu, Jul 25, 2013 at 08:56:41AM -0400, Jeff Cody wrote: > On Thu, Jul 25, 2013 at 05:01:45PM +0800, Fam Zheng wrote: > > We call bdrv_attach_dev when initializing whether or not bs is created > > locally, so call bdrv_detach_dev and let the refcnt handle the > > lifecycle. > > > > Signed-off-by: Fam Zheng > > --- > > hw/block/xen_disk.c | 7 +------ > > 1 file changed, 1 insertion(+), 6 deletions(-) > > > > diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c > > index 99537e8..3ec4bd2 100644 > > --- a/hw/block/xen_disk.c > > +++ b/hw/block/xen_disk.c > > @@ -910,12 +910,7 @@ static void blk_disconnect(struct XenDevice *xendev) > > struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); > > > > if (blkdev->bs) { > > - if (!blkdev->dinfo) { > > - /* close/delete only if we created it ourself */ > > - bdrv_close(blkdev->bs); > > - bdrv_detach_dev(blkdev->bs, blkdev); > > - bdrv_unref(blkdev->bs); > > - } > > + bdrv_detach_dev(blkdev->bs, blkdev); > > blkdev->bs = NULL; > > If the refcnt for blkdev->bs is > 1, then this leaks blkdev->bs, and > doesn't call bdrv_close(). > Same with this, I don't think it will leak this either. > > } > > xen_be_unbind_evtchn(&blkdev->xendev); > > -- > > 1.8.3.2 > > > >