[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 10/16] migration: introduce migrate_params_check()
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PULL 10/16] migration: introduce migrate_params_check() |
Date: |
Tue, 18 Jul 2017 17:41:21 +0200 |
From: Peter Xu <address@hidden>
Helper to check the parameters. Abstracted from
qmp_migrate_set_parameters().
Reviewed-by: Juan Quintela <address@hidden>
Signed-off-by: Peter Xu <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Juan Quintela <address@hidden>
---
migration/migration.c | 42 ++++++++++++++++++++++++++++++++----------
1 file changed, 32 insertions(+), 10 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index 16f5d9a..02d6987 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -644,64 +644,86 @@ void
qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
}
}
-void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp)
+/*
+ * Check whether the parameters are valid. Error will be put into errp
+ * (if provided). Return true if valid, otherwise false.
+ */
+static bool migrate_params_check(MigrationParameters *params, Error **errp)
{
- MigrationState *s = migrate_get_current();
-
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;
+ return false;
}
+
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;
+ return false;
}
+
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;
+ return false;
}
+
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");
- return;
+ return false;
}
+
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");
- return;
+ return false;
}
+
if (params->has_max_bandwidth &&
(params->max_bandwidth < 0 || params->max_bandwidth > SIZE_MAX)) {
error_setg(errp, "Parameter 'max_bandwidth' expects an integer in the"
" range of 0 to %zu bytes/second", SIZE_MAX);
- return;
+ return false;
}
+
if (params->has_downtime_limit &&
(params->downtime_limit < 0 ||
params->downtime_limit > MAX_MIGRATE_DOWNTIME)) {
error_setg(errp, "Parameter 'downtime_limit' expects an integer in "
"the range of 0 to %d milliseconds",
MAX_MIGRATE_DOWNTIME);
- return;
+ return false;
}
+
if (params->has_x_checkpoint_delay && (params->x_checkpoint_delay < 0)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
"x_checkpoint_delay",
"is invalid, it should be positive");
+ return false;
+ }
+
+ return true;
+}
+
+void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp)
+{
+ MigrationState *s = migrate_get_current();
+
+ if (!migrate_params_check(params, errp)) {
+ /* Invalid parameter */
+ return;
}
if (params->has_compress_level) {
--
2.9.4
- [Qemu-devel] [PULL 00/16] Migration, Juan Quintela, 2017/07/18
- [Qemu-devel] [PULL 02/16] migration: Close file on failed migration load, Juan Quintela, 2017/07/18
- [Qemu-devel] [PULL 01/16] migration/rdma: Fix race on source, Juan Quintela, 2017/07/18
- [Qemu-devel] [PULL 03/16] migration/rdma: fix qemu_rdma_block_for_wrid error paths, Juan Quintela, 2017/07/18
- [Qemu-devel] [PULL 04/16] migration/rdma: Allow cancelling while waiting for wrid, Juan Quintela, 2017/07/18
- [Qemu-devel] [PULL 05/16] migration/rdma: Safely convert control types, Juan Quintela, 2017/07/18
- [Qemu-devel] [PULL 06/16] migration/rdma: Send error during cancelling, Juan Quintela, 2017/07/18
- [Qemu-devel] [PULL 07/16] qdev: provide DEFINE_PROP_INT64(), Juan Quintela, 2017/07/18
- [Qemu-devel] [PULL 09/16] migration: export capabilities to props, Juan Quintela, 2017/07/18
- [Qemu-devel] [PULL 08/16] migration: export parameters to props, Juan Quintela, 2017/07/18
- [Qemu-devel] [PULL 10/16] migration: introduce migrate_params_check(),
Juan Quintela <=
- [Qemu-devel] [PULL 11/16] migration: provide migrate_params_apply(), Juan Quintela, 2017/07/18
- [Qemu-devel] [PULL 13/16] migration: remove check against colo support, Juan Quintela, 2017/07/18
- [Qemu-devel] [PULL 12/16] migration: check global params for validity, Juan Quintela, 2017/07/18
- [Qemu-devel] [PULL 14/16] migration: provide migrate_caps_check(), Juan Quintela, 2017/07/18
- [Qemu-devel] [PULL 15/16] migration: provide migrate_cap_add(), Juan Quintela, 2017/07/18
- [Qemu-devel] [PULL 16/16] migration: check global caps for validity, Juan Quintela, 2017/07/18
- Re: [Qemu-devel] [PULL 00/16] Migration, no-reply, 2017/07/18
- Re: [Qemu-devel] [PULL 00/16] Migration, Peter Maydell, 2017/07/19