qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH RFC v2 1/8] qmp: print dirty bitmap


From: Vladimir Sementsov-Ogievskiy
Subject: Re: [Qemu-devel] [PATCH RFC v2 1/8] qmp: print dirty bitmap
Date: Tue, 27 Jan 2015 19:23:02 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

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 <address@hidden>
---
  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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]