yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-block-dirty-bitmaps-prohibit-enable-disable-on-locke.patch

26ba25
From c5dddad12032351514c74083854393390ebd64e2 Mon Sep 17 00:00:00 2001
26ba25
From: John Snow <jsnow@redhat.com>
26ba25
Date: Tue, 20 Nov 2018 18:18:19 +0000
26ba25
Subject: [PATCH 25/35] block/dirty-bitmaps: prohibit enable/disable on
26ba25
 locked/frozen bitmaps
26ba25
26ba25
RH-Author: John Snow <jsnow@redhat.com>
26ba25
Message-id: <20181120181828.15132-16-jsnow@redhat.com>
26ba25
Patchwork-id: 83059
26ba25
O-Subject: [RHEL8/rhel qemu-kvm PATCH 15/24] block/dirty-bitmaps: prohibit enable/disable on locked/frozen bitmaps
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
We're not being consistent about this. If it's in use by an operation,
26ba25
the user should not be able to change the behavior of that bitmap.
26ba25
26ba25
Signed-off-by: John Snow <jsnow@redhat.com>
26ba25
Reviewed-by: Eric Blake <eblake@redhat.com>
26ba25
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
26ba25
Message-id: 20181002230218.13949-5-jsnow@redhat.com
26ba25
Signed-off-by: John Snow <jsnow@redhat.com>
26ba25
(cherry picked from commit b053bb55738f35832f3d6472b12277a75c32a038)
26ba25
Signed-off-by: John Snow <jsnow@redhat.com>
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 blockdev.c | 26 ++++++++++++++++++++------
26ba25
 1 file changed, 20 insertions(+), 6 deletions(-)
26ba25
26ba25
diff --git a/blockdev.c b/blockdev.c
26ba25
index 220b317..916153e 100644
26ba25
--- a/blockdev.c
26ba25
+++ b/blockdev.c
26ba25
@@ -2168,6 +2168,13 @@ static void block_dirty_bitmap_enable_prepare(BlkActionState *common,
26ba25
         return;
26ba25
     }
26ba25
 
26ba25
+    if (bdrv_dirty_bitmap_user_locked(state->bitmap)) {
26ba25
+        error_setg(errp,
26ba25
+                   "Bitmap '%s' is currently in use by another operation"
26ba25
+                   " and cannot be enabled", action->name);
26ba25
+        return;
26ba25
+    }
26ba25
+
26ba25
     state->was_enabled = bdrv_dirty_bitmap_enabled(state->bitmap);
26ba25
     bdrv_enable_dirty_bitmap(state->bitmap);
26ba25
 }
26ba25
@@ -2202,6 +2209,13 @@ static void block_dirty_bitmap_disable_prepare(BlkActionState *common,
26ba25
         return;
26ba25
     }
26ba25
 
26ba25
+    if (bdrv_dirty_bitmap_user_locked(state->bitmap)) {
26ba25
+        error_setg(errp,
26ba25
+                   "Bitmap '%s' is currently in use by another operation"
26ba25
+                   " and cannot be disabled", action->name);
26ba25
+        return;
26ba25
+    }
26ba25
+
26ba25
     state->was_enabled = bdrv_dirty_bitmap_enabled(state->bitmap);
26ba25
     bdrv_disable_dirty_bitmap(state->bitmap);
26ba25
 }
26ba25
@@ -3043,10 +3057,10 @@ void qmp_x_block_dirty_bitmap_enable(const char *node, const char *name,
26ba25
         return;
26ba25
     }
26ba25
 
26ba25
-    if (bdrv_dirty_bitmap_frozen(bitmap)) {
26ba25
+    if (bdrv_dirty_bitmap_user_locked(bitmap)) {
26ba25
         error_setg(errp,
26ba25
-                   "Bitmap '%s' is currently frozen and cannot be enabled",
26ba25
-                   name);
26ba25
+                   "Bitmap '%s' is currently in use by another operation"
26ba25
+                   " and cannot be enabled", name);
26ba25
         return;
26ba25
     }
26ba25
 
26ba25
@@ -3064,10 +3078,10 @@ void qmp_x_block_dirty_bitmap_disable(const char *node, const char *name,
26ba25
         return;
26ba25
     }
26ba25
 
26ba25
-    if (bdrv_dirty_bitmap_frozen(bitmap)) {
26ba25
+    if (bdrv_dirty_bitmap_user_locked(bitmap)) {
26ba25
         error_setg(errp,
26ba25
-                   "Bitmap '%s' is currently frozen and cannot be disabled",
26ba25
-                   name);
26ba25
+                   "Bitmap '%s' is currently in use by another operation"
26ba25
+                   " and cannot be disabled", name);
26ba25
         return;
26ba25
     }
26ba25
 
26ba25
-- 
26ba25
1.8.3.1
26ba25