|
|
ae23c9 |
From 61f7fec68d66c61a6d3058991470cce978fe1e10 Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
Date: Wed, 18 Jul 2018 22:54:40 +0200
|
|
|
ae23c9 |
Subject: [PATCH 222/268] qapi: add x-block-dirty-bitmap-merge
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
Message-id: <20180718225511.14878-5-jsnow@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 81397
|
|
|
ae23c9 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 04/35] qapi: add x-block-dirty-bitmap-merge
|
|
|
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 |
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-5-jsnow@redhat.com
|
|
|
ae23c9 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit b598e531f1123d2fb72615f1161c66093be751ea)
|
|
|
ae23c9 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
block/dirty-bitmap.c | 18 ++++++++++++++++++
|
|
|
ae23c9 |
blockdev.c | 30 ++++++++++++++++++++++++++++++
|
|
|
ae23c9 |
include/block/dirty-bitmap.h | 3 ++-
|
|
|
ae23c9 |
qapi/block-core.json | 38 ++++++++++++++++++++++++++++++++++++++
|
|
|
ae23c9 |
4 files changed, 88 insertions(+), 1 deletion(-)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
|
|
|
ae23c9 |
index 5623425..4159d39 100644
|
|
|
ae23c9 |
--- a/block/dirty-bitmap.c
|
|
|
ae23c9 |
+++ b/block/dirty-bitmap.c
|
|
|
ae23c9 |
@@ -757,3 +757,21 @@ int64_t bdrv_dirty_bitmap_next_zero(BdrvDirtyBitmap *bitmap, uint64_t offset)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
return hbitmap_next_zero(bitmap->bitmap, offset);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src,
|
|
|
ae23c9 |
+ Error **errp)
|
|
|
ae23c9 |
+{
|
|
|
ae23c9 |
+ /* only bitmaps from one bds are supported */
|
|
|
ae23c9 |
+ assert(dest->mutex == src->mutex);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ qemu_mutex_lock(dest->mutex);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ assert(bdrv_dirty_bitmap_enabled(dest));
|
|
|
ae23c9 |
+ assert(!bdrv_dirty_bitmap_readonly(dest));
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ if (!hbitmap_merge(dest->bitmap, src->bitmap)) {
|
|
|
ae23c9 |
+ error_setg(errp, "Bitmaps are incompatible and can't be merged");
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ qemu_mutex_unlock(dest->mutex);
|
|
|
ae23c9 |
+}
|
|
|
ae23c9 |
diff --git a/blockdev.c b/blockdev.c
|
|
|
ae23c9 |
index b74b7d4..837183c 100644
|
|
|
ae23c9 |
--- a/blockdev.c
|
|
|
ae23c9 |
+++ b/blockdev.c
|
|
|
ae23c9 |
@@ -3045,6 +3045,36 @@ void qmp_x_block_dirty_bitmap_disable(const char *node, const char *name,
|
|
|
ae23c9 |
bdrv_disable_dirty_bitmap(bitmap);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+void qmp_x_block_dirty_bitmap_merge(const char *node, const char *dst_name,
|
|
|
ae23c9 |
+ const char *src_name, Error **errp)
|
|
|
ae23c9 |
+{
|
|
|
ae23c9 |
+ BlockDriverState *bs;
|
|
|
ae23c9 |
+ BdrvDirtyBitmap *dst, *src;
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ dst = block_dirty_bitmap_lookup(node, dst_name, &bs, errp);
|
|
|
ae23c9 |
+ if (!dst) {
|
|
|
ae23c9 |
+ return;
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ if (bdrv_dirty_bitmap_frozen(dst)) {
|
|
|
ae23c9 |
+ error_setg(errp, "Bitmap '%s' is frozen and cannot be modified",
|
|
|
ae23c9 |
+ dst_name);
|
|
|
ae23c9 |
+ return;
|
|
|
ae23c9 |
+ } else if (bdrv_dirty_bitmap_readonly(dst)) {
|
|
|
ae23c9 |
+ error_setg(errp, "Bitmap '%s' is readonly and cannot be modified",
|
|
|
ae23c9 |
+ dst_name);
|
|
|
ae23c9 |
+ return;
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ src = bdrv_find_dirty_bitmap(bs, src_name);
|
|
|
ae23c9 |
+ if (!src) {
|
|
|
ae23c9 |
+ error_setg(errp, "Dirty bitmap '%s' not found", src_name);
|
|
|
ae23c9 |
+ return;
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ bdrv_merge_dirty_bitmap(dst, src, errp);
|
|
|
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/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
|
|
|
ae23c9 |
index 1ff8949..1e14743 100644
|
|
|
ae23c9 |
--- a/include/block/dirty-bitmap.h
|
|
|
ae23c9 |
+++ b/include/block/dirty-bitmap.h
|
|
|
ae23c9 |
@@ -70,7 +70,8 @@ void bdrv_dirty_bitmap_set_readonly(BdrvDirtyBitmap *bitmap, bool value);
|
|
|
ae23c9 |
void bdrv_dirty_bitmap_set_persistance(BdrvDirtyBitmap *bitmap,
|
|
|
ae23c9 |
bool persistent);
|
|
|
ae23c9 |
void bdrv_dirty_bitmap_set_qmp_locked(BdrvDirtyBitmap *bitmap, bool qmp_locked);
|
|
|
ae23c9 |
-
|
|
|
ae23c9 |
+void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src,
|
|
|
ae23c9 |
+ Error **errp);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
/* Functions that require manual locking. */
|
|
|
ae23c9 |
void bdrv_dirty_bitmap_lock(BdrvDirtyBitmap *bitmap);
|
|
|
ae23c9 |
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
|
|
ae23c9 |
index 6f3fdf4..50a2763 100644
|
|
|
ae23c9 |
--- a/qapi/block-core.json
|
|
|
ae23c9 |
+++ b/qapi/block-core.json
|
|
|
ae23c9 |
@@ -1741,6 +1741,20 @@
|
|
|
ae23c9 |
'*persistent': 'bool', '*autoload': 'bool' } }
|
|
|
ae23c9 |
|
|
|
ae23c9 |
##
|
|
|
ae23c9 |
+# @BlockDirtyBitmapMerge:
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# @node: name of device/node which the bitmap is tracking
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# @dst_name: name of the destination dirty bitmap
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# @src_name: name of the source dirty bitmap
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# Since: 3.0
|
|
|
ae23c9 |
+##
|
|
|
ae23c9 |
+{ 'struct': 'BlockDirtyBitmapMerge',
|
|
|
ae23c9 |
+ 'data': { 'node': 'str', 'dst_name': 'str', 'src_name': 'str' } }
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+##
|
|
|
ae23c9 |
# @block-dirty-bitmap-add:
|
|
|
ae23c9 |
#
|
|
|
ae23c9 |
# Create a dirty bitmap with a name on the node, and start tracking the writes.
|
|
|
ae23c9 |
@@ -1851,6 +1865,30 @@
|
|
|
ae23c9 |
'data': 'BlockDirtyBitmap' }
|
|
|
ae23c9 |
|
|
|
ae23c9 |
##
|
|
|
ae23c9 |
+# @x-block-dirty-bitmap-merge:
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# Merge @src_name dirty bitmap to @dst_name dirty bitmap. @src_name dirty
|
|
|
ae23c9 |
+# bitmap is unchanged. On error, @dst_name is unchanged.
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# Returns: nothing on success
|
|
|
ae23c9 |
+# If @node is not a valid block device, DeviceNotFound
|
|
|
ae23c9 |
+# If @dst_name or @src_name is not found, GenericError
|
|
|
ae23c9 |
+# If bitmaps has different sizes or granularities, GenericError
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# Since: 3.0
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# Example:
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# -> { "execute": "x-block-dirty-bitmap-merge",
|
|
|
ae23c9 |
+# "arguments": { "node": "drive0", "dst_name": "bitmap0",
|
|
|
ae23c9 |
+# "src_name": "bitmap1" } }
|
|
|
ae23c9 |
+# <- { "return": {} }
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+##
|
|
|
ae23c9 |
+ { 'command': 'x-block-dirty-bitmap-merge',
|
|
|
ae23c9 |
+ 'data': 'BlockDirtyBitmapMerge' }
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+##
|
|
|
ae23c9 |
# @BlockDirtyBitmapSha256:
|
|
|
ae23c9 |
#
|
|
|
ae23c9 |
# SHA256 hash of dirty bitmap data
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|