From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WO66T-0007JS-Bu for qemu-devel@nongnu.org; Thu, 13 Mar 2014 09:55:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WO66N-000060-CR for qemu-devel@nongnu.org; Thu, 13 Mar 2014 09:55:21 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:56125 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WO66N-00005q-4I for qemu-devel@nongnu.org; Thu, 13 Mar 2014 09:55:15 -0400 Date: Thu, 13 Mar 2014 14:55:13 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140313135513.GF4534@irqsave.net> References: <1394605864-32237-1-git-send-email-famz@redhat.com> <1394605864-32237-8-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1394605864-32237-8-git-send-email-famz@redhat.com> 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: Fam Zheng Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 more > 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(BlockDr= iverState *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(BlockDriverState = *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 *b= itmap) > +{ > + 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 *device,= const char *name, > bdrv_release_dirty_bitmap(bs, bitmap); > } > =20 > +void qmp_dirty_bitmap_enable(const char *device, const char *name, > + bool has_granularity, int64_t granularity= , What is the use of this line ? > + 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, > + bool has_granularity, int64_t granularit= y, Same question ? > + 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_data) > { > 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(BlockDriver= State *bs, > const BdrvDirtyBitmap *bitmap, > 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 *b= itmap); > 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 mess= age > +# > +# 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 mess= age > +# > +# Since 2.1 > +## > +{'command': 'dirty-bitmap-disable', > + 'data': 'DirtyBitmap' } Granularity is not defined on the QMP interface. Does it even compile ? > + > +## > # @migrate_cancel > # > # Cancel the current executing migration process. > diff --git a/qmp-commands.hx b/qmp-commands.hx > index c42516d..205343b 100644 > --- a/qmp-commands.hx > +++ b/qmp-commands.hx > @@ -1194,6 +1194,16 @@ EQMP > .args_type =3D "device:B,name:s", > .mhandler.cmd_new =3D qmp_marshal_input_dirty_bitmap_remove, > }, > + { > + .name =3D "dirty-bitmap-enable", > + .args_type =3D "device:B,name:s", > + .mhandler.cmd_new =3D qmp_marshal_input_dirty_bitmap_enable, > + }, > + { > + .name =3D "dirty-bitmap-disable", > + .args_type =3D "device:B,name:s", > + .mhandler.cmd_new =3D qmp_marshal_input_dirty_bitmap_disable, > + }, > =20 > SQMP > =20 > --=20 > 1.9.0 >=20 >=20