From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2L67-0004Q4-Hn for qemu-devel@nongnu.org; Thu, 25 Jul 2013 08:56:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V2L64-0001vW-OI for qemu-devel@nongnu.org; Thu, 25 Jul 2013 08:56:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28009) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2L64-0001vR-G7 for qemu-devel@nongnu.org; Thu, 25 Jul 2013 08:56:44 -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 r6PCuhuD013687 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 25 Jul 2013 08:56:43 -0400 Date: Thu, 25 Jul 2013 08:56:41 -0400 From: Jeff Cody Message-ID: <20130725125641.GB19682@localhost.localdomain> References: <1374742906-4489-1-git-send-email-famz@redhat.com> <1374742906-4489-8-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1374742906-4489-8-git-send-email-famz@redhat.com> 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 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(). > } > xen_be_unbind_evtchn(&blkdev->xendev); > -- > 1.8.3.2 > >