mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
migrate: Use boxed qapi for migrate-set-parameters
Now that QAPI makes it easy to pass a struct around, we don't have to declare as many parameters or local variables. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
parent
de63ab6124
commit
7f375e0446
3 changed files with 46 additions and 61 deletions
|
@ -766,78 +766,67 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
|
|||
}
|
||||
}
|
||||
|
||||
void qmp_migrate_set_parameters(bool has_compress_level,
|
||||
int64_t compress_level,
|
||||
bool has_compress_threads,
|
||||
int64_t compress_threads,
|
||||
bool has_decompress_threads,
|
||||
int64_t decompress_threads,
|
||||
bool has_cpu_throttle_initial,
|
||||
int64_t cpu_throttle_initial,
|
||||
bool has_cpu_throttle_increment,
|
||||
int64_t cpu_throttle_increment,
|
||||
bool has_tls_creds,
|
||||
const char *tls_creds,
|
||||
bool has_tls_hostname,
|
||||
const char *tls_hostname,
|
||||
Error **errp)
|
||||
void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp)
|
||||
{
|
||||
MigrationState *s = migrate_get_current();
|
||||
|
||||
if (has_compress_level && (compress_level < 0 || compress_level > 9)) {
|
||||
if (params->has_compress_level &&
|
||||
(params->compress_level < 0 || params->compress_level > 9)) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level",
|
||||
"is invalid, it should be in the range of 0 to 9");
|
||||
return;
|
||||
}
|
||||
if (has_compress_threads &&
|
||||
(compress_threads < 1 || compress_threads > 255)) {
|
||||
if (params->has_compress_threads &&
|
||||
(params->compress_threads < 1 || params->compress_threads > 255)) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
|
||||
"compress_threads",
|
||||
"is invalid, it should be in the range of 1 to 255");
|
||||
return;
|
||||
}
|
||||
if (has_decompress_threads &&
|
||||
(decompress_threads < 1 || decompress_threads > 255)) {
|
||||
if (params->has_decompress_threads &&
|
||||
(params->decompress_threads < 1 || params->decompress_threads > 255)) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
|
||||
"decompress_threads",
|
||||
"is invalid, it should be in the range of 1 to 255");
|
||||
return;
|
||||
}
|
||||
if (has_cpu_throttle_initial &&
|
||||
(cpu_throttle_initial < 1 || cpu_throttle_initial > 99)) {
|
||||
if (params->has_cpu_throttle_initial &&
|
||||
(params->cpu_throttle_initial < 1 ||
|
||||
params->cpu_throttle_initial > 99)) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
|
||||
"cpu_throttle_initial",
|
||||
"an integer in the range of 1 to 99");
|
||||
}
|
||||
if (has_cpu_throttle_increment &&
|
||||
(cpu_throttle_increment < 1 || cpu_throttle_increment > 99)) {
|
||||
if (params->has_cpu_throttle_increment &&
|
||||
(params->cpu_throttle_increment < 1 ||
|
||||
params->cpu_throttle_increment > 99)) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
|
||||
"cpu_throttle_increment",
|
||||
"an integer in the range of 1 to 99");
|
||||
}
|
||||
|
||||
if (has_compress_level) {
|
||||
s->parameters.compress_level = compress_level;
|
||||
if (params->has_compress_level) {
|
||||
s->parameters.compress_level = params->compress_level;
|
||||
}
|
||||
if (has_compress_threads) {
|
||||
s->parameters.compress_threads = compress_threads;
|
||||
if (params->has_compress_threads) {
|
||||
s->parameters.compress_threads = params->compress_threads;
|
||||
}
|
||||
if (has_decompress_threads) {
|
||||
s->parameters.decompress_threads = decompress_threads;
|
||||
if (params->has_decompress_threads) {
|
||||
s->parameters.decompress_threads = params->decompress_threads;
|
||||
}
|
||||
if (has_cpu_throttle_initial) {
|
||||
s->parameters.cpu_throttle_initial = cpu_throttle_initial;
|
||||
if (params->has_cpu_throttle_initial) {
|
||||
s->parameters.cpu_throttle_initial = params->cpu_throttle_initial;
|
||||
}
|
||||
if (has_cpu_throttle_increment) {
|
||||
s->parameters.cpu_throttle_increment = cpu_throttle_increment;
|
||||
if (params->has_cpu_throttle_increment) {
|
||||
s->parameters.cpu_throttle_increment = params->cpu_throttle_increment;
|
||||
}
|
||||
if (has_tls_creds) {
|
||||
if (params->has_tls_creds) {
|
||||
g_free(s->parameters.tls_creds);
|
||||
s->parameters.tls_creds = g_strdup(tls_creds);
|
||||
s->parameters.tls_creds = g_strdup(params->tls_creds);
|
||||
}
|
||||
if (has_tls_hostname) {
|
||||
if (params->has_tls_hostname) {
|
||||
g_free(s->parameters.tls_hostname);
|
||||
s->parameters.tls_hostname = g_strdup(tls_hostname);
|
||||
s->parameters.tls_hostname = g_strdup(params->tls_hostname);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue