qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, pbonzini@redhat.com,
	"Benoît Canet" <benoit.canet@irqsave.net>,
	stefanha@redhat.com
Subject: [Qemu-devel] [PATCH v3 2/2] qapi: Change BlockDirtyInfo to list
Date: Wed, 13 Nov 2013 18:29:44 +0800	[thread overview]
Message-ID: <1384338584-14065-3-git-send-email-famz@redhat.com> (raw)
In-Reply-To: <1384338584-14065-1-git-send-email-famz@redhat.com>

We have multiple dirty bitmaps in BDS now, switch QAPI to allow query
it (BlockInfo.dirty_bitmaps), and also drop old BlockInfo.dirty.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 block.c               | 20 ++++++++++++++++++++
 block/qapi.c          |  5 +++++
 include/block/block.h |  1 +
 qapi-schema.json      |  6 +++---
 4 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/block.c b/block.c
index ef7a55f..f57ae83 100644
--- a/block.c
+++ b/block.c
@@ -4379,6 +4379,26 @@ void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap)
     }
 }
 
+BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs)
+{
+    BdrvDirtyBitmap *bm;
+    BlockDirtyInfoList *list = NULL;
+    BlockDirtyInfoList **plist = &list;
+
+    QLIST_FOREACH(bm, &bs->dirty_bitmaps, list) {
+        BlockDirtyInfo *info = g_malloc0(sizeof(BlockDirtyInfo));
+        BlockDirtyInfoList *entry = g_malloc0(sizeof(BlockDirtyInfoList));
+        info->count = bdrv_get_dirty_count(bs, bm);
+        info->granularity =
+            ((int64_t) BDRV_SECTOR_SIZE << hbitmap_granularity(bm->bitmap));
+        entry->value = info;
+        *plist = entry;
+        plist = &entry->next;
+    }
+
+    return list;
+}
+
 int bdrv_get_dirty(BlockDriverState *bs, BdrvDirtyBitmap *bitmap, int64_t sector)
 {
     if (bitmap) {
diff --git a/block/qapi.c b/block/qapi.c
index 6b0cdcf..a32cb79 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -204,6 +204,11 @@ void bdrv_query_info(BlockDriverState *bs,
         info->io_status = bs->iostatus;
     }
 
+    if (!QLIST_EMPTY(&bs->dirty_bitmaps)) {
+        info->has_dirty_bitmaps = true;
+        info->dirty_bitmaps = bdrv_query_dirty_bitmaps(bs);
+    }
+
     if (bs->drv) {
         info->has_inserted = true;
         info->inserted = g_malloc0(sizeof(*info->inserted));
diff --git a/include/block/block.h b/include/block/block.h
index 06f424c..00f2711 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -391,6 +391,7 @@ struct HBitmapIter;
 typedef struct BdrvDirtyBitmap BdrvDirtyBitmap;
 BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, int granularity);
 void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap);
+BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs);
 int bdrv_get_dirty(BlockDriverState *bs, BdrvDirtyBitmap *bitmap, int64_t sector);
 void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector, int nr_sectors);
 void bdrv_reset_dirty(BlockDriverState *bs, int64_t cur_sector, int nr_sectors);
diff --git a/qapi-schema.json b/qapi-schema.json
index 81a375b..931d710 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -948,8 +948,8 @@
 # @tray_open: #optional True if the device has a tray and it is open
 #             (only present if removable is true)
 #
-# @dirty: #optional dirty bitmap information (only present if the dirty
-#         bitmap is enabled)
+# @dirty-bitmaps: #optional dirty bitmaps information (only present if the
+#                 driver has one or more dirty bitmaps)
 #
 # @io-status: #optional @BlockDeviceIoStatus. Only present if the device
 #             supports it and the VM is configured to stop on errors
@@ -963,7 +963,7 @@
   'data': {'device': 'str', 'type': 'str', 'removable': 'bool',
            'locked': 'bool', '*inserted': 'BlockDeviceInfo',
            '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
-           '*dirty': 'BlockDirtyInfo' } }
+           '*dirty-bitmaps': ['BlockDirtyInfo'] } }
 
 ##
 # @query-block:
-- 
1.8.4.2

  parent reply	other threads:[~2013-11-13 10:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-13 10:29 [Qemu-devel] [PATCH v3 0/2] block: per caller dirty bitmap Fam Zheng
2013-11-13 10:29 ` [Qemu-devel] [PATCH v3 1/2] " Fam Zheng
2013-11-13 14:33   ` Fam Zheng
2013-11-13 14:36     ` Kevin Wolf
2013-11-13 10:29 ` Fam Zheng [this message]
2013-11-13 14:19   ` [Qemu-devel] [PATCH v3 2/2] qapi: Change BlockDirtyInfo to list Kevin Wolf
2013-11-13 14:40     ` Paolo Bonzini
2013-11-13 14:40     ` Fam Zheng
2013-11-14  2:13       ` Wenchao Xia
2013-11-14  2:22         ` Fam Zheng
2013-11-13 20:37     ` Eric Blake
2013-11-13 20:44   ` Eric Blake
2013-11-14  2:33     ` [Qemu-devel] [PATCH] qapi: Add (Since 1.8) to BlockInfo.dirty-bitmaps Fam Zheng
2013-11-14 12:19       ` Kevin Wolf
2013-11-14  1:31   ` [Qemu-devel] [PATCH v3 2/2] qapi: Change BlockDirtyInfo to list Wenchao Xia
2013-11-14  1:39     ` Fam Zheng
2013-11-14  2:03     ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1384338584-14065-3-git-send-email-famz@redhat.com \
    --to=famz@redhat.com \
    --cc=benoit.canet@irqsave.net \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).