From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YG8v6-0006ww-9k for qemu-devel@nongnu.org; Tue, 27 Jan 2015 11:23:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YG8v2-0005h7-7g for qemu-devel@nongnu.org; Tue, 27 Jan 2015 11:23:16 -0500 Received: from mx2.parallels.com ([199.115.105.18]:49871) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YG8v2-0005gr-31 for qemu-devel@nongnu.org; Tue, 27 Jan 2015 11:23:12 -0500 Message-ID: <54C7BB66.8040709@parallels.com> Date: Tue, 27 Jan 2015 19:23:02 +0300 From: Vladimir Sementsov-Ogievskiy MIME-Version: 1.0 References: <1422356197-5285-1-git-send-email-vsementsov@parallels.com> <1422356197-5285-2-git-send-email-vsementsov@parallels.com> <54C7BA34.3010804@redhat.com> In-Reply-To: <54C7BA34.3010804@redhat.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH RFC v2 1/8] qmp: print dirty bitmap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , qemu-devel@nongnu.org Cc: kwolf@redhat.com, den@openvz.org, jsnow@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Ok, I agree. It was just a simple way to test the other staff. I'll rewrite it in the following versions of my two series. Best regards, Vladimir On 27.01.2015 19:17, Eric Blake wrote: > On 01/27/2015 03:56 AM, Vladimir Sementsov-Ogievskiy wrote: >> Adds qmp and hmp commands to print dirty bitmap. This is needed only for >> testing. >> >> Signed-off-by: Vladimir Sementsov-Ogievskiy >> --- >> block.c | 33 +++++++++++++++++++++++++++++++++ >> blockdev.c | 13 +++++++++++++ >> hmp-commands.hx | 15 +++++++++++++++ >> hmp.c | 8 ++++++++ >> hmp.h | 1 + >> include/block/block.h | 2 ++ >> qapi-schema.json | 3 ++- >> qapi/block-core.json | 3 +++ >> qmp-commands.hx | 5 +++++ >> 9 files changed, 82 insertions(+), 1 deletion(-) >> >> +void bdrv_print_dirty_bitmap(BdrvDirtyBitmap *bitmap) >> +{ >> + unsigned long a = 0, b = 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"); >> + >> +void qmp_block_dirty_bitmap_print(const char *node_ref, const char *name, >> + Error **errp) >> +{ >> + BdrvDirtyBitmap *bitmap; >> + >> + bitmap = block_dirty_bitmap_lookup(node_ref, name, NULL, errp); >> + if (!bitmap) { >> + return; >> + } >> + >> + bdrv_print_dirty_bitmap(bitmap); > Won't work. You cannot assume that stdout is usable when invoked from > QMP. The only sane thing to do is to bundle up the structured data into > JSON, pass that back over the QMP connection, and let the client decide > how to print it. > > I'm opposed to adding this command as-is. >