From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52991) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WO5fC-0001yj-7J for qemu-devel@nongnu.org; Thu, 13 Mar 2014 09:27:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WO5f1-0006xW-2a for qemu-devel@nongnu.org; Thu, 13 Mar 2014 09:27:10 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:56116 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WO5f0-0006wk-Ph for qemu-devel@nongnu.org; Thu, 13 Mar 2014 09:26:58 -0400 Date: Thu, 13 Mar 2014 14:26:57 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140313132657.GB4534@irqsave.net> References: <1394605864-32237-1-git-send-email-famz@redhat.com> <1394605864-32237-3-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-3-git-send-email-famz@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 2/9] qmp: Add dirty-bitmap-add and dirty-bitmap-remove 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:30:57 (+0800), Fam Zheng wrote : > The new command pair is added to manage user created dirty bitmap. The > dirty bitmap's name is mandatory and must be unique for the same device= , > but different devices can have bitmaps with the same names. >=20 > Signed-off-by: Fam Zheng > --- > blockdev.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++ > qapi-schema.json | 45 ++++++++++++++++++++++++++++++++++++++++++ > qmp-commands.hx | 49 +++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 154 insertions(+) >=20 > diff --git a/blockdev.c b/blockdev.c > index c3422a1..662c950 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -1713,6 +1713,66 @@ void qmp_block_set_io_throttle(const char *devic= e, int64_t bps, int64_t bps_rd, > } > } > =20 > +void qmp_dirty_bitmap_add(const char *device, const char *name, Do we want this to work on node-names too ? > + bool has_granularity, int64_t granularity, > + Error **errp) > +{ > + BlockDriverState *bs; > + BdrvDirtyBitmap *bitmap; > + > + bs =3D bdrv_find(device); Do we want bdrv_lookup_bs here ? > + if (!bs) { > + error_set(errp, QERR_DEVICE_NOT_FOUND, device); > + return; > + } > + > + if (!name || name[0] =3D=3D '\0') { > + error_setg(errp, "Bitmap name cannot be empty"); > + return; > + } > + if (has_granularity) { > + if (granularity & (granularity - 1)) { > + error_setg(errp, "Granularity must be power of 2"); > + return; > + } > + } else { > + granularity =3D 65536; > + } > + > + bitmap =3D bdrv_create_dirty_bitmap(bs, granularity, name, errp); > + if (!bitmap) { > + return; > + } > +} > + > +void qmp_dirty_bitmap_remove(const char *device, const char *name, > + Error **errp) > +{ > + BlockDriverState *bs; > + BdrvDirtyBitmap *bitmap; > + > + bs =3D bdrv_find(device); > + if (!bs) { > + error_set(errp, QERR_DEVICE_NOT_FOUND, device); > + return; > + } > + > + if (!name || name[0] =3D=3D '\0') { > + error_setg(errp, "Bitmap name cannot be empty"); > + return; > + } > + bitmap =3D bdrv_find_dirty_bitmap(bs, name); > + if (!bitmap) { > + error_setg(errp, "Dirty bitmap not found: %s", name); > + return; > + } > + > + /* Make it invisible to user in case the following > + * bdrv_release_dirty_bitmap doens't free it because of refcnt */ > + bdrv_dirty_bitmap_make_anon(bs, bitmap); > + bdrv_release_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/qapi-schema.json b/qapi-schema.json > index 4d5bc13..632bb10 100644 > --- a/qapi-schema.json > +++ b/qapi-schema.json > @@ -2180,6 +2180,51 @@ > '*on-target-error': 'BlockdevOnError' } } > =20 > ## > +# @DirtyBitmap > +# > +# @device: name of device which the bitmap is tracking > +# > +# @name: name of the dirty bitmap > +# > +# @granularity: #optional the bitmap granularity, default is 64k for > +# dirty-bitmap-add > +# > +# Since 2.1 > +## > +{ 'type': 'DirtyBitmap', > + 'data': { 'device': 'str', 'name': 'str', '*granularity': 'int' } } > + > +## > +# @dirty-bitmap-add > +# > +# Create a dirty bitmap with a name on the device > +# > +# Returns: nothing on success > +# If @device is not a valid block device, DeviceNotFound > +# If @name is already taken, GenericError with an explaining = message > +# > +# Since 2.1 > +## > +{'command': 'dirty-bitmap-add', > + 'data': 'DirtyBitmap' } > + > +## > +# @dirty-bitmap-remove > +# > +# Remove 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-remove', > + 'data': { 'device': 'str', 'name': 'str' } } > + > +## > # @migrate_cancel > # > # Cancel the current executing migration process. > diff --git a/qmp-commands.hx b/qmp-commands.hx > index d982cd6..c42516d 100644 > --- a/qmp-commands.hx > +++ b/qmp-commands.hx > @@ -1185,6 +1185,55 @@ Example: > EQMP > =20 > { > + .name =3D "dirty-bitmap-add", > + .args_type =3D "device:B,name:s,granularity:i?", > + .mhandler.cmd_new =3D qmp_marshal_input_dirty_bitmap_add, > + }, > + { > + .name =3D "dirty-bitmap-remove", > + .args_type =3D "device:B,name:s", > + .mhandler.cmd_new =3D qmp_marshal_input_dirty_bitmap_remove, > + }, > + > +SQMP > + > +dirty-bitmap-add > +---------------- > + > +Create a dirty bitmap with a name on the device, and start tracking th= e writes. > + > +Arguments: > + > +- "device": device name to create dirty bitmap (json-string) > +- "name": name of the new dirty bitmap (json-string) > +- "granularity": granularity to track writes with. (int) > + > +Example: > + > +-> { "execute": "dirty-bitmap-add", "arguments": { "device": "drive0", > + "name": "bitmap0" }= } > +<- { "return": {} } > + > +dirty-bitmap-remove > +---------------- > + > +Stop write tracking and remove the dirty bitmap that was created with s/remove the/remove a/ > +dirty-bitmap-add. > + > +Arguments: > + > +- "device": device name to remove dirty bitmap (json-string) > +- "name": name of the dirty bitmap to remove (json-string) > + > +Example: > + > +-> { "execute": "dirty-bitmap-remove", "arguments": { "device": "drive= 0", > + "name": "bitmap0= " } } > +<- { "return": {} } > + > +EQMP > + > + { > .name =3D "blockdev-snapshot-sync", > .args_type =3D "device:s?,node-name:s?,snapshot-file:s,snapsh= ot-node-name:s?,format:s?,mode:s?", > .mhandler.cmd_new =3D qmp_marshal_input_blockdev_snapshot_sync= , > --=20 > 1.9.0 >=20 >=20