From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42870) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5Rop-0004rn-SD for qemu-devel@nongnu.org; Mon, 20 Jan 2014 22:16:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W5Rok-0000by-Q2 for qemu-devel@nongnu.org; Mon, 20 Jan 2014 22:16:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5Rok-0000aY-GT for qemu-devel@nongnu.org; Mon, 20 Jan 2014 22:15:58 -0500 Date: Tue, 21 Jan 2014 11:15:53 +0800 From: Fam Zheng Message-ID: <20140121031553.GE29842@T430.redhat.com> References: <1386862440-8003-1-git-send-email-benoit@irqsave.net> <1386862440-8003-3-git-send-email-benoit@irqsave.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1386862440-8003-3-git-send-email-benoit@irqsave.net> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH V5 2/7] block: Allow the user to define "node-name" option. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?iso-8859-1?Q?Beno=EEt?= Canet Cc: kwolf@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, armbru@redhat.com On Thu, 12/12 16:33, Beno=EEt Canet wrote: > Signed-off-by: Benoit Canet > --- > block.c | 38 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 38 insertions(+) >=20 > diff --git a/block.c b/block.c > index 481d566..1c57f0d 100644 > --- a/block.c > +++ b/block.c > @@ -735,6 +735,39 @@ static int bdrv_open_flags(BlockDriverState *bs, i= nt flags) > return open_flags; > } > =20 > +static int bdrv_get_node_name(BlockDriverState *bs, > + QDict *options, > + Error **errp) This function actually assigns the node-name to bs, could you call it "bdrv_set_node_name" or "bdrv_assign_node_name", and only pass in the nod= e-name and move the parsing of options to the caller? Fam > +{ > + const char *node_name =3D NULL; > + > + node_name =3D qdict_get_try_str(options, "node-name"); > + > + if (!node_name) { > + return 0; > + } > + > + /* empty string node name is invalid */ > + if (node_name[0] =3D=3D '\0') { > + error_setg(errp, "Empty node name"); > + return -EINVAL; > + } > + > + /* takes care of avoiding duplicates node names */ > + if (bdrv_find_node(node_name)) { > + error_setg(errp, "Duplicate node name"); > + return -EINVAL; > + } > + > + /* copy node name into the bs and insert it into the graph list */ > + pstrcpy(bs->node_name, sizeof(bs->node_name), node_name); > + QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list); > + > + qdict_del(options, "node-name"); > + > + return 0; > +} > + > /* > * Common part for opening disk images and files > * > @@ -759,6 +792,11 @@ static int bdrv_open_common(BlockDriverState *bs, = BlockDriverState *file, > =20 > trace_bdrv_open_common(bs, filename ?: "", flags, drv->format_name= ); > =20 > + ret =3D bdrv_get_node_name(bs, options, errp); > + if (ret < 0) { > + return ret; > + } > + > /* bdrv_open() with directly using a protocol as drv. This layer i= s already > * opened, so assign it to bs (while file becomes a closed BlockDr= iverState) > * and return immediately. */ > --=20 > 1.8.3.2 >=20 >=20