From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YG8Se-0006Wy-5L for qemu-devel@nongnu.org; Tue, 27 Jan 2015 10:53:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YG8Sa-0002xF-W0 for qemu-devel@nongnu.org; Tue, 27 Jan 2015 10:53:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41153) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YG8Sa-0002x0-OE for qemu-devel@nongnu.org; Tue, 27 Jan 2015 10:53:48 -0500 Message-ID: <54C7B48A.4030606@redhat.com> Date: Tue, 27 Jan 2015 08:53:46 -0700 From: Eric Blake MIME-Version: 1.0 References: <1421168546-6232-1-git-send-email-vsementsov@parallels.com> <1421168546-6232-8-git-send-email-vsementsov@parallels.com> In-Reply-To: <1421168546-6232-8-git-send-email-vsementsov@parallels.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="I0KESl3SX86UxJnrQoQTje4OFbIfP0Gwe" Subject: Re: [Qemu-devel] [PATCH 7/8] qmp: print dirty bitmap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org Cc: kwolf@redhat.com, den@openvz.org, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --I0KESl3SX86UxJnrQoQTje4OFbIfP0Gwe Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01/13/2015 10:02 AM, Vladimir Sementsov-Ogievskiy wrote: > Adds qmp and hmp commands to print dirty bitmap. This is needed only fo= r > testing persistent dirty bitmap feature. >=20 > Signed-off-by: Vladimir Sementsov-Ogievskiy > --- > +++ b/block.c > @@ -5445,6 +5445,39 @@ int bdrv_store_dirty_bitmap(BdrvDirtyBitmap *bit= map) > return res; > } > =20 > +void bdrv_print_dirty_bitmap(BdrvDirtyBitmap *bitmap) > +{ > + unsigned long a =3D 0, b =3D 0; > + > + printf("bitmap '%s'\n", bitmap->name ? bitmap->name : "no name"); > + printf("enabled: %s\n", bitmap->enabled ? "true" : "false"); > + printf("size: %" PRId64 "\n", bitmap->size); > + printf("granularity: %" PRId64 "\n", bitmap->granularity); > + printf("dirty regions begin:\n"); > +++ b/blockdev.c > @@ -2079,6 +2079,19 @@ void qmp_block_dirty_bitmap_add(const char *node= _ref, const char *name, > aio_context_release(aio_context); > } > =20 > +void qmp_block_dirty_bitmap_print(const char *node_ref, const char *na= me, > + Error **errp) > +{ > + BdrvDirtyBitmap *bitmap; > + > + bitmap =3D block_dirty_bitmap_lookup(node_ref, name, NULL, errp); > + if (!bitmap) { > + return; > + } > + > + bdrv_print_dirty_bitmap(bitmap); Eww. This assumes that stdout is usable. But that is not the case for QMP commands. It would be better to package up the output in a structured format and return it to the caller, and let the caller decide how to print it. > +++ b/qapi/block-core.json > @@ -982,6 +982,9 @@ > {'command': 'block-dirty-bitmap-disable', > 'data': 'BlockDirtyBitmap' } > =20 > +{'command': 'block-dirty-bitmap-print', > + 'data': 'BlockDirtyBitmap' } Missing documentation, if we even want this command. As mentioned above, this should return ALL of the information necessary for the client to then decide how to print the information, rather than directly printing information to stdout itself. And it might be better to name this command in the 'query-' namespace. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --I0KESl3SX86UxJnrQoQTje4OFbIfP0Gwe 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 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJUx7SKAAoJEKeha0olJ0NqEywH/Akh31Onl4pGUUFsNM5StECi 5PltOPOe0nBanNYPkycmnqZEp84BcVoh7zGh7yDnoGPGmOlamJq/N5oQwNLzUE5t gl+dNfwCJIi8H9x5UG7WdHuvPA1HFzQKSxQd6Acdoyx8Gj++n3CL0eLEQ6jtT862 p1p2nvzbemGJtUeg1aNgl5CxXEvA0Kc/esb5EQrAF3MRJKj5GXZMtL2ZLeNwyOIR AbDibVJ3FczyxtofNGETWcvLAXe6uu9tKMdZhG6maAsAle9q6pGN1YSyUzsQeUQu WEwLewoLwzguDZ2iRzUN/EzJnQO8qhk+wjnW8TpwlLwp0Jg7h023tRx3bkY/rDY= =vK4b -----END PGP SIGNATURE----- --I0KESl3SX86UxJnrQoQTje4OFbIfP0Gwe--