qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] quorum: Implement bdrv_get_specific_info


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH] quorum: Implement bdrv_get_specific_info
Date: Thu, 24 Mar 2016 10:55:54 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0

On 03/23/2016 09:17 PM, Wen Congyang wrote:
> The monitor command 'query-block' or 'info block' will output the format 
> specific
> information. So we can get each child's child-name after this patch. This 
> useful
> for dynamic reconfiguration.
> 
> Signed-off-by: Wen Congyang <address@hidden>
> ---
>  block/quorum.c       | 27 +++++++++++++++++++++++++++
>  qapi/block-core.json | 15 ++++++++++++++-
>  2 files changed, 41 insertions(+), 1 deletion(-)

Can you add an example QMP session with the new information included, as
part of the commit message, to make it easier to see in context what you
are adding?

> 
> diff --git a/block/quorum.c b/block/quorum.c
> index da15465..afe6c3f 100644
> --- a/block/quorum.c
> +++ b/block/quorum.c
> @@ -1054,6 +1054,31 @@ static void quorum_refresh_filename(BlockDriverState 
> *bs, QDict *options)
>      bs->full_open_options = opts;
>  }
>  
> +static ImageInfoSpecific *quorum_get_specific_info(BlockDriverState *bs)
> +{
> +    int i;
> +    BDRVQuorumState *s = bs->opaque;
> +    ImageInfoSpecific *spec_info = g_new0(ImageInfoSpecific, 1);

Others have pointed out that this can be g_new(), since...

> +    strList **next;
> +
> +    *spec_info = (ImageInfoSpecific){
> +        .type = IMAGE_INFO_SPECIFIC_KIND_QUORUM,

...you are assigning all fields here.

> +        .u = {
> +            .quorum.data = g_new0(ImageInfoSpecificQuorum, 1),
> +        },

I think you could just directly do:

  .u.quorum.data = ...

instead of nesting {}.

> +    };
> +
> +    next = &spec_info->u.quorum.data->child_name;
> +    for (i = 0; i < s->num_children; i++) {
> +        *next = g_new0(strList, 1);
> +        (*next)->value = g_strdup(s->children[i]->name);
> +        (*next)->next = NULL;

Dead assignment, thanks to the g_new0() above.

> +        next = &(*next)->next;
> +    }
> +
> +    return spec_info;
> +}
> +

> +++ b/qapi/block-core.json
> @@ -75,6 +75,18 @@
>    } }
>  
>  ##
> +# @ImageInfoSpecificQuorum:
> +#
> +# @child-name: List of child name

As others have pointed out, I'd prefer:

@children: list of children's names

> +#
> +# Since: 2.7

Is this information needed in 2.6 (basically, a bug fix to finish an
incomplete feature addition), or are you really okay deferring it to 2.7?

> +##
> +{ 'struct': 'ImageInfoSpecificQuorum',
> +  'data': {
> +      'child-name': ['str']
> +  } }

Other than the naming, it looks okay.

> @@ -85,7 +97,8 @@
>  { 'union': 'ImageInfoSpecific',
>    'data': {
>        'qcow2': 'ImageInfoSpecificQCow2',
> -      'vmdk': 'ImageInfoSpecificVmdk'
> +      'vmdk': 'ImageInfoSpecificVmdk',
> +      'quorum': 'ImageInfoSpecificQuorum'

Worth keeping this list sorted?  QAPI doesn't care, but as the list gets
longer, sorted is easier to maintain.

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