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.
> 
> Signed-off-by: Alberto Garcia <be...@igalia.com>
> Reviewed-by: Max Reitz <mre...@redhat.com>
> ---
>  block.c               | 9 +++++++++
>  block/quorum.c        | 5 +----
>  include/block/block.h | 1 +
>  3 files changed, 11 insertions(+), 4 deletions(-)
> 
> 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 
> BlockDriverState *bs)
>      return bs->blk ? blk_name(bs->blk) : "";
>  }
>  
> +/* 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 <ebl...@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to