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 <vsement...@parallels.com>
---
  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