From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3Li-0006Yj-V2 for qemu-devel@nongnu.org; Wed, 02 Sep 2015 04:24:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX3Lf-0001B0-II for qemu-devel@nongnu.org; Wed, 02 Sep 2015 04:24:54 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:21602) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3Le-00019B-O1 for qemu-devel@nongnu.org; Wed, 02 Sep 2015 04:24:51 -0400 From: zhanghailiang Date: Wed, 2 Sep 2015 16:23:12 +0800 Message-ID: <1441182199-8328-26-git-send-email-zhang.zhanghailiang@huawei.com> In-Reply-To: <1441182199-8328-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1441182199-8328-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH COLO-Frame v9 25/32] 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, Luiz Capitulino , arei.gonglei@huawei.com, stefanha@redhat.com, amit.shah@redhat.com, yanghy@cn.fujitsu.com, 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 --- hmp.c | 8 ++++++++ migration/colo.c | 12 +++++------- migration/migration.c | 27 ++++++++++++++++++++++++++- qapi-schema.json | 17 ++++++++++++++--- 4 files changed, 53 insertions(+), 11 deletions(-) diff --git a/hmp.c b/hmp.c index 94b0149..2f78666 100644 --- a/hmp.c +++ b/hmp.c @@ -273,6 +273,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict) monitor_printf(mon, " %s: %" PRId64, MigrationParameter_lookup[MIGRATION_PARAMETER_DECOMPRESS_THREADS], params->decompress_threads); + monitor_printf(mon, " %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_CHECKPOINT_DELAY], + params->checkpoint_delay); monitor_printf(mon, "\n"); } @@ -1222,6 +1225,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) bool has_compress_level = false; bool has_compress_threads = false; bool has_decompress_threads = false; + bool has_checkpoint_delay = false; int i; for (i = 0; i < MIGRATION_PARAMETER_MAX; i++) { @@ -1236,10 +1240,14 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) case MIGRATION_PARAMETER_DECOMPRESS_THREADS: has_decompress_threads = true; break; + case MIGRATION_PARAMETER_CHECKPOINT_DELAY: + has_checkpoint_delay = true; + break; } qmp_migrate_set_parameters(has_compress_level, value, has_compress_threads, value, has_decompress_threads, value, + has_checkpoint_delay, value, &err); break; } diff --git a/migration/colo.c b/migration/colo.c index 6bfebd1..0113e1b 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. @@ -36,6 +32,7 @@ static QEMUBH *colo_bh; static bool vmstate_loading; + /* colo buffer */ #define COLO_BUFFER_BASE_SIZE (4 * 1024 * 1024) @@ -360,7 +357,8 @@ static void *colo_thread(void *opaque) } 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 f7ca2c4..b140678 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -49,6 +49,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); @@ -72,6 +77,8 @@ MigrationState *migrate_get_current(void) DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT, .parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS] = DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT, + .parameters[MIGRATION_PARAMETER_CHECKPOINT_DELAY] = + DEFAULT_MIGRATE_CHECKPOINT_DELAY, }; return ¤t_migration; @@ -393,6 +400,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) s->parameters[MIGRATION_PARAMETER_COMPRESS_THREADS]; params->decompress_threads = s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS]; + params->checkpoint_delay = + s->parameters[MIGRATION_PARAMETER_CHECKPOINT_DELAY]; return params; } @@ -526,7 +535,10 @@ void qmp_migrate_set_parameters(bool has_compress_level, bool has_compress_threads, int64_t compress_threads, bool has_decompress_threads, - int64_t decompress_threads, Error **errp) + int64_t decompress_threads, + bool has_checkpoint_delay, + int64_t checkpoint_delay, + Error **errp) { MigrationState *s = migrate_get_current(); @@ -549,6 +561,11 @@ void qmp_migrate_set_parameters(bool has_compress_level, "is invalid, it should be in the range of 1 to 255"); return; } + 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; @@ -560,6 +577,9 @@ void qmp_migrate_set_parameters(bool has_compress_level, s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS] = decompress_threads; } + if (has_checkpoint_delay) { + s->parameters[MIGRATION_PARAMETER_CHECKPOINT_DELAY] = checkpoint_delay; + } } /* shared migration helpers */ @@ -676,6 +696,8 @@ static MigrationState *migrate_init(const MigrationParams *params) s->parameters[MIGRATION_PARAMETER_COMPRESS_THREADS]; int decompress_thread_count = s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS]; + int checkpoint_delay = + s->parameters[MIGRATION_PARAMETER_CHECKPOINT_DELAY]; memcpy(enabled_capabilities, s->enabled_capabilities, sizeof(enabled_capabilities)); @@ -691,6 +713,9 @@ static MigrationState *migrate_init(const MigrationParams *params) compress_thread_count; s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS] = decompress_thread_count; + 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 f75e96b..75e1770 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -599,10 +599,14 @@ # compression, so set the decompress-threads to the number about 1/4 # of compress-threads is adequate. # +# @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'] } + 'data': ['compress-level', 'compress-threads', 'decompress-threads', + 'checkpoint-delay' ] } # # @migrate-set-parameters @@ -615,12 +619,15 @@ # # @decompress-threads: decompression thread count # +# @checkpoint-delay: the delay time between two checkpoints +# # Since: 2.4 ## { 'command': 'migrate-set-parameters', 'data': { '*compress-level': 'int', '*compress-threads': 'int', - '*decompress-threads': 'int'} } + '*decompress-threads': 'int', + '*checkpoint-delay': 'int' } } # # @MigrationParameters @@ -631,12 +638,16 @@ # # @decompress-threads: decompression thread count # +# @checkpoint-delay: the delay time between two COLO checkpoints +# # Since: 2.4 ## { 'struct': 'MigrationParameters', 'data': { 'compress-level': 'int', 'compress-threads': 'int', - 'decompress-threads': 'int'} } + 'decompress-threads': 'int', + 'checkpoint-delay': 'int'} } + ## # @query-migrate-parameters # -- 1.8.3.1