From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TrAer-0000Of-Iw for qemu-devel@nongnu.org; Fri, 04 Jan 2013 12:02:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TrAep-0005q3-Tb for qemu-devel@nongnu.org; Fri, 04 Jan 2013 12:02:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:25387) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TrAep-0005ps-Mu for qemu-devel@nongnu.org; Fri, 04 Jan 2013 12:02:11 -0500 Message-ID: <50E70B0E.8070908@redhat.com> Date: Fri, 04 Jan 2013 10:02:06 -0700 From: Eric Blake MIME-Version: 1.0 References: <1356770725-4804-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1356770725-4804-5-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: <1356770725-4804-5-git-send-email-xiawenc@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig0D7AB6188F987155BFFE4C33" Subject: Re: [Qemu-devel] [PATCH 04/11] qemu-img: move image retrieving function to block layer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wenchao Xia Cc: kwolf@redhat.com, aliguori@us.ibm.com, phrdina@redhat.com, stefanha@gmail.com, qemu-devel@nongnu.org, armbru@redhat.com, pbonzini@redhat.com, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig0D7AB6188F987155BFFE4C33 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 12/29/2012 01:45 AM, Wenchao Xia wrote: > This patch moves collect_image_info() and collect_snapshot() > to general block layer and encapsulate them as bdrv_query_image_info() > and bdrv_query_snapshot_infolist(), as mirror function to brdv_query_in= fo(). > The called function in qemu-img.c is switched to bdrv_query_image_info(= ). > To help filter out snapshot info not needed, a call back function is > added in bdrv_query_snapshot_infolist(). >=20 > Signed-off-by: Wenchao Xia > --- > block.c | 118 +++++++++++++++++++++++++++++++++++++++++= ++++++++ > include/block/block.h | 9 ++++ > qemu-img.c | 88 +----------------------------------- > 3 files changed, 129 insertions(+), 86 deletions(-) >=20 > +SnapshotInfoList *bdrv_query_snapshot_infolist(BlockDriverState *bs, > + SnapshotFilterFunc filt= er, > + void *opaque, > + Error **errp) > +{ > + int i, sn_count; > + QEMUSnapshotInfo *sn_tab =3D NULL; > + SnapshotInfoList *info_list, *cur_item =3D NULL, *head =3D NULL; > + sn_count =3D bdrv_snapshot_list(bs, &sn_tab); > + if (sn_count < 0) { > + if (errp !=3D NULL) { > + error_setg(errp, "bdrv_snapshot_list: error %d\n", sn_coun= t); > + } > + return NULL; > + } > + > + for (i =3D 0; i < sn_count; i++) { > + if ((filter !=3D NULL) && (filter(&sn_tab[i], opaque) !=3D 0))= { My brief glance through qemu sources makes me think you over-parenthesized this, and that: if (filter && filter(&sn_tab[i], opaque) !=3D 0) { would be sufficient. > + bdrv_get_backing_filename(bs, backing_filename, sizeof(backing_fil= ename)); > + if (backing_filename[0] !=3D '\0') { > + info->backing_filename =3D g_strdup(backing_filename); > + info->has_backing_filename =3D true; > + bdrv_get_full_backing_filename(bs, backing_filename2, > + sizeof(backing_filename2)); > + > + if (strcmp(backing_filename, backing_filename2) !=3D 0) { > + info->full_backing_filename =3D > + g_strdup(backing_filename2); I know it's just code motion, but why the line wrap here? > +++ b/include/block/block.h > @@ -316,8 +316,17 @@ void bdrv_get_backing_filename(BlockDriverState *b= s, > char *filename, int filename_size); > void bdrv_get_full_backing_filename(BlockDriverState *bs, > char *dest, size_t sz); > + > +typedef int (*SnapshotFilterFunc)(const QEMUSnapshotInfo *sn, void *op= aque); > +/* assume bs is already openned, use g_free to free returned value. */= s/openned/opened/ --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig0D7AB6188F987155BFFE4C33 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.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with undefined - http://www.enigmail.net/ iQEcBAEBCAAGBQJQ5wsOAAoJEKeha0olJ0Nq8NAH/RMzLOi/tntwgfvpO0Nx8jnL xaKzylbKjE+zGtjj9tMof/S7ASiDv4PpKJN/HHK/Mog16MN0KiOBWb28zNxZ2jgz DNUWGqEsE/oIr6c9duKKZOTINWN3rf7iCMPvnodUP+uxq1HW8mFXvDa9yaiG/U5l x8uwcWxIQxh/iF7nx0uMHptIEJEGvgH1FAPZJnAXuAAvfob46jgCuIAA2kRwfats tYK3968jxS6rJ4TqGWhxR+6C8RD+qCAE50ZqNsflCPVoMKC+wwg6K7B+9mAgy5Jy YfMejDShHHZLe5aWjBt7yAmG5Xvq8mE6xSoH4PGRCXkRU+qeRQ0ouKjS3TqXPEs= =btsq -----END PGP SIGNATURE----- --------------enig0D7AB6188F987155BFFE4C33--