@@ -960,15 +960,22 @@ void qcow2_bitmap_store(BlockDriverState *bs,
}
if (bmh == NULL) {
+ uint32_t flags =
+ bdrv_dirty_bitmap_get_autoload(bitmap) ? BME_FLAG_AUTO : 0;
ret = directory_push(bs, bm_name, granularity, table_offset,
- table_size, 0);
+ table_size, flags);
if (ret < 0) {
error_setg_errno(errp, ret, "Can't create dirty bitmap in qcow2.");
goto fail;
}
} else {
+ uint32_t flags = bmh->flags;
+ flags &= ~(BME_FLAG_IN_USE | BME_FLAG_AUTO);
+ if (bdrv_dirty_bitmap_get_autoload(bitmap)) {
+ flags |= BME_FLAG_AUTO;
+ }
ret = directory_set(bs, bmh, granularity, table_offset, table_size,
- bmh->flags & ~BME_FLAG_IN_USE);
+ flags);
if (ret < 0) {
error_setg_errno(errp, ret, "Can't update dirty bitmap in qcow2.");
goto fail;