The bitmap should be auto-loaded if auto flag is set. For now, actually, there are no methods to set it.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> --- block/qcow2-dirty-bitmap.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/block/qcow2-dirty-bitmap.c b/block/qcow2-dirty-bitmap.c index 70c6e36..159e935 100644 --- a/block/qcow2-dirty-bitmap.c +++ b/block/qcow2-dirty-bitmap.c @@ -42,8 +42,9 @@ #define BME_MAX_NAME_SIZE 1023 /* Bitmap directory entry flags */ -#define BME_RESERVED_FLAGS 0xfffffffe +#define BME_RESERVED_FLAGS 0xfffffffc #define BME_FLAG_IN_USE 1 +#define BME_FLAG_AUTO (1U << 1) /* bits [1, 8] U [56, 63] are reserved */ #define BME_TABLE_ENTRY_RESERVED_MASK 0xff000000000001fe @@ -52,6 +53,9 @@ typedef enum BitmapType { BT_DIRTY_TRACKING_BITMAP = 1 } BitmapType; +static BdrvDirtyBitmap *load_bitmap(BlockDriverState *bs, QCow2Bitmap *bm, + Error **errp); + void qcow2_free_bitmaps(BlockDriverState *bs) { BDRVQcow2State *s = bs->opaque; @@ -215,6 +219,13 @@ static int directory_read(BlockDriverState *bs, Error **errp) bm->offset = offset; bm->name = g_strndup((char *)(h + 1), h->name_size); + if (h->flags & BME_FLAG_AUTO) { + load_bitmap(bs, bm, errp); + if (*errp != NULL) { + goto fail; + } + } + offset += dir_entry_size(h); } return 0; -- 1.8.3.1