qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH 1/3] block: add bdrv_get_device_or_node_name()


From: Eric Blake
Subject: Re: [Qemu-block] [PATCH 1/3] block: add bdrv_get_device_or_node_name()
Date: Wed, 08 Apr 2015 10:32:11 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

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 <address@hidden>
> Reviewed-by: Max Reitz <address@hidden>
> ---
>  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 <address@hidden>

-- 
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

[Prev in Thread] Current Thread [Next in Thread]