diff mbox series

[RFC,v2,3/6] bitmaps: prohibit merge on locked bitmaps

Message ID 20180921222847.1012-4-jsnow@redhat.com (mailing list archive)
State New, archived
Headers show
Series dirty-bitmaps: fix QMP command permissions | expand

Commit Message

John Snow Sept. 21, 2018, 10:28 p.m. UTC
Like frozen, "qmp locked" bitmaps must not be modified by the user.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 block/dirty-bitmap.c | 1 +
 blockdev.c           | 4 ++++
 2 files changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index 5c8a7bbf6f..216baec388 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -798,6 +798,7 @@  void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src,
     qemu_mutex_lock(dest->mutex);
 
     assert(!bdrv_dirty_bitmap_frozen(dest));
+    assert(!bdrv_dirty_bitmap_qmp_locked(dest));
     assert(!bdrv_dirty_bitmap_readonly(dest));
 
     if (!hbitmap_merge(dest->bitmap, src->bitmap)) {
diff --git a/blockdev.c b/blockdev.c
index bb8d75c832..b21e635c68 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2955,6 +2955,10 @@  void qmp_x_block_dirty_bitmap_merge(const char *node, const char *dst_name,
         error_setg(errp, "Bitmap '%s' is readonly and cannot be modified",
                    dst_name);
         return;
+    } else if (bdrv_dirty_bitmap_qmp_locked(dst)) {
+        error_setg(errp, "Bitmap '%s' is in-use by an operation "
+                   "and cannot be modified", dst_name);
+        return;
     }
 
     src = bdrv_find_dirty_bitmap(bs, src_name);