From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:52761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USbHa-0002yG-0Q for qemu-devel@nongnu.org; Wed, 17 Apr 2013 18:56:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USbHY-0001dt-Tv for qemu-devel@nongnu.org; Wed, 17 Apr 2013 18:56:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25228) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USbHY-0001di-M8 for qemu-devel@nongnu.org; Wed, 17 Apr 2013 18:56:52 -0400 Message-ID: <516F28AF.3030303@redhat.com> Date: Wed, 17 Apr 2013 16:56:47 -0600 From: Eric Blake MIME-Version: 1.0 References: <1365843407-16504-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1365843407-16504-9-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: <1365843407-16504-9-git-send-email-xiawenc@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2TMUXQSRQXGHKUPKWHHHE" Subject: Re: [Qemu-devel] [PATCH V12 08/18] block: add image info query function bdrv_query_image_info() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wenchao Xia Cc: kwolf@redhat.com, phrdina@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, stefanha@gmail.com, pbonzini@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2TMUXQSRQXGHKUPKWHHHE Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 04/13/2013 02:56 AM, Wenchao Xia wrote: > This patch adds function bdrv_query_image_info(), which will > retrieve image info in qmp object format. The implementation is > based on the code moved from qemu-img.c, but uses block layer > function to get snapshot info. >=20 > Signed-off-by: Wenchao Xia > --- > block/qapi.c | 37 +++++++++++++++++++++++++++++++------ > include/block/qapi.h | 6 +++--- > qemu-img.c | 7 ++----- > 3 files changed, 36 insertions(+), 14 deletions(-) >=20 > +/* return 0 on success, and @p_info will be set only on success. */ > +int bdrv_query_image_info(BlockDriverState *bs, > + ImageInfo **p_info, > + Error **errp) Is it necessary to return a value? If all callers pass in an errp, then this function can be void, and you can use the error parameter as the lone indication of problems. > +++ b/qemu-img.c > @@ -1733,11 +1733,8 @@ static ImageInfoList *collect_image_info_list(co= nst char *filename, > goto err; > } > =20 > - info =3D g_new0(ImageInfo, 1); > - bdrv_collect_image_info(bs, info, filename); > - bdrv_query_snapshot_info_list(bs, &info->snapshots, false, NUL= L); > - if (info->snapshots) { > - info->has_snapshots =3D true; > + if (bdrv_query_image_info(bs, &info, NULL)) { > + goto err; But then this caller would need to pass in a local error parameter, where Pavel's idea of qemu_img_handle_error would make it easier. https://lists.gnu.org/archive/html/qemu-devel/2013-04/msg03288.html --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2TMUXQSRQXGHKUPKWHHHE Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJRbyivAAoJEKeha0olJ0NqMvYH/2jkYv7uy6JU+UMKCKjhXzzL zown/05gnFBfoynrmaCwPISi7NDreBJ7XhDvwfXMOv8XqpJYvtMo8k4zN9SDOJkt uguKJXHFlmcQMHcTQDA8+ixwa7P9+6qQEdWmfnmcIEBSIyQAGi93z4B2RZO4r7JH ODg2deLUj4eyd2SLSgE2REAKHPsbNn+tP+lRx7ufXazBfbWNkwc2/XHkDlZhrqRy OiCw9/dWw0R3xSi1qWPLr3BJOGUHda/I71PwDkzmgCDynE4fiPynTG/7OHhivowa Hy8aY+xsiqHydhLYzt76SPr5rb55IQXFiuqZKXqT6E9Q/VO11vyscnp6Fj7zbFs= =3q5r -----END PGP SIGNATURE----- ------enig2TMUXQSRQXGHKUPKWHHHE--