From: Peter Krempa <pkrempa@redhat.com>
To: qemu-devel@nongnu.org
Cc: John Snow <jsnow@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
Markus Armbruster <armbru@redhat.com>,
qemu-block@nongnu.org
Subject: [PATCH 1/2] migration: dirty-bitmap: Convert alias map inner members to a struct
Date: Wed, 3 Feb 2021 13:59:59 +0100 [thread overview]
Message-ID: <8e40a7337e3b9a0a4f11ee3b0e2f3ae4c76f2dbd.1612356810.git.pkrempa@redhat.com> (raw)
In-Reply-To: <cover.1612356810.git.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 convert the members to a
struct.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
migration/block-dirty-bitmap.c | 37 ++++++++++++++++++++++++++++------
1 file changed, 31 insertions(+), 6 deletions(-)
diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
index c61d382be8..b0403dd00c 100644
--- a/migration/block-dirty-bitmap.c
+++ b/migration/block-dirty-bitmap.c
@@ -169,6 +169,18 @@ typedef struct DBMState {
static DBMState dbm_state;
+typedef struct AliasMapInnerBitmap {
+ char *string;
+} AliasMapInnerBitmap;
+
+static void free_alias_map_inner_bitmap(void *amin_ptr)
+{
+ AliasMapInnerBitmap *amin = amin_ptr;
+
+ g_free(amin->string);
+ g_free(amin);
+}
+
/* For hash tables that map node/bitmap names to aliases */
typedef struct AliasMapInnerNode {
char *string;
@@ -264,7 +276,7 @@ static GHashTable *construct_alias_map(const BitmapMigrationNodeAliasList *bbm,
}
bitmaps_map = g_hash_table_new_full(g_str_hash, g_str_equal,
- g_free, g_free);
+ g_free, free_alias_map_inner_bitmap);
amin = g_new(AliasMapInnerNode, 1);
*amin = (AliasMapInnerNode){
@@ -277,6 +289,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;
+ AliasMapInnerBitmap *bmap_inner;
if (strlen(bmba->alias) > UINT8_MAX) {
error_setg(errp,
@@ -311,8 +324,11 @@ static GHashTable *construct_alias_map(const BitmapMigrationNodeAliasList *bbm,
}
}
+ bmap_inner = g_new0(AliasMapInnerBitmap, 1);
+ bmap_inner->string = g_strdup(bmap_map_to);
+
g_hash_table_insert(bitmaps_map,
- g_strdup(bmap_map_from), g_strdup(bmap_map_to));
+ g_strdup(bmap_map_from), bmap_inner);
}
}
@@ -538,11 +554,16 @@ 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) {
+ AliasMapInnerBitmap *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->string;
} else {
if (strlen(bitmap_name) > UINT8_MAX) {
error_report("Cannot migrate bitmap '%s' on node '%s': "
@@ -1074,14 +1095,18 @@ 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,
+ AliasMapInnerBitmap *bmap_inner;
+
+ bmap_inner = g_hash_table_lookup(bitmap_alias_map,
s->bitmap_alias);
- if (!bitmap_name) {
+ 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);
}
+
+ bitmap_name = bmap_inner->string;
}
if (!s->cancelled) {
--
2.29.2
next prev parent reply other threads:[~2021-02-03 13:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-03 12:59 [PATCH 0/2] migration: dirty-bitmap: Allow control of bitmap persistence on destination Peter Krempa
2021-02-03 12:59 ` Peter Krempa [this message]
2021-02-04 19:12 ` [PATCH 1/2] migration: dirty-bitmap: Convert alias map inner members to a struct Eric Blake
2021-02-05 7:04 ` Vladimir Sementsov-Ogievskiy
2021-02-03 13:00 ` [PATCH 2/2] migration: dirty-bitmap: Allow control of bitmap persistence on destination Peter Krempa
2021-02-03 13:23 ` Vladimir Sementsov-Ogievskiy
2021-02-03 13:27 ` Peter Krempa
2021-02-03 13:39 ` Peter Krempa
2021-02-03 14:14 ` Vladimir Sementsov-Ogievskiy
2021-02-04 19:15 ` Eric Blake
2021-02-05 8:01 ` Vladimir Sementsov-Ogievskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8e40a7337e3b9a0a4f11ee3b0e2f3ae4c76f2dbd.1612356810.git.pkrempa@redhat.com \
--to=pkrempa@redhat.com \
--cc=armbru@redhat.com \
--cc=jsnow@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).