yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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