migrate: move max-bandwidth and downtime-limit to migrate_set_parameter
PATCH v6 1/1 migrate: move max-bandwidth and downtime-limit to migrate_set_parameter
Mark the old commands 'migrate_set_speed' and 'migrate_set_downtime' as deprecated.
Move max-bandwidth and downtime-limit into migrate-set-parameters for setting maximum migration speed and expected downtime limit parameters respectively.
Change downtime units to milliseconds (only for new-command) and set its upper bound limit to 2000 seconds.
Update the query part in both hmp and qmp qemu control interfaces.
---
Changes in v6
-Improve the commit message
-Mention new upper limit of downtime in commit message
-Drop the use of file-level variable 'max_downtime' completely -Fix the scale of downtime to milliseconds everywhere
-Revert back to use the name 'value' instead of 'valuebw' and 'valuedowntime' -Substitute 'SIZE_MAX' with '%zu' in bounds check to be more generic -NOTE: This patch is based on Eric's new 'boxed parameters from QAPI' patch
- series
--- hmp.c | 27 ++++++++++++++ include/migration/migration.h | 1 - migration/migration.c | 84 ++++++++++++++++++++++++++----------------- qapi-schema.json | 23 ++++++++++-- qmp-commands.hx | 14 ++++++-- 5 files changed, 109 insertions(+), 40 deletions(-)
hmp.c +27 -0
@@ -309,6 +309,14 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)monitor_printf (mon," %s: '%s'" , MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_HOSTNAME ], params->has_tls_hostname ? params->tls_hostname :"" ); +assert (params->has_max_bandwidth); +monitor_printf (mon," %s: %" PRId64" bytes/second" , + MigrationParameter_lookup[MIGRATION_PARAMETER_MAX_BANDWIDTH ], + params->max_bandwidth); +assert (params->has_downtime_limit); +monitor_printf (mon," %s: %" PRId64" milliseconds" , + MigrationParameter_lookup[MIGRATION_PARAMETER_DOWNTIME_LIMIT ], + params->downtime_limit);monitor_printf (mon,"\n" ); }
@@ -1200,6 +1208,7 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &err); } +/* Kept for backwards compatibility */ void hmp_migrate_set_downtime (Monitor *mon,const QDict *qdict) {double value =qdict_get_double (qdict,"value" );
@@ -1218,6 +1227,7 @@ void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict) } } +/* Kept for backwards compatibility */ void hmp_migrate_set_speed (Monitor *mon,const QDict *qdict) {int64_t value =qdict_get_int (qdict,"value" );
@@ -1258,7 +1268,9 @@ 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 ;long valueint =0 ; +char *endp;Error *err =NULL ;bool use_int_value = false;int i;
@@ -1295,6 +1307,20 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) p.has_tls_hostname = true; p.tls_hostname = (char *) valuestr;break ; +case MIGRATION_PARAMETER_MAX_BANDWIDTH : + p.has_max_bandwidth = true; + valuebw =qemu_strtosz (valuestr, &endp); +if (valuebw <0 || (size_t )valuebw != valuebw + || *endp !='\0' ) { +error_setg (&err,"Invalid size %s" , valuestr); + goto cleanup; + } + p.max_bandwidth = valuebw; +break ; +case MIGRATION_PARAMETER_DOWNTIME_LIMIT : + p.has_downtime_limit = true; + use_int_value = true; +break ; }if (use_int_value) {
@@ -1310,6 +1336,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) p.decompress_threads = valueint; p.cpu_throttle_initial = valueint; p.cpu_throttle_increment = valueint; + p.downtime_limit = valueint; }qmp_migrate_set_parameters (&p, &err);
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 +51 -33
153 lines not on this page · raw message
qapi-schema.json +20 -3
@@ -637,12 +637,19 @@ # 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. maximum speed in +# bytes per second. (Since 2.8) +# +# @downtime-limit: set maximum tolerated downtime for migration. maximum +# downtime in milliseconds (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
@@ -691,6 +698,12 @@ # 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. maximum speed in +# bytes per second. (Since 2.8) +# +# @downtime-limit: set maximum tolerated downtime for migration. maximum +# downtime in milliseconds (Since 2.8) +# # Since: 2.4 ## { 'struct': 'MigrationParameters',
@@ -700,7 +713,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 #
@@ -1782,6 +1797,8 @@ # # Returns: nothing on success # +# Notes: This command is deprecated in favor of 'migrate-set-parameters' +# # Since: 0.14.0 ## { 'command': 'migrate_set_downtime', 'data': {'value': 'number'} }
@@ -1795,7 +1812,7 @@ # # Returns: nothing on success # -# Notes: A value lesser than zero will be automatically round up to zero. +# Notes: This command is deprecated in favor of 'migrate-set-parameters' # # Since: 0.14.0 ##
qmp-commands.hx +11 -3
@@ -3800,7 +3800,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 (in bytes/sec) (json-int) +- "downtime-limit": set maximum tolerated downtime (in milliseconds) for + migrations (json-int) Arguments: Example:
@@ -3813,7 +3815,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:i?", .mhandler.cmd_new = qmp_marshal_migrate_set_parameters, }, SQMP
@@ -3830,6 +3832,10 @@ Query current migration parameters throttled (json-int) - "cpu-throttle-increment" : throttle increasing percentage for auto-converge (json-int) + - "max-bandwidth" : maximium migration speed in bytes per second + (json-int) + - "downtime-limit" : maximum tolerated downtime of migration in + milliseconds (json-int) Arguments:
@@ -3842,7 +3848,9 @@ Example: "cpu-throttle-increment": 10, "compress-threads": 8, "compress-level": 1, - "cpu-throttle-initial": 20 + "cpu-throttle-initial": 20, + "max-bandwidth": 33554432, + "downtime-limit": 300 } }
Signature · 1 line
2.6.2
Quoted 15 lines · Ashijeet Acharya
Mark the old commands '
migrate_set_speed' and 'migrate_set_downtime' as deprecated.
Move max-bandwidth and downtime-limit into migrate-set-parameters for setting maximum migration speed and expected downtime limit parameters respectively.
Change downtime units to milliseconds (only for new-command) and set its upper bound limit to 2000 seconds.
Update the query part in both hmp and qmp qemu control interfaces.Signed-off-by Ashijeet Acharya <[email protected]>---
+++
b/migration/migration.c
migration/migration.c void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp) · line 809
Quoted 8 lines
migration/migration.c +5
-0@@ -804,6 +802,20 @@ void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp)"cpu_throttle_increment" , "an integer in the range of 1 to 99"); } +if (params->has_max_bandwidth && + (params->max_bandwidth <0 || params->max_bandwidth >SIZE_MAX )) { +error_setg (errp,QERR_INVALID_PARAMETER_VALUE "%zu" , +"max_bandwidth" , +"an integer in the range of 0 to " ,SIZE_MAX );
That looks weird (not necessarily your fault; but it explains why we've been trying to avoid new QERR_ macros). No other use of QERR_INVALID_PARAMETER_VALUE adds additional text. So I'm thinking it's better to just follow suit with a shorter non-parameterized message; such as in this instance:
balloon.c: error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
"target", "a size");
Or, just open-code the full error message, instead of having half the message hidden behind the QERR_INVALID_PARAMETER_VALUE macro.
Otherwise, it looks good to me. With the error message sorted out, you can add:
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 31 lines · Eric Blake
Quoted 15 lines · Ashijeet Acharya
Mark the old commands '
migrate_set_speed' and 'migrate_set_downtime' as deprecated.
Move max-bandwidth and downtime-limit into migrate-set-parameters for setting maximum migration speed and expected downtime limit parameters respectively.
Change downtime units to milliseconds (only for new-command) and set its upper bound limit to 2000 seconds.
Update the query part in both hmp and qmp qemu control interfaces.Signed-off-by Ashijeet Acharya <[email protected]>---
+++
b/migration/migration.cmigration/migration.c void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp) · line 809
Quoted 8 lines
migration/migration.c +5
-0@@ -804,6 +802,20 @@ void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp)"cpu_throttle_increment" , "an integer in the range of 1 to 99"); } +if (params->has_max_bandwidth && + (params->max_bandwidth <0 || params->max_bandwidth >SIZE_MAX )) { +error_setg (errp,QERR_INVALID_PARAMETER_VALUE "%zu" , +"max_bandwidth" , +"an integer in the range of 0 to " ,SIZE_MAX );That looks weird (not necessarily your fault; but it explains why we've been trying to avoid new
QERR_macros). No other use ofQERR_INVALID_PARAMETER_VALUEadds additional text. So I'm thinking it's better to just follow suit with a shorter non-parameterized message; such as in this instance:
Quoted 5 lines
balloon.c: error_setg(errp,QERR_INVALID_PARAMETER_VALUE,
"target", "a size");Or, just open-code the full error message, instead of having half the message hidden behind the
QERR_INVALID_PARAMETER_VALUEmacro.
Alright, I will open-code the error message completely and drop the QERR_INVALID_PARAMETER_VALUE macro.
That will look much cleaner.
Quoted 5 lines
Otherwise, it looks good to me. With the error message sorted out, you can add:
Reviewed-by Eric Blake <[email protected]>
Okay, I will sort out the error message and submit v7 along with your R-b tag.
Ashijeet
Quoted 5 lines
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org