Received: from eggs.gnu.org ([2001:4830:134:3::10]:49517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VeWpy-0000IX-Tt for qemu-devel@nongnu.org; Thu, 07 Nov 2013 16:10:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VeWpt-00033c-A3 for qemu-devel@nongnu.org; Thu, 07 Nov 2013 16:09:58 -0500 Received: from nodalink.pck.nerim.net ([62.212.105.220]:42117 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VeWps-00033I-VL for qemu-devel@nongnu.org; Thu, 07 Nov 2013 16:09:53 -0500 Date: Thu, 7 Nov 2013 22:09:48 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20131107210947.GJ2921@irqsave.net> References: <1383836503-25447-1-git-send-email-benoit@irqsave.net> <1383836503-25447-2-git-send-email-benoit@irqsave.net> <527BF6CF.8070407@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <527BF6CF.8070407@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/2] block: Add bs->node_name to hold the name of a bs node of the bs graph. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, armbru@redhat.com Le Thursday 07 Nov 2013 =E0 13:23:43 (-0700), Eric Blake a =E9crit : > On 11/07/2013 08:01 AM, Beno=EEt Canet wrote: > > Add the minimum of code to prepare the followings patches. > >=20 > > If no node_name is provided to bdrv_new the bs->node_name is set to "= undefined". > > This will allow to have some default string to communicate in QMP and= HMP. > > This also make "undefined" a reserved string for bs->node_name. > >=20 > > Signed-off-by: Benoit Canet > > --- >=20 > > + /* if node name is given store it in bs and insert bs in the gra= ph bs list > > + * note: undefined is a reserved node name > > + */ > > + if (node_name && > > + node_name[0] !=3D '\0' && > > + strcmp(node_name, "undefined")) { > > + pstrcpy(bs->node_name, sizeof(bs->node_name), node_name); > > + QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list); > > + /* else set the bs node name to undefined for QMP and HMP */ > > + } else { > > + sprintf(bs->node_name, "undefined"); >=20 > strcpy() is more efficient than sprintf() with no % in the format strin= g. >=20 >=20 > > =20 > > +/* This function is to find a node in the bs graph */ > > +BlockDriverState *bdrv_find_node(const char *node_name) > > +{ > > + BlockDriverState *bs; > > + >=20 > Should this function assert that node_name is not "undefined"? >=20 >=20 > > +++ b/include/block/block_int.h > > @@ -297,11 +297,18 @@ struct BlockDriverState { > > BlockdevOnError on_read_error, on_write_error; > > bool iostatus_enabled; > > BlockDeviceIoStatus iostatus; > > + > > + /* the following member give a name to every node on the BlockDr= iverState >=20 > s/give/gives/ >=20 > > + * graph. > > + */ > > + char node_name[32]; > > + QTAILQ_ENTRY(BlockDriverState) node_list; > > + /* Device name is the name associated with the "drive" the guest= see */ >=20 > s/see/sees/ >=20 > > char device_name[32]; > > + QTAILQ_ENTRY(BlockDriverState) device_list; >=20 > Maybe I missed it, but is there code that ensures there are no duplicat= e > node names (other than the magic "undefined")? >=20 Your are right I will add some checkings. > Seems like it's moving in the right direction, although I'm not sure > it's worth applying this until we know the qapi for working with node > names makes sense. I am not seeking for fast commit of these patch, I am only trying to avoi= d posting a long series at once. Best regards Beno=EEt >=20 > --=20 > Eric Blake eblake redhat com +1-919-301-3266 > Libvirt virtualization library http://libvirt.org >=20