On 02/03/2017 04:40 AM, Vladimir Sementsov-Ogievskiy wrote:
> Mirror AUTO flag from Qcow2 bitmap in BdrvDirtyBitmap. This will be
> needed in future, to save this flag back to Qcow2 for persistent
> bitmaps.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com>
> Reviewed-by: Max Reitz <mre...@redhat.com>
> ---
>  block/dirty-bitmap.c         | 16 ++++++++++++++++
>  block/qcow2-bitmap.c         |  2 ++
>  include/block/dirty-bitmap.h |  2 ++
>  3 files changed, 20 insertions(+)
> 
> diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
> index 90af37287f..2d27494dc7 100644
> --- a/block/dirty-bitmap.c
> +++ b/block/dirty-bitmap.c
> @@ -44,6 +44,8 @@ struct BdrvDirtyBitmap {
>      int64_t size;               /* Size of the bitmap (Number of sectors) */
>      bool disabled;              /* Bitmap is read-only */
>      int active_iterators;       /* How many iterators are active */
> +    bool autoload;              /* For persistent bitmaps: bitmap must be
> +                                   autoloaded on image opening */
>      QLIST_ENTRY(BdrvDirtyBitmap) list;
>  };
>  
> @@ -70,6 +72,8 @@ void bdrv_dirty_bitmap_make_anon(BdrvDirtyBitmap *bitmap)
>      assert(!bdrv_dirty_bitmap_frozen(bitmap));
>      g_free(bitmap->name);
>      bitmap->name = NULL;
> +
> +    bitmap->autoload = false;
>  }
>  

No real need for the extra line.

>  BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs,
> @@ -238,6 +242,8 @@ BdrvDirtyBitmap 
> *bdrv_dirty_bitmap_abdicate(BlockDriverState *bs,
>      bitmap->name = NULL;
>      successor->name = name;
>      bitmap->successor = NULL;
> +    successor->autoload = bitmap->autoload;
> +    bitmap->autoload = false;
>      bdrv_release_dirty_bitmap(bs, bitmap);
>  
>      return successor;
> @@ -540,3 +546,13 @@ int64_t bdrv_get_meta_dirty_count(BdrvDirtyBitmap 
> *bitmap)
>  {
>      return hbitmap_count(bitmap->meta);
>  }
> +
> +void bdrv_dirty_bitmap_set_autoload(BdrvDirtyBitmap *bitmap, bool autoload)
> +{
> +    bitmap->autoload = autoload;
> +}
> +
> +bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap)
> +{
> +    return bitmap->autoload;
> +}
> diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
> index eeeec1aa7f..bcbb0491ee 100644
> --- a/block/qcow2-bitmap.c
> +++ b/block/qcow2-bitmap.c
> @@ -706,6 +706,8 @@ void 
> qcow2_load_autoloading_dirty_bitmaps(BlockDriverState *bs, Error **errp)
>              if (bitmap == NULL) {
>                  goto fail;
>              }
> +
> +            bdrv_dirty_bitmap_set_autoload(bitmap, true);
>              bm->flags |= BME_FLAG_IN_USE;
>              created_dirty_bitmaps =
>                      g_slist_append(created_dirty_bitmaps, bitmap);
> diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
> index 1e17729ac2..45a389a20a 100644
> --- a/include/block/dirty-bitmap.h
> +++ b/include/block/dirty-bitmap.h
> @@ -75,4 +75,6 @@ void bdrv_dirty_bitmap_deserialize_ones(BdrvDirtyBitmap 
> *bitmap,
>                                          bool finish);
>  void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap *bitmap);
>  
> +void bdrv_dirty_bitmap_set_autoload(BdrvDirtyBitmap *bitmap, bool autoload);
> +bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap);
>  #endif
> 

Reviewed-by: John Snow <js...@redhat.com>

Reply via email to