From 50e9a629c6c92e73260cd3d7c2e3f5bfd84e47e2 Mon Sep 17 00:00:00 2001 From: Liang Li Date: Mon, 23 Mar 2015 16:32:29 +0800 Subject: migration: Add hmp interface to set and query parameters Add the hmp interface to tune and query the parameters used in live migration. Signed-off-by: Liang Li Signed-off-by: Yang Zhang Signed-off-by: Juan Quintela --- hmp.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'hmp.c') diff --git a/hmp.c b/hmp.c index 3010d04..e17852d 100644 --- a/hmp.c +++ b/hmp.c @@ -252,6 +252,29 @@ void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict) qapi_free_MigrationCapabilityStatusList(caps); } +void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict) +{ + MigrationParameters *params; + + params = qmp_query_migrate_parameters(NULL); + + if (params) { + monitor_printf(mon, "parameters:"); + monitor_printf(mon, " %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_COMPRESS_LEVEL], + params->compress_level); + monitor_printf(mon, " %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_COMPRESS_THREADS], + params->compress_threads); + monitor_printf(mon, " %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_DECOMPRESS_THREADS], + params->decompress_threads); + monitor_printf(mon, "\n"); + } + + qapi_free_MigrationParameters(params); +} + void hmp_info_migrate_cache_size(Monitor *mon, const QDict *qdict) { monitor_printf(mon, "xbzrel cache size: %" PRId64 " kbytes\n", @@ -1185,6 +1208,48 @@ void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict) } } +void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) +{ + const char *param = qdict_get_str(qdict, "parameter"); + int value = qdict_get_int(qdict, "value"); + Error *err = NULL; + bool has_compress_level = false; + bool has_compress_threads = false; + bool has_decompress_threads = false; + int i; + + for (i = 0; i < MIGRATION_PARAMETER_MAX; i++) { + if (strcmp(param, MigrationParameter_lookup[i]) == 0) { + switch (i) { + case MIGRATION_PARAMETER_COMPRESS_LEVEL: + has_compress_level = true; + break; + case MIGRATION_PARAMETER_COMPRESS_THREADS: + has_compress_threads = true; + break; + case MIGRATION_PARAMETER_DECOMPRESS_THREADS: + has_decompress_threads = true; + break; + } + qmp_migrate_set_parameters(has_compress_level, value, + has_compress_threads, value, + has_decompress_threads, value, + &err); + break; + } + } + + if (i == MIGRATION_PARAMETER_MAX) { + error_set(&err, QERR_INVALID_PARAMETER, param); + } + + if (err) { + monitor_printf(mon, "migrate_set_parameter: %s\n", + error_get_pretty(err)); + error_free(err); + } +} + void hmp_set_password(Monitor *mon, const QDict *qdict) { const char *protocol = qdict_get_str(qdict, "protocol"); -- cgit v1.1