cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-dirty-bitmap-switch-assert-fails-to-errors-in-bdrv_m.patch

26ba25
From dd277015d70cd5521398d298dbc236b9aeb296f5 Mon Sep 17 00:00:00 2001
26ba25
From: John Snow <jsnow@redhat.com>
26ba25
Date: Tue, 20 Nov 2018 18:18:11 +0000
26ba25
Subject: [PATCH 17/35] dirty-bitmap: switch assert-fails to errors in
26ba25
 bdrv_merge_dirty_bitmap
26ba25
26ba25
RH-Author: John Snow <jsnow@redhat.com>
26ba25
Message-id: <20181120181828.15132-8-jsnow@redhat.com>
26ba25
Patchwork-id: 83055
26ba25
O-Subject: [RHEL8/rhel qemu-kvm PATCH 07/24] dirty-bitmap: switch assert-fails to errors in bdrv_merge_dirty_bitmap
26ba25
Bugzilla: 1518989
26ba25
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
26ba25
RH-Acked-by: Max Reitz <mreitz@redhat.com>
26ba25
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
26ba25
26ba25
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
26ba25
26ba25
Move checks from qmp_x_block_dirty_bitmap_merge() to
26ba25
bdrv_merge_dirty_bitmap(), to share them with dirty bitmap merge
26ba25
transaction action in future commit.
26ba25
26ba25
Note: for now, only qmp_x_block_dirty_bitmap_merge() calls
26ba25
bdrv_merge_dirty_bitmap().
26ba25
26ba25
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
26ba25
Reviewed-by: John Snow <jsnow@redhat.com>
26ba25
(cherry picked from commit 06bf50068a7e952afff8c4f6470ec54a712570f7)
26ba25
Signed-off-by: John Snow <jsnow@redhat.com>
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 block/dirty-bitmap.c | 15 +++++++++++++--
26ba25
 blockdev.c           | 10 ----------
26ba25
 2 files changed, 13 insertions(+), 12 deletions(-)
26ba25
26ba25
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
26ba25
index c9b8a6f..6c8761e 100644
26ba25
--- a/block/dirty-bitmap.c
26ba25
+++ b/block/dirty-bitmap.c
26ba25
@@ -798,12 +798,23 @@ void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src,
26ba25
 
26ba25
     qemu_mutex_lock(dest->mutex);
26ba25
 
26ba25
-    assert(bdrv_dirty_bitmap_enabled(dest));
26ba25
-    assert(!bdrv_dirty_bitmap_readonly(dest));
26ba25
+    if (bdrv_dirty_bitmap_frozen(dest)) {
26ba25
+        error_setg(errp, "Bitmap '%s' is frozen and cannot be modified",
26ba25
+                   dest->name);
26ba25
+        goto out;
26ba25
+    }
26ba25
+
26ba25
+    if (bdrv_dirty_bitmap_readonly(dest)) {
26ba25
+        error_setg(errp, "Bitmap '%s' is readonly and cannot be modified",
26ba25
+                   dest->name);
26ba25
+        goto out;
26ba25
+    }
26ba25
 
26ba25
     if (!hbitmap_merge(dest->bitmap, src->bitmap)) {
26ba25
         error_setg(errp, "Bitmaps are incompatible and can't be merged");
26ba25
+        goto out;
26ba25
     }
26ba25
 
26ba25
+out:
26ba25
     qemu_mutex_unlock(dest->mutex);
26ba25
 }
26ba25
diff --git a/blockdev.c b/blockdev.c
26ba25
index a722188..b3d265b 100644
26ba25
--- a/blockdev.c
26ba25
+++ b/blockdev.c
26ba25
@@ -3071,16 +3071,6 @@ void qmp_x_block_dirty_bitmap_merge(const char *node, const char *dst_name,
26ba25
         return;
26ba25
     }
26ba25
 
26ba25
-    if (bdrv_dirty_bitmap_frozen(dst)) {
26ba25
-        error_setg(errp, "Bitmap '%s' is frozen and cannot be modified",
26ba25
-                   dst_name);
26ba25
-        return;
26ba25
-    } else if (bdrv_dirty_bitmap_readonly(dst)) {
26ba25
-        error_setg(errp, "Bitmap '%s' is readonly and cannot be modified",
26ba25
-                   dst_name);
26ba25
-        return;
26ba25
-    }
26ba25
-
26ba25
     src = bdrv_find_dirty_bitmap(bs, src_name);
26ba25
     if (!src) {
26ba25
         error_setg(errp, "Dirty bitmap '%s' not found", src_name);
26ba25
-- 
26ba25
1.8.3.1
26ba25