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

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