thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

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

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