From: "Benoît Canet" <benoit.canet@irqsave.net>
To: Fam Zheng <famz@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 2/9] qmp: Add dirty-bitmap-add and dirty-bitmap-remove
Date: Thu, 13 Mar 2014 14:26:57 +0100 [thread overview]
Message-ID: <20140313132657.GB4534@irqsave.net> (raw)
In-Reply-To: <1394605864-32237-3-git-send-email-famz@redhat.com>
The Wednesday 12 Mar 2014 à 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.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> blockdev.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> qapi-schema.json | 45 ++++++++++++++++++++++++++++++++++++++++++
> qmp-commands.hx | 49 +++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 154 insertions(+)
>
> 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 *device, int64_t bps, int64_t bps_rd,
> }
> }
>
> +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 = 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] == '\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 = 65536;
> + }
> +
> + bitmap = 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 = bdrv_find(device);
> + if (!bs) {
> + error_set(errp, QERR_DEVICE_NOT_FOUND, device);
> + return;
> + }
> +
> + if (!name || name[0] == '\0') {
> + error_setg(errp, "Bitmap name cannot be empty");
> + return;
> + }
> + bitmap = 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 = 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' } }
>
> ##
> +# @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 message
> +#
> +# 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
>
> {
> + .name = "dirty-bitmap-add",
> + .args_type = "device:B,name:s,granularity:i?",
> + .mhandler.cmd_new = qmp_marshal_input_dirty_bitmap_add,
> + },
> + {
> + .name = "dirty-bitmap-remove",
> + .args_type = "device:B,name:s",
> + .mhandler.cmd_new = qmp_marshal_input_dirty_bitmap_remove,
> + },
> +
> +SQMP
> +
> +dirty-bitmap-add
> +----------------
> +
> +Create a dirty bitmap with a name on the device, and start tracking the 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": "drive0",
> + "name": "bitmap0" } }
> +<- { "return": {} }
> +
> +EQMP
> +
> + {
> .name = "blockdev-snapshot-sync",
> .args_type = "device:s?,node-name:s?,snapshot-file:s,snapshot-node-name:s?,format:s?,mode:s?",
> .mhandler.cmd_new = qmp_marshal_input_blockdev_snapshot_sync,
> --
> 1.9.0
>
>
next prev parent reply other threads:[~2014-03-13 13:27 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-12 6:30 [Qemu-devel] [PATCH v2 0/9] QMP: Introduce incremental drive-backup with in-memory dirty bitmap Fam Zheng
2014-03-12 6:30 ` [Qemu-devel] [PATCH v2 1/9] qapi: Add optional field "name" to block " Fam Zheng
2014-03-13 13:15 ` Benoît Canet
2014-03-14 7:16 ` Fam Zheng
2014-03-12 6:30 ` [Qemu-devel] [PATCH v2 2/9] qmp: Add dirty-bitmap-add and dirty-bitmap-remove Fam Zheng
2014-03-13 13:26 ` Benoît Canet [this message]
2014-03-14 7:18 ` Fam Zheng
2014-03-14 12:32 ` Eric Blake
2014-03-12 6:30 ` [Qemu-devel] [PATCH v2 3/9] block: Handle error of bdrv_getlength in bdrv_create_dirty_bitmap Fam Zheng
2014-03-13 13:29 ` Benoît Canet
2014-03-12 6:30 ` [Qemu-devel] [PATCH v2 4/9] block: Introduce bdrv_dirty_bitmap_granularity() Fam Zheng
2014-03-13 13:30 ` Benoît Canet
2014-03-12 6:31 ` [Qemu-devel] [PATCH v2 5/9] hbitmap: Add hbitmap_copy Fam Zheng
2014-03-13 13:45 ` Benoît Canet
2014-03-13 14:28 ` Paolo Bonzini
2014-03-20 10:22 ` Paolo Bonzini
2014-03-20 10:47 ` Fam Zheng
2014-03-12 6:31 ` [Qemu-devel] [PATCH v2 6/9] block: Add bdrv_copy_dirty_bitmap and bdrv_reset_dirty_bitmap Fam Zheng
2014-03-12 6:31 ` [Qemu-devel] [PATCH v2 7/9] qmp: Add dirty-bitmap-enable and dirty-bitmap-disable Fam Zheng
2014-03-13 13:55 ` Benoît Canet
2014-03-14 7:25 ` Fam Zheng
2014-03-12 6:31 ` [Qemu-devel] [PATCH v2 8/9] qmp: Add support of "dirty-bitmap" sync mode for drive-backup Fam Zheng
2014-03-13 14:32 ` Benoît Canet
2014-03-14 7:27 ` Fam Zheng
2014-03-12 6:31 ` [Qemu-devel] [PATCH v2 9/9] qapi: Add transaction support to dirty-bitmap-{add, disable} Fam Zheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140313132657.GB4534@irqsave.net \
--to=benoit.canet@irqsave.net \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).