diff mbox

[22/22] qcow2-dirty-bitmap: add EXTRA_DATA_COMPATIBLE flag

Message ID 1458072268-53705-23-git-send-email-vsementsov@virtuozzo.com (mailing list archive)
State New, archived
Headers show

Commit Message

Vladimir Sementsov-Ogievskiy March 15, 2016, 8:04 p.m. UTC
If this flag is unset and exta data present the bitmap should be
read-only. For now just return error for this case.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/qcow2-dirty-bitmap.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Eric Blake March 22, 2016, 6:51 p.m. UTC | #1
On 03/15/2016 02:04 PM, Vladimir Sementsov-Ogievskiy wrote:
> If this flag is unset and exta data present the bitmap should be

s/exta/extra/
s/present/is present/

> read-only. For now just return error for this case.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  block/qcow2-dirty-bitmap.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/block/qcow2-dirty-bitmap.c b/block/qcow2-dirty-bitmap.c
> index 159e935..95c166c 100644
> --- a/block/qcow2-dirty-bitmap.c
> +++ b/block/qcow2-dirty-bitmap.c
> @@ -45,6 +45,7 @@
>  #define BME_RESERVED_FLAGS 0xfffffffc
>  #define BME_FLAG_IN_USE 1
>  #define BME_FLAG_AUTO   (1U << 1)
> +#define BME_FLAG_EXTRA_DATA_COMPATIBLE   (1U << 1)
>  
>  /* bits [1, 8] U [56, 63] are reserved */
>  #define BME_TABLE_ENTRY_RESERVED_MASK 0xff000000000001fe
> @@ -333,6 +334,13 @@ static BdrvDirtyBitmap *load_bitmap(BlockDriverState *bs, QCow2Bitmap *bm,
>          return NULL;
>      }
>  
> +    if (!(bmh->flags & BME_FLAG_EXTRA_DATA_COMPATIBLE) &&
> +            bmh->extra_data_size != 0) {
> +        error_setg(errp, "Uncompatible extra data found for bitmap '%s'",

s/Uncompatible/Incompatible/

> +                   bm->name);
> +        return NULL;
> +    }
> +
>      bitmap_table = g_try_malloc(bmh->bitmap_table_size * sizeof(uint64_t));
>      if (bitmap_table == NULL) {
>          error_setg_errno(errp, -ENOMEM,
>
diff mbox

Patch

diff --git a/block/qcow2-dirty-bitmap.c b/block/qcow2-dirty-bitmap.c
index 159e935..95c166c 100644
--- a/block/qcow2-dirty-bitmap.c
+++ b/block/qcow2-dirty-bitmap.c
@@ -45,6 +45,7 @@ 
 #define BME_RESERVED_FLAGS 0xfffffffc
 #define BME_FLAG_IN_USE 1
 #define BME_FLAG_AUTO   (1U << 1)
+#define BME_FLAG_EXTRA_DATA_COMPATIBLE   (1U << 1)
 
 /* bits [1, 8] U [56, 63] are reserved */
 #define BME_TABLE_ENTRY_RESERVED_MASK 0xff000000000001fe
@@ -333,6 +334,13 @@  static BdrvDirtyBitmap *load_bitmap(BlockDriverState *bs, QCow2Bitmap *bm,
         return NULL;
     }
 
+    if (!(bmh->flags & BME_FLAG_EXTRA_DATA_COMPATIBLE) &&
+            bmh->extra_data_size != 0) {
+        error_setg(errp, "Uncompatible extra data found for bitmap '%s'",
+                   bm->name);
+        return NULL;
+    }
+
     bitmap_table = g_try_malloc(bmh->bitmap_table_size * sizeof(uint64_t));
     if (bitmap_table == NULL) {
         error_setg_errno(errp, -ENOMEM,