From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34106) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yfsto-00032J-JS for qemu-devel@nongnu.org; Wed, 08 Apr 2015 12:32:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yfstn-0003Im-Ie for qemu-devel@nongnu.org; Wed, 08 Apr 2015 12:32:20 -0400 Message-ID: <5525580B.1030307@redhat.com> Date: Wed, 08 Apr 2015 10:32:11 -0600 From: Eric Blake MIME-Version: 1.0 References: <4fa30aa8d61d9052ce266fd5429a59a14e941255.1428485266.git.berto@igalia.com> In-Reply-To: <4fa30aa8d61d9052ce266fd5429a59a14e941255.1428485266.git.berto@igalia.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="U8hamiNGdE9fu6DSi2M63oBPJaFouVBB9" Subject: Re: [Qemu-devel] [PATCH 1/3] block: add bdrv_get_device_or_node_name() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alberto Garcia , qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, Markus Armbruster , Stefan Hajnoczi , Max Reitz This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --U8hamiNGdE9fu6DSi2M63oBPJaFouVBB9 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 04/08/2015 03:29 AM, Alberto Garcia wrote: > This function gets the device name associated with a BlockDriverState, > or its node name if the device name is empty. >=20 > Signed-off-by: Alberto Garcia > Reviewed-by: Max Reitz > --- > block.c | 9 +++++++++ > block/quorum.c | 5 +---- > include/block/block.h | 1 + > 3 files changed, 11 insertions(+), 4 deletions(-) >=20 > diff --git a/block.c b/block.c > index f2f8ae7..24adfc1 100644 > --- a/block.c > +++ b/block.c > @@ -3953,6 +3953,15 @@ const char *bdrv_get_device_name(const BlockDriv= erState *bs) > return bs->blk ? blk_name(bs->blk) : ""; > } > =20 > +/* This can be used to identify nodes that might not have a device > + * name associated. Since node and device names live in the same > + * namespace, the result is unambiguous. The exception is if both are > + * absent, then this returns an empty (non-null) string. */ > +const char *bdrv_get_device_or_node_name(const BlockDriverState *bs) > +{ > + return bs->blk ? blk_name(bs->blk) : bs->node_name; I had to check; bs->node_name is an array rather than a pointer, so it always contains a non-null string (whether or not it is the empty string), so your comment is correct. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --U8hamiNGdE9fu6DSi2M63oBPJaFouVBB9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVJVgLAAoJEKeha0olJ0NqkwwH/2F/o5TifIr9SaFDT6nP5T2Z f1OfrgL9lmNskGcVT2RxEE6OcvS90ntcYlAx/kh800IT7fu/hnPcVvKkmmq425Bx cPOxJGHbXDaMsMK72MUpC61mdNMnjnaSl2QdNFJzT7sj49E+itZDavmF82urm1Zv 6rLZKKsSJrYCkccE012Y73GgM9g2L74ODG3JBBAuS1SmmOqvLlYN7loipdsQ+85K JPTiD+zKqk6oD6l8cRX5cZd8qOeDxGpJ/vlxkc40tx/VF5wgBd8bo5GITHVeLlMP xHVS9lWfTXfc6w4C7MHibxVy1g5E2cCpV5SsRT1xjiA165hgtpUprrr/PmPW0bw= =Q/oD -----END PGP SIGNATURE----- --U8hamiNGdE9fu6DSi2M63oBPJaFouVBB9--