mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
migration: Unshare MigrationParameters struct for now
Commitde63ab6
"migrate: Share common MigrationParameters struct" reused MigrationParameters for the arguments of migrate-set-parameters, with the following rationale: It is rather verbose, and slightly error-prone, to repeat the same set of parameters for input (migrate-set-parameters) as for output (query-migrate-parameters), where the only difference is whether the members are optional. We can just document that the optional members will always be present on output, and then share a common struct between both commands. The next patch can then reduce the amount of code needed on input. I need to unshare them to correct a design flaw in a stupid, but minimally invasive way, in the next commit. We can restore the sharing when we redo that patch in a less stupid way. Add a suitable TODO comment. Note that I revert only the sharing part of commitde63ab6
, not the part that made the members of query-migrate-parameters' result optional. The schema (and thus introspection) remains inaccurate for query-migrate-parameters. If we decide not to restore the sharing, we should revert that part, too. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
e87fae4c48
commit
1bda8b3c69
3 changed files with 140 additions and 15 deletions
|
@ -742,7 +742,59 @@ static bool migrate_params_check(MigrationParameters *params, Error **errp)
|
|||
return true;
|
||||
}
|
||||
|
||||
static void migrate_params_apply(MigrationParameters *params)
|
||||
static void migrate_params_test_apply(MigrateSetParameters *params,
|
||||
MigrationParameters *dest)
|
||||
{
|
||||
*dest = migrate_get_current()->parameters;
|
||||
|
||||
/* TODO use QAPI_CLONE() instead of duplicating it inline */
|
||||
|
||||
if (params->has_compress_level) {
|
||||
dest->compress_level = params->compress_level;
|
||||
}
|
||||
|
||||
if (params->has_compress_threads) {
|
||||
dest->compress_threads = params->compress_threads;
|
||||
}
|
||||
|
||||
if (params->has_decompress_threads) {
|
||||
dest->decompress_threads = params->decompress_threads;
|
||||
}
|
||||
|
||||
if (params->has_cpu_throttle_initial) {
|
||||
dest->cpu_throttle_initial = params->cpu_throttle_initial;
|
||||
}
|
||||
|
||||
if (params->has_cpu_throttle_increment) {
|
||||
dest->cpu_throttle_increment = params->cpu_throttle_increment;
|
||||
}
|
||||
|
||||
if (params->has_tls_creds) {
|
||||
dest->tls_creds = g_strdup(params->tls_creds);
|
||||
}
|
||||
|
||||
if (params->has_tls_hostname) {
|
||||
dest->tls_hostname = g_strdup(params->tls_hostname);
|
||||
}
|
||||
|
||||
if (params->has_max_bandwidth) {
|
||||
dest->max_bandwidth = params->max_bandwidth;
|
||||
}
|
||||
|
||||
if (params->has_downtime_limit) {
|
||||
dest->downtime_limit = params->downtime_limit;
|
||||
}
|
||||
|
||||
if (params->has_x_checkpoint_delay) {
|
||||
dest->x_checkpoint_delay = params->x_checkpoint_delay;
|
||||
}
|
||||
|
||||
if (params->has_block_incremental) {
|
||||
dest->block_incremental = params->block_incremental;
|
||||
}
|
||||
}
|
||||
|
||||
static void migrate_params_apply(MigrateSetParameters *params)
|
||||
{
|
||||
MigrationState *s = migrate_get_current();
|
||||
|
||||
|
@ -802,9 +854,13 @@ static void migrate_params_apply(MigrationParameters *params)
|
|||
}
|
||||
}
|
||||
|
||||
void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp)
|
||||
void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp)
|
||||
{
|
||||
if (!migrate_params_check(params, errp)) {
|
||||
MigrationParameters tmp;
|
||||
|
||||
migrate_params_test_apply(params, &tmp);
|
||||
|
||||
if (!migrate_params_check(&tmp, errp)) {
|
||||
/* Invalid parameter */
|
||||
return;
|
||||
}
|
||||
|
@ -1240,7 +1296,7 @@ int64_t qmp_query_migrate_cache_size(Error **errp)
|
|||
|
||||
void qmp_migrate_set_speed(int64_t value, Error **errp)
|
||||
{
|
||||
MigrationParameters p = {
|
||||
MigrateSetParameters p = {
|
||||
.has_max_bandwidth = true,
|
||||
.max_bandwidth = value,
|
||||
};
|
||||
|
@ -1260,7 +1316,7 @@ void qmp_migrate_set_downtime(double value, Error **errp)
|
|||
value *= 1000; /* Convert to milliseconds */
|
||||
value = MAX(0, MIN(INT64_MAX, value));
|
||||
|
||||
MigrationParameters p = {
|
||||
MigrateSetParameters p = {
|
||||
.has_downtime_limit = true,
|
||||
.downtime_limit = value,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue