From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDwAz-0002Kd-KT for qemu-devel@nongnu.org; Thu, 13 Feb 2014 08:18:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDwAt-0007Re-JX for qemu-devel@nongnu.org; Thu, 13 Feb 2014 08:18:01 -0500 Received: from paradis.irqsave.net ([62.212.105.220]:49928) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDwAt-0007RP-7j for qemu-devel@nongnu.org; Thu, 13 Feb 2014 08:17:55 -0500 Date: Thu, 13 Feb 2014 14:17:53 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140213131753.GE4547@irqsave.net> References: <1390972061-26560-1-git-send-email-famz@redhat.com> <1390972061-26560-8-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1390972061-26560-8-git-send-email-famz@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v13 07/14] block: Parse "backing" option to reference existing BDS List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: kwolf@redhat.com, rjones@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, imain@redhat.com, stefanha@redhat.com, pbonzini@redhat.com The Wednesday 29 Jan 2014 =E0 13:07:34 (+0800), Fam Zheng wrote : > Now it's safe to allow reference for backing_hd in the interface. >=20 > Signed-off-by: Fam Zheng > --- > block.c | 26 ++++++++++++++++++++++++-- > 1 file changed, 24 insertions(+), 2 deletions(-) >=20 > diff --git a/block.c b/block.c > index 4e3b393..9d57223 100644 > --- a/block.c > +++ b/block.c > @@ -1392,12 +1392,34 @@ int bdrv_open(BlockDriverState *bs, const char = *filename, QDict *options, > /* If there is a backing file, use it */ > if ((flags & BDRV_O_NO_BACKING) =3D=3D 0) { > QDict *backing_options; > + const char *backing_name; > + BlockDriverState *backing_hd; > =20 > + backing_name =3D qdict_get_try_str(options, "backing"); > qdict_extract_subqdict(options, &backing_options, "backing."); > - ret =3D bdrv_open_backing_file(bs, backing_options, &local_err= ); > - if (ret < 0) { > + > + if (backing_name && qdict_size(backing_options)) { > + error_setg(&local_err, > + "Option \"backing\" and \"backing.*\" cannot be= " > + "used together"); > + ret =3D -EINVAL; > goto close_and_fail; > } > + if (backing_name) { > + backing_hd =3D bdrv_find(backing_name); Is backing_name a reference ? If so it would be nice if backing_name could refer to a bs by id or or an element of the graph by node-name. I posted a series which relax bdrv_lookup_bs rules to do so. Maybe this could be done after merge in another patch. > + if (!backing_hd) { > + error_set(&local_err, QERR_DEVICE_NOT_FOUND, backing_n= ame); > + ret =3D -ENOENT; > + goto close_and_fail; > + } > + qdict_del(options, "backing"); > + bdrv_set_backing_hd(bs, backing_hd); > + } else { > + ret =3D bdrv_open_backing_file(bs, backing_options, &local= _err); > + if (ret < 0) { > + goto close_and_fail; > + } > + } > } > =20 > /* Check if any unknown options were used */ > --=20 > 1.8.5.3 >=20 >=20