[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 1/5] migration: dirty-bitmap: Use struct for alias map inner membe
From: |
Eric Blake |
Subject: |
[PULL 1/5] migration: dirty-bitmap: Use struct for alias map inner members |
Date: |
Fri, 12 Feb 2021 17:21:30 -0600 |
From: Peter Krempa <pkrempa@redhat.com>
Currently the alias mapping hash stores just strings of the target
objects internally. In further patches we'll be adding another member
which will need to be stored in the map so pass a copy of the whole
BitmapMigrationBitmapAlias QAPI struct into the map.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Message-Id:
<fc5f27e1fe16cb75e08a248c2d938de3997b9bfb.1613150869.git.pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[eblake: adjust long lines]
Signed-off-by: Eric Blake <eblake@redhat.com>
---
migration/block-dirty-bitmap.c | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
index c61d382be87c..b39c13ce4ebe 100644
--- a/migration/block-dirty-bitmap.c
+++ b/migration/block-dirty-bitmap.c
@@ -75,6 +75,8 @@
#include "qemu/id.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-migration.h"
+#include "qapi/qapi-visit-migration.h"
+#include "qapi/clone-visitor.h"
#include "trace.h"
#define CHUNK_SIZE (1 << 10)
@@ -224,6 +226,7 @@ static GHashTable *construct_alias_map(const
BitmapMigrationNodeAliasList *bbm,
AliasMapInnerNode *amin;
GHashTable *bitmaps_map;
const char *node_map_from, *node_map_to;
+ GDestroyNotify gdn;
if (!id_wellformed(bmna->alias)) {
error_setg(errp, "The node alias '%s' is not well-formed",
@@ -263,8 +266,9 @@ static GHashTable *construct_alias_map(const
BitmapMigrationNodeAliasList *bbm,
node_map_to = bmna->node_name;
}
- bitmaps_map = g_hash_table_new_full(g_str_hash, g_str_equal,
- g_free, g_free);
+ gdn = (GDestroyNotify) qapi_free_BitmapMigrationBitmapAlias;
+ bitmaps_map = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
+ gdn);
amin = g_new(AliasMapInnerNode, 1);
*amin = (AliasMapInnerNode){
@@ -276,7 +280,7 @@ static GHashTable *construct_alias_map(const
BitmapMigrationNodeAliasList *bbm,
for (bmbal = bmna->bitmaps; bmbal; bmbal = bmbal->next) {
const BitmapMigrationBitmapAlias *bmba = bmbal->value;
- const char *bmap_map_from, *bmap_map_to;
+ const char *bmap_map_from;
if (strlen(bmba->alias) > UINT8_MAX) {
error_setg(errp,
@@ -293,7 +297,6 @@ static GHashTable *construct_alias_map(const
BitmapMigrationNodeAliasList *bbm,
if (name_to_alias) {
bmap_map_from = bmba->name;
- bmap_map_to = bmba->alias;
if (g_hash_table_contains(bitmaps_map, bmba->name)) {
error_setg(errp, "The bitmap '%s'/'%s' is mapped twice",
@@ -302,7 +305,6 @@ static GHashTable *construct_alias_map(const
BitmapMigrationNodeAliasList *bbm,
}
} else {
bmap_map_from = bmba->alias;
- bmap_map_to = bmba->name;
if (g_hash_table_contains(bitmaps_map, bmba->alias)) {
error_setg(errp, "The bitmap alias '%s'/'%s' is used
twice",
@@ -311,8 +313,8 @@ static GHashTable *construct_alias_map(const
BitmapMigrationNodeAliasList *bbm,
}
}
- g_hash_table_insert(bitmaps_map,
- g_strdup(bmap_map_from),
g_strdup(bmap_map_to));
+ g_hash_table_insert(bitmaps_map, g_strdup(bmap_map_from),
+ QAPI_CLONE(BitmapMigrationBitmapAlias, bmba));
}
}
@@ -538,11 +540,15 @@ static int add_bitmaps_to_list(DBMSaveState *s,
BlockDriverState *bs,
}
if (bitmap_aliases) {
- bitmap_alias = g_hash_table_lookup(bitmap_aliases, bitmap_name);
- if (!bitmap_alias) {
+ BitmapMigrationBitmapAlias *bmap_inner;
+
+ bmap_inner = g_hash_table_lookup(bitmap_aliases, bitmap_name);
+ if (!bmap_inner) {
/* Skip bitmaps with no alias */
continue;
}
+
+ bitmap_alias = bmap_inner->alias;
} else {
if (strlen(bitmap_name) > UINT8_MAX) {
error_report("Cannot migrate bitmap '%s' on node '%s': "
@@ -1074,13 +1080,16 @@ static int dirty_bitmap_load_header(QEMUFile *f,
DBMLoadState *s,
bitmap_name = s->bitmap_alias;
if (!s->cancelled && bitmap_alias_map) {
- bitmap_name = g_hash_table_lookup(bitmap_alias_map,
- s->bitmap_alias);
- if (!bitmap_name) {
+ BitmapMigrationBitmapAlias *bmap_inner;
+
+ bmap_inner = g_hash_table_lookup(bitmap_alias_map,
s->bitmap_alias);
+ if (!bmap_inner) {
error_report("Error: Unknown bitmap alias '%s' on node "
"'%s' (alias '%s')", s->bitmap_alias,
s->bs->node_name, s->node_alias);
cancel_incoming_locked(s);
+ } else {
+ bitmap_name = bmap_inner->name;
}
}
--
2.30.1
- [PULL 0/5] bitmaps patches through 2021-02-12, Eric Blake, 2021/02/12
- [PULL 1/5] migration: dirty-bitmap: Use struct for alias map inner members,
Eric Blake <=
- [PULL 3/5] qemu-iotests: 300: Add test case for modifying persistence of bitmap, Eric Blake, 2021/02/12
- Re: [PULL 3/5] qemu-iotests: 300: Add test case for modifying persistence of bitmap, Kevin Wolf, 2021/02/15
- Re: [PULL 3/5] qemu-iotests: 300: Add test case for modifying persistence of bitmap, Eric Blake, 2021/02/15
- Re: [PULL 3/5] qemu-iotests: 300: Add test case for modifying persistence of bitmap, Kevin Wolf, 2021/02/15
- Re: [PULL 3/5] qemu-iotests: 300: Add test case for modifying persistence of bitmap, Eric Blake, 2021/02/15
- Re: [PULL 3/5] qemu-iotests: 300: Add test case for modifying persistence of bitmap, John Snow, 2021/02/15
- Re: [PULL 3/5] qemu-iotests: 300: Add test case for modifying persistence of bitmap, Eric Blake, 2021/02/15
- Re: [PULL 3/5] qemu-iotests: 300: Add test case for modifying persistence of bitmap, John Snow, 2021/02/15
[PULL 4/5] block: return status from bdrv_append and friends, Eric Blake, 2021/02/12
[PULL 5/5] block: use return status of bdrv_append(), Eric Blake, 2021/02/12