yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-blockdev-Promote-several-bitmap-functions-to-non-sta.patch

902636
From 0c8ba0a96a7d0cbf371f1a5fbee543e8b2cb2595 Mon Sep 17 00:00:00 2001
902636
From: Eric Blake <eblake@redhat.com>
902636
Date: Tue, 2 Jun 2020 02:34:13 +0100
902636
Subject: [PATCH 08/26] blockdev: Promote several bitmap functions to
902636
 non-static
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-6-eblake@redhat.com>
902636
Patchwork-id: 97077
902636
O-Subject: [RHEL-AV-8.2.1 qemu-kvm PATCH 05/12] blockdev: Promote several bitmap functions to non-static
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 split blockdev.c, which will require accessing
902636
some previously-static functions from more than one .c file.  But part
902636
of promoting a function to public is picking a naming scheme that does
902636
not reek of exposing too many internals (two of the three functions
902636
were named starting with 'do_').  To make future code motion easier,
902636
perform the function rename and non-static promotion into its own
902636
patch.
902636
902636
Signed-off-by: Eric Blake <eblake@redhat.com>
902636
Reviewed-by: Max Reitz <mreitz@redhat.com>
902636
Message-Id: <20200513011648.166876-5-eblake@redhat.com>
902636
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
902636
(cherry picked from commit c6996cf9a6c759c29919642be9a73ac64b38301b)
902636
Signed-off-by: Eric Blake <eblake@redhat.com>
902636
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
902636
---
902636
 blockdev.c                | 47 +++++++++++++++++++----------------------------
902636
 include/block/block_int.h | 12 ++++++++++++
902636
 2 files changed, 31 insertions(+), 28 deletions(-)
902636
902636
diff --git a/blockdev.c b/blockdev.c
902636
index 86eb115..3958058 100644
902636
--- a/blockdev.c
902636
+++ b/blockdev.c
902636
@@ -1262,10 +1262,10 @@ out_aio_context:
902636
  *
902636
  * @return: A bitmap object on success, or NULL on failure.
902636
  */
902636
-static BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *node,
902636
-                                                  const char *name,
902636
-                                                  BlockDriverState **pbs,
902636
-                                                  Error **errp)
902636
+BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *node,
902636
+                                           const char *name,
902636
+                                           BlockDriverState **pbs,
902636
+                                           Error **errp)
902636
 {
902636
     BlockDriverState *bs;
902636
     BdrvDirtyBitmap *bitmap;
902636
@@ -2241,11 +2241,6 @@ static void block_dirty_bitmap_disable_abort(BlkActionState *common)
902636
     }
902636
 }
902636
 
902636
-static BdrvDirtyBitmap *do_block_dirty_bitmap_merge(
902636
-        const char *node, const char *target,
902636
-        BlockDirtyBitmapMergeSourceList *bitmaps,
902636
-        HBitmap **backup, Error **errp);
902636
-
902636
 static void block_dirty_bitmap_merge_prepare(BlkActionState *common,
902636
                                              Error **errp)
