Received: from eggs.gnu.org ([2001:4830:134:3::10]:59979) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgsLY-0007OY-FO for qemu-devel@nongnu.org; Mon, 05 Sep 2016 07:45:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bgsLS-0008SM-BK for qemu-devel@nongnu.org; Mon, 05 Sep 2016 07:45:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47568) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgsLS-0008SE-24 for qemu-devel@nongnu.org; Mon, 05 Sep 2016 07:45:46 -0400 References: <20160905111620.GA22359@work-vm> <1473075436-32489-1-git-send-email-ashijeetacharya@gmail.com> From: Paolo Bonzini Message-ID: <122bc56c-0025-695a-8e2f-63aa03377879@redhat.com> Date: Mon, 5 Sep 2016 13:45:40 +0200 MIME-Version: 1.0 In-Reply-To: <1473075436-32489-1-git-send-email-ashijeetacharya@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2] Move migrate_set_speed and migrate_set_downtime into migrate_set_parameter List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ashijeet Acharya , lcapitulino@redhat.com Cc: quintela@redhat.com, amit.shah@redhat.com, eblake@redhat.com, armbru@redhat.com, dgilbert@redhat.com, qemu-devel@nongnu.org On 05/09/2016 13:37, Ashijeet Acharya wrote: > Include migrate_set_speed and migrate_set_downtime inside migrate_set_p= arameters for setting maximum migration speed and expected downtime param= eters respectively. Also update the query part for both in qmp and hmp qe= mu control interfaces. >=20 > Signed-off-by: Ashijeet Acharya > --- > 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(-) >=20 > diff --git a/hmp-commands.hx b/hmp-commands.hx > index 848efee..4dc7899 100644 > --- a/hmp-commands.hx > +++ b/hmp-commands.hx > @@ -1009,15 +1009,15 @@ ETEXI > =20 > { > .name =3D "migrate_set_parameter", > - .args_type =3D "parameter:s,value:s", > - .params =3D "parameter value", > + .args_type =3D "parameter:s,value:s?,speed:o?", > + .params =3D "parameter value speed", > .help =3D "Set the parameter for migration", > .mhandler.cmd =3D hmp_migrate_set_parameter, > .command_completion =3D migrate_set_parameter_completion, > }, > =20 > 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. > @findex migrate_set_parameter > Set the parameter @var{parameter} for migration. > ETEXI > diff --git a/hmp.c b/hmp.c > index cc2056e..fd50e83 100644 > --- a/hmp.c > +++ b/hmp.c > @@ -304,6 +304,12 @@ void hmp_info_migrate_parameters(Monitor *mon, con= st 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"); > } > =20 > @@ -1193,6 +1199,7 @@ void hmp_migrate_incoming(Monitor *mon, const QDi= ct *qdict) > hmp_handle_error(mon, &err); > } > =20 > +/* Kept for old-commands compatibility */ > void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict) > { > double value =3D qdict_get_double(qdict, "value"); > @@ -1211,6 +1218,7 @@ void hmp_migrate_set_cache_size(Monitor *mon, con= st QDict *qdict) > } > } > =20 > +/* Kept for old-commands compatibility */ > void hmp_migrate_set_speed(Monitor *mon, const QDict *qdict) > { > int64_t value =3D qdict_get_int(qdict, "value"); > @@ -1250,8 +1258,11 @@ void hmp_migrate_set_capability(Monitor *mon, co= nst QDict *qdict) > void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) > { > const char *param =3D qdict_get_str(qdict, "parameter"); > - const char *valuestr =3D qdict_get_str(qdict, "value"); > + const char *valuestr =3D qdict_get_try_str(qdict, "value"); > + int64_t valuespeed =3D 0; > + double valuedowntime =3D 0; > long valueint =3D 0; > + char *endp; > Error *err =3D NULL; > bool has_compress_level =3D false; > bool has_compress_threads =3D false; > @@ -1260,6 +1271,8 @@ void hmp_migrate_set_parameter(Monitor *mon, cons= t QDict *qdict) > bool has_cpu_throttle_increment =3D false; > bool has_tls_creds =3D false; > bool has_tls_hostname =3D false; > + bool has_migrate_set_speed =3D false; > + bool has_migrate_set_downtime =3D false; > bool use_int_value =3D false; > int i; > =20 > @@ -1291,6 +1304,19 @@ void hmp_migrate_set_parameter(Monitor *mon, con= st QDict *qdict) > case MIGRATION_PARAMETER_TLS_HOSTNAME: > has_tls_hostname =3D true; > break; > + case MIGRATION_PARAMETER_MIGRATE_SET_SPEED: > + has_migrate_set_speed =3D true; > + valuespeed =3D qdict_get_int(qdict, "speed"); > + break; > + case MIGRATION_PARAMETER_MIGRATE_SET_DOWNTIME: > + has_migrate_set_downtime =3D true; > + valuedowntime =3D strtod(valuestr, &endp); > + if (valuestr =3D=3D endp) { > + error_setg(&err, "Unable to parse '%s' as a number= ", > + valuestr); > + goto cleanup; > + } > + break; > } > =20 > if (use_int_value) { > @@ -89,6 +91,8 @@ MigrationState *migrate_get_current(void) > .decompress_threads =3D DEFAULT_MIGRATE_DECOMPRESS_THREAD_= COUNT, > .cpu_throttle_initial =3D DEFAULT_MIGRATE_CPU_THROTTLE_INI= TIAL, > .cpu_throttle_increment =3D DEFAULT_MIGRATE_CPU_THROTTLE_I= NCREMENT, > + .migrate_set_speed =3D MAX_THROTTLE, > + .migrate_set_downtime =3D DEFAULT_MIGRATE_SET_DOWNTIME, > }, > }; > =20 > @@ -566,6 +570,8 @@ MigrationParameters *qmp_query_migrate_parameters(E= rror **errp) > params->cpu_throttle_increment =3D s->parameters.cpu_throttle_incr= ement; > params->tls_creds =3D g_strdup(s->parameters.tls_creds); > params->tls_hostname =3D g_strdup(s->parameters.tls_hostname); > + params->migrate_set_speed =3D s->parameters.migrate_set_speed; > + params->migrate_set_downtime =3D s->parameters.migrate_set_downtim= e; > =20 > 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 =3D 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 =3D 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. > } > =20 > =20 > @@ -1175,18 +1191,24 @@ void qmp_migrate_set_speed(int64_t value, Error= **errp) > } > =20 > s =3D migrate_get_current(); > - s->bandwidth_limit =3D value; > + s->parameters.migrate_set_speed =3D 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_LIM= IT_RATIO); > } > } > =20 > void qmp_migrate_set_downtime(double value, Error **errp) > { > + MigrationState *s; > + > value *=3D 1e9; > value =3D MAX(0, MIN(UINT64_MAX, value)); > + > + s =3D migrate_get_current(); > + > max_downtime =3D (uint64_t)value; > + s->parameters.migrate_set_downtime =3D max_downtime; > } > =20 > bool migrate_postcopy_ram(void) > @@ -1858,7 +1880,7 @@ void migrate_fd_connect(MigrationState *s) > =20 > 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_LI= MIT_RATIO); > =20 > /* Notify before starting migration thread */ > notifier_list_notify(&migration_state_notifiers, s); > diff --git a/qapi-schema.json b/qapi-schema.json > index 5658723..b98be44 100644 > --- a/qapi-schema.json > +++ b/qapi-schema.json > @@ -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 less= er 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. > +# > # 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. > =20 > # > # @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 less= er 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'} } Same here. > =20 > # > # @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 less= er 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". > +# > # 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. > ## > # @query-migrate-parameters > # > diff --git a/qmp-commands.hx b/qmp-commands.hx > index 6866264..c4d3809 100644 > --- a/qmp-commands.hx > +++ b/qmp-commands.hx > @@ -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. > Arguments: > =20 > Example: > @@ -3803,7 +3805,7 @@ EQMP > { > .name =3D "migrate-set-parameters", > .args_type =3D > - "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. > .mhandler.cmd_new =3D qmp_marshal_migrate_set_parameters, > }, > SQMP > @@ -3820,6 +3822,9 @@ Query current migration parameters > throttled (json-int) > - "cpu-throttle-increment" : throttle increasing percentage f= or > auto-converge (json-int) > + - "migrate-set-speed" : maximium migration speed (json-octets= ) > + - "migration-set-downtime" : maximum tolerated downtime of mi= gration > + (json-number) Same here about the names. > Arguments: > =20 > @@ -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. > } > } > =20 >=20