qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 7/9] qmp: Add dirty-bitmap-enable and dirty-b


From: Benoît Canet
Subject: Re: [Qemu-devel] [PATCH v2 7/9] qmp: Add dirty-bitmap-enable and dirty-bitmap-disable
Date: Thu, 13 Mar 2014 14:55:13 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

The Wednesday 12 Mar 2014 à 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.
> 
> It will be used before backup or writing to persistent file.
> 
> Signed-off-by: Fam Zheng <address@hidden>
> ---
>  block.c               | 15 +++++++++++++++
>  blockdev.c            | 44 ++++++++++++++++++++++++++++++++++++++++++++
>  include/block/block.h |  2 ++
>  qapi-schema.json      | 32 ++++++++++++++++++++++++++++++++
>  qmp-commands.hx       | 10 ++++++++++
>  5 files changed, 103 insertions(+)
> 
> 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;
>  };
>  
> @@ -5120,6 +5121,7 @@ BdrvDirtyBitmap 
> *bdrv_create_dirty_bitmap(BlockDriverState *bs,
>      if (name) {
>          bitmap->name = g_strdup(name);
>      }
> +    bitmap->enabled = true;
>      QLIST_INSERT_HEAD(&bs->dirty_bitmaps, bitmap, list);
>      return bitmap;
>  }
> @@ -5138,6 +5140,16 @@ void bdrv_release_dirty_bitmap(BlockDriverState *bs, 
> BdrvDirtyBitmap *bitmap)
>      }
>  }
>  
> +void bdrv_disable_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap)
> +{
> +    bitmap->enabled = false;
> +}
> +
> +void bdrv_enable_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap)
> +{
> +    bitmap->enabled = 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);
>  }
>  
> +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 = bdrv_find(device);
> +    if (!bs) {
> +        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
> +        return;
> +    }
> +
> +    bitmap = 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 granularity,
Same question ?

> +                              Error **errp)
> +{
> +    BlockDriverState *bs;
> +    BdrvDirtyBitmap *bitmap;
> +
> +    bs = bdrv_find(device);
> +    if (!bs) {
> +        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
> +        return;
> +    }
> +
> +    bitmap = 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 = 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(BlockDriverState 
> *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 *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' } }
>  
>  ##
> +# @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 message
> +#
> +# 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 message
> +#
> +# 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  = "device:B,name:s",
>          .mhandler.cmd_new = qmp_marshal_input_dirty_bitmap_remove,
>      },
> +    {
> +        .name       = "dirty-bitmap-enable",
> +        .args_type  = "device:B,name:s",
> +        .mhandler.cmd_new = qmp_marshal_input_dirty_bitmap_enable,
> +    },
> +    {
> +        .name       = "dirty-bitmap-disable",
> +        .args_type  = "device:B,name:s",
> +        .mhandler.cmd_new = qmp_marshal_input_dirty_bitmap_disable,
> +    },
>  
>  SQMP
>  
> -- 
> 1.9.0
> 
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]