From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnKKb-0006Mn-QJ for qemu-devel@nongnu.org; Sun, 01 Dec 2013 22:38:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VnKKS-0007M4-Se for qemu-devel@nongnu.org; Sun, 01 Dec 2013 22:37:57 -0500 Received: from e28smtp06.in.ibm.com ([122.248.162.6]:55805) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnKKS-0007Kg-6c for qemu-devel@nongnu.org; Sun, 01 Dec 2013 22:37:48 -0500 Received: from /spool/local by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 2 Dec 2013 09:07:40 +0530 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id 62A1E1258051 for ; Mon, 2 Dec 2013 09:08:39 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id rB23bZrE48169078 for ; Mon, 2 Dec 2013 09:07:35 +0530 Received: from d28av03.in.ibm.com (localhost [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id rB23bZDq019798 for ; Mon, 2 Dec 2013 09:07:35 +0530 Message-ID: <529C0080.7070106@linux.vnet.ibm.com> Date: Mon, 02 Dec 2013 11:37:36 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1385757689-23524-1-git-send-email-mreitz@redhat.com> In-Reply-To: <1385757689-23524-1-git-send-email-mreitz@redhat.com> Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v2] block: Close backing file early in bdrv_img_create List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi ÓÚ 2013/11/30 4:41, Max Reitz дµÀ: > Leaving the backing file open although it is not needed anymore can > cause problems if it is opened through a block driver which allows > exclusive access only and if the create function of the block driver > used for the top image (the one being created) tries to close and reopen > the image file (which will include opening the backing file a second > time). > > In particular, this will happen with a backing file opened through > qemu-nbd and using qcow2 as the top image file format (which reopens the > image to flush it to disk). > > Signed-off-by: Max Reitz > --- > v2: > - Minimizing the changes prevents introducing a leak of the > BlockDriverState in case of an error in bdrv_open() (thanks, Kevin). > --- > block.c | 3 +++ > 1 file changed, 3 insertions(+) > Minor comments: I think your v1 have better orgnize of code, since it tips reader that bs is a variable used only in backing file code. Why not improve it by just adding one line in v1: line 4587: ret = bdrv_open(bs, backing_file->value.s, NULL, back_flags, backing_drv, &local_err); if (ret < 0) { error_setg_errno(errp, -ret, "Could not open '%s': %s", backing_file->value.s, error_get_pretty(local_err)); error_free(local_err); local_err = NULL; bdrv_unref(bs); goto out; } It is not a big problem, I am OK if you stick to this version.