From: Max Reitz <mreitz@redhat.com>
To: Wen Congyang <wency@cn.fujitsu.com>,
qemu-devl <qemu-devel@nongnu.org>,
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 18:02:20 +0100 [thread overview]
Message-ID: <56F41D9C.6050408@redhat.com> (raw)
In-Reply-To: <56F35C38.3040804@cn.fujitsu.com>
[-- Attachment #1.1: Type: text/plain, Size: 3630 bytes --]
On 24.03.2016 04:17, 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(-)
>
> 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);
> + strList **next;
> +
> + *spec_info = (ImageInfoSpecific){
> + .type = IMAGE_INFO_SPECIFIC_KIND_QUORUM,
> + .u = {
> + .quorum.data = g_new0(ImageInfoSpecificQuorum, 1),
> + },
> + };
> +
> + 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;
> + next = &(*next)->next;
> + }
> +
> + return spec_info;
> +}
> +
> static BlockDriver bdrv_quorum = {
> .format_name = "quorum",
> .protocol_name = "quorum",
> @@ -1077,6 +1102,8 @@ static BlockDriver bdrv_quorum = {
>
> .is_filter = true,
> .bdrv_recurse_is_first_non_filter = quorum_recurse_is_first_non_filter,
> +
> + .bdrv_get_specific_info = quorum_get_specific_info,
> };
>
> static void bdrv_quorum_init(void)
> diff --git a/qapi/block-core.json b/qapi/block-core.json
> index b1cf77d..bd3e12d 100644
> --- a/qapi/block-core.json
> +++ b/qapi/block-core.json
> @@ -75,6 +75,18 @@
> } }
>
> ##
> +# @ImageInfoSpecificQuorum:
> +#
> +# @child-name: List of child name
> +#
> +# Since: 2.7
> +##
> +{ 'struct': 'ImageInfoSpecificQuorum',
> + 'data': {
> + 'child-name': ['str']
> + } }
I'd rather make this a generic struct than a str and rename the key to
'children', as Fam suggested, because in the future we may want to emit
more information about each child.
In any case, while it is true that I suggested this solution, I also
said that I think a generic solution for the whole block layer would
make sense.
Because I generally think that general solutions are better than
specialized ones (if both do the same thing, basically), I'd prefer the
general solution. Is there a reason why you chose to go for the
specialized quorum-only implementation, other than because it's easier
to do?
(I admit that introducing the graph querying command I suggested would
probably be subjected to more discussion than the design chosen in this
patch. But I personally think it's worth it.)
Max
> +
> +##
> # @ImageInfoSpecific:
> #
> # A discriminated record of image format specific information structures.
> @@ -85,7 +97,8 @@
> { 'union': 'ImageInfoSpecific',
> 'data': {
> 'qcow2': 'ImageInfoSpecificQCow2',
> - 'vmdk': 'ImageInfoSpecificVmdk'
> + 'vmdk': 'ImageInfoSpecificVmdk',
> + 'quorum': 'ImageInfoSpecificQuorum'
> } }
>
> ##
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
prev parent reply other threads:[~2016-03-24 17:02 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
2016-03-24 17:02 ` Max Reitz [this message]
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=56F41D9C.6050408@redhat.com \
--to=mreitz@redhat.com \
--cc=berto@igalia.com \
--cc=dgilbert@redhat.com \
--cc=kwolf@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).