yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-qemu-img-Factor-out-code-for-merging-bitmaps.patch

ddf19c
From 58816c3709e5058e8805333ca011cc4e793d67ff Mon Sep 17 00:00:00 2001
ddf19c
From: Eric Blake <eblake@redhat.com>
ddf19c
Date: Tue, 2 Jun 2020 02:34:18 +0100
ddf19c
Subject: [PATCH 13/26] qemu-img: Factor out code for merging bitmaps
ddf19c
MIME-Version: 1.0
ddf19c
Content-Type: text/plain; charset=UTF-8
ddf19c
Content-Transfer-Encoding: 8bit
ddf19c
ddf19c
RH-Author: Eric Blake <eblake@redhat.com>
ddf19c
Message-id: <20200602023420.2133649-11-eblake@redhat.com>
ddf19c
Patchwork-id: 97078
ddf19c
O-Subject: [RHEL-AV-8.2.1 qemu-kvm PATCH 10/12] qemu-img: Factor out code for merging bitmaps
ddf19c
Bugzilla: 1779893 1779904
ddf19c
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
ddf19c
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ddf19c
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ddf19c
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
ddf19c
ddf19c
The next patch will add another client that wants to merge dirty
ddf19c
bitmaps; it will be easier to refactor the code to construct the QAPI
ddf19c
struct correctly into a helper function.
ddf19c
ddf19c
Signed-off-by: Eric Blake <eblake@redhat.com>
ddf19c
Message-Id: <20200521192137.1120211-4-eblake@redhat.com>
ddf19c
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
ddf19c
(cherry picked from commit 6c729dd832207d7347ecb074912f538e2942f269)
ddf19c
Signed-off-by: Eric Blake <eblake@redhat.com>
ddf19c
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ddf19c
---
ddf19c
 qemu-img.c | 34 +++++++++++++++++++++-------------
ddf19c
 1 file changed, 21 insertions(+), 13 deletions(-)
ddf19c
ddf19c
diff --git a/qemu-img.c b/qemu-img.c
ddf19c
index b57856e..39e1586 100644
ddf19c
--- a/qemu-img.c
ddf19c
+++ b/qemu-img.c
ddf19c
@@ -1582,6 +1582,24 @@ out4:
ddf19c
     return ret;
ddf19c
 }
ddf19c
 
ddf19c
+/* Convenience wrapper around qmp_block_dirty_bitmap_merge */
ddf19c
+static void do_dirty_bitmap_merge(const char *dst_node, const char *dst_name,
ddf19c
+                                  const char *src_node, const char *src_name,
ddf19c
+                                  Error **errp)
ddf19c
+{
ddf19c
+    BlockDirtyBitmapMergeSource *merge_src;
ddf19c
+    BlockDirtyBitmapMergeSourceList *list;
ddf19c
+
ddf19c
+    merge_src = g_new0(BlockDirtyBitmapMergeSource, 1);
ddf19c
+    merge_src->type = QTYPE_QDICT;
ddf19c
+    merge_src->u.external.node = g_strdup(src_node);
ddf19c
+    merge_src->u.external.name = g_strdup(src_name);
ddf19c
+    list = g_new0(BlockDirtyBitmapMergeSourceList, 1);
ddf19c
+    list->value = merge_src;
ddf19c
+    qmp_block_dirty_bitmap_merge(dst_node, dst_name, list, errp);
ddf19c
+    qapi_free_BlockDirtyBitmapMergeSourceList(list);
ddf19c
+}
ddf19c
+
ddf19c
 enum ImgConvertBlockStatus {
ddf19c
     BLK_DATA,
ddf19c
     BLK_ZERO,
ddf19c
@@ -4614,21 +4632,11 @@ static int img_bitmap(int argc, char **argv)
ddf19c
             qmp_block_dirty_bitmap_disable(bs->node_name, bitmap, &err;;
ddf19c
             op = "disable";
ddf19c
             break;
ddf19c
-        case BITMAP_MERGE: {
ddf19c
-            BlockDirtyBitmapMergeSource *merge_src;
ddf19c
-            BlockDirtyBitmapMergeSourceList *list;
ddf19c
-
ddf19c
-            merge_src = g_new0(BlockDirtyBitmapMergeSource, 1);
ddf19c
-            merge_src->type = QTYPE_QDICT;
ddf19c
-            merge_src->u.external.node = g_strdup(src_bs->node_name);
ddf19c
-            merge_src->u.external.name = g_strdup(act->src);
ddf19c
-            list = g_new0(BlockDirtyBitmapMergeSourceList, 1);
ddf19c
-            list->value = merge_src;
ddf19c
-            qmp_block_dirty_bitmap_merge(bs->node_name, bitmap, list, &err;;
ddf19c
-            qapi_free_BlockDirtyBitmapMergeSourceList(list);
ddf19c
+        case BITMAP_MERGE:
ddf19c
+            do_dirty_bitmap_merge(bs->node_name, bitmap, src_bs->node_name,
ddf19c
+                                  act->src, &err;;
ddf19c
             op = "merge";
ddf19c
             break;
ddf19c
-        }
ddf19c
         default:
ddf19c
             g_assert_not_reached();
ddf19c
         }
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c