Blame SOURCES/kvm-qapi-add-x-block-dirty-bitmap-enable-disable.patch

1bdc94
From 65fa69814f994a95b1574dd16ea81aef4774fec5 Mon Sep 17 00:00:00 2001
1bdc94
From: John Snow <jsnow@redhat.com>
1bdc94
Date: Wed, 18 Jul 2018 22:54:38 +0200
1bdc94
Subject: [PATCH 53/89] qapi: add x-block-dirty-bitmap-enable/disable
1bdc94
1bdc94
RH-Author: John Snow <jsnow@redhat.com>
1bdc94
Message-id: <20180718225511.14878-3-jsnow@redhat.com>
1bdc94
Patchwork-id: 81406
1bdc94
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 02/35] qapi: add x-block-dirty-bitmap-enable/disable
1bdc94
Bugzilla: 1207657
1bdc94
RH-Acked-by: Eric Blake <eblake@redhat.com>
1bdc94
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
1bdc94
RH-Acked-by: Fam Zheng <famz@redhat.com>
1bdc94
1bdc94
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1bdc94
1bdc94
Expose the ability to turn bitmaps "on" or "off". This is experimental
1bdc94
and principally for the sake of the Libvirt Checkpoints API, and it may
1bdc94
or may not be committed for 3.0.
1bdc94
1bdc94
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1bdc94
Signed-off-by: John Snow <jsnow@redhat.com>
1bdc94
Reviewed-by: Jeff Cody <jcody@redhat.com>
1bdc94
Message-id: 20180606182449.1607-3-jsnow@redhat.com
1bdc94
Signed-off-by: John Snow <jsnow@redhat.com>
1bdc94
(cherry picked from commit 5c5d2e50e5ac85234d793f0127a20ea3424a1229)
1bdc94
Signed-off-by: John Snow <jsnow@redhat.com>
1bdc94
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
1bdc94
---
1bdc94
 blockdev.c           | 42 ++++++++++++++++++++++++++++++++++++++++++
1bdc94
 qapi/block-core.json | 42 ++++++++++++++++++++++++++++++++++++++++++
1bdc94
 2 files changed, 84 insertions(+)
1bdc94
1bdc94
diff --git a/blockdev.c b/blockdev.c
1bdc94
index d8b6520..ca2ffff 100644
1bdc94
--- a/blockdev.c
1bdc94
+++ b/blockdev.c
1bdc94
@@ -2965,6 +2965,48 @@ void qmp_block_dirty_bitmap_clear(const char *node, const char *name,
1bdc94
     bdrv_clear_dirty_bitmap(bitmap, NULL);
1bdc94
 }
1bdc94
 
1bdc94
+void qmp_x_block_dirty_bitmap_enable(const char *node, const char *name,
1bdc94
+                                   Error **errp)
1bdc94
+{
1bdc94
+    BlockDriverState *bs;
1bdc94
+    BdrvDirtyBitmap *bitmap;
1bdc94
+
1bdc94
+    bitmap = block_dirty_bitmap_lookup(node, name, &bs, errp);
1bdc94
+    if (!bitmap) {
1bdc94
+        return;
1bdc94
+    }
1bdc94
+
1bdc94
+    if (bdrv_dirty_bitmap_frozen(bitmap)) {
1bdc94
+        error_setg(errp,
1bdc94
+                   "Bitmap '%s' is currently frozen and cannot be enabled",
1bdc94
+                   name);
1bdc94
+        return;
1bdc94
+    }
1bdc94
+
1bdc94
+    bdrv_enable_dirty_bitmap(bitmap);
1bdc94
+}
1bdc94
+
1bdc94
+void qmp_x_block_dirty_bitmap_disable(const char *node, const char *name,
1bdc94
+                                    Error **errp)
1bdc94
+{
1bdc94
+    BlockDriverState *bs;
1bdc94
+    BdrvDirtyBitmap *bitmap;
1bdc94
+
1bdc94
+    bitmap = block_dirty_bitmap_lookup(node, name, &bs, errp);
1bdc94
+    if (!bitmap) {
1bdc94
+        return;
1bdc94
+    }
1bdc94
+
1bdc94
+    if (bdrv_dirty_bitmap_frozen(bitmap)) {
1bdc94
+        error_setg(errp,
1bdc94
+                   "Bitmap '%s' is currently frozen and cannot be disabled",
1bdc94
+                   name);
1bdc94
+        return;
1bdc94
+    }
1bdc94
+
1bdc94
+    bdrv_disable_dirty_bitmap(bitmap);
1bdc94
+}
1bdc94
+
1bdc94
 BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *node,
1bdc94
                                                               const char *name,
1bdc94
                                                               Error **errp)
1bdc94
diff --git a/qapi/block-core.json b/qapi/block-core.json
1bdc94
index 0b07e41..5c8cfa3 100644
1bdc94
--- a/qapi/block-core.json
1bdc94
+++ b/qapi/block-core.json
1bdc94
@@ -1809,6 +1809,48 @@
1bdc94
   'data': 'BlockDirtyBitmap' }
1bdc94
 
1bdc94
 ##
1bdc94
+# @x-block-dirty-bitmap-enable:
1bdc94
+#
1bdc94
+# Enables a dirty bitmap so that it will begin tracking disk changes.
1bdc94
+#
1bdc94
+# Returns: nothing on success
1bdc94
+#          If @node is not a valid block device, DeviceNotFound
1bdc94
+#          If @name is not found, GenericError with an explanation
1bdc94
+#
1bdc94
+# Since: 3.0
1bdc94
+#
1bdc94
+# Example:
1bdc94
+#
1bdc94
+# -> { "execute": "x-block-dirty-bitmap-enable",
1bdc94
+#      "arguments": { "node": "drive0", "name": "bitmap0" } }
1bdc94
+# <- { "return": {} }
1bdc94
+#
1bdc94
+##
1bdc94
+  { 'command': 'x-block-dirty-bitmap-enable',
1bdc94
+    'data': 'BlockDirtyBitmap' }
1bdc94
+
1bdc94
+##
1bdc94
+# @x-block-dirty-bitmap-disable:
1bdc94
+#
1bdc94
+# Disables a dirty bitmap so that it will stop tracking disk changes.
1bdc94
+#
1bdc94
+# Returns: nothing on success
1bdc94
+#          If @node is not a valid block device, DeviceNotFound
1bdc94
+#          If @name is not found, GenericError with an explanation
1bdc94
+#
1bdc94
+# Since: 3.0
1bdc94
+#
1bdc94
+# Example:
1bdc94
+#
1bdc94
+# -> { "execute": "x-block-dirty-bitmap-disable",
1bdc94
+#      "arguments": { "node": "drive0", "name": "bitmap0" } }
1bdc94
+# <- { "return": {} }
1bdc94
+#
1bdc94
+##
1bdc94
+    { 'command': 'x-block-dirty-bitmap-disable',
1bdc94
+      'data': 'BlockDirtyBitmap' }
1bdc94
+
1bdc94
+##
1bdc94
 # @BlockDirtyBitmapSha256:
1bdc94
 #
1bdc94
 # SHA256 hash of dirty bitmap data
1bdc94
-- 
1bdc94
1.8.3.1
1bdc94