[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/3] block: add bdrv_get_device_or_node_name()
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH 1/3] block: add bdrv_get_device_or_node_name() |
Date: |
Fri, 20 Mar 2015 08:40:32 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Alberto Garcia <address@hidden> writes:
> 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>
> ---
> block.c | 5 +++++
> block/quorum.c | 5 +----
> include/block/block.h | 1 +
> 3 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/block.c b/block.c
> index 0fe97de..af284e3 100644
> --- a/block.c
> +++ b/block.c
> @@ -3920,6 +3920,11 @@ const char *bdrv_get_device_name(const
> BlockDriverState *bs)
> return bs->blk ? blk_name(bs->blk) : "";
> }
>
> +const char *bdrv_get_device_or_node_name(const BlockDriverState *bs)
> +{
> + return bs->blk ? blk_name(bs->blk) : bs->node_name;
> +}
> +
Does this have uses beyond identifying @bs to the user?
> int bdrv_get_flags(BlockDriverState *bs)
> {
> return bs->open_flags;
> diff --git a/block/quorum.c b/block/quorum.c
> index 437b122..f91ef75 100644
> --- a/block/quorum.c
> +++ b/block/quorum.c
> @@ -226,10 +226,7 @@ static void quorum_report_bad(QuorumAIOCB *acb, char
> *node_name, int ret)
>
> static void quorum_report_failure(QuorumAIOCB *acb)
> {
> - const char *reference = bdrv_get_device_name(acb->common.bs)[0] ?
> - bdrv_get_device_name(acb->common.bs) :
> - acb->common.bs->node_name;
> -
> + const char *reference = bdrv_get_device_or_node_name(acb->common.bs);
> qapi_event_send_quorum_failure(reference, acb->sector_num,
> acb->nb_sectors, &error_abort);
> }
Preexisting: what if reference is null?
event.json suggests it can't be null:
##
# @QUORUM_FAILURE
#
# Emitted by the Quorum block driver if it fails to establish a quorum
#
# @reference: device name if defined else node name
#
# @sector-num: number of the first sector of the failed read operation
#
# @sectors-count: failed read operation sector count
#
# Since: 2.0
##
{ 'event': 'QUORUM_FAILURE',
'data': { 'reference': 'str', 'sector-num': 'int', 'sectors-count': 'int'
} }
> diff --git a/include/block/block.h b/include/block/block.h
> index 4c57d63..b285e0d 100644
> --- a/include/block/block.h
> +++ b/include/block/block.h
> @@ -398,6 +398,7 @@ void bdrv_iterate_format(void (*it)(void *opaque, const
> char *name),
> void *opaque);
> const char *bdrv_get_node_name(const BlockDriverState *bs);
> const char *bdrv_get_device_name(const BlockDriverState *bs);
> +const char *bdrv_get_device_or_node_name(const BlockDriverState *bs);
> int bdrv_get_flags(BlockDriverState *bs);
> int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
> const uint8_t *buf, int nb_sectors);