From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45837) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCtdX-0007hb-3H for qemu-devel@nongnu.org; Mon, 10 Feb 2014 11:23:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCtdR-00081p-BE for qemu-devel@nongnu.org; Mon, 10 Feb 2014 11:23:10 -0500 Received: from paradis.irqsave.net ([62.212.105.220]:49583) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCtdR-00081g-0h for qemu-devel@nongnu.org; Mon, 10 Feb 2014 11:23:05 -0500 Date: Mon, 10 Feb 2014 17:23:04 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140210162304.GA5685@irqsave.net> References: <1391881159-13585-1-git-send-email-mreitz@redhat.com> <1391881159-13585-7-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1391881159-13585-7-git-send-email-mreitz@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 6/8] block: Handle bs->options in bdrv_open() only List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , Jeff Cody , qemu-devel@nongnu.org, Stefan Hajnoczi Le Saturday 08 Feb 2014 =E0 18:39:17 (+0100), Max Reitz a =E9crit : > The fail paths of bdrv_file_open() and bdrv_open() naturally exhibit > similarities, thus it is possible to reuse the one from bdrv_open() and > shorten the one in bdrv_file_open() accordingly. >=20 > Also, setting bs->options in bdrv_file_open() is not necessary if it is > already done in bdrv_open(). >=20 > Signed-off-by: Max Reitz > --- > block.c | 38 +++++++++++++++----------------------- > 1 file changed, 15 insertions(+), 23 deletions(-) >=20 > diff --git a/block.c b/block.c > index c57ad2c..1fcd7e0 100644 > --- a/block.c > +++ b/block.c > @@ -962,14 +962,6 @@ static int bdrv_file_open(BlockDriverState *bs, co= nst char *filename, > Error *local_err =3D NULL; > int ret; > =20 > - /* NULL means an empty set of options */ > - if (options =3D=3D NULL) { > - options =3D qdict_new(); > - } > - > - bs->options =3D options; > - options =3D qdict_clone_shallow(options); > - > /* Fetch the file name from the options QDict if necessary */ > if (!filename) { > filename =3D qdict_get_try_str(options, "filename"); > @@ -1044,9 +1036,6 @@ static int bdrv_file_open(BlockDriverState *bs, c= onst char *filename, > =20 > fail: > QDECREF(options); > - if (!bs->drv) { > - QDECREF(bs->options); > - } > return ret; > } > =20 > @@ -1244,18 +1233,6 @@ int bdrv_open(BlockDriverState **pbs, const char= *filename, > bs =3D bdrv_new(""); > } > =20 > - if (flags & BDRV_O_PROTOCOL) { > - assert(!drv); > - ret =3D bdrv_file_open(bs, filename, options, flags & ~BDRV_O_= PROTOCOL, > - errp); > - if (ret && !*pbs) { > - bdrv_unref(bs); > - } else if (!ret) { > - *pbs =3D bs; > - } > - return ret; > - } > - > /* NULL means an empty set of options */ > if (options =3D=3D NULL) { > options =3D qdict_new(); > @@ -1263,6 +1240,21 @@ int bdrv_open(BlockDriverState **pbs, const char= *filename, > bs->options =3D options; > options =3D qdict_clone_shallow(options); > =20 > + if (flags & BDRV_O_PROTOCOL) { > + assert(!drv); > + ret =3D bdrv_file_open(bs, filename, options, flags & ~BDRV_O_= PROTOCOL, > + &local_err); > + options =3D NULL; > + if (!ret) { > + *pbs =3D bs; > + return 0; > + } else if (bs->drv) { > + goto close_and_fail; > + } else { > + goto fail; > + } > + } > + > /* For snapshot=3Don, create a temporary qcow2 overlay */ > if (flags & BDRV_O_SNAPSHOT) { > BlockDriverState *bs1; > --=20 > 1.8.5.4 >=20 >=20 Reviewed-by: Benoit Canet