qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 5/8] qcow2: add qcow2_dirty_bitmap_delete_all


From: Vladimir Sementsov-Ogievskiy
Subject: [Qemu-devel] [PATCH 5/8] qcow2: add qcow2_dirty_bitmap_delete_all
Date: Mon, 8 Jun 2015 18:21:23 +0300

From: Vladimir Sementsov-Ogievskiy <address@hidden>

Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
 block/qcow2-dirty-bitmap.c | 29 +++++++++++++++++++++++++++++
 block/qcow2.h              |  2 ++
 2 files changed, 31 insertions(+)

diff --git a/block/qcow2-dirty-bitmap.c b/block/qcow2-dirty-bitmap.c
index bc0167c..db83112 100644
--- a/block/qcow2-dirty-bitmap.c
+++ b/block/qcow2-dirty-bitmap.c
@@ -501,3 +501,32 @@ int qcow2_dirty_bitmap_delete(BlockDriverState *bs,
 
     return ret;
 }
+
+int qcow2_delete_all_dirty_bitmaps(BlockDriverState *bs, Error **errp)
+{
+    BDRVQcowState *s = bs->opaque;
+    int ret = 0, i;
+
+    for (i = 0; i < s->nb_dirty_bitmaps; ++i) {
+        ret = qcow2_dirty_bitmap_free_clusters(bs, s->dirty_bitmaps + i);
+        if (ret < 0) {
+            error_setg_errno(errp, -ret,
+                             "Failed to free dirty bitmap clusters");
+            return ret;
+        }
+        g_free(s->dirty_bitmaps[i].name);
+    }
+
+    g_free(s->dirty_bitmaps);
+    s->nb_dirty_bitmaps = 0;
+
+    ret = qcow2_write_dirty_bitmaps(bs);
+    if (ret < 0) {
+        error_setg_errno(errp, -ret,
+                         "Failed to remove dirty bitmaps"
+                         " from dirty bitmap list");
+        return ret;
+    }
+
+    return ret;
+}
diff --git a/block/qcow2.h b/block/qcow2.h
index 24beee0..b5e576c 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -616,6 +616,8 @@ int qcow2_dirty_bitmap_create(BlockDriverState *bs, const 
char *name,
 int qcow2_dirty_bitmap_delete(BlockDriverState *bs,
                               const char *name,
                               Error **errp);
+int qcow2_delete_all_dirty_bitmaps(BlockDriverState *bs,
+                                   Error **errp);
 
 void qcow2_free_dirty_bitmaps(BlockDriverState *bs);
 int qcow2_read_dirty_bitmaps(BlockDriverState *bs);
-- 
1.9.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]