From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38293) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xtvv2-00061e-4Y for qemu-devel@nongnu.org; Thu, 27 Nov 2014 05:03:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xtvuv-0006SM-5Z for qemu-devel@nongnu.org; Thu, 27 Nov 2014 05:03:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54392) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xtvuu-0006S0-UF for qemu-devel@nongnu.org; Thu, 27 Nov 2014 05:03:17 -0500 Message-ID: <5476F6E0.3030505@redhat.com> Date: Thu, 27 Nov 2014 11:03:12 +0100 From: Max Reitz MIME-Version: 1.0 References: <1417023715-18210-1-git-send-email-jsnow@redhat.com> <1417023715-18210-7-git-send-email-jsnow@redhat.com> In-Reply-To: <1417023715-18210-7-git-send-email-jsnow@redhat.com> Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v8 06/10] qmp: Add block-dirty-bitmap-enable and block-dirty-bitmap-disable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow , qemu-devel@nongnu.org Cc: kwolf@redhat.com, Fam Zheng , armbru@redhat.com, vsementsov@parallels.com, stefanha@redhat.com, pbonzini@redhat.com On 2014-11-26 at 18:41, John Snow wrote: > From: Fam Zheng > > This allows to put the dirty bitmap into a disabled state where no more > writes will be tracked. > > It will be used before backup or writing to persistent file. > > Signed-off-by: Fam Zheng > Signed-off-by: John Snow > --- > block.c | 15 +++++++++++++ > blockdev.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ > include/block/block.h | 2 ++ > qapi/block-core.json | 28 +++++++++++++++++++++++ > qmp-commands.hx | 10 +++++++++ > 5 files changed, 116 insertions(+) > > diff --git a/block.c b/block.c > index 40cb9cf..1aa723b 100644 > --- a/block.c > +++ b/block.c > @@ -56,6 +56,7 @@ struct BdrvDirtyBitmap { > int64_t size; > int64_t granularity; > char *name; > + bool enabled; > QLIST_ENTRY(BdrvDirtyBitmap) list; > }; > > @@ -5361,6 +5362,7 @@ BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, > bitmap->granularity = granularity; > bitmap->bitmap = hbitmap_alloc(bitmap->size, ffs(sector_granularity) - 1); > bitmap->name = g_strdup(name); > + bitmap->enabled = true; > QLIST_INSERT_HEAD(&bs->dirty_bitmaps, bitmap, list); > return bitmap; > } > @@ -5379,6 +5381,16 @@ void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap) > } > } > > +void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap) > +{ > + bitmap->enabled = false; > +} > + > +void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap) > +{ > + bitmap->enabled = true; > +} > + > BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs) > { > BdrvDirtyBitmap *bm; > @@ -5447,6 +5459,9 @@ void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector, > { > BdrvDirtyBitmap *bitmap; > QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) { > + if (!bitmap->enabled) { > + continue; > + } > hbitmap_set(bitmap->bitmap, cur_sector, nr_sectors); > } > } > diff --git a/blockdev.c b/blockdev.c > index af1152f..276a31b 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -1159,6 +1159,41 @@ SnapshotInfo *qmp_blockdev_snapshot_delete_internal_sync(const char *device, > return info; This conflicts with Stefan's AioContext series, so it doesn't apply to block-next. The above line should read "return NULL;" instead. > } > > +/** > + * Return a dirty bitmap (if present), after validating > + * the device and bitmap names. Returns NULL on error, > + * including when the device and/or bitmap is not found. > + */ > +static BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *device, > + const char *name, > + Error **errp) > +{ > + BlockDriverState *bs; > + BdrvDirtyBitmap *bitmap; > + > + if (!device) { > + error_setg(errp, "Device cannot be NULL"); > + return NULL; > + } > + if (!name) { > + error_setg(errp, "Bitmap name cannot be NULL"); > + return NULL; > + } > + > + bs = bdrv_lookup_bs(device, NULL, errp); > + if (!bs) { > + return NULL; > + } > + > + bitmap = bdrv_find_dirty_bitmap(bs, name); > + if (!bitmap) { > + error_setg(errp, "Dirty bitmap not found: %s", name); > + return NULL; > + } > + > + return bitmap; > +} > + > /* New and old BlockDriverState structs for group snapshots */ And this line should read "/* New and old BlockDriverState structs for atomic group operations */". With those changes it applies. With that changed (it's not even a change of the code, just a change of the patch): Reviewed-by: Max Reitz