Skip to contentSkip to conversation

migration: check the value of cpu throttle in migrate_set_parameters

PATCH New Chao Fan 1 participant 1 message Nov 23, 2016

lore
Share & tools
lore

Chao Fan

author
#0 lore raw

PATCH v2 1/1 migration: check the value of cpu throttle in migrate_set_parameters

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.

---
v2: fix the wrong variable type

---
 migration/migration.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
migration/migration.c +18 -0
index f498ab8..51fd20d 100644
@@ -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"
Signature · 1 line
2.7.4