From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOMUn-0005hk-4w for qemu-devel@nongnu.org; Fri, 14 Mar 2014 03:25:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WOMUg-00078M-8t for qemu-devel@nongnu.org; Fri, 14 Mar 2014 03:25:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOMUf-00078G-Ro for qemu-devel@nongnu.org; Fri, 14 Mar 2014 03:25:26 -0400 Date: Fri, 14 Mar 2014 15:25:34 +0800 From: Fam Zheng Message-ID: <20140314072534.GC11745@T430.nay.redhat.com> References: <1394605864-32237-1-git-send-email-famz@redhat.com> <1394605864-32237-8-git-send-email-famz@redhat.com> <20140313135513.GF4534@irqsave.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20140313135513.GF4534@irqsave.net> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 7/9] qmp: Add dirty-bitmap-enable and dirty-bitmap-disable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?iso-8859-1?Q?Beno=EEt?= Canet Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com On Thu, 03/13 14:55, Beno=EEt Canet wrote: > The Wednesday 12 Mar 2014 =E0 14:31:02 (+0800), Fam Zheng wrote : > > This allows to put the dirty bitmap into a disabled state where no mo= re > > writes will be tracked. > >=20 > > It will be used before backup or writing to persistent file. > >=20 > > Signed-off-by: Fam Zheng > > --- > > block.c | 15 +++++++++++++++ > > blockdev.c | 44 +++++++++++++++++++++++++++++++++++++++++= +++ > > include/block/block.h | 2 ++ > > qapi-schema.json | 32 ++++++++++++++++++++++++++++++++ > > qmp-commands.hx | 10 ++++++++++ > > 5 files changed, 103 insertions(+) > >=20 > > diff --git a/block.c b/block.c > > index 199a465..1530fd1 100644 > > --- a/block.c > > +++ b/block.c > > @@ -55,6 +55,7 @@ struct BdrvDirtyBitmap { > > int64_t size; > > int64_t granularity; > > char *name; > > + bool enabled; > > QLIST_ENTRY(BdrvDirtyBitmap) list; > > }; > > =20 > > @@ -5120,6 +5121,7 @@ BdrvDirtyBitmap *bdrv_create_dirty_bitmap(Block= DriverState *bs, > > if (name) { > > bitmap->name =3D g_strdup(name); > > } > > + bitmap->enabled =3D true; > > QLIST_INSERT_HEAD(&bs->dirty_bitmaps, bitmap, list); > > return bitmap; > > } > > @@ -5138,6 +5140,16 @@ void bdrv_release_dirty_bitmap(BlockDriverStat= e *bs, BdrvDirtyBitmap *bitmap) > > } > > } > > =20 > > +void bdrv_disable_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap= *bitmap) > > +{ > > + bitmap->enabled =3D false; > > +} > > + > > +void bdrv_enable_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap = *bitmap) > > +{ > > + bitmap->enabled =3D true; > > +} > > + > > BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs) > > { > > BdrvDirtyBitmap *bm; > > @@ -5186,6 +5198,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 662c950..aa3ee55 100644 > > --- a/blockdev.c > > +++ b/blockdev.c > > @@ -1773,6 +1773,50 @@ void qmp_dirty_bitmap_remove(const char *devic= e, const char *name, > > bdrv_release_dirty_bitmap(bs, bitmap); > > } > > =20 > > +void qmp_dirty_bitmap_enable(const char *device, const char *name, >=20 > > + bool has_granularity, int64_t granulari= ty, > What is the use of this line ? Not useful for this command, but it's good to make the bitmap friends fam= ily reuse the same data (DirtyBitmap, see below), especially for transaction support. >=20 > > + Error **errp) > > +{ > > + BlockDriverState *bs; > > + BdrvDirtyBitmap *bitmap; > > + > > + bs =3D bdrv_find(device); > > + if (!bs) { > > + error_set(errp, QERR_DEVICE_NOT_FOUND, device); > > + return; > > + } > > + > > + bitmap =3D bdrv_find_dirty_bitmap(bs, name); > > + if (!bitmap) { > > + error_setg(errp, "Dirty bitmap not found: %s", name); > > + return; > > + } > > + > > + bdrv_enable_dirty_bitmap(bs, bitmap); > > +} > > + > > +void qmp_dirty_bitmap_disable(const char *device, const char *name, >=20 > > + bool has_granularity, int64_t granular= ity, > Same question ? Same answer :) >=20 > > + Error **errp) > > +{ > > + BlockDriverState *bs; > > + BdrvDirtyBitmap *bitmap; > > + > > + bs =3D bdrv_find(device); > > + if (!bs) { > > + error_set(errp, QERR_DEVICE_NOT_FOUND, device); > > + return; > > + } > > + > > + bitmap =3D bdrv_find_dirty_bitmap(bs, name); > > + if (!bitmap) { > > + error_setg(errp, "Dirty bitmap not found: %s", name); > > + return; > > + } > > + > > + bdrv_disable_dirty_bitmap(bs, bitmap); > > +} > > + > > int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_dat= a) > > { > > const char *id =3D qdict_get_str(qdict, "id"); > > diff --git a/include/block/block.h b/include/block/block.h > > index 66aae57..2875d7d 100644 > > --- a/include/block/block.h > > +++ b/include/block/block.h > > @@ -449,6 +449,8 @@ BdrvDirtyBitmap *bdrv_copy_dirty_bitmap(BlockDriv= erState *bs, > > const BdrvDirtyBitmap *bitma= p, > > const char *name); > > void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap= *bitmap); > > +void bdrv_disable_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap= *bitmap); > > +void bdrv_enable_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap = *bitmap); > > BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs); > > int bdrv_dirty_bitmap_granularity(BlockDriverState *bs, > > BdrvDirtyBitmap *bitmap); > > diff --git a/qapi-schema.json b/qapi-schema.json > > index 632bb10..f8cd6b8 100644 > > --- a/qapi-schema.json > > +++ b/qapi-schema.json > > @@ -2225,6 +2225,38 @@ > > 'data': { 'device': 'str', 'name': 'str' } } > > =20 > > ## > > +# @dirty-bitmap-enable > > +# > > +# Enable a dirty bitmap on the device > > +# > > +# Setting granularity has no effect here. > > +# > > +# Returns: nothing on success > > +# If @device is not a valid block device, DeviceNotFound > > +# If @name is not found, GenericError with an explaining me= ssage > > +# > > +# Since 2.1 > > +## > > +{'command': 'dirty-bitmap-enable', > > + 'data': 'DirtyBitmap' } > > + > > +## > > +# @dirty-bitmap-disable > > +# > > +# Disable a dirty bitmap on the device > > +# > > +# Setting granularity has no effect here. > > +# > > +# Returns: nothing on success > > +# If @device is not a valid block device, DeviceNotFound > > +# If @name is not found, GenericError with an explaining me= ssage > > +# > > +# Since 2.1 > > +## > > +{'command': 'dirty-bitmap-disable', > > + 'data': 'DirtyBitmap' } >=20 > Granularity is not defined on the QMP interface. Does it even compile ? Yes it is defined in DirtyBitmap. See patch 2. Thanks, Fam