Received: from eggs.gnu.org ([2001:4830:134:3::10]:36284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxG8h-0006aU-R9 for qemu-devel@nongnu.org; Wed, 18 Jun 2014 09:43:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxG8c-0000Bp-Nm for qemu-devel@nongnu.org; Wed, 18 Jun 2014 09:42:59 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:51542 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxG8c-0000BV-HY for qemu-devel@nongnu.org; Wed, 18 Jun 2014 09:42:54 -0400 Date: Wed, 18 Jun 2014 15:42:52 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140618134252.GB4424@irqsave.net> References: <1403043250-28472-1-git-send-email-mreitz@redhat.com> <1403043250-28472-2-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1403043250-28472-2-git-send-email-mreitz@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/2] block: Do not prematurely remove "filename" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi The Wednesday 18 Jun 2014 =E0 00:14:09 (+0200), Max Reitz wrote : > If "filename" is removed from the options QDict before entering > bdrv_open_common(), it cannot be stored in the BDS. Therefore, wait > until it has been copied there and remove it from the options only > afterwards. >=20 > This fixes "filename" in the BDS being empty for block drivers which do > not need the filename because they have parsed it already (e.g. NBD). >=20 > Signed-off-by: Max Reitz > --- > block.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) >=20 > diff --git a/block.c b/block.c > index 43abe96..1fdfa66 100644 > --- a/block.c > +++ b/block.c > @@ -954,6 +954,14 @@ static int bdrv_open_common(BlockDriverState *bs, = BlockDriverState *file, > bs->filename[0] =3D '\0'; > } > =20 > + if (!drv->bdrv_needs_filename) { > + qdict_del(options, "filename"); > + /* The pointer "filename" may reference the just deleted QDict= entry; in > + * any case, it is no longer needed, so indicate that by setti= ng it to > + * NULL. */ > + filename =3D NULL; > + } > + > bs->drv =3D drv; > bs->opaque =3D g_malloc0(drv->instance_size); > =20 > @@ -1070,9 +1078,7 @@ static int bdrv_file_open(BlockDriverState *bs, c= onst char *filename, > goto fail; > } > =20 > - if (!drv->bdrv_needs_filename) { > - qdict_del(*options, "filename"); > - } else { > + if (drv->bdrv_needs_filename) { > filename =3D qdict_get_str(*options, "filename"); > } > } > --=20 > 2.0.0 >=20 >=20 Reviewed-by: Benoit Canet