From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtaJb-0003Yj-DY for qemu-devel@nongnu.org; Tue, 03 Nov 2015 07:03:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZtaJZ-0003VI-U3 for qemu-devel@nongnu.org; Tue, 03 Nov 2015 07:03:51 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:63523) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtaJZ-0003VC-19 for qemu-devel@nongnu.org; Tue, 03 Nov 2015 07:03:49 -0500 From: zhanghailiang Date: Tue, 3 Nov 2015 19:56:44 +0800 Message-ID: <1446551816-15768-27-git-send-email-zhang.zhanghailiang@huawei.com> In-Reply-To: <1446551816-15768-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1446551816-15768-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH COLO-Frame v10 26/38] COLO: Control the checkpoint delay time by migrate-set-parameters command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: lizhijian@cn.fujitsu.com, quintela@redhat.com, Markus Armbruster , yunhong.jiang@intel.com, eddie.dong@intel.com, peter.huangpeng@huawei.com, dgilbert@redhat.com, arei.gonglei@huawei.com, stefanha@redhat.com, amit.shah@redhat.com, Luiz Capitulino , zhanghailiang Add checkpoint-delay parameter for migrate-set-parameters, so that we can control the checkpoint frequency when COLO is in periodic mode. Cc: Luiz Capitulino Cc: Eric Blake Cc: Markus Armbruster Signed-off-by: zhanghailiang Signed-off-by: Li Zhijian --- v10: Fix related qmp command --- hmp.c | 7 +++++++ migration/colo.c | 12 +++++------- migration/migration.c | 28 +++++++++++++++++++++++++++- qapi-schema.json | 19 ++++++++++++++++--- qmp-commands.hx | 2 +- 5 files changed, 56 insertions(+), 12 deletions(-) diff --git a/hmp.c b/hmp.c index 5e416d0..dedbadc 100644 --- a/hmp.c +++ b/hmp.c @@ -284,6 +284,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict) monitor_printf(mon, " %s: %" PRId64, MigrationParameter_lookup[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT], params->x_cpu_throttle_increment); + monitor_printf(mon, " %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_CHECKPOINT_DELAY], + params->checkpoint_delay); monitor_printf(mon, "\n"); } @@ -1235,6 +1238,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) bool has_decompress_threads = false; bool has_x_cpu_throttle_initial = false; bool has_x_cpu_throttle_increment = false; + bool has_checkpoint_delay = false; int i; for (i = 0; i < MIGRATION_PARAMETER_MAX; i++) { @@ -1254,6 +1258,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) break; case MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT: has_x_cpu_throttle_increment = true; + case MIGRATION_PARAMETER_CHECKPOINT_DELAY: + has_checkpoint_delay = true; break; } qmp_migrate_set_parameters(has_compress_level, value, @@ -1261,6 +1267,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) has_decompress_threads, value, has_x_cpu_throttle_initial, value, has_x_cpu_throttle_increment, value, + has_checkpoint_delay, value, &err); break; } diff --git a/migration/colo.c b/migration/colo.c index 9960bd6..74e091d 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -19,12 +19,8 @@ #include "qemu/sockets.h" #include "migration/failover.h" #include "qapi-event.h" - -/* - * checkpoint interval: unit ms - * Note: Please change this default value to 10000 when we support hybrid mode. - */ -#define CHECKPOINT_MAX_PEROID 200 +#include "qmp-commands.h" +#include "qapi-types.h" /* * The delay time before qemu begin the procedure of default failover treatment. @@ -35,6 +31,7 @@ #define DEFAULT_FAILOVER_DELAY 2000 static bool vmstate_loading; + /* colo buffer */ #define COLO_BUFFER_BASE_SIZE (4 * 1024 * 1024) @@ -356,7 +353,8 @@ static void colo_process_checkpoint(MigrationState *s) } current_time = qemu_clock_get_ms(QEMU_CLOCK_HOST); - if (current_time - checkpoint_time < CHECKPOINT_MAX_PEROID) { + if (current_time - checkpoint_time < + s->parameters[MIGRATION_PARAMETER_CHECKPOINT_DELAY]) { g_usleep(100000); continue; } diff --git a/migration/migration.c b/migration/migration.c index 227243e..41ec693 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -53,6 +53,11 @@ /* Migration XBZRLE default cache size */ #define DEFAULT_MIGRATE_CACHE_SIZE (64 * 1024 * 1024) +/* The delay time (in ms) between two COLO checkpoints + * Note: Please change this default value to 10000 when we support hybrid mode. + */ +#define DEFAULT_MIGRATE_CHECKPOINT_DELAY 200 + static NotifierList migration_state_notifiers = NOTIFIER_LIST_INITIALIZER(migration_state_notifiers); @@ -80,6 +85,8 @@ MigrationState *migrate_get_current(void) DEFAULT_MIGRATE_X_CPU_THROTTLE_INITIAL, .parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT] = DEFAULT_MIGRATE_X_CPU_THROTTLE_INCREMENT, + .parameters[MIGRATION_PARAMETER_CHECKPOINT_DELAY] = + DEFAULT_MIGRATE_CHECKPOINT_DELAY, }; return ¤t_migration; @@ -426,6 +433,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL]; params->x_cpu_throttle_increment = s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT]; + params->checkpoint_delay = + s->parameters[MIGRATION_PARAMETER_CHECKPOINT_DELAY]; return params; } @@ -568,7 +577,10 @@ void qmp_migrate_set_parameters(bool has_compress_level, bool has_x_cpu_throttle_initial, int64_t x_cpu_throttle_initial, bool has_x_cpu_throttle_increment, - int64_t x_cpu_throttle_increment, Error **errp) + int64_t x_cpu_throttle_increment, + bool has_checkpoint_delay, + int64_t checkpoint_delay, + Error **errp) { MigrationState *s = migrate_get_current(); @@ -603,6 +615,11 @@ void qmp_migrate_set_parameters(bool has_compress_level, "x_cpu_throttle_increment", "an integer in the range of 1 to 99"); } + if (has_checkpoint_delay && (checkpoint_delay < 0)) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, + "checkpoint_delay", + "is invalid, it should be positive"); + } if (has_compress_level) { s->parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL] = compress_level; @@ -623,6 +640,10 @@ void qmp_migrate_set_parameters(bool has_compress_level, s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT] = x_cpu_throttle_increment; } + + if (has_checkpoint_delay) { + s->parameters[MIGRATION_PARAMETER_CHECKPOINT_DELAY] = checkpoint_delay; + } } /* shared migration helpers */ @@ -743,6 +764,8 @@ static MigrationState *migrate_init(const MigrationParams *params) s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL]; int x_cpu_throttle_increment = s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT]; + int checkpoint_delay = + s->parameters[MIGRATION_PARAMETER_CHECKPOINT_DELAY]; memcpy(enabled_capabilities, s->enabled_capabilities, sizeof(enabled_capabilities)); @@ -762,6 +785,9 @@ static MigrationState *migrate_init(const MigrationParams *params) x_cpu_throttle_initial; s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT] = x_cpu_throttle_increment; + s->parameters[MIGRATION_PARAMETER_CHECKPOINT_DELAY] = + checkpoint_delay; + s->bandwidth_limit = bandwidth_limit; migrate_set_state(&s->state, MIGRATION_STATUS_NONE, MIGRATION_STATUS_SETUP); diff --git a/qapi-schema.json b/qapi-schema.json index 8cc1f60..143abea 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -617,11 +617,16 @@ # @x-cpu-throttle-increment: throttle percentage increase each time # auto-converge detects that migration is not making # progress. The default value is 10. (Since 2.5) +# +# @checkpoint-delay: The delay time (in ms) between two COLO checkpoints in +# periodic mode. +# # Since: 2.4 ## { 'enum': 'MigrationParameter', 'data': ['compress-level', 'compress-threads', 'decompress-threads', - 'x-cpu-throttle-initial', 'x-cpu-throttle-increment'] } + 'x-cpu-throttle-initial', 'x-cpu-throttle-increment', + 'checkpoint-delay' ] } # # @migrate-set-parameters @@ -641,6 +646,9 @@ # @x-cpu-throttle-increment: throttle percentage increase each time # auto-converge detects that migration is not making # progress. The default value is 10. (Since 2.5) +# +# @checkpoint-delay: the delay time between two checkpoints +# # Since: 2.4 ## { 'command': 'migrate-set-parameters', @@ -648,7 +656,8 @@ '*compress-threads': 'int', '*decompress-threads': 'int', '*x-cpu-throttle-initial': 'int', - '*x-cpu-throttle-increment': 'int'} } + '*x-cpu-throttle-increment': 'int', + '*checkpoint-delay': 'int' } } # # @MigrationParameters @@ -667,6 +676,8 @@ # auto-converge detects that migration is not making # progress. The default value is 10. (Since 2.5) # +# @checkpoint-delay: the delay time between two COLO checkpoints +# # Since: 2.4 ## { 'struct': 'MigrationParameters', @@ -674,7 +685,9 @@ 'compress-threads': 'int', 'decompress-threads': 'int', 'x-cpu-throttle-initial': 'int', - 'x-cpu-throttle-increment': 'int'} } + 'x-cpu-throttle-increment': 'int', + 'checkpoint-delay': 'int'} } + ## # @query-migrate-parameters # diff --git a/qmp-commands.hx b/qmp-commands.hx index eccdd17..2f3c081 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3556,7 +3556,7 @@ EQMP { .name = "migrate-set-parameters", .args_type = - "compress-level:i?,compress-threads:i?,decompress-threads:i?", + "compress-level:i?,compress-threads:i?,decompress-threads:i?,checkpoint-delay:i?", .mhandler.cmd_new = qmp_marshal_migrate_set_parameters, }, SQMP -- 1.8.3.1