diff mbox

[v2] migration: check the value of cpu throttle in migrate_set_parameters

Message ID 1479901669-23165-1-git-send-email-fanc.fnst@cn.fujitsu.com
State New
Headers show

Commit Message

Chao Fan Nov. 23, 2016, 11:47 a.m. UTC
When cpu thrpttle is turned on in migration, the first throttle value
is cpu_throttle_initial. And then, when more throttle is needed,
the next throttle value will be cpu_throttle_increment, so maybe
it should be smaller than the percentage of CPU frequency after
first throttle. Otherwise, cpu_throttle_increment will be useless,
as the the percentage of CPU frequency will be 1, the least value.

Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>

---
v2: fix the wrong variable type
---
 migration/migration.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
diff mbox

Patch

diff --git a/migration/migration.c b/migration/migration.c
index f498ab8..51fd20d 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -832,6 +832,15 @@  void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp)
                    "an integer in the range of 1 to 99");
         return;
     }
+    if (params->has_cpu_throttle_initial &&
+        (100 - params->cpu_throttle_initial <=
+         s->parameters.cpu_throttle_increment)) {
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE "%" PRId64 "",
+                   "cpu_throttle_initial",
+                   "an integer smaller than ",
+                   100 - s->parameters.cpu_throttle_increment);
+        return;
+    }
     if (params->has_cpu_throttle_increment &&
         (params->cpu_throttle_increment < 1 ||
          params->cpu_throttle_increment > 99)) {
@@ -840,6 +849,15 @@  void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp)
                    "an integer in the range of 1 to 99");
         return;
     }
+    if (params->has_cpu_throttle_increment &&
+        (params->cpu_throttle_increment >=
+         100 - s->parameters.cpu_throttle_initial)) {
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE "%" PRId64 "",
+                   "cpu_throttle_increment",
+                   "an integer smaller than ",
+                   100 - s->parameters.cpu_throttle_initial);
+        return;
+    }
     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"