diff mbox

[24/29] qcow2-bitmap: maintian BlockDirtyBitmap.autoload

Message ID 1470668720-211300-25-git-send-email-vsementsov@virtuozzo.com (mailing list archive)
State New, archived
Headers show

Commit Message

Vladimir Sementsov-Ogievskiy Aug. 8, 2016, 3:05 p.m. UTC
Sync qcow2 dirty bitmap autload flag and BlockDirtyBitmap autoload flag

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
 block/qcow2-bitmap.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index a00eae4..49066bd 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -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;