From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VeW7O-0006um-7I for qemu-devel@nongnu.org; Thu, 07 Nov 2013 15:23:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VeW7J-00062U-HO for qemu-devel@nongnu.org; Thu, 07 Nov 2013 15:23:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:18091) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VeW7J-00062M-9G for qemu-devel@nongnu.org; Thu, 07 Nov 2013 15:23:49 -0500 Message-ID: <527BF6CF.8070407@redhat.com> Date: Thu, 07 Nov 2013 13:23:43 -0700 From: Eric Blake MIME-Version: 1.0 References: <1383836503-25447-1-git-send-email-benoit@irqsave.net> <1383836503-25447-2-git-send-email-benoit@irqsave.net> In-Reply-To: <1383836503-25447-2-git-send-email-benoit@irqsave.net> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="uflHsa0biP07Sqb1qQarLroOkRCNUNKxo" 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: =?UTF-8?B?QmVub8OudCBDYW5ldA==?= , qemu-devel@nongnu.org Cc: kwolf@redhat.com, famz@redhat.com, armbru@redhat.com, stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --uflHsa0biP07Sqb1qQarLroOkRCNUNKxo Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 11/07/2013 08:01 AM, Beno=C3=AEt 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 "un= defined". > This will allow to have some default string to communicate in QMP and H= MP. > This also make "undefined" a reserved string for bs->node_name. >=20 > Signed-off-by: Benoit Canet > --- > + /* if node name is given store it in bs and insert bs in the graph= 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"); strcpy() is more efficient than sprintf() with no % in the format string.= > =20 > +/* This function is to find a node in the bs graph */ > +BlockDriverState *bdrv_find_node(const char *node_name) > +{ > + BlockDriverState *bs; > + Should this function assert that node_name is not "undefined"? > +++ 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 BlockDriv= erState s/give/gives/ > + * graph. > + */ > + char node_name[32]; > + QTAILQ_ENTRY(BlockDriverState) node_list; > + /* Device name is the name associated with the "drive" the guest s= ee */ s/see/sees/ > char device_name[32]; > + QTAILQ_ENTRY(BlockDriverState) device_list; Maybe I missed it, but is there code that ensures there are no duplicate node names (other than the magic "undefined")? 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. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --uflHsa0biP07Sqb1qQarLroOkRCNUNKxo Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSe/bPAAoJEKeha0olJ0Nq8s0H/jTqAKLjEkVQkXuUvgr+PKjX TztH/AW6rSj9RW/FImT90A+pyRyE4GqIFkxhmvA2SHpKmxRSK0Ccttocrs66ddCM HYM7s02k/pLESd4JiBK3euwkOMmTuDRZBTh0yN4RAf8vaEKzYIQV2L/T6A3LZb45 44l7AxLShdHfVqZy4yWthmblQNB8AmdfIwiGxC5yMlE6pE7vQYP61YPqbF2oxXoe SztEJ6WOo3mT/KxQTkXn8uaSVMEteL5Uy/+FVuTYSX60PM1KZ/0+jqEBx8SaW2WP RvnF8VyWtLMfWNB57kFRgYX681C120NvVAVJmKcgmRspAkofzhORCWwS4s/yC6g= =5zBc -----END PGP SIGNATURE----- --uflHsa0biP07Sqb1qQarLroOkRCNUNKxo--