902636
 {
902636
@@ -2259,15 +2254,11 @@ static void block_dirty_bitmap_merge_prepare(BlkActionState *common,
902636
 
902636
     action = common->action->u.block_dirty_bitmap_merge.data;
902636
 
902636
-    state->bitmap = do_block_dirty_bitmap_merge(action->node, action->target,
902636
-                                                action->bitmaps, &state->backup,
902636
-                                                errp);
902636
+    state->bitmap = block_dirty_bitmap_merge(action->node, action->target,
902636
+                                             action->bitmaps, &state->backup,
902636
+                                             errp);
902636
 }
902636
 
902636
-static BdrvDirtyBitmap *do_block_dirty_bitmap_remove(
902636
-        const char *node, const char *name, bool release,
902636
-        BlockDriverState **bitmap_bs, Error **errp);
902636
-
902636
 static void block_dirty_bitmap_remove_prepare(BlkActionState *common,
902636
                                               Error **errp)
902636
 {
902636
@@ -2281,8 +2272,8 @@ static void block_dirty_bitmap_remove_prepare(BlkActionState *common,
902636
 
902636
     action = common->action->u.block_dirty_bitmap_remove.data;
902636
 
902636
-    state->bitmap = do_block_dirty_bitmap_remove(action->node, action->name,
902636
-                                                 false, &state->bs, errp);
902636
+    state->bitmap = block_dirty_bitmap_remove(action->node, action->name,
902636
+                                              false, &state->bs, errp);
902636
     if (state->bitmap) {
902636
         bdrv_dirty_bitmap_skip_store(state->bitmap, true);
902636
         bdrv_dirty_bitmap_set_busy(state->bitmap, true);
902636
@@ -3046,9 +3037,10 @@ out:
902636
     aio_context_release(aio_context);
902636
 }
902636
 
902636
-static BdrvDirtyBitmap *do_block_dirty_bitmap_remove(
902636
-        const char *node, const char *name, bool release,
902636
-        BlockDriverState **bitmap_bs, Error **errp)
902636
+BdrvDirtyBitmap *block_dirty_bitmap_remove(const char *node, const char *name,
902636
+                                           bool release,
902636
+                                           BlockDriverState **bitmap_bs,
902636
+                                           Error **errp)
902636
 {
902636
     BlockDriverState *bs;
902636
     BdrvDirtyBitmap *bitmap;
902636
@@ -3090,7 +3082,7 @@ static BdrvDirtyBitmap *do_block_dirty_bitmap_remove(
902636
 void qmp_block_dirty_bitmap_remove(const char *node, const char *name,
902636
                                    Error **errp)
902636
 {
902636
-    do_block_dirty_bitmap_remove(node, name, true, NULL, errp);
902636
+    block_dirty_bitmap_remove(node, name, true, NULL, errp);
902636
 }
902636
 
902636
 /**
902636
@@ -3151,10 +3143,9 @@ void qmp_block_dirty_bitmap_disable(const char *node, const char *name,
902636
     bdrv_disable_dirty_bitmap(bitmap);
902636
 }
902636
 
902636
-static BdrvDirtyBitmap *do_block_dirty_bitmap_merge(
902636
-        const char *node, const char *target,
902636
-        BlockDirtyBitmapMergeSourceList *bitmaps,
902636
-        HBitmap **backup, Error **errp)
902636
+BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *target,
902636
+                                          BlockDirtyBitmapMergeSourceList *bms,
902636
+                                          HBitmap **backup, Error **errp)
902636
 {
902636
     BlockDriverState *bs;
902636
     BdrvDirtyBitmap *dst, *src, *anon;
902636
@@ -3172,7 +3163,7 @@ static BdrvDirtyBitmap *do_block_dirty_bitmap_merge(
902636
         return NULL;
902636
     }
902636
 
902636
-    for (lst = bitmaps; lst; lst = lst->next) {
902636
+    for (lst = bms; lst; lst = lst->next) {
902636
         switch (lst->value->type) {
902636
             const char *name, *node;
902636
         case QTYPE_QSTRING:
902636
@@ -3217,7 +3208,7 @@ void qmp_block_dirty_bitmap_merge(const char *node, const char *target,
902636
                                   BlockDirtyBitmapMergeSourceList *bitmaps,
902636
                                   Error **errp)
902636
 {
902636
-    do_block_dirty_bitmap_merge(node, target, bitmaps, NULL, errp);
902636
+    block_dirty_bitmap_merge(node, target, bitmaps, NULL, errp);
902636
 }
902636
 
902636
 BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *node,
902636
diff --git a/include/block/block_int.h b/include/block/block_int.h
902636
index cc18e8d..876a83d 100644
902636
--- a/include/block/block_int.h
902636
+++ b/include/block/block_int.h
902636
@@ -1341,4 +1341,16 @@ int coroutine_fn bdrv_co_create_opts_simple(BlockDriver *drv,
902636
                                             Error **errp);
902636
 extern QemuOptsList bdrv_create_opts_simple;
902636
 
902636
+BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *node,
902636
+                                           const char *name,
902636
+                                           BlockDriverState **pbs,
902636
+                                           Error **errp);
902636
+BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *target,
902636
+                                          BlockDirtyBitmapMergeSourceList *bms,
902636
+                                          HBitmap **backup, Error **errp);
902636
+BdrvDirtyBitmap *block_dirty_bitmap_remove(const char *node, const char *name,
902636
+                                           bool release,
902636
+                                           BlockDriverState **bitmap_bs,
902636
+                                           Error **errp);
902636
+
902636
 #endif /* BLOCK_INT_H */
902636
-- 
902636
1.8.3.1
902636