From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VmW88-0002GJ-5y for qemu-devel@nongnu.org; Fri, 29 Nov 2013 17:01:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VmW83-0004mz-5g for qemu-devel@nongnu.org; Fri, 29 Nov 2013 17:01:44 -0500 Received: from nodalink.pck.nerim.net ([62.212.105.220]:41945 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VmW82-0004mp-R3 for qemu-devel@nongnu.org; Fri, 29 Nov 2013 17:01:39 -0500 Date: Fri, 29 Nov 2013 23:01:30 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20131129220130.GA4332@irqsave.net> References: <1385757689-23524-1-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1385757689-23524-1-git-send-email-mreitz@redhat.com> Content-Transfer-Encoding: quoted-printable 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 Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi Le Friday 29 Nov 2013 =E0 21:41:29 (+0100), Max Reitz a =E9crit : > 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 reope= n > the image file (which will include opening the backing file a second > time). >=20 > In particular, this will happen with a backing file opened through > qemu-nbd and using qcow2 as the top image file format (which reopens th= e > image to flush it to disk). >=20 > 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(+) >=20 > diff --git a/block.c b/block.c > index 382ea71..6d571ad 100644 > --- a/block.c > +++ b/block.c > @@ -4608,6 +4608,9 @@ void bdrv_img_create(const char *filename, const = char *fmt, > =20 > snprintf(buf, sizeof(buf), "%" PRId64, size); > set_option_parameter(param, BLOCK_OPT_SIZE, buf); > + > + bdrv_unref(bs); > + bs =3D NULL; > } else { > error_setg(errp, "Image creation needs a size parameter"); > goto out; Reviewed-by: Benoit Canet > --=20 > 1.8.4.2 >=20 >=20