From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTGQ7-0000A4-9N for qemu-devel@nongnu.org; Tue, 09 Feb 2016 17:06:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTGQ6-0003EI-0I for qemu-devel@nongnu.org; Tue, 09 Feb 2016 17:06:03 -0500 References: <1453804705-7205-1-git-send-email-famz@redhat.com> <1453804705-7205-9-git-send-email-famz@redhat.com> From: John Snow Message-ID: <56BA62C1.7040204@redhat.com> Date: Tue, 9 Feb 2016 17:05:53 -0500 MIME-Version: 1.0 In-Reply-To: <1453804705-7205-9-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH 08/16] qmp: Add optional parameter "persistent" in block-dirty-bitmap-add List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, Markus Armbruster , mreitz@redhat.com, vsementsov@parallels.com, Stefan Hajnoczi On 01/26/2016 05:38 AM, Fam Zheng wrote: > When omitted it defaults to false with unchanged behavior. > > When set to true, the created dirty bitmap is made persistent if supported, it > requires support from the active image format. Otherwise an error is returned. > > Signed-off-by: Fam Zheng > --- > blockdev.c | 8 +++++++- > qapi/block-core.json | 6 +++++- > qmp-commands.hx | 3 ++- > 3 files changed, 14 insertions(+), 3 deletions(-) > > diff --git a/blockdev.c b/blockdev.c > index 07cfe25..08236f2 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -1997,6 +1997,7 @@ static void block_dirty_bitmap_add_prepare(BlkActionState *common, > /* AIO context taken and released within qmp_block_dirty_bitmap_add */ > qmp_block_dirty_bitmap_add(action->node, action->name, > action->has_granularity, action->granularity, > + action->has_persistent, action->persistent, > &local_err); > > if (!local_err) { > @@ -2640,10 +2641,12 @@ out: > > void qmp_block_dirty_bitmap_add(const char *node, const char *name, > bool has_granularity, uint32_t granularity, > + bool has_persistent, bool persistent, > Error **errp) > { > AioContext *aio_context; > BlockDriverState *bs; > + BdrvDirtyBitmap *bitmap; > > if (!name || name[0] == '\0') { > error_setg(errp, "Bitmap name cannot be empty"); > @@ -2669,7 +2672,10 @@ void qmp_block_dirty_bitmap_add(const char *node, const char *name, > granularity = bdrv_get_default_bitmap_granularity(bs); > } > > - bdrv_create_dirty_bitmap(bs, granularity, name, errp); > + bitmap = bdrv_create_dirty_bitmap(bs, granularity, name, errp); > + if (bitmap && has_persistent && persistent) { > + bdrv_dirty_bitmap_set_persistent(bs, bitmap, true, false, errp); > + } > > out: > aio_context_release(aio_context); > diff --git a/qapi/block-core.json b/qapi/block-core.json > index 30c2e5f..0ac107c 100644 > --- a/qapi/block-core.json > +++ b/qapi/block-core.json > @@ -1162,10 +1162,14 @@ > # @granularity: #optional the bitmap granularity, default is 64k for > # block-dirty-bitmap-add > # > +# @persistent: #optinal whether to make the bitmap persistent, default is false. > +# (Since 2.6) > +# optional > # Since 2.4 > ## > { 'struct': 'BlockDirtyBitmapAdd', > - 'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32' } } > + 'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32', > + '*persistent': 'bool' } } > > ## > # @block-dirty-bitmap-add > diff --git a/qmp-commands.hx b/qmp-commands.hx > index db072a6..bd4428e 100644 > --- a/qmp-commands.hx > +++ b/qmp-commands.hx > @@ -1373,7 +1373,7 @@ EQMP > > { > .name = "block-dirty-bitmap-add", > - .args_type = "node:B,name:s,granularity:i?", > + .args_type = "node:B,name:s,granularity:i?,persistent:b?", > .mhandler.cmd_new = qmp_marshal_block_dirty_bitmap_add, > }, > > @@ -1390,6 +1390,7 @@ Arguments: > - "node": device/node on which to create dirty bitmap (json-string) > - "name": name of the new dirty bitmap (json-string) > - "granularity": granularity to track writes with (int, optional) > +- "persistent": whether the bitmap is persistent (bool, optional, default to no) > > Example: > > With typo fixed: Reviewed-by: John Snow