From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj8YE-0000BU-Ka for qemu-devel@nongnu.org; Thu, 24 Mar 2016 12:56:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aj8YA-0005iN-BA for qemu-devel@nongnu.org; Thu, 24 Mar 2016 12:56:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53091) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj8YA-0005iE-3l for qemu-devel@nongnu.org; Thu, 24 Mar 2016 12:55:58 -0400 References: <56F35C38.3040804@cn.fujitsu.com> From: Eric Blake Message-ID: <56F41C1A.6070004@redhat.com> Date: Thu, 24 Mar 2016 10:55:54 -0600 MIME-Version: 1.0 In-Reply-To: <56F35C38.3040804@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="l4bOPAx8EDKB90gOgm5RepjsgiTc7CkbJ" Subject: Re: [Qemu-devel] [PATCH] quorum: Implement bdrv_get_specific_info List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wen Congyang , qemu-devl , Max Reitz , Alberto Garcia , "Dr. David Alan Gilbert" , Kevin Wolf Cc: Changlong Xie , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --l4bOPAx8EDKB90gOgm5RepjsgiTc7CkbJ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 03/23/2016 09:17 PM, Wen Congyang wrote: > The monitor command 'query-block' or 'info block' will output the forma= t specific > information. So we can get each child's child-name after this patch. Th= is useful > for dynamic reconfiguration. >=20 > Signed-off-by: Wen Congyang > --- > 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? >=20 > 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(BlockDriverS= tate *bs, QDict *options) > bs->full_open_options =3D opts; > } > =20 > +static ImageInfoSpecific *quorum_get_specific_info(BlockDriverState *b= s) > +{ > + int i; > + BDRVQuorumState *s =3D bs->opaque; > + ImageInfoSpecific *spec_info =3D g_new0(ImageInfoSpecific, 1); Others have pointed out that this can be g_new(), since... > + strList **next; > + > + *spec_info =3D (ImageInfoSpecific){ > + .type =3D IMAGE_INFO_SPECIFIC_KIND_QUORUM, =2E..you are assigning all fields here. > + .u =3D { > + .quorum.data =3D g_new0(ImageInfoSpecificQuorum, 1), > + }, I think you could just directly do: .u.quorum.data =3D ... instead of nesting {}. > + }; > + > + next =3D &spec_info->u.quorum.data->child_name; > + for (i =3D 0; i < s->num_children; i++) { > + *next =3D g_new0(strList, 1); > + (*next)->value =3D g_strdup(s->children[i]->name); > + (*next)->next =3D NULL; Dead assignment, thanks to the g_new0() above. > + next =3D &(*next)->next; > + } > + > + return spec_info; > +} > + > +++ b/qapi/block-core.json > @@ -75,6 +75,18 @@ > } } > =20 > ## > +# @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. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --l4bOPAx8EDKB90gOgm5RepjsgiTc7CkbJ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJW9BwaAAoJEKeha0olJ0NqqDYH/jf5akk2rh08XlBRvnsavPXq eCCUnR+iIQiAlj11bFFiq4Bsmi5Z+q21OJxgB1dqeGluIjjMjwOLBpU13bZewS6I Jk07qz0tqRdmf8+13dPsvDRkJPlHVzWVyuCtde6abqEGKzOiDFOJp3Yu+uzKpYw6 1ADGv4Qt/Vr+/qyE7Pzgh+y5K7Y3xHYO6JDiXIA80AqOElMoH9ZGRLqEpWdVfR12 JKPZd40OEPXwMyCQrgIdK0DlSbRHDiUvokNFZSqkCZ+jHNl5pf0o2tH7R0VGiAY4 K0ky1bVuDNdSCEzWbtbINBGo0nZcYlPEDV/9MzyPo+BcqdKgDOaOs115e6oPmjE= =2H5X -----END PGP SIGNATURE----- --l4bOPAx8EDKB90gOgm5RepjsgiTc7CkbJ--