From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48773) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9Ud6-0002Ea-SQ for qemu-devel@nongnu.org; Wed, 23 Nov 2016 05:18:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9Ud3-0000ch-NF for qemu-devel@nongnu.org; Wed, 23 Nov 2016 05:18:16 -0500 Received: from [59.151.112.132] (port=43207 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9Ud3-0000b5-Ac for qemu-devel@nongnu.org; Wed, 23 Nov 2016 05:18:13 -0500 From: Chao Fan Date: Wed, 23 Nov 2016 18:16:34 +0800 Message-ID: <1479896194-32672-1-git-send-email-fanc.fnst@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH] migration: check the value of cpu throttle in migrate_set_parameters List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: quintela@redhat.com, amit.shah@redhat.com, jjherne@linux.vnet.ibm.com, caoj.fnst@cn.fujitsu.com, douly.fnst@cn.fujitsu.com, Chao Fan 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 --- migration/migration.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index f498ab8..a6d0334 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 " %ld", + "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 " %ld", + "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" -- 2.7.4