yeahuh / 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

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