qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Wen Congyang <wency@cn.fujitsu.com>,
	qemu-devl <qemu-devel@nongnu.org>, Max Reitz <mreitz@redhat.com>,
	Alberto Garcia <berto@igalia.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>
Cc: Changlong Xie <xiecl.fnst@cn.fujitsu.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] quorum: Implement bdrv_get_specific_info
Date: Thu, 24 Mar 2016 10:55:54 -0600	[thread overview]
Message-ID: <56F41C1A.6070004@redhat.com> (raw)
In-Reply-To: <56F35C38.3040804@cn.fujitsu.com>

[-- Attachment #1: Type: text/plain, Size: 2974 bytes --]

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 <wency@cn.fujitsu.com>
> ---
>  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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  parent reply	other threads:[~2016-03-24 16:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-24  3:17 [Qemu-devel] [PATCH] quorum: Implement bdrv_get_specific_info Wen Congyang
2016-03-24  3:26 ` Fam Zheng
2016-03-24 12:52 ` Alberto Garcia
2016-03-24 16:55 ` Eric Blake [this message]
2016-03-24 17:02 ` Max Reitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56F41C1A.6070004@redhat.com \
    --to=eblake@redhat.com \
    --cc=berto@igalia.com \
    --cc=dgilbert@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=wency@cn.fujitsu.com \
    --cc=xiecl.fnst@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).