mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
migration: Add block-bitmap-mapping parameter
This migration parameter allows mapping block node names and bitmap names to aliases for the purpose of block dirty bitmap migration. This way, management tools can use different node and bitmap names on the source and destination and pass the mapping of how bitmaps are to be transferred to qemu (on the source, the destination, or even both with arbitrary aliases in the migration stream). While touching this code, fix a bug where bitmap names longer than 255 bytes would fail an assertion in qemu_put_counted_string(). Suggested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Signed-off-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200820150725.68687-2-mreitz@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
+359
-55
File diff suppressed because it is too large
Load Diff
@@ -36,6 +36,7 @@
|
||||
#include "block/block.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/clone-visitor.h"
|
||||
#include "qapi/qapi-visit-migration.h"
|
||||
#include "qapi/qapi-visit-sockets.h"
|
||||
#include "qapi/qapi-commands-migration.h"
|
||||
#include "qapi/qapi-events-migration.h"
|
||||
@@ -843,6 +844,13 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp)
|
||||
params->has_announce_step = true;
|
||||
params->announce_step = s->parameters.announce_step;
|
||||
|
||||
if (s->parameters.has_block_bitmap_mapping) {
|
||||
params->has_block_bitmap_mapping = true;
|
||||
params->block_bitmap_mapping =
|
||||
QAPI_CLONE(BitmapMigrationNodeAliasList,
|
||||
s->parameters.block_bitmap_mapping);
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
@@ -1308,6 +1316,13 @@ static bool migrate_params_check(MigrationParameters *params, Error **errp)
|
||||
"is invalid, it must be in the range of 1 to 10000 ms");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (params->has_block_bitmap_mapping &&
|
||||
!check_dirty_bitmap_mig_alias_map(params->block_bitmap_mapping, errp)) {
|
||||
error_prepend(errp, "Invalid mapping given for block-bitmap-mapping: ");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1402,6 +1417,11 @@ static void migrate_params_test_apply(MigrateSetParameters *params,
|
||||
if (params->has_announce_step) {
|
||||
dest->announce_step = params->announce_step;
|
||||
}
|
||||
|
||||
if (params->has_block_bitmap_mapping) {
|
||||
dest->has_block_bitmap_mapping = true;
|
||||
dest->block_bitmap_mapping = params->block_bitmap_mapping;
|
||||
}
|
||||
}
|
||||
|
||||
static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
|
||||
@@ -1514,6 +1534,16 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
|
||||
if (params->has_announce_step) {
|
||||
s->parameters.announce_step = params->announce_step;
|
||||
}
|
||||
|
||||
if (params->has_block_bitmap_mapping) {
|
||||
qapi_free_BitmapMigrationNodeAliasList(
|
||||
s->parameters.block_bitmap_mapping);
|
||||
|
||||
s->parameters.has_block_bitmap_mapping = true;
|
||||
s->parameters.block_bitmap_mapping =
|
||||
QAPI_CLONE(BitmapMigrationNodeAliasList,
|
||||
params->block_bitmap_mapping);
|
||||
}
|
||||
}
|
||||
|
||||
void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp)
|
||||
|
||||
@@ -337,6 +337,9 @@ void migrate_send_rp_resume_ack(MigrationIncomingState *mis, uint32_t value);
|
||||
void dirty_bitmap_mig_before_vm_start(void);
|
||||
void dirty_bitmap_mig_cancel_outgoing(void);
|
||||
void dirty_bitmap_mig_cancel_incoming(void);
|
||||
bool check_dirty_bitmap_mig_alias_map(const BitmapMigrationNodeAliasList *bbm,
|
||||
Error **errp);
|
||||
|
||||
void migrate_add_address(SocketAddress *address);
|
||||
|
||||
int foreach_not_ignored_block(RAMBlockIterFunc func, void *opaque);
|
||||
|
||||
@@ -469,6 +469,32 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
|
||||
monitor_printf(mon, "%s: '%s'\n",
|
||||
MigrationParameter_str(MIGRATION_PARAMETER_TLS_AUTHZ),
|
||||
params->tls_authz);
|
||||
|
||||
if (params->has_block_bitmap_mapping) {
|
||||
const BitmapMigrationNodeAliasList *bmnal;
|
||||
|
||||
monitor_printf(mon, "%s:\n",
|
||||
MigrationParameter_str(
|
||||
MIGRATION_PARAMETER_BLOCK_BITMAP_MAPPING));
|
||||
|
||||
for (bmnal = params->block_bitmap_mapping;
|
||||
bmnal;
|
||||
bmnal = bmnal->next)
|
||||
{
|
||||
const BitmapMigrationNodeAlias *bmna = bmnal->value;
|
||||
const BitmapMigrationBitmapAliasList *bmbal;
|
||||
|
||||
monitor_printf(mon, " '%s' -> '%s'\n",
|
||||
bmna->node_name, bmna->alias);
|
||||
|
||||
for (bmbal = bmna->bitmaps; bmbal; bmbal = bmbal->next) {
|
||||
const BitmapMigrationBitmapAlias *bmba = bmbal->value;
|
||||
|
||||
monitor_printf(mon, " '%s' -> '%s'\n",
|
||||
bmba->name, bmba->alias);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qapi_free_MigrationParameters(params);
|
||||
@@ -1384,6 +1410,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
|
||||
p->has_announce_step = true;
|
||||
visit_type_size(v, param, &p->announce_step, &err);
|
||||
break;
|
||||
case MIGRATION_PARAMETER_BLOCK_BITMAP_MAPPING:
|
||||
error_setg(&err, "The block-bitmap-mapping parameter can only be set "
|
||||
"through QMP");
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
+101
-3
@@ -508,6 +508,44 @@
|
||||
'data': [ 'none', 'zlib',
|
||||
{ 'name': 'zstd', 'if': 'defined(CONFIG_ZSTD)' } ] }
|
||||
|
||||
##
|
||||
# @BitmapMigrationBitmapAlias:
|
||||
#
|
||||
# @name: The name of the bitmap.
|
||||
#
|
||||
# @alias: An alias name for migration (for example the bitmap name on
|
||||
# the opposite site).
|
||||
#
|
||||
# Since: 5.2
|
||||
##
|
||||
{ 'struct': 'BitmapMigrationBitmapAlias',
|
||||
'data': {
|
||||
'name': 'str',
|
||||
'alias': 'str'
|
||||
} }
|
||||
|
||||
##
|
||||
# @BitmapMigrationNodeAlias:
|
||||
#
|
||||
# Maps a block node name and the bitmaps it has to aliases for dirty
|
||||
# bitmap migration.
|
||||
#
|
||||
# @node-name: A block node name.
|
||||
#
|
||||
# @alias: An alias block node name for migration (for example the
|
||||
# node name on the opposite site).
|
||||
#
|
||||
# @bitmaps: Mappings for the bitmaps on this node.
|
||||
#
|
||||
# Since: 5.2
|
||||
##
|
||||
{ 'struct': 'BitmapMigrationNodeAlias',
|
||||
'data': {
|
||||
'node-name': 'str',
|
||||
'alias': 'str',
|
||||
'bitmaps': [ 'BitmapMigrationBitmapAlias' ]
|
||||
} }
|
||||
|
||||
##
|
||||
# @MigrationParameter:
|
||||
#
|
||||
@@ -642,6 +680,25 @@
|
||||
# will consume more CPU.
|
||||
# Defaults to 1. (Since 5.0)
|
||||
#
|
||||
# @block-bitmap-mapping: Maps block nodes and bitmaps on them to
|
||||
# aliases for the purpose of dirty bitmap migration. Such
|
||||
# aliases may for example be the corresponding names on the
|
||||
# opposite site.
|
||||
# The mapping must be one-to-one, but not necessarily
|
||||
# complete: On the source, unmapped bitmaps and all bitmaps
|
||||
# on unmapped nodes will be ignored. On the destination,
|
||||
# encountering an unmapped alias in the incoming migration
|
||||
# stream will result in a report, and all further bitmap
|
||||
# migration data will then be discarded.
|
||||
# Note that the destination does not know about bitmaps it
|
||||
# does not receive, so there is no limitation or requirement
|
||||
# regarding the number of bitmaps received, or how they are
|
||||
# named, or on which nodes they are placed.
|
||||
# By default (when this parameter has never been set), bitmap
|
||||
# names are mapped to themselves. Nodes are mapped to their
|
||||
# block device name if there is one, and to their node name
|
||||
# otherwise. (Since 5.2)
|
||||
#
|
||||
# Since: 2.4
|
||||
##
|
||||
{ 'enum': 'MigrationParameter',
|
||||
@@ -656,7 +713,8 @@
|
||||
'multifd-channels',
|
||||
'xbzrle-cache-size', 'max-postcopy-bandwidth',
|
||||
'max-cpu-throttle', 'multifd-compression',
|
||||
'multifd-zlib-level' ,'multifd-zstd-level' ] }
|
||||
'multifd-zlib-level' ,'multifd-zstd-level',
|
||||
'block-bitmap-mapping' ] }
|
||||
|
||||
##
|
||||
# @MigrateSetParameters:
|
||||
@@ -782,6 +840,25 @@
|
||||
# will consume more CPU.
|
||||
# Defaults to 1. (Since 5.0)
|
||||
#
|
||||
# @block-bitmap-mapping: Maps block nodes and bitmaps on them to
|
||||
# aliases for the purpose of dirty bitmap migration. Such
|
||||
# aliases may for example be the corresponding names on the
|
||||
# opposite site.
|
||||
# The mapping must be one-to-one, but not necessarily
|
||||
# complete: On the source, unmapped bitmaps and all bitmaps
|
||||
# on unmapped nodes will be ignored. On the destination,
|
||||
# encountering an unmapped alias in the incoming migration
|
||||
# stream will result in a report, and all further bitmap
|
||||
# migration data will then be discarded.
|
||||
# Note that the destination does not know about bitmaps it
|
||||
# does not receive, so there is no limitation or requirement
|
||||
# regarding the number of bitmaps received, or how they are
|
||||
# named, or on which nodes they are placed.
|
||||
# By default (when this parameter has never been set), bitmap
|
||||
# names are mapped to themselves. Nodes are mapped to their
|
||||
# block device name if there is one, and to their node name
|
||||
# otherwise. (Since 5.2)
|
||||
#
|
||||
# Since: 2.4
|
||||
##
|
||||
# TODO either fuse back into MigrationParameters, or make
|
||||
@@ -812,7 +889,8 @@
|
||||
'*max-cpu-throttle': 'int',
|
||||
'*multifd-compression': 'MultiFDCompression',
|
||||
'*multifd-zlib-level': 'int',
|
||||
'*multifd-zstd-level': 'int' } }
|
||||
'*multifd-zstd-level': 'int',
|
||||
'*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ] } }
|
||||
|
||||
##
|
||||
# @migrate-set-parameters:
|
||||
@@ -958,6 +1036,25 @@
|
||||
# will consume more CPU.
|
||||
# Defaults to 1. (Since 5.0)
|
||||
#
|
||||
# @block-bitmap-mapping: Maps block nodes and bitmaps on them to
|
||||
# aliases for the purpose of dirty bitmap migration. Such
|
||||
# aliases may for example be the corresponding names on the
|
||||
# opposite site.
|
||||
# The mapping must be one-to-one, but not necessarily
|
||||
# complete: On the source, unmapped bitmaps and all bitmaps
|
||||
# on unmapped nodes will be ignored. On the destination,
|
||||
# encountering an unmapped alias in the incoming migration
|
||||
# stream will result in a report, and all further bitmap
|
||||
# migration data will then be discarded.
|
||||
# Note that the destination does not know about bitmaps it
|
||||
# does not receive, so there is no limitation or requirement
|
||||
# regarding the number of bitmaps received, or how they are
|
||||
# named, or on which nodes they are placed.
|
||||
# By default (when this parameter has never been set), bitmap
|
||||
# names are mapped to themselves. Nodes are mapped to their
|
||||
# block device name if there is one, and to their node name
|
||||
# otherwise. (Since 5.2)
|
||||
#
|
||||
# Since: 2.4
|
||||
##
|
||||
{ 'struct': 'MigrationParameters',
|
||||
@@ -986,7 +1083,8 @@
|
||||
'*max-cpu-throttle': 'uint8',
|
||||
'*multifd-compression': 'MultiFDCompression',
|
||||
'*multifd-zlib-level': 'uint8',
|
||||
'*multifd-zstd-level': 'uint8' } }
|
||||
'*multifd-zstd-level': 'uint8',
|
||||
'*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ] } }
|
||||
|
||||
##
|
||||
# @query-migrate-parameters:
|
||||
|
||||
Reference in New Issue
Block a user