Move migrate_set_speed and migrate_set_downtime into migrate_set_parameter
PATCH 1/1 Move migrate_set_speed and migrate_set_downtime into migrate_set_parameter
Include migrate_set_speed and migrate_set_downtime inside migrate_set_parameters respectively for setting maximum migration speed and expected downtime parameters. Also add the query part for both in qmp and hmp qemu control interfaces.
--- hmp-commands.hx | 35 +++------------------------- hmp.c | 40 +++++++++++++++++++++----------- include/migration/migration.h | 5 +++- migration/migration.c | 34 ++++++++++++++++++++++----- qapi-schema.json | 53 ++++++++++++++++++------------------------- qmp-commands.hx | 51 ++++------------------------------------- 6 files changed, 88 insertions(+), 130 deletions(-)
hmp-commands.hx +3 -32
@@ -964,35 +964,6 @@ Set cache size to @var{value} (in bytes) for xbzrle migrations. ETEXI { - .name = "migrate_set_speed", - .args_type = "value:o", - .params = "value", - .help = "set maximum speed (in bytes) for migrations. " - "Defaults to MB if no size suffix is specified, ie. B/K/M/G/T", - .mhandler.cmd = hmp_migrate_set_speed, - }, - -STEXI -@item migrate_set_speed @var{value} -@findex migrate_set_speed -Set maximum speed to @var{value} (in bytes) for migrations. -ETEXI - - { - .name = "migrate_set_downtime", - .args_type = "value:T", - .params = "value", - .help = "set maximum tolerated downtime (in seconds) for migrations", - .mhandler.cmd = hmp_migrate_set_downtime, - }, - -STEXI -@item migrate_set_downtime @var{second} -@findex migrate_set_downtime -Set maximum tolerated downtime (in seconds) for migration. -ETEXI - - { .name = "migrate_set_capability", .args_type = "capability:s,state:b", .params = "capability state",
@@ -1009,15 +980,15 @@ ETEXI { .name = "migrate_set_parameter", - .args_type = "parameter:s,value:s", - .params = "parameter value", + .args_type = "parameter:s,value:s?,speed:o?", + .params = "parameter value speed", .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} +@item migrate_set_parameter @var{parameter} @var{value} @var{speed} @findex migrate_set_parameter Set the parameter @var{parameter} for migration. ETEXI
hmp.c +27 -13
@@ -304,6 +304,12 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)monitor_printf (mon," %s: '%s'" , MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_HOSTNAME ], params->tls_hostname ? :"" ); +monitor_printf (mon," %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_MIGRATE_SET_SPEED ], + params->migrate_set_speed); +monitor_printf (mon," %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_MIGRATE_SET_DOWNTIME ], + params->migrate_set_downtime);monitor_printf (mon,"\n" ); }
@@ -1193,12 +1199,6 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err); } -void hmp_migrate_set_downtime (Monitor *mon,const QDict *qdict) -{ -double value =qdict_get_double (qdict,"value" ); -qmp_migrate_set_downtime (value,NULL ); -} -void hmp_migrate_set_cache_size (Monitor *mon,const QDict *qdict) {int64_t value =qdict_get_int (qdict,"value" );
@@ -1211,12 +1211,6 @@ void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict) } } -void hmp_migrate_set_speed (Monitor *mon,const QDict *qdict) -{ -int64_t value =qdict_get_int (qdict,"value" ); -qmp_migrate_set_speed (value,NULL ); -} -void hmp_migrate_set_capability (Monitor *mon,const QDict *qdict) {const char *cap =qdict_get_str (qdict,"capability" );
@@ -1250,8 +1244,11 @@ 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" ); -const char *valuestr =qdict_get_str (qdict,"value" ); +const char *valuestr =qdict_get_try_str (qdict,"value" ); +int64_t valuespeed =0 ; +double valuedowntime =0 ;long valueint =0 ; +char *endp;Error *err =NULL ;bool has_compress_level = false;bool has_compress_threads = false;
@@ -1260,6 +1257,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)bool has_cpu_throttle_increment = false;bool has_tls_creds = false;bool has_tls_hostname = false; +bool has_migrate_set_speed = false; +bool has_migrate_set_downtime = false;bool use_int_value = false;int i;
@@ -1291,6 +1290,19 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)case MIGRATION_PARAMETER_TLS_HOSTNAME : has_tls_hostname = true;break ; +case MIGRATION_PARAMETER_MIGRATE_SET_SPEED : + has_migrate_set_speed = true; + valuespeed =qdict_get_int (qdict,"speed" ); +break ; +case MIGRATION_PARAMETER_MIGRATE_SET_DOWNTIME : + has_migrate_set_downtime = true; + valuedowntime =strtod (valuestr, &endp); +if (valuestr == endp) { +error_setg (&err,"Unable to parse '%s' as a number" , + valuestr); + goto cleanup; + } +break ; }if (use_int_value) {
@@ -1308,6 +1320,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) has_cpu_throttle_increment, valueint, has_tls_creds, valuestr, has_tls_hostname, valuestr, + has_migrate_set_speed, valuespeed, + has_migrate_set_downtime, valuedowntime, &err);break ; }
include/migration/migration.h +4 -1
@@ -129,7 +129,6 @@ struct MigrationSrcPageRequest {struct MigrationState { -int64_t bandwidth_limit;size_t bytes_xfer;size_t xfer_limit;QemuThread thread;
@@ -205,6 +204,10 @@ void migration_tls_channel_connect(MigrationState *s,uint64_t migrate_max_downtime (void ); +void migrate_set_preferred_speed (int64_t value,Error **errp); + +void migrate_set_expected_downtime (double value,Error **errp); +void exec_start_incoming_migration (const char *host_port,Error **errp);void exec_start_outgoing_migration (MigrationState *s,const char *host_port,Error **errp);
migration/migration.c +28 -6
@@ -44,6 +44,9 @@#define BUFFER_DELAY 100#define XFER_LIMIT_RATIO (1000 / BUFFER_DELAY) +/* Amount of nanoseconds we are willing to wait for migration to be down. */ +#define DEFAULT_MIGRATE_SET_DOWNTIME 300000000 +/* Default compression thread count */ #define DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT 8/* Default decompression thread count, usually decompression is at
@@ -80,7 +83,6 @@ MigrationState *migrate_get_current(void)static bool once;static MigrationState current_migration = { .state =MIGRATION_STATUS_NONE , - .bandwidth_limit =MAX_THROTTLE , .xbzrle_cache_size =DEFAULT_MIGRATE_CACHE_SIZE , .mbps =-1 , .parameters = {
@@ -89,6 +91,8 @@ MigrationState *migrate_get_current(void) .decompress_threads = DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT, .cpu_throttle_initial = DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL, .cpu_throttle_increment = DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT, + .migrate_set_speed = MAX_THROTTLE, + .migrate_set_downtime = DEFAULT_MIGRATE_SET_DOWNTIME, }, };
@@ -566,6 +570,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) params->cpu_throttle_increment = s->parameters.cpu_throttle_increment; params->tls_creds =g_strdup (s->parameters.tls_creds); params->tls_hostname =g_strdup (s->parameters.tls_hostname); + params->migrate_set_speed = s->parameters.migrate_set_speed; + params->migrate_set_downtime = s->parameters.migrate_set_downtime;return params; }
@@ -773,6 +779,10 @@ void qmp_migrate_set_parameters(bool has_compress_level,const char *tls_creds, bool has_tls_hostname, const char *tls_hostname, + bool has_migrate_set_speed, + int64_t migrate_set_speed, + bool has_migrate_set_downtime, + double migrate_set_downtime, Error **errp) { MigrationState *s = migrate_get_current();
@@ -832,6 +842,12 @@ void qmp_migrate_set_parameters(bool has_compress_level,g_free (s->parameters.tls_hostname); s->parameters.tls_hostname =g_strdup (tls_hostname); } +if (has_migrate_set_speed) { +migrate_set_preferred_speed (migrate_set_speed,NULL ); + } +if (has_migrate_set_downtime) { +migrate_set_expected_downtime (migrate_set_downtime,NULL ); + } }
@@ -1163,7 +1179,7 @@ int64_t qmp_query_migrate_cache_size(Error **errp)return migrate_xbzrle_cache_size (); } -void qmp_migrate_set_speed (int64_t value,Error **errp) +void migrate_set_preferred_speed (int64_t value,Error **errp) {MigrationState *s;
@@ -1175,18 +1191,24 @@ void qmp_migrate_set_speed(int64_t value, Error **errp) } s =migrate_get_current (); - s->bandwidth_limit = value; + s->parameters.migrate_set_speed = value;if (s->to_dst_file) {qemu_file_set_rate_limit (s->to_dst_file, - s->bandwidth_limit /XFER_LIMIT_RATIO ); + s->parameters.migrate_set_speed /XFER_LIMIT_RATIO ); } } -void qmp_migrate_set_downtime (double value,Error **errp) +void migrate_set_expected_downtime (double value,Error **errp) { +MigrationState *s; + value *=1e9 ; value =MAX (0 ,MIN (UINT64_MAX , value)); + + s =migrate_get_current (); + max_downtime = (uint64_t )value; + s->parameters.migrate_set_downtime = max_downtime; }bool migrate_postcopy_ram (void )
@@ -1858,7 +1880,7 @@ void migrate_fd_connect(MigrationState *s)qemu_file_set_blocking (s->to_dst_file, true);qemu_file_set_rate_limit (s->to_dst_file, - s->bandwidth_limit /XFER_LIMIT_RATIO ); + s->parameters.migrate_set_speed /XFER_LIMIT_RATIO );/* Notify before starting migration thread */ notifier_list_notify (&migration_state_notifiers, s);
qapi-schema.json +22 -31
94 lines not on this page · raw message
qmp-commands.hx +4 -47
69 lines not on this page · raw message
Signature · 1 line
2.6.2
Quoted 6 lines · Ashijeet Acharya
Include
migrate_set_speedandmigrate_set_downtimeinsidemigrate_set_parametersrespectively for setting maximum migration speed and expected downtime parameters. Also add the query part for both in qmp and hmp qemu control interfaces.Signed-off-by Ashijeet Acharya <[email protected]>
You cannot break backwards compatibility for everyone that is using those commands, sorry.
Paolo
Quoted 476 lines
--- hmp-commands.hx | 35 +++------------------------- hmp.c | 40 +++++++++++++++++++++----------- include/migration/migration.h | 5 +++- migration/migration.c | 34 ++++++++++++++++++++++----- qapi-schema.json | 53 ++++++++++++++++++------------------------- qmp-commands.hx | 51 ++++------------------------------------- 6 files changed, 88 insertions(+), 130 deletions(-)hmp-commands.hx +3
-32@@ -964,35 +964,6 @@ Set cache size to @var{value} (in bytes) for xbzrle migrations. ETEXI { - .name = "migrate_set_speed", - .args_type = "value:o", - .params = "value", - .help = "set maximum speed (in bytes) for migrations. " - "Defaults to MB if no size suffix is specified, ie. B/K/M/G/T", - .mhandler.cmd = hmp_migrate_set_speed, - }, - -STEXI -@item migrate_set_speed @var{value} -@findex migrate_set_speed -Set maximum speed to @var{value} (in bytes) for migrations. -ETEXI - - { - .name = "migrate_set_downtime", - .args_type = "value:T", - .params = "value", - .help = "set maximum tolerated downtime (in seconds) for migrations", - .mhandler.cmd = hmp_migrate_set_downtime, - }, - -STEXI -@item migrate_set_downtime @var{second} -@findex migrate_set_downtime -Set maximum tolerated downtime (in seconds) for migration. -ETEXI - - { .name = "migrate_set_capability", .args_type = "capability:s,state:b", .params = "capability state",@@ -1009,15 +980,15 @@ ETEXI { .name = "migrate_set_parameter", - .args_type = "parameter:s,value:s", - .params = "parameter value", + .args_type = "parameter:s,value:s?,speed:o?", + .params = "parameter value speed", .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} +@item migrate_set_parameter @var{parameter} @var{value} @var{speed} @findex migrate_set_parameter Set the parameter @var{parameter} for migration. ETEXIhmp.c +27
-13@@ -304,6 +304,12 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)monitor_printf (mon," %s: '%s'" , MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_HOSTNAME ], params->tls_hostname ? :"" ); +monitor_printf (mon," %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_MIGRATE_SET_SPEED ], + params->migrate_set_speed); +monitor_printf (mon," %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_MIGRATE_SET_DOWNTIME ], + params->migrate_set_downtime);monitor_printf (mon,"\n" ); }@@ -1193,12 +1199,6 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err); } -void hmp_migrate_set_downtime (Monitor *mon,const QDict *qdict) -{ -double value =qdict_get_double (qdict,"value" ); -qmp_migrate_set_downtime (value,NULL ); -} -void hmp_migrate_set_cache_size (Monitor *mon,const QDict *qdict) {int64_t value =qdict_get_int (qdict,"value" );@@ -1211,12 +1211,6 @@ void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict) } } -void hmp_migrate_set_speed (Monitor *mon,const QDict *qdict) -{ -int64_t value =qdict_get_int (qdict,"value" ); -qmp_migrate_set_speed (value,NULL ); -} -void hmp_migrate_set_capability (Monitor *mon,const QDict *qdict) {const char *cap =qdict_get_str (qdict,"capability" );@@ -1250,8 +1244,11 @@ 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" ); -const char *valuestr =qdict_get_str (qdict,"value" ); +const char *valuestr =qdict_get_try_str (qdict,"value" ); +int64_t valuespeed =0 ; +double valuedowntime =0 ;long valueint =0 ; +char *endp;Error *err =NULL ;bool has_compress_level = false;bool has_compress_threads = false;@@ -1260,6 +1257,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)bool has_cpu_throttle_increment = false;bool has_tls_creds = false;bool has_tls_hostname = false; +bool has_migrate_set_speed = false; +bool has_migrate_set_downtime = false;bool use_int_value = false;int i;@@ -1291,6 +1290,19 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)case MIGRATION_PARAMETER_TLS_HOSTNAME : has_tls_hostname = true;break ; +case MIGRATION_PARAMETER_MIGRATE_SET_SPEED : + has_migrate_set_speed = true; + valuespeed =qdict_get_int (qdict,"speed" ); +break ; +case MIGRATION_PARAMETER_MIGRATE_SET_DOWNTIME : + has_migrate_set_downtime = true; + valuedowntime =strtod (valuestr, &endp); +if (valuestr == endp) { +error_setg (&err,"Unable to parse '%s' as a number" , + valuestr); + goto cleanup; + } +break ; }if (use_int_value) {@@ -1308,6 +1320,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) has_cpu_throttle_increment, valueint, has_tls_creds, valuestr, has_tls_hostname, valuestr, + has_migrate_set_speed, valuespeed, + has_migrate_set_downtime, valuedowntime, &err);break ; }include/migration/migration.h +4
-1@@ -129,7 +129,6 @@ struct MigrationSrcPageRequest {struct MigrationState { -int64_t bandwidth_limit;size_t bytes_xfer;size_t xfer_limit;QemuThread thread;@@ -205,6 +204,10 @@ void migration_tls_channel_connect(MigrationState *s,uint64_t migrate_max_downtime (void ); +void migrate_set_preferred_speed (int64_t value,Error **errp); + +void migrate_set_expected_downtime (double value,Error **errp); +void exec_start_incoming_migration (const char *host_port,Error **errp);void exec_start_outgoing_migration (MigrationState *s,const char *host_port,Error **errp);migration/migration.c +28
-6@@ -44,6 +44,9 @@#define BUFFER_DELAY 100#define XFER_LIMIT_RATIO (1000 / BUFFER_DELAY) +/* Amount of nanoseconds we are willing to wait for migration to be down. */ +#define DEFAULT_MIGRATE_SET_DOWNTIME 300000000 +/* Default compression thread count */ #define DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT 8/* Default decompression thread count, usually decompression is at @@ -80,7 +83,6 @@ MigrationState *migrate_get_current(void)static bool once;static MigrationState current_migration = { .state =MIGRATION_STATUS_NONE , - .bandwidth_limit =MAX_THROTTLE , .xbzrle_cache_size =DEFAULT_MIGRATE_CACHE_SIZE , .mbps =-1 , .parameters = {@@ -89,6 +91,8 @@ MigrationState *migrate_get_current(void) .decompress_threads = DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT, .cpu_throttle_initial = DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL, .cpu_throttle_increment = DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT, + .migrate_set_speed = MAX_THROTTLE, + .migrate_set_downtime = DEFAULT_MIGRATE_SET_DOWNTIME, }, };@@ -566,6 +570,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) params->cpu_throttle_increment = s->parameters.cpu_throttle_increment; params->tls_creds =g_strdup (s->parameters.tls_creds); params->tls_hostname =g_strdup (s->parameters.tls_hostname); + params->migrate_set_speed = s->parameters.migrate_set_speed; + params->migrate_set_downtime = s->parameters.migrate_set_downtime;return params; }@@ -773,6 +779,10 @@ void qmp_migrate_set_parameters(bool has_compress_level,const char *tls_creds, bool has_tls_hostname, const char *tls_hostname, + bool has_migrate_set_speed, + int64_t migrate_set_speed, + bool has_migrate_set_downtime, + double migrate_set_downtime, Error **errp) { MigrationState *s = migrate_get_current();@@ -832,6 +842,12 @@ void qmp_migrate_set_parameters(bool has_compress_level,g_free (s->parameters.tls_hostname); s->parameters.tls_hostname =g_strdup (tls_hostname); } +if (has_migrate_set_speed) { +migrate_set_preferred_speed (migrate_set_speed,NULL ); + } +if (has_migrate_set_downtime) { +migrate_set_expected_downtime (migrate_set_downtime,NULL ); + } }@@ -1163,7 +1179,7 @@ int64_t qmp_query_migrate_cache_size(Error **errp)return migrate_xbzrle_cache_size (); } -void qmp_migrate_set_speed (int64_t value,Error **errp) +void migrate_set_preferred_speed (int64_t value,Error **errp) {MigrationState *s;@@ -1175,18 +1191,24 @@ void qmp_migrate_set_speed(int64_t value, Error **errp) } s =migrate_get_current (); - s->bandwidth_limit = value; + s->parameters.migrate_set_speed = value;if (s->to_dst_file) {qemu_file_set_rate_limit (s->to_dst_file, - s->bandwidth_limit /XFER_LIMIT_RATIO ); + s->parameters.migrate_set_speed /XFER_LIMIT_RATIO ); } } -void qmp_migrate_set_downtime (double value,Error **errp) +void migrate_set_expected_downtime (double value,Error **errp) { +MigrationState *s; + value *=1e9 ; value =MAX (0 ,MIN (UINT64_MAX , value)); + + s =migrate_get_current (); + max_downtime = (uint64_t )value; + s->parameters.migrate_set_downtime = max_downtime; }bool migrate_postcopy_ram (void )@@ -1858,7 +1880,7 @@ void migrate_fd_connect(MigrationState *s)qemu_file_set_blocking (s->to_dst_file, true);qemu_file_set_rate_limit (s->to_dst_file, - s->bandwidth_limit /XFER_LIMIT_RATIO ); + s->parameters.migrate_set_speed /XFER_LIMIT_RATIO );/* Notify before starting migration thread */ notifier_list_notify (&migration_state_notifiers, s);qapi-schema.json +22
-31@@ -637,12 +637,17 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @migrate-set-speed: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. +# +# @migrate-set-downtime: set maximum tolerated downtime for migration. # Since: 2.4 ## { 'enum': 'MigrationParameter', 'data': ['compress-level', 'compress-threads', 'decompress-threads', 'cpu-throttle-initial', 'cpu-throttle-increment', - 'tls-creds', 'tls-hostname'] } + 'tls-creds', 'tls-hostname', 'migrate-set-speed', + 'migrate-set-downtime'] } # # @migrate-set-parameters@@ -678,6 +683,11 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @migrate-set-speed: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. +# +# @migrate-set-downtime: set maximum tolerated downtime for migration. +# # Since: 2.4 ## { 'command': 'migrate-set-parameters',@@ -687,7 +697,9 @@ '*cpu-throttle-initial': 'int', '*cpu-throttle-increment': 'int', '*tls-creds': 'str', - '*tls-hostname': 'str'} } + '*tls-hostname': 'str', + '*migrate-set-speed': 'int', + '*migrate-set-downtime': 'number'} } # # @MigrationParameters@@ -721,6 +733,11 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @migrate-set-speed: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. +# +# @migrate-set-downtime: set maximum tolerated downtime for migration. +# # Since: 2.4 ## { 'struct': 'MigrationParameters',@@ -730,7 +747,9 @@ 'cpu-throttle-initial': 'int', 'cpu-throttle-increment': 'int', 'tls-creds': 'str', - 'tls-hostname': 'str'} } + 'tls-hostname': 'str', + 'migrate-set-speed': 'int', + 'migrate-set-downtime': 'int'} } ## # @query-migrate-parameters #@@ -1804,34 +1823,6 @@ { 'command': 'migrate_cancel' } ## -# @migrate_set_downtime -# -# Set maximum tolerated downtime for migration. -# -# @value: maximum downtime in seconds -# -# Returns: nothing on success -# -# Since: 0.14.0 -## -{ 'command': 'migrate_set_downtime', 'data': {'value': 'number'} } - -## -# @migrate_set_speed -# -# Set maximum speed for migration. -# -# @value: maximum speed in bytes. -# -# Returns: nothing on success -# -# Notes: A value lesser than zero will be automatically round up to zero. -# -# Since: 0.14.0 -## -{ 'command': 'migrate_set_speed', 'data': {'value': 'int'} } - -## # @migrate-set-cache-size # # Set XBZRLE cache sizeqmp-commands.hx +4
-47@@ -784,52 +784,6 @@ Example: EQMP { - .name = "migrate_set_speed", - .args_type = "value:o", - .mhandler.cmd_new = qmp_marshal_migrate_set_speed, - }, - -SQMP -migrate_set_speed ------------------ - -Set maximum speed for migrations. - -Arguments: - -- "value": maximum speed, in bytes per second (json-int) - -Example: - --> { "execute": "migrate_set_speed", "arguments": { "value": 1024 } } -<- { "return": {} } - -EQMP - - { - .name = "migrate_set_downtime", - .args_type = "value:T", - .mhandler.cmd_new = qmp_marshal_migrate_set_downtime, - }, - -SQMP -migrate_set_downtime --------------------- - -Set maximum tolerated downtime (in seconds) for migrations. - -Arguments: - -- "value": maximum downtime (json-number) - -Example: - --> { "execute": "migrate_set_downtime", "arguments": { "value": 0.1 } } -<- { "return": {} } - -EQMP - - { .name = "client_migrate_info", .args_type = "protocol:s,hostname:s,port:i?,tls-port:i?,cert-subject:s?", .params = "protocol hostname port tls-port cert-subject",@@ -3790,6 +3744,9 @@ Set migration parameters throttled for auto-converge (json-int) - "cpu-throttle-increment": set throttle increasing percentage for auto-converge (json-int) +- "migrate-set-speed": set maximum speed for migrations (json-int) +- "migrate-set-downtime": set maximum tolerated downtime (in seconds) for + migrations (json-number) Arguments:@@ -3803,7 +3760,7 @@ EQMP { .name = "migrate-set-parameters", .args_type = - "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?", + "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?,migrate-set-speed:i?,migrate-set-downtime:T?", .mhandler.cmd_new = qmp_marshal_migrate_set_parameters, }, SQMP
Quoted 8 lines · Paolo Bonzini
Quoted 5 lines · Ashijeet Acharya
Include
migrate_set_speedandmigrate_set_downtimeinsidemigrate_set_parametersrespectively for setting maximum migration speed and expected downtime parameters. Also add the query part for both in qmp and hmp qemu control interfaces.
Quoted 6 lines
Quoted 1 line
Signed-off-by Ashijeet Acharya <[email protected]>You cannot break backwards compatibility for everyone that is using those commands, sorry.
Paolo
So should I keep the old commands too and add the new ones anyway for the query part?
The old ones will also be modified for query. So we will have compatibility as well as the
query.
Ashijeet
Quoted 477 lines
Quoted 477 lines
--- hmp-commands.hx | 35 +++------------------------- hmp.c | 40 +++++++++++++++++++++----------- include/migration/migration.h | 5 +++- migration/migration.c | 34 ++++++++++++++++++++++----- qapi-schema.json | 53 ++++++++++++++++++------------------------- qmp-commands.hx | 51 ++++------------------------------------- 6 files changed, 88 insertions(+), 130 deletions(-)hmp-commands.hx +3
-32@@ -964,35 +964,6 @@ Set cache size to @var{value} (in bytes) for xbzrle migrations. ETEXI { - .name = "migrate_set_speed", - .args_type = "value:o", - .params = "value", - .help = "set maximum speed (in bytes) for migrations. " - "Defaults to MB if no size suffix is specified, ie. B/K/M/G/T", - .mhandler.cmd = hmp_migrate_set_speed, - }, - -STEXI -@item migrate_set_speed @var{value} -@findex migrate_set_speed -Set maximum speed to @var{value} (in bytes) for migrations. -ETEXI - - { - .name = "migrate_set_downtime", - .args_type = "value:T", - .params = "value", - .help = "set maximum tolerated downtime (in seconds) for migrations", - .mhandler.cmd = hmp_migrate_set_downtime, - }, - -STEXI -@item migrate_set_downtime @var{second} -@findex migrate_set_downtime -Set maximum tolerated downtime (in seconds) for migration. -ETEXI - - { .name = "migrate_set_capability", .args_type = "capability:s,state:b", .params = "capability state",@@ -1009,15 +980,15 @@ ETEXI { .name = "migrate_set_parameter", - .args_type = "parameter:s,value:s", - .params = "parameter value", + .args_type = "parameter:s,value:s?,speed:o?", + .params = "parameter value speed", .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} +@item migrate_set_parameter @var{parameter} @var{value} @var{speed} @findex migrate_set_parameter Set the parameter @var{parameter} for migration. ETEXIhmp.c +27
-13@@ -304,6 +304,12 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)monitor_printf (mon," %s: '%s'" , MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_HOSTNAME ], params->tls_hostname ? :"" ); +monitor_printf (mon," %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_MIGRATE_SET_SPEED ], + params->migrate_set_speed); +monitor_printf (mon," %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_MIGRATE_SET_DOWNTIME ], + params->migrate_set_downtime);monitor_printf (mon,"\n" ); }@@ -1193,12 +1199,6 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err); } -void hmp_migrate_set_downtime (Monitor *mon,const QDict *qdict) -{ -double value =qdict_get_double (qdict,"value" ); -qmp_migrate_set_downtime (value,NULL ); -} -void hmp_migrate_set_cache_size (Monitor *mon,const QDict *qdict) {int64_t value =qdict_get_int (qdict,"value" );@@ -1211,12 +1211,6 @@ void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict) } } -void hmp_migrate_set_speed (Monitor *mon,const QDict *qdict) -{ -int64_t value =qdict_get_int (qdict,"value" ); -qmp_migrate_set_speed (value,NULL ); -} -void hmp_migrate_set_capability (Monitor *mon,const QDict *qdict) {const char *cap =qdict_get_str (qdict,"capability" );@@ -1250,8 +1244,11 @@ 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" ); -const char *valuestr =qdict_get_str (qdict,"value" ); +const char *valuestr =qdict_get_try_str (qdict,"value" ); +int64_t valuespeed =0 ; +double valuedowntime =0 ;long valueint =0 ; +char *endp;Error *err =NULL ;bool has_compress_level = false;bool has_compress_threads = false;@@ -1260,6 +1257,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)bool has_cpu_throttle_increment = false;bool has_tls_creds = false;bool has_tls_hostname = false; +bool has_migrate_set_speed = false; +bool has_migrate_set_downtime = false;bool use_int_value = false;int i;@@ -1291,6 +1290,19 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)case MIGRATION_PARAMETER_TLS_HOSTNAME : has_tls_hostname = true;break ; +case MIGRATION_PARAMETER_MIGRATE_SET_SPEED : + has_migrate_set_speed = true; + valuespeed =qdict_get_int (qdict,"speed" ); +break ; +case MIGRATION_PARAMETER_MIGRATE_SET_DOWNTIME : + has_migrate_set_downtime = true; + valuedowntime =strtod (valuestr, &endp); +if (valuestr == endp) { +error_setg (&err,"Unable to parse '%s' as a number" , + valuestr); + goto cleanup; + } +break ; }if (use_int_value) {@@ -1308,6 +1320,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) has_cpu_throttle_increment, valueint, has_tls_creds, valuestr, has_tls_hostname, valuestr, + has_migrate_set_speed, valuespeed, + has_migrate_set_downtime, valuedowntime, &err);break ; }include/migration/migration.h +4
-1@@ -129,7 +129,6 @@ struct MigrationSrcPageRequest {struct MigrationState { -int64_t bandwidth_limit;size_t bytes_xfer;size_t xfer_limit;QemuThread thread;@@ -205,6 +204,10 @@ void migration_tls_channel_connect(MigrationState *s,uint64_t migrate_max_downtime (void ); +void migrate_set_preferred_speed (int64_t value,Error **errp); + +void migrate_set_expected_downtime (double value,Error **errp); +void exec_start_incoming_migration (const char *host_port,Error **errp);void exec_start_outgoing_migration (MigrationState *s,const char *host_port,Error **errp);migration/migration.c +28
-6@@ -44,6 +44,9 @@#define BUFFER_DELAY 100#define XFER_LIMIT_RATIO (1000 / BUFFER_DELAY) +/* Amount of nanoseconds we are willing to wait for migration to be down. */ +#define DEFAULT_MIGRATE_SET_DOWNTIME 300000000 +/* Default compression thread count */ #define DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT 8/* Default decompression thread count, usually decompression is at @@ -80,7 +83,6 @@ MigrationState *migrate_get_current(void)static bool once;static MigrationState current_migration = { .state =MIGRATION_STATUS_NONE , - .bandwidth_limit =MAX_THROTTLE , .xbzrle_cache_size =DEFAULT_MIGRATE_CACHE_SIZE , .mbps =-1 , .parameters = {@@ -89,6 +91,8 @@ MigrationState *migrate_get_current(void) .decompress_threads = DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT, .cpu_throttle_initial = DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL, .cpu_throttle_increment = DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT, + .migrate_set_speed = MAX_THROTTLE, + .migrate_set_downtime = DEFAULT_MIGRATE_SET_DOWNTIME, }, };@@ -566,6 +570,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) params->cpu_throttle_increment = s->parameters.cpu_throttle_increment; params->tls_creds =g_strdup (s->parameters.tls_creds); params->tls_hostname =g_strdup (s->parameters.tls_hostname); + params->migrate_set_speed = s->parameters.migrate_set_speed; + params->migrate_set_downtime = s->parameters.migrate_set_downtime;return params; }@@ -773,6 +779,10 @@ void qmp_migrate_set_parameters(bool has_compress_level,const char *tls_creds, bool has_tls_hostname, const char *tls_hostname, + bool has_migrate_set_speed, + int64_t migrate_set_speed, + bool has_migrate_set_downtime, + double migrate_set_downtime, Error **errp) { MigrationState *s = migrate_get_current();@@ -832,6 +842,12 @@ void qmp_migrate_set_parameters(bool has_compress_level,g_free (s->parameters.tls_hostname); s->parameters.tls_hostname =g_strdup (tls_hostname); } +if (has_migrate_set_speed) { +migrate_set_preferred_speed (migrate_set_speed,NULL ); + } +if (has_migrate_set_downtime) { +migrate_set_expected_downtime (migrate_set_downtime,NULL ); + } }@@ -1163,7 +1179,7 @@ int64_t qmp_query_migrate_cache_size(Error **errp)return migrate_xbzrle_cache_size (); } -void qmp_migrate_set_speed (int64_t value,Error **errp) +void migrate_set_preferred_speed (int64_t value,Error **errp) {MigrationState *s;@@ -1175,18 +1191,24 @@ void qmp_migrate_set_speed(int64_t value, Error **errp) } s =migrate_get_current (); - s->bandwidth_limit = value; + s->parameters.migrate_set_speed = value;if (s->to_dst_file) {qemu_file_set_rate_limit (s->to_dst_file, - s->bandwidth_limit /XFER_LIMIT_RATIO ); + s->parameters.migrate_set_speed /XFER_LIMIT_RATIO ); } } -void qmp_migrate_set_downtime (double value,Error **errp) +void migrate_set_expected_downtime (double value,Error **errp) { +MigrationState *s; + value *=1e9 ; value =MAX (0 ,MIN (UINT64_MAX , value)); + + s =migrate_get_current (); + max_downtime = (uint64_t )value; + s->parameters.migrate_set_downtime = max_downtime; }bool migrate_postcopy_ram (void )@@ -1858,7 +1880,7 @@ void migrate_fd_connect(MigrationState *s)qemu_file_set_blocking (s->to_dst_file, true);qemu_file_set_rate_limit (s->to_dst_file, - s->bandwidth_limit /XFER_LIMIT_RATIO ); + s->parameters.migrate_set_speed /XFER_LIMIT_RATIO );/* Notify before starting migration thread */ notifier_list_notify (&migration_state_notifiers, s);qapi-schema.json +22
-31@@ -637,12 +637,17 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @migrate-set-speed: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. +# +# @migrate-set-downtime: set maximum tolerated downtime for migration. # Since: 2.4 ## { 'enum': 'MigrationParameter', 'data': ['compress-level', 'compress-threads', 'decompress-threads', 'cpu-throttle-initial', 'cpu-throttle-increment', - 'tls-creds', 'tls-hostname'] } + 'tls-creds', 'tls-hostname', 'migrate-set-speed', + 'migrate-set-downtime'] } # # @migrate-set-parameters@@ -678,6 +683,11 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @migrate-set-speed: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. +# +# @migrate-set-downtime: set maximum tolerated downtime for migration. +# # Since: 2.4 ## { 'command': 'migrate-set-parameters',@@ -687,7 +697,9 @@ '*cpu-throttle-initial': 'int', '*cpu-throttle-increment': 'int', '*tls-creds': 'str', - '*tls-hostname': 'str'} } + '*tls-hostname': 'str', + '*migrate-set-speed': 'int', + '*migrate-set-downtime': 'number'} } # # @MigrationParameters@@ -721,6 +733,11 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @migrate-set-speed: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. +# +# @migrate-set-downtime: set maximum tolerated downtime for migration. +# # Since: 2.4 ## { 'struct': 'MigrationParameters',@@ -730,7 +747,9 @@ 'cpu-throttle-initial': 'int', 'cpu-throttle-increment': 'int', 'tls-creds': 'str', - 'tls-hostname': 'str'} } + 'tls-hostname': 'str', + 'migrate-set-speed': 'int', + 'migrate-set-downtime': 'int'} } ## # @query-migrate-parameters #@@ -1804,34 +1823,6 @@ { 'command': 'migrate_cancel' } ## -# @migrate_set_downtime -# -# Set maximum tolerated downtime for migration. -# -# @value: maximum downtime in seconds -# -# Returns: nothing on success -# -# Since: 0.14.0 -## -{ 'command': 'migrate_set_downtime', 'data': {'value': 'number'} } - -## -# @migrate_set_speed -# -# Set maximum speed for migration. -# -# @value: maximum speed in bytes. -# -# Returns: nothing on success -# -# Notes: A value lesser than zero will be automatically round up to zero. -# -# Since: 0.14.0 -## -{ 'command': 'migrate_set_speed', 'data': {'value': 'int'} } - -## # @migrate-set-cache-size # # Set XBZRLE cache sizeqmp-commands.hx +4
-47@@ -784,52 +784,6 @@ Example: EQMP { - .name = "migrate_set_speed", - .args_type = "value:o", - .mhandler.cmd_new = qmp_marshal_migrate_set_speed, - }, - -SQMP -migrate_set_speed ------------------ - -Set maximum speed for migrations. - -Arguments: - -- "value": maximum speed, in bytes per second (json-int) - -Example: - --> { "execute": "migrate_set_speed", "arguments": { "value": 1024 } } -<- { "return": {} } - -EQMP - - { - .name = "migrate_set_downtime", - .args_type = "value:T", - .mhandler.cmd_new = qmp_marshal_migrate_set_downtime, - }, - -SQMP -migrate_set_downtime --------------------- - -Set maximum tolerated downtime (in seconds) for migrations. - -Arguments: - -- "value": maximum downtime (json-number) - -Example: - --> { "execute": "migrate_set_downtime", "arguments": { "value": 0.1 } } -<- { "return": {} } - -EQMP - - { .name = "client_migrate_info", .args_type = "protocol:s,hostname:s,port:i?,tls-port:i?,cert-subject:s?", .params = "protocol hostname port tls-port cert-subject",@@ -3790,6 +3744,9 @@ Set migration parameters throttled for auto-converge (json-int) - "cpu-throttle-increment": set throttle increasing percentage for auto-converge (json-int) +- "migrate-set-speed": set maximum speed for migrations (json-int) +- "migrate-set-downtime": set maximum tolerated downtime (in seconds) for + migrations (json-number) Arguments:@@ -3803,7 +3760,7 @@ EQMP { .name = "migrate-set-parameters", .args_type = - "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?", + "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?,migrate-set-speed:i?,migrate-set-downtime:T?", .mhandler.cmd_new = qmp_marshal_migrate_set_parameters, }, SQMP
Quoted 5 lines · Ashijeet Acharya
Quoted 5 lines
Quoted 5 lines
Include
migrate_set_speedandmigrate_set_downtimeinsidemigrate_set_parametersrespectively for setting maximum migration speed and expected downtime parameters. Also add the query part for both in qmp and hmp qemu control interfaces.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Ashijeet Acharya <[email protected]>You cannot break backwards compatibility for everyone that is using those commands, sorry.
So should I keep the old commands too and add the new ones anyway for the query part?
You do not need query for the old ones, but you can indeed add support for speed and downtime in migrate-set-parameters and MigrationParameters.
(Note: I'm not a migration maintainer, so they might say something else).
Paolo
Quoted 3 lines
The old ones will also be modified for query. So we will have compatibility as well as the
query.
Quoted 10 lines · Paolo Bonzini
Quoted 7 lines · Ashijeet Acharya
Quoted 7 lines
Quoted 6 lines
Include
migrate_set_speedandmigrate_set_downtimeinsidemigrate_set_parametersrespectively for setting maximum migration speed and expected downtime parameters. Also add the query part for both in qmp and hmp qemu control interfaces.Signed-off-by Ashijeet Acharya <[email protected]>
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
You cannot break backwards compatibility for everyone that is using those commands, sorry.
So should I keep the old commands too and add the new ones anyway for the query part?
You do not need query for the old ones, but you can indeed add support for speed and downtime in migrate-set-parameters and MigrationParameters.
Right. So I will add the old-commands back and just add support for the new ones under migration-set-parameters along with the query.
Quoted 1 line
(Note: I'm not a migration maintainer, so they might say something else).
Okay. I will wait for their views too.
Ashijeet
Quoted 6 lines
Paolo
Quoted 3 lines
The old ones will also be modified for query. So we will have compatibility as well as the
query.
Quoted 14 lines · * Ashijeet Acharya ([email protected]) wrote:
Quoted 13 lines · Paolo Bonzini
Quoted 10 lines · Ashijeet Acharya
Quoted 9 lines
Quoted 6 lines
Include
migrate_set_speedandmigrate_set_downtimeinsidemigrate_set_parametersrespectively for setting maximum migration speed and expected downtime parameters. Also add the query part for both in qmp and hmp qemu control interfaces.Signed-off-by Ashijeet Acharya <[email protected]>You cannot break backwards compatibility for everyone that is using those commands, sorry.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
So should I keep the old commands too and add the new ones anyway for the query part?
You do not need query for the old ones, but you can indeed add support for speed and downtime in migrate-set-parameters and MigrationParameters.
Right. So I will add the old-commands back and just add support for the new ones under migration-set-parameters along with the query.
Yes add them to both migrate_set_parameters and query_migrate_parameters and the hmp equivalents; but don't remove the old functions; just make them simple wrappers to call the migrate_set_parameters etc. Add a comment on them like 'kept for compatibility'.
Dave
Quoted 11 lines
Quoted 1 line
(Note: I'm not a migration maintainer, so they might say something else).
Okay. I will wait for their views too.
Ashijeet
Quoted 6 lines
Paolo
Quoted 3 lines
The old ones will also be modified for query. So we will have compatibility as well as the
query.
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH v2 1/1 Move migrate_set_speed and migrate_set_downtime into migrate_set_parameter
Include migrate_set_speed and migrate_set_downtime inside migrate_set_parameters for setting maximum migration speed and expected downtime parameters respectively. Also update the query part for both in qmp and hmp qemu control interfaces.
--- hmp-commands.hx | 6 +++--- hmp.c | 30 +++++++++++++++++++++++++++++- include/migration/migration.h | 1 - migration/migration.c | 30 ++++++++++++++++++++++++++---- qapi-schema.json | 26 +++++++++++++++++++++++--- qmp-commands.hx | 13 ++++++++++--- 6 files changed, 91 insertions(+), 15 deletions(-)
hmp-commands.hx +3 -3
@@ -1009,15 +1009,15 @@ ETEXI { .name = "migrate_set_parameter", - .args_type = "parameter:s,value:s", - .params = "parameter value", + .args_type = "parameter:s,value:s?,speed:o?", + .params = "parameter value speed", .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} +@item migrate_set_parameter @var{parameter} @var{value} @var{speed} @findex migrate_set_parameter Set the parameter @var{parameter} for migration. ETEXI
hmp.c +29 -1
@@ -304,6 +304,12 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)monitor_printf (mon," %s: '%s'" , MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_HOSTNAME ], params->tls_hostname ? :"" ); +monitor_printf (mon," %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_MIGRATE_SET_SPEED ], + params->migrate_set_speed); +monitor_printf (mon," %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_MIGRATE_SET_DOWNTIME ], + params->migrate_set_downtime);monitor_printf (mon,"\n" ); }
@@ -1193,6 +1199,7 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err); } +/* Kept for old-commands compatibility */ void hmp_migrate_set_downtime (Monitor *mon,const QDict *qdict) {double value =qdict_get_double (qdict,"value" );
@@ -1211,6 +1218,7 @@ void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict) } } +/* Kept for old-commands compatibility */ void hmp_migrate_set_speed (Monitor *mon,const QDict *qdict) {int64_t value =qdict_get_int (qdict,"value" );
@@ -1250,8 +1258,11 @@ 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" ); -const char *valuestr =qdict_get_str (qdict,"value" ); +const char *valuestr =qdict_get_try_str (qdict,"value" ); +int64_t valuespeed =0 ; +double valuedowntime =0 ;long valueint =0 ; +char *endp;Error *err =NULL ;bool has_compress_level = false;bool has_compress_threads = false;
@@ -1260,6 +1271,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)bool has_cpu_throttle_increment = false;bool has_tls_creds = false;bool has_tls_hostname = false; +bool has_migrate_set_speed = false; +bool has_migrate_set_downtime = false;bool use_int_value = false;int i;
@@ -1291,6 +1304,19 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)case MIGRATION_PARAMETER_TLS_HOSTNAME : has_tls_hostname = true;break ; +case MIGRATION_PARAMETER_MIGRATE_SET_SPEED : + has_migrate_set_speed = true; + valuespeed =qdict_get_int (qdict,"speed" ); +break ; +case MIGRATION_PARAMETER_MIGRATE_SET_DOWNTIME : + has_migrate_set_downtime = true; + valuedowntime =strtod (valuestr, &endp); +if (valuestr == endp) { +error_setg (&err,"Unable to parse '%s' as a number" , + valuestr); + goto cleanup; + } +break ; }if (use_int_value) {
@@ -1308,6 +1334,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) has_cpu_throttle_increment, valueint, has_tls_creds, valuestr, has_tls_hostname, valuestr, + has_migrate_set_speed, valuespeed, + has_migrate_set_downtime, valuedowntime, &err);break ; }
include/migration/migration.h +0 -1
@@ -129,7 +129,6 @@ struct MigrationSrcPageRequest {struct MigrationState { -int64_t bandwidth_limit;size_t bytes_xfer;size_t xfer_limit;QemuThread thread;
migration/migration.c +26 -4
@@ -44,6 +44,9 @@#define BUFFER_DELAY 100#define XFER_LIMIT_RATIO (1000 / BUFFER_DELAY) +/* Amount of nanoseconds we are willing to wait for migration to be down. */ +#define DEFAULT_MIGRATE_SET_DOWNTIME 300000000 +/* Default compression thread count */ #define DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT 8/* Default decompression thread count, usually decompression is at
@@ -80,7 +83,6 @@ MigrationState *migrate_get_current(void)static bool once;static MigrationState current_migration = { .state =MIGRATION_STATUS_NONE , - .bandwidth_limit =MAX_THROTTLE , .xbzrle_cache_size =DEFAULT_MIGRATE_CACHE_SIZE , .mbps =-1 , .parameters = {
@@ -89,6 +91,8 @@ MigrationState *migrate_get_current(void) .decompress_threads = DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT, .cpu_throttle_initial = DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL, .cpu_throttle_increment = DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT, + .migrate_set_speed = MAX_THROTTLE, + .migrate_set_downtime = DEFAULT_MIGRATE_SET_DOWNTIME, }, };
@@ -566,6 +570,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) params->cpu_throttle_increment = s->parameters.cpu_throttle_increment; params->tls_creds =g_strdup (s->parameters.tls_creds); params->tls_hostname =g_strdup (s->parameters.tls_hostname); + params->migrate_set_speed = s->parameters.migrate_set_speed; + params->migrate_set_downtime = s->parameters.migrate_set_downtime;return params; }
@@ -773,6 +779,10 @@ void qmp_migrate_set_parameters(bool has_compress_level,const char *tls_creds, bool has_tls_hostname, const char *tls_hostname, + bool has_migrate_set_speed, + int64_t migrate_set_speed, + bool has_migrate_set_downtime, + double migrate_set_downtime, Error **errp) { MigrationState *s = migrate_get_current();
@@ -832,6 +842,12 @@ void qmp_migrate_set_parameters(bool has_compress_level,g_free (s->parameters.tls_hostname); s->parameters.tls_hostname =g_strdup (tls_hostname); } +if (has_migrate_set_speed) { +qmp_migrate_set_speed (migrate_set_speed,NULL ); + } +if (has_migrate_set_downtime) { +qmp_migrate_set_downtime (migrate_set_downtime,NULL ); + } }
@@ -1175,18 +1191,24 @@ void qmp_migrate_set_speed(int64_t value, Error **errp) } s =migrate_get_current (); - s->bandwidth_limit = value; + s->parameters.migrate_set_speed = value;if (s->to_dst_file) {qemu_file_set_rate_limit (s->to_dst_file, - s->bandwidth_limit /XFER_LIMIT_RATIO ); + s->parameters.migrate_set_speed /XFER_LIMIT_RATIO ); } }void qmp_migrate_set_downtime (double value,Error **errp) { +MigrationState *s; + value *=1e9 ; value =MAX (0 ,MIN (UINT64_MAX , value)); + + s =migrate_get_current (); + max_downtime = (uint64_t )value; + s->parameters.migrate_set_downtime = max_downtime; }bool migrate_postcopy_ram (void )
@@ -1858,7 +1880,7 @@ void migrate_fd_connect(MigrationState *s)qemu_file_set_blocking (s->to_dst_file, true);qemu_file_set_rate_limit (s->to_dst_file, - s->bandwidth_limit /XFER_LIMIT_RATIO ); + s->parameters.migrate_set_speed /XFER_LIMIT_RATIO );/* Notify before starting migration thread */ notifier_list_notify (&migration_state_notifiers, s);
qapi-schema.json +23 -3
@@ -637,12 +637,18 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @migrate-set-speed: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. +# +# @migrate-set-downtime: set maximum tolerated downtime for migration. +# # Since: 2.4 ## { 'enum': 'MigrationParameter', 'data': ['compress-level', 'compress-threads', 'decompress-threads', 'cpu-throttle-initial', 'cpu-throttle-increment', - 'tls-creds', 'tls-hostname'] } + 'tls-creds', 'tls-hostname', 'migrate-set-speed', + 'migrate-set-downtime'] } # # @migrate-set-parameters
@@ -678,6 +684,11 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @migrate-set-speed: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. +# +# @migrate-set-downtime: set maximum tolerated downtime for migration. +# # Since: 2.4 ## { 'command': 'migrate-set-parameters',
@@ -687,7 +698,9 @@ '*cpu-throttle-initial': 'int', '*cpu-throttle-increment': 'int', '*tls-creds': 'str', - '*tls-hostname': 'str'} } + '*tls-hostname': 'str', + '*migrate-set-speed': 'int', + '*migrate-set-downtime': 'number'} } # # @MigrationParameters
@@ -721,6 +734,11 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @migrate-set-speed: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. +# +# @migrate-set-downtime: set maximum tolerated downtime for migration. +# # Since: 2.4 ## { 'struct': 'MigrationParameters',
@@ -730,7 +748,9 @@ 'cpu-throttle-initial': 'int', 'cpu-throttle-increment': 'int', 'tls-creds': 'str', - 'tls-hostname': 'str'} } + 'tls-hostname': 'str', + 'migrate-set-speed': 'int', + 'migrate-set-downtime': 'int'} } ## # @query-migrate-parameters #
qmp-commands.hx +10 -3
@@ -3790,7 +3790,9 @@ Set migration parameters throttled for auto-converge (json-int) - "cpu-throttle-increment": set throttle increasing percentage for auto-converge (json-int) - +- "migrate-set-speed": set maximum speed for migrations (json-octets) +- "migrate-set-downtime": set maximum tolerated downtime (in seconds) for + migrations (json-number) Arguments: Example:
@@ -3803,7 +3805,7 @@ EQMP { .name = "migrate-set-parameters", .args_type = - "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?", + "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?,migrate-set-speed:o?,migrate-set-downtime:T?", .mhandler.cmd_new = qmp_marshal_migrate_set_parameters, }, SQMP
@@ -3820,6 +3822,9 @@ Query current migration parameters throttled (json-int) - "cpu-throttle-increment" : throttle increasing percentage for auto-converge (json-int) + - "migrate-set-speed" : maximium migration speed (json-octets) + - "migration-set-downtime" : maximum tolerated downtime of migration + (json-number) Arguments:
@@ -3832,7 +3837,9 @@ Example: "cpu-throttle-increment": 10, "compress-threads": 8, "compress-level": 1, - "cpu-throttle-initial": 20 + "cpu-throttle-initial": 20, + "migration-set-speed": 33554432, + "migration-set-downtime": 300000000 } }
Signature · 1 line
2.6.2
Quoted 22 lines · Ashijeet Acharya
Include
migrate_set_speedandmigrate_set_downtimeinsidemigrate_set_parametersfor setting maximum migration speed and expected downtime parameters respectively. Also update the query part for both in qmp and hmp qemu control interfaces.Signed-off-by Ashijeet Acharya <[email protected]>--- hmp-commands.hx | 6 +++--- hmp.c | 30 +++++++++++++++++++++++++++++- include/migration/migration.h | 1 - migration/migration.c | 30 ++++++++++++++++++++++++++---- qapi-schema.json | 26 +++++++++++++++++++++++--- qmp-commands.hx | 13 ++++++++++--- 6 files changed, 91 insertions(+), 15 deletions(-)hmp-commands.hx +0
-2@@ -1009,15 +1009,15 @@ ETEXI { .name = "migrate_set_parameter", - .args_type = "parameter:s,value:s", - .params = "parameter value",
hmp-commands.hx ETEXI · line 1020
Quoted 10 lines
hmp-commands.hx +3
-1+ .args_type = "parameter:s,value:s?,speed:o?", + .params = "parameter value speed", .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} +@item migrate_set_parameter @var{parameter} @var{value} @var{speed}
This is wrong, it should not use a third argument. migrate_set_parameter is just receiving a key/value pair.
Since value is a string, you can use qemu_strtosz in hmp_migrate_set_parameter to convert it to bytes and print an "invalid size" error if invalid.
Quoted 108 lines
hmp-commands.hx +0
-0@findex migrate_set_parameter Set the parameter @var{parameter} for migration. ETEXIhmp.c +35
-1@@ -304,6 +304,12 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)monitor_printf (mon," %s: '%s'" , MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_HOSTNAME ], params->tls_hostname ? :"" ); +monitor_printf (mon," %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_MIGRATE_SET_SPEED ], + params->migrate_set_speed); +monitor_printf (mon," %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_MIGRATE_SET_DOWNTIME ], + params->migrate_set_downtime);monitor_printf (mon,"\n" ); }@@ -1193,6 +1199,7 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err); } +/* Kept for old-commands compatibility */ void hmp_migrate_set_downtime (Monitor *mon,const QDict *qdict) {double value =qdict_get_double (qdict,"value" );@@ -1211,6 +1218,7 @@ void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict) } } +/* Kept for old-commands compatibility */ void hmp_migrate_set_speed (Monitor *mon,const QDict *qdict) {int64_t value =qdict_get_int (qdict,"value" );@@ -1250,8 +1258,11 @@ 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" ); -const char *valuestr =qdict_get_str (qdict,"value" ); +const char *valuestr =qdict_get_try_str (qdict,"value" ); +int64_t valuespeed =0 ; +double valuedowntime =0 ;long valueint =0 ; +char *endp;Error *err =NULL ;bool has_compress_level = false;bool has_compress_threads = false;@@ -1260,6 +1271,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)bool has_cpu_throttle_increment = false;bool has_tls_creds = false;bool has_tls_hostname = false; +bool has_migrate_set_speed = false; +bool has_migrate_set_downtime = false;bool use_int_value = false;int i;@@ -1291,6 +1304,19 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)case MIGRATION_PARAMETER_TLS_HOSTNAME : has_tls_hostname = true;break ; +case MIGRATION_PARAMETER_MIGRATE_SET_SPEED : + has_migrate_set_speed = true; + valuespeed =qdict_get_int (qdict,"speed" ); +break ; +case MIGRATION_PARAMETER_MIGRATE_SET_DOWNTIME : + has_migrate_set_downtime = true; + valuedowntime =strtod (valuestr, &endp); +if (valuestr == endp) { +error_setg (&err,"Unable to parse '%s' as a number" , + valuestr); + goto cleanup; + } +break ; }if (use_int_value) {@@ -89,6 +91,8 @@ MigrationState *migrate_get_current(void) .decompress_threads = DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT, .cpu_throttle_initial = DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL, .cpu_throttle_increment = DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT, + .migrate_set_speed = MAX_THROTTLE, + .migrate_set_downtime = DEFAULT_MIGRATE_SET_DOWNTIME, }, };@@ -566,6 +570,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) params->cpu_throttle_increment = s->parameters.cpu_throttle_increment; params->tls_creds =g_strdup (s->parameters.tls_creds); params->tls_hostname =g_strdup (s->parameters.tls_hostname); + params->migrate_set_speed = s->parameters.migrate_set_speed; + params->migrate_set_downtime = s->parameters.migrate_set_downtime;return params; }@@ -773,6 +779,10 @@ void qmp_migrate_set_parameters(bool has_compress_level,const char *tls_creds, bool has_tls_hostname, const char *tls_hostname, + bool has_migrate_set_speed, + int64_t migrate_set_speed, + bool has_migrate_set_downtime, + double migrate_set_downtime, Error **errp) { MigrationState *s = migrate_get_current();
hmp.c void qmp_migrate_set_parameters(bool has_compress_level, · line 850
Quoted 9 lines
hmp.c +6
-0@@ -832,6 +842,12 @@ void qmp_migrate_set_parameters(bool has_compress_level,g_free (s->parameters.tls_hostname); s->parameters.tls_hostname =g_strdup (tls_hostname); } +if (has_migrate_set_speed) { +qmp_migrate_set_speed (migrate_set_speed,NULL ); + } +if (has_migrate_set_downtime) { +qmp_migrate_set_downtime (migrate_set_downtime,NULL ); + }
This is backwards; qmp_migrate_set_speed and qmp_migrate_set_downtime should be implemented in terms of qmp_migrate_set_parameters, not the other way round.
Quoted 44 lines
hmp.c +9
-3}@@ -1175,18 +1191,24 @@ void qmp_migrate_set_speed(int64_t value, Error **errp) } s =migrate_get_current (); - s->bandwidth_limit = value; + s->parameters.migrate_set_speed = value;if (s->to_dst_file) {qemu_file_set_rate_limit (s->to_dst_file, - s->bandwidth_limit /XFER_LIMIT_RATIO ); + s->parameters.migrate_set_speed /XFER_LIMIT_RATIO ); } }void qmp_migrate_set_downtime (double value,Error **errp) { +MigrationState *s; + value *=1e9 ; value =MAX (0 ,MIN (UINT64_MAX , value)); + + s =migrate_get_current (); + max_downtime = (uint64_t )value; + s->parameters.migrate_set_downtime = max_downtime; }bool migrate_postcopy_ram (void )@@ -1858,7 +1880,7 @@ void migrate_fd_connect(MigrationState *s)qemu_file_set_blocking (s->to_dst_file, true);qemu_file_set_rate_limit (s->to_dst_file, - s->bandwidth_limit /XFER_LIMIT_RATIO ); + s->parameters.migrate_set_speed /XFER_LIMIT_RATIO );/* Notify before starting migration thread */ notifier_list_notify (&migration_state_notifiers, s);qapi-schema.json +0
-0
qapi-schema.json line 643
Quoted 7 lines
qapi-schema.json +4
-0@@ -637,12 +637,18 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @migrate-set-speed: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. +# +# @migrate-set-downtime: set maximum tolerated downtime for migration.
Please add "Since 2.8" to the documentation for the new members.
qapi-schema.json line 651
Quoted 9 lines
qapi-schema.json +3
-1+# # Since: 2.4 ## { 'enum': 'MigrationParameter', 'data': ['compress-level', 'compress-threads', 'decompress-threads', 'cpu-throttle-initial', 'cpu-throttle-increment', - 'tls-creds', 'tls-hostname'] } + 'tls-creds', 'tls-hostname', 'migrate-set-speed', + 'migrate-set-downtime'] }
MigrationParameter names are not verbs. It should be "downtime-limit" and "max-bandwidth", or something similar.
Quoted 16 lines
qapi-schema.json +5
-0# # @migrate-set-parameters@@ -678,6 +684,11 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @migrate-set-speed: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. +# +# @migrate-set-downtime: set maximum tolerated downtime for migration. +# # Since: 2.4 ## { 'command': 'migrate-set-parameters',
qapi-schema.json line 703
Quoted 7 lines
qapi-schema.json +3
-1@@ -687,7 +698,9 @@ '*cpu-throttle-initial': 'int', '*cpu-throttle-increment': 'int', '*tls-creds': 'str', - '*tls-hostname': 'str'} } + '*tls-hostname': 'str', + '*migrate-set-speed': 'int', + '*migrate-set-downtime': 'number'} }
Same here.
qapi-schema.json line 740
Quoted 11 lines
qapi-schema.json +4
-0# # @MigrationParameters@@ -721,6 +734,11 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @migrate-set-speed: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. +# +# @migrate-set-downtime: set maximum tolerated downtime for migration.
Same here, note that these are "Since 2.8".
qapi-schema.json line 753
Quoted 12 lines
qapi-schema.json +4
-1+# # Since: 2.4 ## { 'struct': 'MigrationParameters',@@ -730,7 +748,9 @@ 'cpu-throttle-initial': 'int', 'cpu-throttle-increment': 'int', 'tls-creds': 'str', - 'tls-hostname': 'str'} } + 'tls-hostname': 'str', + 'migrate-set-speed': 'int', + 'migrate-set-downtime': 'int'} }
Same here about the names.
Quoted 8 lines
qapi-schema.json +0
-0## # @query-migrate-parameters #qmp-commands.hx +0
-0
qmp-commands.hx Set migration parameters · line 3795
Quoted 7 lines
qmp-commands.hx +3
-1@@ -3790,7 +3790,9 @@ Set migration parameters throttled for auto-converge (json-int) - "cpu-throttle-increment": set throttle increasing percentage for auto-converge (json-int) - +- "migrate-set-speed": set maximum speed for migrations (json-octets) +- "migrate-set-downtime": set maximum tolerated downtime (in seconds) for + migrations (json-number)
Same here about the names.
qmp-commands.hx EQMP · line 3808
Quoted 9 lines
qmp-commands.hx +1
-1Arguments: Example:@@ -3803,7 +3805,7 @@ EQMP { .name = "migrate-set-parameters", .args_type = - "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?", + "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?,migrate-set-speed:o?,migrate-set-downtime:T?",
Same here about the names. Also use "i" for QMP commands.
qmp-commands.hx Query current migration parameters · line 3827
Quoted 10 lines
qmp-commands.hx +3
-0.mhandler.cmd_new = qmp_marshal_migrate_set_parameters, }, SQMP@@ -3820,6 +3822,9 @@ Query current migration parameters throttled (json-int) - "cpu-throttle-increment" : throttle increasing percentage for auto-converge (json-int) + - "migrate-set-speed" : maximium migration speed (json-octets) + - "migration-set-downtime" : maximum tolerated downtime of migration + (json-number)
Same here about the names.
qmp-commands.hx Example: · line 3842
Quoted 10 lines
qmp-commands.hx +3
-1Arguments:@@ -3832,7 +3837,9 @@ Example: "cpu-throttle-increment": 10, "compress-threads": 8, "compress-level": 1, - "cpu-throttle-initial": 20 + "cpu-throttle-initial": 20, + "migration-set-speed": 33554432, + "migration-set-downtime": 300000000
Same here about the names.
Quoted 4 lines
qmp-commands.hx +0
-0} }
Quoted 39 lines · Paolo Bonzini
Quoted 22 lines · Ashijeet Acharya
Include
migrate_set_speedandmigrate_set_downtimeinsidemigrate_set_parametersfor setting maximum migration speed and expected downtime parameters respectively. Also update the query part for both in qmp and hmp qemu control interfaces.Signed-off-by Ashijeet Acharya <[email protected]>--- hmp-commands.hx | 6 +++--- hmp.c | 30 +++++++++++++++++++++++++++++- include/migration/migration.h | 1 - migration/migration.c | 30 ++++++++++++++++++++++++++---- qapi-schema.json | 26 +++++++++++++++++++++++--- qmp-commands.hx | 13 ++++++++++--- 6 files changed, 91 insertions(+), 15 deletions(-)hmp-commands.hx +0
-2@@ -1009,15 +1009,15 @@ ETEXI { .name = "migrate_set_parameter", - .args_type = "parameter:s,value:s", - .params = "parameter value",hmp-commands.hx ETEXI · line 1020
Quoted 10 lines
hmp-commands.hx +3
-1+ .args_type = "parameter:s,value:s?,speed:o?", + .params = "parameter value speed", .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} +@item migrate_set_parameter @var{parameter} @var{value} @var{speed}This is wrong, it should not use a third argument.
migrate_set_parameteris just receiving a key/value pair.
Quoted 3 lines
Since value is a string, you can use
qemu_strtoszinhmp_migrate_set_parameterto convert it to bytes and print an "invalid size" error if invalid.
Yeah. This one was bugging me but wasn't sure what the right logic was. Will make these changes asap.
Quoted 114 lines
Quoted 114 lines
hmp-commands.hx +0
-0@findex migrate_set_parameter Set the parameter @var{parameter} for migration. ETEXIhmp.c +37
-1@@ -304,6 +304,12 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)monitor_printf (mon," %s: '%s'" , MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_HOSTNAME ], params->tls_hostname ? :"" ); +monitor_printf (mon," %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_MIGRATE_SET_SPEED ], + params->migrate_set_speed); +monitor_printf (mon," %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_MIGRATE_SET_DOWNTIME ], + params->migrate_set_downtime);monitor_printf (mon,"\n" ); }@@ -1193,6 +1199,7 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err); } +/* Kept for old-commands compatibility */ void hmp_migrate_set_downtime (Monitor *mon,const QDict *qdict) {double value =qdict_get_double (qdict,"value" );@@ -1211,6 +1218,7 @@ void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict) } } +/* Kept for old-commands compatibility */ void hmp_migrate_set_speed (Monitor *mon,const QDict *qdict) {int64_t value =qdict_get_int (qdict,"value" );@@ -1250,8 +1258,11 @@ 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" ); -const char *valuestr =qdict_get_str (qdict,"value" ); +const char *valuestr =qdict_get_try_str (qdict,"value" ); +int64_t valuespeed =0 ; +double valuedowntime =0 ;long valueint =0 ; +char *endp;Error *err =NULL ;bool has_compress_level = false;bool has_compress_threads = false;@@ -1260,6 +1271,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)bool has_cpu_throttle_increment = false;bool has_tls_creds = false;bool has_tls_hostname = false; +bool has_migrate_set_speed = false; +bool has_migrate_set_downtime = false;bool use_int_value = false;int i;@@ -1291,6 +1304,19 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)case MIGRATION_PARAMETER_TLS_HOSTNAME : has_tls_hostname = true;break ; +case MIGRATION_PARAMETER_MIGRATE_SET_SPEED : + has_migrate_set_speed = true; + valuespeed =qdict_get_int (qdict,"speed" ); +break ; +case MIGRATION_PARAMETER_MIGRATE_SET_DOWNTIME : + has_migrate_set_downtime = true; + valuedowntime =strtod (valuestr, &endp); +if (valuestr == endp) { +error_setg (&err,"Unable to parse '%s' as a number" , + valuestr); + goto cleanup; + } +break ; }if (use_int_value) {@@ -89,6 +91,8 @@ MigrationState *migrate_get_current(void) .decompress_threads = DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT, .cpu_throttle_initial = DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL, .cpu_throttle_increment = DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT, + .migrate_set_speed = MAX_THROTTLE, + .migrate_set_downtime = DEFAULT_MIGRATE_SET_DOWNTIME, }, };@@ -566,6 +570,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) params->cpu_throttle_increment = s->parameters.cpu_throttle_increment; params->tls_creds =g_strdup (s->parameters.tls_creds); params->tls_hostname =g_strdup (s->parameters.tls_hostname); + params->migrate_set_speed = s->parameters.migrate_set_speed; + params->migrate_set_downtime = s->parameters.migrate_set_downtime;return params; }@@ -773,6 +779,10 @@ void qmp_migrate_set_parameters(bool has_compress_level,const char *tls_creds, bool has_tls_hostname, const char *tls_hostname, + bool has_migrate_set_speed, + int64_t migrate_set_speed, + bool has_migrate_set_downtime, + double migrate_set_downtime, Error **errp) { MigrationState *s = migrate_get_current();@@ -832,6 +842,12 @@ void qmp_migrate_set_parameters(bool has_compress_level,g_free (s->parameters.tls_hostname); s->parameters.tls_hostname =g_strdup (tls_hostname); } +if (has_migrate_set_speed) { +qmp_migrate_set_speed (migrate_set_speed,NULL );
Quoted 8 lines
hmp.c void qmp_migrate_set_parameters(bool has_compress_level, · line 850
Quoted 4 lines
hmp.c +4
-0+ } +if (has_migrate_set_downtime) { +qmp_migrate_set_downtime (migrate_set_downtime,NULL ); + }This is backwards;
qmp_migrate_set_speedandqmp_migrate_set_downtimeshould be implemented in terms ofqmp_migrate_set_parameters, not the other way round.
Okay. Got it!
Quoted 38 lines
Quoted 38 lines
hmp.c +9
-3}@@ -1175,18 +1191,24 @@ void qmp_migrate_set_speed(int64_t value, Error **errp) } s =migrate_get_current (); - s->bandwidth_limit = value; + s->parameters.migrate_set_speed = value;if (s->to_dst_file) {qemu_file_set_rate_limit (s->to_dst_file, - s->bandwidth_limit /XFER_LIMIT_RATIO ); + s->parameters.migrate_set_speed /XFER_LIMIT_RATIO ); } }void qmp_migrate_set_downtime (double value,Error **errp) { +MigrationState *s; + value *=1e9 ; value =MAX (0 ,MIN (UINT64_MAX , value)); + + s =migrate_get_current (); + max_downtime = (uint64_t )value; + s->parameters.migrate_set_downtime = max_downtime; }bool migrate_postcopy_ram (void )@@ -1858,7 +1880,7 @@ void migrate_fd_connect(MigrationState *s)qemu_file_set_blocking (s->to_dst_file, true);qemu_file_set_rate_limit (s->to_dst_file, - s->bandwidth_limit /XFER_LIMIT_RATIO ); + s->parameters.migrate_set_speed /XFER_LIMIT_RATIO );
Quoted 16 lines
Quoted 7 lines
hmp.c +0
-0/* Notify before starting migration thread */ notifier_list_notify (&migration_state_notifiers, s);qapi-schema.json +0
-0qapi-schema.json line 643
Quoted 7 lines
qapi-schema.json +4
-0@@ -637,12 +637,18 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @migrate-set-speed: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. +# +# @migrate-set-downtime: set maximum tolerated downtime for migration.Please add "Since 2.8" to the documentation for the new members.
Alright.
Quoted 11 lines
qapi-schema.json line 651
Quoted 10 lines
qapi-schema.json +3
-1+# # Since: 2.4 ## { 'enum': 'MigrationParameter', 'data': ['compress-level', 'compress-threads', 'decompress-threads', 'cpu-throttle-initial', 'cpu-throttle-increment', - 'tls-creds', 'tls-hostname'] } + 'tls-creds', 'tls-hostname', 'migrate-set-speed', + 'migrate-set-downtime'] }
Quoted 3 lines
MigrationParameter names are not verbs. It should be "downtime-limit" and "max-bandwidth", or something similar.
I will change the names then.
Quoted 115 lines
Quoted 16 lines
qapi-schema.json +5
-0# # @migrate-set-parameters@@ -678,6 +684,11 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @migrate-set-speed: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. +# +# @migrate-set-downtime: set maximum tolerated downtime for migration. +# # Since: 2.4 ## { 'command': 'migrate-set-parameters',qapi-schema.json line 703
Quoted 7 lines
qapi-schema.json +3
-1@@ -687,7 +698,9 @@ '*cpu-throttle-initial': 'int', '*cpu-throttle-increment': 'int', '*tls-creds': 'str', - '*tls-hostname': 'str'} } + '*tls-hostname': 'str', + '*migrate-set-speed': 'int', + '*migrate-set-downtime': 'number'} }Same here.
qapi-schema.json line 740
Quoted 11 lines
qapi-schema.json +4
-0# # @MigrationParameters@@ -721,6 +734,11 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @migrate-set-speed: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. +# +# @migrate-set-downtime: set maximum tolerated downtime for migration.Same here, note that these are "Since 2.8".
qapi-schema.json line 753
Quoted 12 lines
qapi-schema.json +4
-1+# # Since: 2.4 ## { 'struct': 'MigrationParameters',@@ -730,7 +748,9 @@ 'cpu-throttle-initial': 'int', 'cpu-throttle-increment': 'int', 'tls-creds': 'str', - 'tls-hostname': 'str'} } + 'tls-hostname': 'str', + 'migrate-set-speed': 'int', + 'migrate-set-downtime': 'int'} }Same here about the names.
Quoted 8 lines
qapi-schema.json +0
-0## # @query-migrate-parameters #qmp-commands.hx +0
-0qmp-commands.hx Set migration parameters · line 3795
Quoted 7 lines
qmp-commands.hx +3
-1@@ -3790,7 +3790,9 @@ Set migration parameters throttled for auto-converge (json-int) - "cpu-throttle-increment": set throttle increasing percentage for auto-converge (json-int) - +- "migrate-set-speed": set maximum speed for migrations (json-octets) +- "migrate-set-downtime": set maximum tolerated downtime (in seconds) for + migrations (json-number)Same here about the names.
qmp-commands.hx EQMP · line 3808
Quoted 9 lines
qmp-commands.hx +1
-1Arguments: Example:@@ -3803,7 +3805,7 @@ EQMP { .name = "migrate-set-parameters", .args_type = - "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?", + "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?,migrate-set-speed:o?,migrate-set-downtime:T?",Same here about the names. Also use "i" for QMP commands.
qmp-commands.hx Query current migration parameters · line 3827
Quoted 10 lines
qmp-commands.hx +3
-0.mhandler.cmd_new = qmp_marshal_migrate_set_parameters, }, SQMP@@ -3820,6 +3822,9 @@ Query current migration parameters throttled (json-int) - "cpu-throttle-increment" : throttle increasing percentage for auto-converge (json-int) + - "migrate-set-speed" : maximium migration speed (json-octets) + - "migration-set-downtime" : maximum tolerated downtime of migration + (json-number)Same here about the names.
qmp-commands.hx Example: · line 3842
Quoted 10 lines
qmp-commands.hx +3
-1Arguments:@@ -3832,7 +3837,9 @@ Example: "cpu-throttle-increment": 10, "compress-threads": 8, "compress-level": 1, - "cpu-throttle-initial": 20 + "cpu-throttle-initial": 20, + "migration-set-speed": 33554432, + "migration-set-downtime": 300000000Same here about the names.
Quoted 4 lines
qmp-commands.hx +0
-0} }
Quoted 7 lines · Ashijeet Acharya
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
migration/migration.c +6
-0+if (has_migrate_set_speed) { +qmp_migrate_set_speed (migrate_set_speed,NULL ); + } +if (has_migrate_set_downtime) { +qmp_migrate_set_downtime (migrate_set_downtime,NULL ); + }
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
This is backwards;
qmp_migrate_set_speedandqmp_migrate_set_downtimeshould be implemented in terms ofqmp_migrate_set_parameters, not the other way round.Okay. Got it!
Thinking more about it, it's even better to have two patches. One doing it this way (qmp_migrate_set_parameters calls the old functions), the second that reverses the direction.
Thanks!
Paolo
Quoted 14 lines · Paolo Bonzini
Quoted 11 lines · Ashijeet Acharya
Quoted 10 lines
Quoted 10 lines
Quoted 6 lines
migration/migration.c void qmp_migrate_set_parameters(bool has_compress_level, · line 850
Quoted 6 lines
migration/migration.c +6
-0+if (has_migrate_set_speed) { +qmp_migrate_set_speed (migrate_set_speed,NULL ); + } +if (has_migrate_set_downtime) { +qmp_migrate_set_downtime (migrate_set_downtime,NULL ); + }This is backwards;
qmp_migrate_set_speedandqmp_migrate_set_downtimeshould be implemented in terms ofqmp_migrate_set_parameters, not the other way round.
Quoted 6 lines
Quoted 1 line
Okay. Got it!
Thinking more about it, it's even better to have two patches. One doing it this way (
qmp_migrate_set_parameterscalls the old functions), the second that reverses the direction.
Fine, I will send both the versions soon.
Ashijeet
Quoted 3 lines
Thanks!
Paolo
Quoted 15 lines · Paolo Bonzini
Quoted 11 lines · Ashijeet Acharya
Include
migrate_set_speedandmigrate_set_downtimeinsidemigrate_set_parametersfor setting maximum migration speed and expected downtime parameters respectively. Also update the query part for both in qmp and hmp qemu control interfaces.Signed-off-by Ashijeet Acharya <[email protected]>--- hmp-commands.hx | 6 +++--- hmp.c | 30 +++++++++++++++++++++++++++++- include/migration/migration.h | 1 - migration/migration.c | 30 ++++++++++++++++++++++++++---- qapi-schema.json | 26 +++++++++++++++++++++++--- qmp-commands.hx | 13 ++++++++++--- 6 files changed, 91 insertions(+), 15 deletions(-)
Quoted 9 lines
qmp-commands.hx EQMP · line 3808
Quoted 7 lines
Example:
qmp-commands.hx +1
-1@@ -3803,7 +3805,7 @@ EQMP { .name = "migrate-set-parameters", .args_type = - "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?", + "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?,migrate-set-speed:o?,migrate-set-downtime:T?",Same here about the names. Also use "i" for QMP commands.
I think we will have to use "T" for downtime at-least otherwise you cant use float values for setting seconds like "0.2" for example. No issues using "i" with bandwidth though.
Ashijeet
Quoted 6 lines · Ashijeet Acharya
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
+ "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?,migrate-set-speed:o?,migrate-set-downtime:T?",
Same here about the names. Also use "i" for QMP commands.
I think we will have to use "T" for downtime at-least otherwise you cant use float values for setting seconds like "0.2" for example. No issues using "i" with bandwidth though.
Right, I should have mentioned that my remark was about the "o" (it caught my eye because of your change to hmp-commands.hx). Sorry!
Paolo
PATCH v3 1/1 Move migrate_set_speed and migrate_set_downtime into migrate_set_parameter
Include migrate_set_speed and migrate_set_downtime inside migrate_set_parameters for setting maximum migration speed and expected downtime parameters respectively. Also update the query part for both in qmp and hmp qemu control interfaces.
--- hmp.c | 33 +++++++++++++++++++++++++++++++++ include/migration/migration.h | 1 - migration/migration.c | 30 ++++++++++++++++++++++++++---- qapi-schema.json | 26 +++++++++++++++++++++++--- qmp-commands.hx | 13 ++++++++++--- 5 files changed, 92 insertions(+), 11 deletions(-)
hmp.c +33 -0
@@ -304,6 +304,12 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)monitor_printf (mon," %s: '%s'" , MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_HOSTNAME ], params->tls_hostname ? :"" ); +monitor_printf (mon," %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_MAX_BANDWIDTH ], + params->max_bandwidth); +monitor_printf (mon," %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_DOWNTIME_LIMIT ], + params->downtime_limit);monitor_printf (mon,"\n" ); }
@@ -1193,6 +1199,7 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err); } +/* Kept for old-commands compatibility */ void hmp_migrate_set_downtime (Monitor *mon,const QDict *qdict) {double value =qdict_get_double (qdict,"value" );
@@ -1211,6 +1218,7 @@ void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict) } } +/* Kept for old-commands compatibility */ void hmp_migrate_set_speed (Monitor *mon,const QDict *qdict) {int64_t value =qdict_get_int (qdict,"value" );
@@ -1251,7 +1259,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) {const char *param =qdict_get_str (qdict,"parameter" );const char *valuestr =qdict_get_str (qdict,"value" ); +int64_t valuebw =0 ; +double valuedowntime =0 ;long valueint =0 ; +char *endp;Error *err =NULL ;bool has_compress_level = false;bool has_compress_threads = false;
@@ -1260,6 +1271,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)bool has_cpu_throttle_increment = false;bool has_tls_creds = false;bool has_tls_hostname = false; +bool has_max_bandwidth = false; +bool has_downtime_limit = false;bool use_int_value = false;int i;
@@ -1291,6 +1304,24 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)case MIGRATION_PARAMETER_TLS_HOSTNAME : has_tls_hostname = true;break ; +case MIGRATION_PARAMETER_MAX_BANDWIDTH : + has_max_bandwidth = true; + valuebw =qemu_strtosz (valuestr, &endp); +if (valuebw <0 || (size_t )valuebw != valuebw || *endp !='\0' + || !is_power_of_2 (valuebw)) { +error_setg (&err,"Invalid size %s" , valuestr); + goto cleanup; + } +break ; +case MIGRATION_PARAMETER_DOWNTIME_LIMIT : + has_downtime_limit = true; + valuedowntime =strtod (valuestr, &endp); +if (valuestr == endp) { +error_setg (&err,"Unable to parse '%s' as a number" , + valuestr); + goto cleanup; + } +break ; }if (use_int_value) {
@@ -1308,6 +1339,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) has_cpu_throttle_increment, valueint, has_tls_creds, valuestr, has_tls_hostname, valuestr, + has_max_bandwidth, valuebw, + has_downtime_limit, valuedowntime, &err);break ; }
include/migration/migration.h +0 -1
@@ -129,7 +129,6 @@ struct MigrationSrcPageRequest {struct MigrationState { -int64_t bandwidth_limit;size_t bytes_xfer;size_t xfer_limit;QemuThread thread;
migration/migration.c +26 -4
@@ -44,6 +44,9 @@#define BUFFER_DELAY 100#define XFER_LIMIT_RATIO (1000 / BUFFER_DELAY) +/* Amount of nanoseconds we are willing to wait for migration to be down. */ +#define DEFAULT_MIGRATE_SET_DOWNTIME 300000000 +/* Default compression thread count */ #define DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT 8/* Default decompression thread count, usually decompression is at
@@ -80,7 +83,6 @@ MigrationState *migrate_get_current(void)static bool once;static MigrationState current_migration = { .state =MIGRATION_STATUS_NONE , - .bandwidth_limit =MAX_THROTTLE , .xbzrle_cache_size =DEFAULT_MIGRATE_CACHE_SIZE , .mbps =-1 , .parameters = {
@@ -89,6 +91,8 @@ MigrationState *migrate_get_current(void) .decompress_threads = DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT, .cpu_throttle_initial = DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL, .cpu_throttle_increment = DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT, + .max_bandwidth = MAX_THROTTLE, + .downtime_limit = DEFAULT_MIGRATE_SET_DOWNTIME, }, };
@@ -566,6 +570,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) params->cpu_throttle_increment = s->parameters.cpu_throttle_increment; params->tls_creds =g_strdup (s->parameters.tls_creds); params->tls_hostname =g_strdup (s->parameters.tls_hostname); + params->max_bandwidth = s->parameters.max_bandwidth; + params->downtime_limit = s->parameters.downtime_limit;return params; }
@@ -773,6 +779,10 @@ void qmp_migrate_set_parameters(bool has_compress_level,const char *tls_creds, bool has_tls_hostname, const char *tls_hostname, + bool has_max_bandwidth, + int64_t max_bandwidth, + bool has_downtime_limit, + double downtime_limit, Error **errp) { MigrationState *s = migrate_get_current();
@@ -832,6 +842,12 @@ void qmp_migrate_set_parameters(bool has_compress_level,g_free (s->parameters.tls_hostname); s->parameters.tls_hostname =g_strdup (tls_hostname); } +if (has_max_bandwidth) { +qmp_migrate_set_speed (max_bandwidth,NULL ); + } +if (has_downtime_limit) { +qmp_migrate_set_downtime (downtime_limit,NULL ); + } }
@@ -1175,18 +1191,24 @@ void qmp_migrate_set_speed(int64_t value, Error **errp) } s =migrate_get_current (); - s->bandwidth_limit = value; + s->parameters.max_bandwidth = value;if (s->to_dst_file) {qemu_file_set_rate_limit (s->to_dst_file, - s->bandwidth_limit /XFER_LIMIT_RATIO ); + s->parameters.max_bandwidth /XFER_LIMIT_RATIO ); } }void qmp_migrate_set_downtime (double value,Error **errp) { +MigrationState *s; + value *=1e9 ; value =MAX (0 ,MIN (UINT64_MAX , value)); + + s =migrate_get_current (); + max_downtime = (uint64_t )value; + s->parameters.downtime_limit = max_downtime; }bool migrate_postcopy_ram (void )
@@ -1858,7 +1880,7 @@ void migrate_fd_connect(MigrationState *s)qemu_file_set_blocking (s->to_dst_file, true);qemu_file_set_rate_limit (s->to_dst_file, - s->bandwidth_limit /XFER_LIMIT_RATIO ); + s->parameters.max_bandwidth /XFER_LIMIT_RATIO );/* Notify before starting migration thread */ notifier_list_notify (&migration_state_notifiers, s);
qapi-schema.json +23 -3
@@ -637,12 +637,18 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @max-bandwidth: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. Since 2.8) +# +# @downtime-limit: set maximum tolerated downtime for migration. Since 2.8) +# # Since: 2.4 ## { 'enum': 'MigrationParameter', 'data': ['compress-level', 'compress-threads', 'decompress-threads', 'cpu-throttle-initial', 'cpu-throttle-increment', - 'tls-creds', 'tls-hostname'] } + 'tls-creds', 'tls-hostname', 'max-bandwidth', + 'downtime-limit'] } # # @migrate-set-parameters
@@ -678,6 +684,11 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @max-bandwidth: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. Since 2.8) +# +# @downtime-limit: set maximum tolerated downtime for migration. Since 2.8) +# # Since: 2.4 ## { 'command': 'migrate-set-parameters',
@@ -687,7 +698,9 @@ '*cpu-throttle-initial': 'int', '*cpu-throttle-increment': 'int', '*tls-creds': 'str', - '*tls-hostname': 'str'} } + '*tls-hostname': 'str', + '*max-bandwidth': 'int', + '*downtime-limit': 'number'} } # # @MigrationParameters
@@ -721,6 +734,11 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @max-bandwidth: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. (Since 2.8) +# +# @downtime-limit: set maximum tolerated downtime for migration. Since 2.8) +# # Since: 2.4 ## { 'struct': 'MigrationParameters',
@@ -730,7 +748,9 @@ 'cpu-throttle-initial': 'int', 'cpu-throttle-increment': 'int', 'tls-creds': 'str', - 'tls-hostname': 'str'} } + 'tls-hostname': 'str', + 'max-bandwidth': 'int', + 'downtime-limit': 'int'} } ## # @query-migrate-parameters #
qmp-commands.hx +10 -3
@@ -3790,7 +3790,9 @@ Set migration parameters throttled for auto-converge (json-int) - "cpu-throttle-increment": set throttle increasing percentage for auto-converge (json-int) - +- "max-bandwidth": set maximum speed for migrations (json-int) +- "downtime-limit": set maximum tolerated downtime (in seconds) for + migrations (json-number) Arguments: Example:
@@ -3803,7 +3805,7 @@ EQMP { .name = "migrate-set-parameters", .args_type = - "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?", + "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?,max-bandwidth:i?,downtime-limit:T?", .mhandler.cmd_new = qmp_marshal_migrate_set_parameters, }, SQMP
@@ -3820,6 +3822,9 @@ Query current migration parameters throttled (json-int) - "cpu-throttle-increment" : throttle increasing percentage for auto-converge (json-int) + - "max-bandwidth" : maximium migration speed (json-int) + - "downtime-limit" : maximum tolerated downtime of migration + (json-int) Arguments:
@@ -3832,7 +3837,9 @@ Example: "cpu-throttle-increment": 10, "compress-threads": 8, "compress-level": 1, - "cpu-throttle-initial": 20 + "cpu-throttle-initial": 20, + "max-downtime": 33554432, + "downtime-limit": 300000000 } }
Signature · 1 line
2.6.2
Quoted 1 line · Ashijeet Acharya
Include
migrate_set_speedandmigrate_set_downtimeinsidemigrate_set_parametersfor setting maximum migration speed and expected downtime parameters respectively. Also update the query part for both in qmp and hmp qemu control interfaces.
Please put line breaks in your commit message at 72 characters
Also, when sending v2, v3, etc it is preferred to send it as a new top-level thread. ie, don't set headers to be a reply to your v1.
Quoted 27 lines
Signed-off-by Ashijeet Acharya <[email protected]>--- hmp.c | 33 +++++++++++++++++++++++++++++++++ include/migration/migration.h | 1 - migration/migration.c | 30 ++++++++++++++++++++++++++---- qapi-schema.json | 26 +++++++++++++++++++++++--- qmp-commands.hx | 13 ++++++++++--- 5 files changed, 92 insertions(+), 11 deletions(-)hmp.c +6
-0@@ -304,6 +304,12 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)monitor_printf (mon," %s: '%s'" , MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_HOSTNAME ], params->tls_hostname ? :"" ); +monitor_printf (mon," %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_MAX_BANDWIDTH ], + params->max_bandwidth); +monitor_printf (mon," %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_DOWNTIME_LIMIT ], + params->downtime_limit);monitor_printf (mon,"\n" ); }
hmp.c void hmp_migrate_incoming(Monitor *mon, const QDict *qdict) · line 1202
Quoted 4 lines
hmp.c +1
-0@@ -1193,6 +1199,7 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err); } +/* Kept for old-commands compatibility */
I don't think this comment really adds any value. Instead, in the qapi schema, you should mark the legacy methods as deprecated though.
Quoted 182 lines
hmp.c +26
-0void hmp_migrate_set_downtime (Monitor *mon,const QDict *qdict) {double value =qdict_get_double (qdict,"value" );@@ -1211,6 +1218,7 @@ void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict) } } +/* Kept for old-commands compatibility */ void hmp_migrate_set_speed (Monitor *mon,const QDict *qdict) {int64_t value =qdict_get_int (qdict,"value" );@@ -1251,7 +1259,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) {const char *param =qdict_get_str (qdict,"parameter" );const char *valuestr =qdict_get_str (qdict,"value" ); +int64_t valuebw =0 ; +double valuedowntime =0 ;long valueint =0 ; +char *endp;Error *err =NULL ;bool has_compress_level = false;bool has_compress_threads = false;@@ -1260,6 +1271,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)bool has_cpu_throttle_increment = false;bool has_tls_creds = false;bool has_tls_hostname = false; +bool has_max_bandwidth = false; +bool has_downtime_limit = false;bool use_int_value = false;int i;@@ -1291,6 +1304,24 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)case MIGRATION_PARAMETER_TLS_HOSTNAME : has_tls_hostname = true;break ; +case MIGRATION_PARAMETER_MAX_BANDWIDTH : + has_max_bandwidth = true; + valuebw =qemu_strtosz (valuestr, &endp); +if (valuebw <0 || (size_t )valuebw != valuebw || *endp !='\0' + || !is_power_of_2 (valuebw)) { +error_setg (&err,"Invalid size %s" , valuestr); + goto cleanup; + } +break ; +case MIGRATION_PARAMETER_DOWNTIME_LIMIT : + has_downtime_limit = true; + valuedowntime =strtod (valuestr, &endp); +if (valuestr == endp) { +error_setg (&err,"Unable to parse '%s' as a number" , + valuestr); + goto cleanup; + } +break ; }if (use_int_value) {@@ -1308,6 +1339,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) has_cpu_throttle_increment, valueint, has_tls_creds, valuestr, has_tls_hostname, valuestr, + has_max_bandwidth, valuebw, + has_downtime_limit, valuedowntime, &err);break ; }include/migration/migration.h +0
-1@@ -129,7 +129,6 @@ struct MigrationSrcPageRequest {struct MigrationState { -int64_t bandwidth_limit;size_t bytes_xfer;size_t xfer_limit;QemuThread thread;migration/migration.c +26
-4@@ -44,6 +44,9 @@#define BUFFER_DELAY 100#define XFER_LIMIT_RATIO (1000 / BUFFER_DELAY) +/* Amount of nanoseconds we are willing to wait for migration to be down. */ +#define DEFAULT_MIGRATE_SET_DOWNTIME 300000000 +/* Default compression thread count */ #define DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT 8/* Default decompression thread count, usually decompression is at @@ -80,7 +83,6 @@ MigrationState *migrate_get_current(void)static bool once;static MigrationState current_migration = { .state =MIGRATION_STATUS_NONE , - .bandwidth_limit =MAX_THROTTLE , .xbzrle_cache_size =DEFAULT_MIGRATE_CACHE_SIZE , .mbps =-1 , .parameters = {@@ -89,6 +91,8 @@ MigrationState *migrate_get_current(void) .decompress_threads = DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT, .cpu_throttle_initial = DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL, .cpu_throttle_increment = DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT, + .max_bandwidth = MAX_THROTTLE, + .downtime_limit = DEFAULT_MIGRATE_SET_DOWNTIME, }, };@@ -566,6 +570,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) params->cpu_throttle_increment = s->parameters.cpu_throttle_increment; params->tls_creds =g_strdup (s->parameters.tls_creds); params->tls_hostname =g_strdup (s->parameters.tls_hostname); + params->max_bandwidth = s->parameters.max_bandwidth; + params->downtime_limit = s->parameters.downtime_limit;return params; }@@ -773,6 +779,10 @@ void qmp_migrate_set_parameters(bool has_compress_level,const char *tls_creds, bool has_tls_hostname, const char *tls_hostname, + bool has_max_bandwidth, + int64_t max_bandwidth, + bool has_downtime_limit, + double downtime_limit, Error **errp) { MigrationState *s = migrate_get_current();@@ -832,6 +842,12 @@ void qmp_migrate_set_parameters(bool has_compress_level,g_free (s->parameters.tls_hostname); s->parameters.tls_hostname =g_strdup (tls_hostname); } +if (has_max_bandwidth) { +qmp_migrate_set_speed (max_bandwidth,NULL ); + } +if (has_downtime_limit) { +qmp_migrate_set_downtime (downtime_limit,NULL ); + } }@@ -1175,18 +1191,24 @@ void qmp_migrate_set_speed(int64_t value, Error **errp) } s =migrate_get_current (); - s->bandwidth_limit = value; + s->parameters.max_bandwidth = value;if (s->to_dst_file) {qemu_file_set_rate_limit (s->to_dst_file, - s->bandwidth_limit /XFER_LIMIT_RATIO ); + s->parameters.max_bandwidth /XFER_LIMIT_RATIO ); } }void qmp_migrate_set_downtime (double value,Error **errp) { +MigrationState *s; + value *=1e9 ; value =MAX (0 ,MIN (UINT64_MAX , value)); + + s =migrate_get_current (); + max_downtime = (uint64_t )value; + s->parameters.downtime_limit = max_downtime; }bool migrate_postcopy_ram (void )@@ -1858,7 +1880,7 @@ void migrate_fd_connect(MigrationState *s)qemu_file_set_blocking (s->to_dst_file, true);qemu_file_set_rate_limit (s->to_dst_file, - s->bandwidth_limit /XFER_LIMIT_RATIO ); + s->parameters.max_bandwidth /XFER_LIMIT_RATIO );/* Notify before starting migration thread */ notifier_list_notify (&migration_state_notifiers, s);qapi-schema.json +0
-0
qapi-schema.json line 641
Quoted 5 lines
qapi-schema.json +2
-0@@ -637,12 +637,18 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @max-bandwidth: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. Since 2.8)
Document the units for this ? eg is it bits-per-second, kb-per-second, mb-per-second, etc
qapi-schema.json line 643
Quoted 2 lines
qapi-schema.json +2
-0+# +# @downtime-limit: set maximum tolerated downtime for migration. Since 2.8)
Again, units ? nanoseconds ? milliseconds ?
Quoted 13 lines
qapi-schema.json +3
-1+# # Since: 2.4 ## { 'enum': 'MigrationParameter', 'data': ['compress-level', 'compress-threads', 'decompress-threads', 'cpu-throttle-initial', 'cpu-throttle-increment', - 'tls-creds', 'tls-hostname'] } + 'tls-creds', 'tls-hostname', 'max-bandwidth', + 'downtime-limit'] } # # @migrate-set-parameters
qapi-schema.json line 688
Quoted 5 lines
qapi-schema.json +2
-0@@ -678,6 +684,11 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @max-bandwidth: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. Since 2.8)
Units
qapi-schema.json line 690
Quoted 2 lines
qapi-schema.json +2
-0+# +# @downtime-limit: set maximum tolerated downtime for migration. Since 2.8)
Units
Quoted 43 lines
qapi-schema.json +12
-2+# # Since: 2.4 ## { 'command': 'migrate-set-parameters',@@ -687,7 +698,9 @@ '*cpu-throttle-initial': 'int', '*cpu-throttle-increment': 'int', '*tls-creds': 'str', - '*tls-hostname': 'str'} } + '*tls-hostname': 'str', + '*max-bandwidth': 'int', + '*downtime-limit': 'number'} } # # @MigrationParameters@@ -721,6 +734,11 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @max-bandwidth: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. (Since 2.8) +# +# @downtime-limit: set maximum tolerated downtime for migration. Since 2.8) +# # Since: 2.4 ## { 'struct': 'MigrationParameters',@@ -730,7 +748,9 @@ 'cpu-throttle-initial': 'int', 'cpu-throttle-increment': 'int', 'tls-creds': 'str', - 'tls-hostname': 'str'} } + 'tls-hostname': 'str', + 'max-bandwidth': 'int', + 'downtime-limit': 'int'} } ## # @query-migrate-parameters #qmp-commands.hx +0
-0
qmp-commands.hx Set migration parameters · line 3793
Quoted 5 lines
qmp-commands.hx +1
-1@@ -3790,7 +3790,9 @@ Set migration parameters throttled for auto-converge (json-int) - "cpu-throttle-increment": set throttle increasing percentage for auto-converge (json-int) - +- "max-bandwidth": set maximum speed for migrations (json-int)
Document units
qmp-commands.hx Set migration parameters · line 3795
Quoted 2 lines
qmp-commands.hx +2
-0+- "downtime-limit": set maximum tolerated downtime (in seconds) for + migrations (json-number)
I'm sure units for this are not "seconds" as that is way too coarse.
Quoted 13 lines
qmp-commands.hx +1
-1Arguments: Example:@@ -3803,7 +3805,7 @@ EQMP { .name = "migrate-set-parameters", .args_type = - "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?", + "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?,max-bandwidth:i?,downtime-limit:T?", .mhandler.cmd_new = qmp_marshal_migrate_set_parameters, }, SQMP
qmp-commands.hx Query current migration parameters · line 3827
Quoted 6 lines
qmp-commands.hx +3
-0@@ -3820,6 +3822,9 @@ Query current migration parameters throttled (json-int) - "cpu-throttle-increment" : throttle increasing percentage for auto-converge (json-int) + - "max-bandwidth" : maximium migration speed (json-int) + - "downtime-limit" : maximum tolerated downtime of migration + (json-int)
Document units
Regards,
Daniel
Signature · 4 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Quoted 8 lines · Daniel P. Berrange
Quoted 1 line · Ashijeet Acharya
Include
migrate_set_speedandmigrate_set_downtimeinsidemigrate_set_parametersfor setting maximum migration speed and expected downtime parameters respectively. Also update the query part for both in qmp and hmp qemu control interfaces.Please put line breaks in your commit message at 72 characters
Also, when sending v2, v3, etc it is preferred to send it as a new top-level thread. ie, don't set headers to be a reply to your v1.
Alright i will keep that in mind from now onwards.
Quoted 27 lines
Quoted 27 lines
Signed-off-by Ashijeet Acharya <[email protected]>--- hmp.c | 33 +++++++++++++++++++++++++++++++++ include/migration/migration.h | 1 - migration/migration.c | 30 ++++++++++++++++++++++++++---- qapi-schema.json | 26 +++++++++++++++++++++++--- qmp-commands.hx | 13 ++++++++++--- 5 files changed, 92 insertions(+), 11 deletions(-)hmp.c +6
-0@@ -304,6 +304,12 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)monitor_printf (mon," %s: '%s'" , MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_HOSTNAME ], params->tls_hostname ? :"" ); +monitor_printf (mon," %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_MAX_BANDWIDTH ], + params->max_bandwidth); +monitor_printf (mon," %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_DOWNTIME_LIMIT ], + params->downtime_limit);monitor_printf (mon,"\n" ); }
Quoted 8 lines
hmp.c void hmp_migrate_incoming(Monitor *mon, const QDict *qdict) · line 1202
Quoted 5 lines
hmp.c +1
-0@@ -1193,6 +1199,7 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err); } +/* Kept for old-commands compatibility */ I don't think this comment really adds any value. Instead, in the qapi schema, you should mark the legacy methods as deprecated though.
Hmm, that would make more sense.
Quoted 176 lines
Quoted 176 lines
hmp.c +26
-0void hmp_migrate_set_downtime (Monitor *mon,const QDict *qdict) {double value =qdict_get_double (qdict,"value" );@@ -1211,6 +1218,7 @@ void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict) } } +/* Kept for old-commands compatibility */ void hmp_migrate_set_speed (Monitor *mon,const QDict *qdict) {int64_t value =qdict_get_int (qdict,"value" );@@ -1251,7 +1259,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) {const char *param =qdict_get_str (qdict,"parameter" );const char *valuestr =qdict_get_str (qdict,"value" ); +int64_t valuebw =0 ; +double valuedowntime =0 ;long valueint =0 ; +char *endp;Error *err =NULL ;bool has_compress_level = false;bool has_compress_threads = false;@@ -1260,6 +1271,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)bool has_cpu_throttle_increment = false;bool has_tls_creds = false;bool has_tls_hostname = false; +bool has_max_bandwidth = false; +bool has_downtime_limit = false;bool use_int_value = false;int i;@@ -1291,6 +1304,24 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)case MIGRATION_PARAMETER_TLS_HOSTNAME : has_tls_hostname = true;break ; +case MIGRATION_PARAMETER_MAX_BANDWIDTH : + has_max_bandwidth = true; + valuebw =qemu_strtosz (valuestr, &endp); +if (valuebw <0 || (size_t )valuebw != valuebw || *endp !='\0' + || !is_power_of_2 (valuebw)) { +error_setg (&err,"Invalid size %s" , valuestr); + goto cleanup; + } +break ; +case MIGRATION_PARAMETER_DOWNTIME_LIMIT : + has_downtime_limit = true; + valuedowntime =strtod (valuestr, &endp); +if (valuestr == endp) { +error_setg (&err,"Unable to parse '%s' as a number" , + valuestr); + goto cleanup; + } +break ; }if (use_int_value) {@@ -1308,6 +1339,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) has_cpu_throttle_increment, valueint, has_tls_creds, valuestr, has_tls_hostname, valuestr, + has_max_bandwidth, valuebw, + has_downtime_limit, valuedowntime, &err);break ; }include/migration/migration.h +0
-1@@ -129,7 +129,6 @@ struct MigrationSrcPageRequest {struct MigrationState { -int64_t bandwidth_limit;size_t bytes_xfer;size_t xfer_limit;QemuThread thread;migration/migration.c +26
-4@@ -44,6 +44,9 @@#define BUFFER_DELAY 100#define XFER_LIMIT_RATIO (1000 / BUFFER_DELAY) +/* Amount of nanoseconds we are willing to wait for migration to be down. */ +#define DEFAULT_MIGRATE_SET_DOWNTIME 300000000 +/* Default compression thread count */ #define DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT 8/* Default decompression thread count, usually decompression is at @@ -80,7 +83,6 @@ MigrationState *migrate_get_current(void)static bool once;static MigrationState current_migration = { .state =MIGRATION_STATUS_NONE , - .bandwidth_limit =MAX_THROTTLE , .xbzrle_cache_size =DEFAULT_MIGRATE_CACHE_SIZE , .mbps =-1 , .parameters = {@@ -89,6 +91,8 @@ MigrationState *migrate_get_current(void) .decompress_threads = DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT, .cpu_throttle_initial = DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL, .cpu_throttle_increment = DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT, + .max_bandwidth = MAX_THROTTLE, + .downtime_limit = DEFAULT_MIGRATE_SET_DOWNTIME, }, };@@ -566,6 +570,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) params->cpu_throttle_increment = s->parameters.cpu_throttle_increment; params->tls_creds =g_strdup (s->parameters.tls_creds); params->tls_hostname =g_strdup (s->parameters.tls_hostname); + params->max_bandwidth = s->parameters.max_bandwidth; + params->downtime_limit = s->parameters.downtime_limit;return params; }@@ -773,6 +779,10 @@ void qmp_migrate_set_parameters(bool has_compress_level,const char *tls_creds, bool has_tls_hostname, const char *tls_hostname, + bool has_max_bandwidth, + int64_t max_bandwidth, + bool has_downtime_limit, + double downtime_limit, Error **errp) { MigrationState *s = migrate_get_current();@@ -832,6 +842,12 @@ void qmp_migrate_set_parameters(bool has_compress_level,g_free (s->parameters.tls_hostname); s->parameters.tls_hostname =g_strdup (tls_hostname); } +if (has_max_bandwidth) { +qmp_migrate_set_speed (max_bandwidth,NULL ); + } +if (has_downtime_limit) { +qmp_migrate_set_downtime (downtime_limit,NULL ); + } }@@ -1175,18 +1191,24 @@ void qmp_migrate_set_speed(int64_t value, Error **errp) } s =migrate_get_current (); - s->bandwidth_limit = value; + s->parameters.max_bandwidth = value;if (s->to_dst_file) {qemu_file_set_rate_limit (s->to_dst_file, - s->bandwidth_limit /XFER_LIMIT_RATIO ); + s->parameters.max_bandwidth /XFER_LIMIT_RATIO ); } }void qmp_migrate_set_downtime (double value,Error **errp) { +MigrationState *s; + value *=1e9 ; value =MAX (0 ,MIN (UINT64_MAX , value)); + + s =migrate_get_current (); + max_downtime = (uint64_t )value; + s->parameters.downtime_limit = max_downtime; }bool migrate_postcopy_ram (void )@@ -1858,7 +1880,7 @@ void migrate_fd_connect(MigrationState *s)qemu_file_set_blocking (s->to_dst_file, true);qemu_file_set_rate_limit (s->to_dst_file, - s->bandwidth_limit /XFER_LIMIT_RATIO ); + s->parameters.max_bandwidth /XFER_LIMIT_RATIO );
Quoted 16 lines
qapi-schema.json line 641
Quoted 12 lines
migration/migration.c +0
-0/* Notify before starting migration thread */ notifier_list_notify (&migration_state_notifiers, s);qapi-schema.json +2
-0@@ -637,12 +637,18 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @max-bandwidth: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. Since 2.8)Document the units for this ? eg is it bits-per-second, kb-per-second, mb-per-second, etc
Should I document it the way it is for old-commands? Like this;
# @migrate_set_speed
#
# Set maximum speed for migration.
#
# @value: maximum speed in bytes.
#
# Returns: nothing on success
#
# Notes: A value lesser than zero will be automatically round up to zero. #
# Since: 0.14.0
##
Quoted 4 lines
qapi-schema.json line 643
Quoted 2 lines
qapi-schema.json +2
-0+# +# @downtime-limit: set maximum tolerated downtime for migration. Since 2.8)Again, units ? nanoseconds ? milliseconds ?
Like this;
# @migrate_set_downtime
#
# Set maximum tolerated downtime for migration.
#
# @value: maximum downtime in seconds
#
# Returns: nothing on success
#
# Since: 0.14.0
Quoted 78 lines
Quoted 14 lines
qapi-schema.json +3
-1+# # Since: 2.4 ## { 'enum': 'MigrationParameter', 'data': ['compress-level', 'compress-threads', 'decompress-threads', 'cpu-throttle-initial', 'cpu-throttle-increment', - 'tls-creds', 'tls-hostname'] } + 'tls-creds', 'tls-hostname', 'max-bandwidth', + 'downtime-limit'] } # # @migrate-set-parametersqapi-schema.json line 688
Quoted 5 lines
qapi-schema.json +2
-0@@ -678,6 +684,11 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @max-bandwidth: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. Since 2.8)Units
qapi-schema.json line 690
Quoted 2 lines
qapi-schema.json +2
-0+# +# @downtime-limit: set maximum tolerated downtime for migration. Since 2.8)Units
Quoted 43 lines
qapi-schema.json +12
-2+# # Since: 2.4 ## { 'command': 'migrate-set-parameters',@@ -687,7 +698,9 @@ '*cpu-throttle-initial': 'int', '*cpu-throttle-increment': 'int', '*tls-creds': 'str', - '*tls-hostname': 'str'} } + '*tls-hostname': 'str', + '*max-bandwidth': 'int', + '*downtime-limit': 'number'} } # # @MigrationParameters@@ -721,6 +734,11 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @max-bandwidth: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. (Since 2.8) +# +# @downtime-limit: set maximum tolerated downtime for migration. Since 2.8) +# # Since: 2.4 ## { 'struct': 'MigrationParameters',@@ -730,7 +748,9 @@ 'cpu-throttle-initial': 'int', 'cpu-throttle-increment': 'int', 'tls-creds': 'str', - 'tls-hostname': 'str'} } + 'tls-hostname': 'str', + 'max-bandwidth': 'int', + 'downtime-limit': 'int'} } ## # @query-migrate-parameters #qmp-commands.hx +0
-0qmp-commands.hx Set migration parameters · line 3793
Quoted 5 lines
qmp-commands.hx +1
-1@@ -3790,7 +3790,9 @@ Set migration parameters throttled for auto-converge (json-int) - "cpu-throttle-increment": set throttle increasing percentage for auto-converge (json-int) - +- "max-bandwidth": set maximum speed for migrations (json-int)Document units
Quoted 4 lines
qmp-commands.hx Set migration parameters · line 3795
Quoted 2 lines
qmp-commands.hx +2
-0+- "downtime-limit": set maximum tolerated downtime (in seconds) for + migrations (json-number)I'm sure units for this are not "seconds" as that is way too coarse.
I dont know, that is exactly what was documented for the old-command migrate_set_downtime.
This is what i found;
migrate_set_downtime
--------------------
Set maximum tolerated downtime (in seconds) for migrations.
Arguments:
- "value": maximum downtime (json-number)
Example:
-> { "execute": "migrate_set_downtime", "arguments": { "value": 0.1 } } <- { "return": {} }
Quoted 31 lines
Quoted 14 lines
qmp-commands.hx +1
-1Arguments: Example:@@ -3803,7 +3805,7 @@ EQMP { .name = "migrate-set-parameters", .args_type = - "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?", + "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?,max-bandwidth:i?,downtime-limit:T?", .mhandler.cmd_new = qmp_marshal_migrate_set_parameters, }, SQMPqmp-commands.hx Query current migration parameters · line 3827
Quoted 6 lines
qmp-commands.hx +3
-0@@ -3820,6 +3822,9 @@ Query current migration parameters throttled (json-int) - "cpu-throttle-increment" : throttle increasing percentage for auto-converge (json-int) + - "max-bandwidth" : maximium migration speed (json-int) + - "downtime-limit" : maximum tolerated downtime of migration + (json-int)Document units
Regards,
Daniel
--|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Quoted 20 lines · Ashijeet Acharya
Quoted 16 lines · Daniel P. Berrange
qapi-schema.json line 641
Quoted 10 lines · Ashijeet Acharya
qapi-schema.json +2
-0@@ -637,12 +637,18 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @max-bandwidth: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. Since 2.8)Document the units for this ? eg is it bits-per-second, kb-per-second, mb-per-second, etc
Should I document it the way it is for old-commands? Like this;
Quoted 12 lines
# @migrate_set_speed
#
# Set maximum speed for migration.
#
# @value: maximum speed in bytes.
#
# Returns: nothing on success
#
# Notes: A value lesser than zero will be automatically round up to zero. #
# Since: 0.14.0
##
No, that syntax isn't appropriate for documenting parameters. You hjust have to put it all together.
@max-bandwidth: set maximum speed for migration in bytes-per-second. A
value lesser than zero will be automatically round upto zero. Since 2.8)
Oh and IMHO we should reject values less than zero as invalid, with an error message, not silently interpret them as meaning zero.
Regards,
Daniel
Signature · 4 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Quoted 34 lines · Daniel P. Berrange
Quoted 20 lines · Ashijeet Acharya
Quoted 16 lines · Daniel P. Berrange
qapi-schema.json line 641
Quoted 10 lines · Ashijeet Acharya
qapi-schema.json +2
-0@@ -637,12 +637,18 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @max-bandwidth: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. Since 2.8)Document the units for this ? eg is it bits-per-second, kb-per-second, mb-per-second, etc
Should I document it the way it is for old-commands? Like this;
Quoted 12 lines
# @migrate_set_speed
#
# Set maximum speed for migration.
#
# @value: maximum speed in bytes.
#
# Returns: nothing on success
#
# Notes: A value lesser than zero will be automatically round up to zero. #
# Since: 0.14.0
##
Quoted 2 lines
No, that syntax isn't appropriate for documenting parameters. You hjust have to put it all together.
Yeah, i was not talking about the syntax, only the comments.
Quoted 7 lines
@max-bandwidth: set maximum speed for migration in bytes-per-second. A
value lesser than zero will be automatically round upto zero. Since 2.8)Oh and IMHO we should reject values less than zero as invalid, with an error message, not silently interpret them as meaning zero.
Alright, so that will take "A value lesser than zero will be automatically round upto zero" out of the comment.
Also as I mentioned in the previous thread; the units for downtime are mentioned to be seconds in the old-commands too, so I am keeping that as seconds. Please tell me if you have something else in mind.
Ashijeet
Quoted 8 lines
Regards,
Daniel
--|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
PATCH v3 1/1 Move migrate_set_speed and migrate_set_downtime into migrate_set_parameter (reversed logic)
In reply to Paolo BonziniInclude migrate_set_speed and migrate_set_downtime inside migrate_set_parameters for setting maximum migration speed and expected downtime parameters respectively. Also update the query part for both in qmp and hmp qemu control interfaces. Make qmp_migrate_set_speed() and qmp_migrate_set_downtime() as wrappers on qmp_migrate_set_parameters().
--- hmp.c | 33 ++++++++++++ include/migration/migration.h | 1 - migration/migration.c | 116 ++++++++++++++++++++++++++++++++---------- qapi-schema.json | 26 ++++++++-- qmp-commands.hx | 13 +++-- 5 files changed, 156 insertions(+), 33 deletions(-)
hmp.c +33 -0
@@ -304,6 +304,12 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)monitor_printf (mon," %s: '%s'" , MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_HOSTNAME ], params->tls_hostname ? :"" ); +monitor_printf (mon," %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_MAX_BANDWIDTH ], + params->max_bandwidth); +monitor_printf (mon," %s: %" PRId64, + MigrationParameter_lookup[MIGRATION_PARAMETER_DOWNTIME_LIMIT ], + params->downtime_limit);monitor_printf (mon,"\n" ); }
@@ -1193,6 +1199,7 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err); } +/* Kept for old-commands compatibility */ void hmp_migrate_set_downtime (Monitor *mon,const QDict *qdict) {double value =qdict_get_double (qdict,"value" );
@@ -1211,6 +1218,7 @@ void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict) } } +/* Kept for old-commands compatibility */ void hmp_migrate_set_speed (Monitor *mon,const QDict *qdict) {int64_t value =qdict_get_int (qdict,"value" );
@@ -1251,7 +1259,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) {const char *param =qdict_get_str (qdict,"parameter" );const char *valuestr =qdict_get_str (qdict,"value" ); +int64_t valuebw =0 ; +double valuedowntime =0 ;long valueint =0 ; +char *endp;Error *err =NULL ;bool has_compress_level = false;bool has_compress_threads = false;
@@ -1260,6 +1271,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)bool has_cpu_throttle_increment = false;bool has_tls_creds = false;bool has_tls_hostname = false; +bool has_max_bandwidth = false; +bool has_downtime_limit = false;bool use_int_value = false;int i;
@@ -1291,6 +1304,24 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)case MIGRATION_PARAMETER_TLS_HOSTNAME : has_tls_hostname = true;break ; +case MIGRATION_PARAMETER_MAX_BANDWIDTH : + has_max_bandwidth = true; + valuebw =qemu_strtosz (valuestr, &endp); +if (valuebw <0 || (size_t )valuebw != valuebw || *endp !='\0' + || !is_power_of_2 (valuebw)) { +error_setg (&err,"Invalid size %s" , valuestr); + goto cleanup; + } +break ; +case MIGRATION_PARAMETER_DOWNTIME_LIMIT : + has_downtime_limit = true; + valuedowntime =strtod (valuestr, &endp); +if (valuestr == endp) { +error_setg (&err,"Unable to parse '%s' as a number" , + valuestr); + goto cleanup; + } +break ; }if (use_int_value) {
@@ -1308,6 +1339,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) has_cpu_throttle_increment, valueint, has_tls_creds, valuestr, has_tls_hostname, valuestr, + has_max_bandwidth, valuebw, + has_downtime_limit, valuedowntime, &err);break ; }
include/migration/migration.h +0 -1
@@ -129,7 +129,6 @@ struct MigrationSrcPageRequest {struct MigrationState { -int64_t bandwidth_limit;size_t bytes_xfer;size_t xfer_limit;QemuThread thread;
migration/migration.c +90 -26
164 lines not on this page · raw message
qapi-schema.json +23 -3
@@ -637,12 +637,18 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @max-bandwidth: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. Since 2.8) +# +# @downtime-limit: set maximum tolerated downtime for migration. Since 2.8) +# # Since: 2.4 ## { 'enum': 'MigrationParameter', 'data': ['compress-level', 'compress-threads', 'decompress-threads', 'cpu-throttle-initial', 'cpu-throttle-increment', - 'tls-creds', 'tls-hostname'] } + 'tls-creds', 'tls-hostname', 'max-bandwidth', + 'downtime-limit'] } # # @migrate-set-parameters
@@ -678,6 +684,11 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @max-bandwidth: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. Since 2.8) +# +# @downtime-limit: set maximum tolerated downtime for migration. Since 2.8) +# # Since: 2.4 ## { 'command': 'migrate-set-parameters',
@@ -687,7 +698,9 @@ '*cpu-throttle-initial': 'int', '*cpu-throttle-increment': 'int', '*tls-creds': 'str', - '*tls-hostname': 'str'} } + '*tls-hostname': 'str', + '*max-bandwidth': 'int', + '*downtime-limit': 'number'} } # # @MigrationParameters
@@ -721,6 +734,11 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @max-bandwidth: to set maximum speed for migration. A value lesser than +# zero will be automatically round upto zero. (Since 2.8) +# +# @downtime-limit: set maximum tolerated downtime for migration. Since 2.8) +# # Since: 2.4 ## { 'struct': 'MigrationParameters',
@@ -730,7 +748,9 @@ 'cpu-throttle-initial': 'int', 'cpu-throttle-increment': 'int', 'tls-creds': 'str', - 'tls-hostname': 'str'} } + 'tls-hostname': 'str', + 'max-bandwidth': 'int', + 'downtime-limit': 'int'} } ## # @query-migrate-parameters #
qmp-commands.hx +10 -3
@@ -3790,7 +3790,9 @@ Set migration parameters throttled for auto-converge (json-int) - "cpu-throttle-increment": set throttle increasing percentage for auto-converge (json-int) - +- "max-bandwidth": set maximum speed for migrations (json-int) +- "downtime-limit": set maximum tolerated downtime (in seconds) for + migrations (json-number) Arguments: Example:
@@ -3803,7 +3805,7 @@ EQMP { .name = "migrate-set-parameters", .args_type = - "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?", + "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?,max-bandwidth:i?,downtime-limit:T?", .mhandler.cmd_new = qmp_marshal_migrate_set_parameters, }, SQMP
@@ -3820,6 +3822,9 @@ Query current migration parameters throttled (json-int) - "cpu-throttle-increment" : throttle increasing percentage for auto-converge (json-int) + - "max-bandwidth" : maximium migration speed (json-int) + - "downtime-limit" : maximum tolerated downtime of migration + (json-int) Arguments:
@@ -3832,7 +3837,9 @@ Example: "cpu-throttle-increment": 10, "compress-threads": 8, "compress-level": 1, - "cpu-throttle-initial": 20 + "cpu-throttle-initial": 20, + "max-downtime": 33554432, + "downtime-limit": 300000000 } }
Signature · 1 line
2.6.2
Quoted 5 lines · Paolo Bonzini
Quoted 2 lines · Ashijeet Acharya
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
+ "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?,migrate-set-speed:o?,migrate-set-downtime:T?",
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Same here about the names. Also use "i" for QMP commands.
I think we will have to use "T" for downtime at-least otherwise you cant use float values for setting seconds like "0.2" for example. No issues using "i" with bandwidth though.
Right, I should have mentioned that my remark was about the "o" (it caught my eye because of your change to hmp-commands.hx). Sorry!
I've always thought it a rather wierd to use fractional seconds for downtime. It sort of made sense for HMP, but should really never have been carried over into QMP. IMHO, we should make it just take integer milliseconds for downtime with the new API.
Regards,
Daniel
Signature · 4 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Quoted 11 lines · Daniel P. Berrange
Quoted 10 lines · Paolo Bonzini
Quoted 6 lines · Ashijeet Acharya
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
+ "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?,migrate-set-speed:o?,migrate-set-downtime:T?",
Same here about the names. Also use "i" for QMP commands.
I think we will have to use "T" for downtime at-least otherwise you cant use float values for setting seconds like "0.2" for example. No issues using "i" with bandwidth though.
Quoted 7 lines
Quoted 2 lines
Right, I should have mentioned that my remark was about the "o" (it caught my eye because of your change to hmp-commands.hx). Sorry!
I've always thought it a rather wierd to use fractional seconds for downtime. It sort of made sense for HMP, but should really never have been carried over into QMP. IMHO, we should make it just take integer milliseconds for downtime with the new API.
Seconds are a fine unit, and using floating-point numbers isn't weird, especially not in JSON.
What's actually weird is our zoo of time units: seconds (migrate_set_downtime), milliseconds (MigrationInfo), microseconds (NetdevTapOptions), nanoseconds (BlockDeviceTimedStats), seconds + fractional nanoseconds (SnapshotInfo), ... No adult supervision.
We should've picked *one* time unit for QMP. The obvious time unit is seconds. Nanoseconds would've worked, too.
Time units are probably beyond repair now. We can still try to make them at least locally consistent, i.e. stick to what related interfaces use.
Quoted 21 lines · Dr. David Alan Gilbert
Quoted 20 lines · * Ashijeet Acharya ([email protected]) wrote:
Quoted 18 lines · Paolo Bonzini
Quoted 5 lines · Ashijeet Acharya
Quoted 5 lines
Quoted 5 lines
Include
migrate_set_speedandmigrate_set_downtimeinsidemigrate_set_parametersrespectively for setting maximum migration speed and expected downtime parameters. Also add the query part for both in qmp and hmp qemu control interfaces.Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Ashijeet Acharya <[email protected]>You cannot break backwards compatibility for everyone that is using those commands, sorry.
So should I keep the old commands too and add the new ones anyway for the query part?
You do not need query for the old ones, but you can indeed add support for speed and downtime in migrate-set-parameters and MigrationParameters.
Quoted 7 lines
Quoted 2 lines
Right. So I will add the old-commands back and just add support for the new ones under migration-set-parameters along with the query.
Yes add them to both
migrate_set_parametersandquery_migrate_parametersand the hmp equivalents; but don't remove the old functions; just make them simple wrappers to call themigrate_set_parametersetc. Add a comment on them like 'kept for compatibility'.
I agree with that approach.
Thanks, Juan.
Quoted 16 lines
Dave
Quoted 11 lines
Quoted 1 line
(Note: I'm not a migration maintainer, so they might say something else).
Okay. I will wait for their views too.
Ashijeet
Quoted 6 lines
Paolo
Quoted 3 lines
The old ones will also be modified for query. So we will have compatibility as well as the
query.--
Dr. David Alan Gilbert / [email protected] / Manchester, UK