From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj8eT-0003Zd-CJ for qemu-devel@nongnu.org; Thu, 24 Mar 2016 13:02:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aj8eO-0006zl-Ov for qemu-devel@nongnu.org; Thu, 24 Mar 2016 13:02:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57601) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj8eO-0006zh-HK for qemu-devel@nongnu.org; Thu, 24 Mar 2016 13:02:24 -0400 References: <56F35C38.3040804@cn.fujitsu.com> From: Max Reitz Message-ID: <56F41D9C.6050408@redhat.com> Date: Thu, 24 Mar 2016 18:02:20 +0100 MIME-Version: 1.0 In-Reply-To: <56F35C38.3040804@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="pACCUEb93P30GOexAM0rU9IHEcRm1nclg" 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 , Alberto Garcia , "Dr. David Alan Gilbert" , Kevin Wolf Cc: Changlong Xie , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --pACCUEb93P30GOexAM0rU9IHEcRm1nclg Content-Type: multipart/mixed; boundary="rErQHbFfvUWTfNde1fOw8nCTcNhUdgija" From: Max Reitz To: Wen Congyang , qemu-devl , Alberto Garcia , "Dr. David Alan Gilbert" , Kevin Wolf Cc: Stefan Hajnoczi , Changlong Xie Message-ID: <56F41D9C.6050408@redhat.com> Subject: Re: [PATCH] quorum: Implement bdrv_get_specific_info References: <56F35C38.3040804@cn.fujitsu.com> In-Reply-To: <56F35C38.3040804@cn.fujitsu.com> --rErQHbFfvUWTfNde1fOw8nCTcNhUdgija Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 24.03.2016 04:17, 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(-) >=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); > + strList **next; > + > + *spec_info =3D (ImageInfoSpecific){ > + .type =3D IMAGE_INFO_SPECIFIC_KIND_QUORUM, > + .u =3D { > + .quorum.data =3D g_new0(ImageInfoSpecificQuorum, 1), > + }, > + }; > + > + 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; > + next =3D &(*next)->next; > + } > + > + return spec_info; > +} > + > static BlockDriver bdrv_quorum =3D { > .format_name =3D "quorum", > .protocol_name =3D "quorum", > @@ -1077,6 +1102,8 @@ static BlockDriver bdrv_quorum =3D { > =20 > .is_filter =3D true, > .bdrv_recurse_is_first_non_filter =3D quorum_recurse_is_first_no= n_filter, > + > + .bdrv_get_specific_info =3D quorum_get_specific_info, > }; > =20 > 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 @@ > } } > =20 > ## > +# @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 structur= es. > @@ -85,7 +97,8 @@ > { 'union': 'ImageInfoSpecific', > 'data': { > 'qcow2': 'ImageInfoSpecificQCow2', > - 'vmdk': 'ImageInfoSpecificVmdk' > + 'vmdk': 'ImageInfoSpecificVmdk', > + 'quorum': 'ImageInfoSpecificQuorum' > } } > =20 > ## >=20 --rErQHbFfvUWTfNde1fOw8nCTcNhUdgija-- --pACCUEb93P30GOexAM0rU9IHEcRm1nclg 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 iQEcBAEBCAAGBQJW9B2cAAoJEDuxQgLoOKytge0H/jsenl7d7kV08hLkQ4I6OiB4 36PpRS6ZYpXp+X/IkUcajwLrQzxykFezKDyxux0MiXiVQZaFEp4pVfgPsRMzzAUf nQ1123ZTGFWTPhcilK0C+EA2Z10LEAt9ojNoKugJTPdCCm8Tumc535X+TFTPVJyS gnAKwglQY7lQgsY3JBKlP6rJRjX3qB6WhuXgqwZyejth4ikmUD2q3k+ddP2K3eDV ZCuC0KRJx5HJCZ6w+jXySMLqG/niBtTMX/0BdkxIw9QDlZ36aOED7yhike+ZOpF/ OWBxkuF61ucEj1BHW0uaqVwCHmKHR92v61rvkBlvgauuM0hpUTMmdSDFnd06skY= =LPSP -----END PGP SIGNATURE----- --pACCUEb93P30GOexAM0rU9IHEcRm1nclg--