mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-06 18:05:37 +00:00
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 <liang.z.li@intel.com> Signed-off-by: Yang Zhang <yang.z.zhang@intel.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
parent
85de83231e
commit
50e9a629c6
|
@ -990,6 +990,21 @@ STEXI
|
|||
@item migrate_set_capability @var{capability} @var{state}
|
||||
@findex migrate_set_capability
|
||||
Enable/Disable the usage of a capability @var{capability} for migration.
|
||||
ETEXI
|
||||
|
||||
{
|
||||
.name = "migrate_set_parameter",
|
||||
.args_type = "parameter:s,value:i",
|
||||
.params = "parameter value",
|
||||
.help = "Set the parameter for migration",
|
||||
.mhandler.cmd = hmp_migrate_set_parameter,
|
||||
.command_completion = migrate_set_parameter_completion,
|
||||
},
|
||||
|
||||
STEXI
|
||||
@item migrate_set_parameter @var{parameter} @var{value}
|
||||
@findex migrate_set_parameter
|
||||
Set the parameter @var{parameter} for migration.
|
||||
ETEXI
|
||||
|
||||
{
|
||||
|
@ -1761,6 +1776,8 @@ show user network stack connection states
|
|||
show migration status
|
||||
@item info migrate_capabilities
|
||||
show current migration capabilities
|
||||
@item info migrate_parameters
|
||||
show current migration parameters
|
||||
@item info migrate_cache_size
|
||||
show current migration XBZRLE cache size
|
||||
@item info balloon
|
||||
|
|
65
hmp.c
65
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");
|
||||
|
|
4
hmp.h
4
hmp.h
|
@ -28,6 +28,7 @@ void hmp_info_chardev(Monitor *mon, const QDict *qdict);
|
|||
void hmp_info_mice(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_migrate(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_migrate_cache_size(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_cpus(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_block(Monitor *mon, const QDict *qdict);
|
||||
|
@ -64,6 +65,7 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict);
|
|||
void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict);
|
||||
void hmp_migrate_set_speed(Monitor *mon, const QDict *qdict);
|
||||
void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict);
|
||||
void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict);
|
||||
void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict);
|
||||
void hmp_set_password(Monitor *mon, const QDict *qdict);
|
||||
void hmp_expire_password(Monitor *mon, const QDict *qdict);
|
||||
|
@ -113,6 +115,8 @@ void watchdog_action_completion(ReadLineState *rs, int nb_args,
|
|||
const char *str);
|
||||
void migrate_set_capability_completion(ReadLineState *rs, int nb_args,
|
||||
const char *str);
|
||||
void migrate_set_parameter_completion(ReadLineState *rs, int nb_args,
|
||||
const char *str);
|
||||
void host_net_add_completion(ReadLineState *rs, int nb_args, const char *str);
|
||||
void host_net_remove_completion(ReadLineState *rs, int nb_args,
|
||||
const char *str);
|
||||
|
|
25
monitor.c
25
monitor.c
|
@ -2858,6 +2858,13 @@ static mon_cmd_t info_cmds[] = {
|
|||
.help = "show current migration capabilities",
|
||||
.mhandler.cmd = hmp_info_migrate_capabilities,
|
||||
},
|
||||
{
|
||||
.name = "migrate_parameters",
|
||||
.args_type = "",
|
||||
.params = "",
|
||||
.help = "show current migration parameters",
|
||||
.mhandler.cmd = hmp_info_migrate_parameters,
|
||||
},
|
||||
{
|
||||
.name = "migrate_cache_size",
|
||||
.args_type = "",
|
||||
|
@ -4540,6 +4547,24 @@ void migrate_set_capability_completion(ReadLineState *rs, int nb_args,
|
|||
}
|
||||
}
|
||||
|
||||
void migrate_set_parameter_completion(ReadLineState *rs, int nb_args,
|
||||
const char *str)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
len = strlen(str);
|
||||
readline_set_completion_index(rs, len);
|
||||
if (nb_args == 2) {
|
||||
int i;
|
||||
for (i = 0; i < MIGRATION_PARAMETER_MAX; i++) {
|
||||
const char *name = MigrationParameter_lookup[i];
|
||||
if (!strncmp(str, name, len)) {
|
||||
readline_add_completion(rs, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void host_net_add_completion(ReadLineState *rs, int nb_args, const char *str)
|
||||
{
|
||||
int i;
|
||||
|
|
Loading…
Reference in a new issue