thebeanogamer / rpms / qemu-kvm

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