cryptospore / rpms / qemu-kvm

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