Changing error message of QMP 'migrate_set_downtime' to seconds
PATCH 1/1 Changing error message of QMP 'migrate_set_downtime' to seconds
The previous error message was displaying the values in miliseconds, being misleading with the command that accepts the value in seconds:
{ "execute": "migrate_set_downtime", "arguments": {"value": 3000}} {"error": {"class": "GenericError", "desc": "Parameter 'downtime_limit' expects an integer in the range of 0 to 2000000 milliseconds"}}
This patch changes it to '2000 seconds' to keep consistency with the expected parameter.
--- migration/migration.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
migration/migration.c +6 -2
@@ -49,6 +49,9 @@* for sending the last part */ #define DEFAULT_MIGRATE_SET_DOWNTIME 300 +/* Maximum migrate downtime set to 2000*1000 miliseconds */ +#define MAX_MIGRATE_SET_DOWNTIME (2000 * 1000) +/* Default compression thread count */ #define DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT 8/* Default decompression thread count, usually decompression is at
@@ -843,10 +846,11 @@ void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp)return ; }if (params->has_downtime_limit && - (params->downtime_limit <0 || params->downtime_limit >2000000 )) { + (params->downtime_limit <0 || + params->downtime_limit >MAX_MIGRATE_SET_DOWNTIME )) {error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"downtime_limit" , -"an integer in the range of 0 to 2000000 milliseconds" ); +"an integer in the range of 0 to 2000 seconds" );return ; }if (params->has_x_checkpoint_delay && (params->x_checkpoint_delay <0 )) {
Signature · 1 line
2.9.3
Quoted 30 lines · Daniel Henrique Barboza
The previous error message was displaying the values in miliseconds, being misleading with the command that accepts the value in seconds:
{ "execute": "
migrate_set_downtime", "arguments": {"value": 3000}} {"error": {"class": "GenericError", "desc": "Parameter 'downtime_limit' expects an integer in the range of 0 to 2000000 milliseconds"}}This patch changes it to '2000 seconds' to keep consistency with the expected parameter.
Signed-off-by Daniel Henrique Barboza <[email protected]>--- migration/migration.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)migration/migration.c +3
-0@@ -49,6 +49,9 @@* for sending the last part */ #define DEFAULT_MIGRATE_SET_DOWNTIME 300 +/* Maximum migrate downtime set to 2000*1000 miliseconds */ +#define MAX_MIGRATE_SET_DOWNTIME (2000 * 1000) +/* Default compression thread count */ #define DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT 8/* Default decompression thread count, usually decompression is at
migration/migration.c void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp) · line 853
Quoted 10 lines
migration/migration.c +3
-2@@ -843,10 +846,11 @@ void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp)return ; }if (params->has_downtime_limit && - (params->downtime_limit <0 || params->downtime_limit >2000000 )) { + (params->downtime_limit <0 || + params->downtime_limit >MAX_MIGRATE_SET_DOWNTIME )) {error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"downtime_limit" , -"an integer in the range of 0 to 2000000 milliseconds" ); +"an integer in the range of 0 to 2000 seconds" );
Perhaps you could use %d and set MAX_MIGRATE_SET_DOWNTIME to 2000? Though perhaps the migration maintainers are okay with the patch as is.
Paolo
Quoted 4 lines
migration/migration.c +0
-0return ; }if (params->has_x_checkpoint_delay && (params->x_checkpoint_delay <0 )) {
Quoted 36 lines · Paolo Bonzini
Quoted 34 lines · Daniel Henrique Barboza
The previous error message was displaying the values in miliseconds, being misleading with the command that accepts the value in seconds:
{ "execute": "
migrate_set_downtime", "arguments": {"value": 3000}} {"error": {"class": "GenericError", "desc": "Parameter 'downtime_limit' expects an integer in the range of 0 to 2000000 milliseconds"}}This patch changes it to '2000 seconds' to keep consistency with the expected parameter.
Signed-off-by Daniel Henrique Barboza <[email protected]>--- migration/migration.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)migration/migration.c +3
-1@@ -49,6 +49,9 @@* for sending the last part */ #define DEFAULT_MIGRATE_SET_DOWNTIME 300 +/* Maximum migrate downtime set to 2000*1000 miliseconds */ +#define MAX_MIGRATE_SET_DOWNTIME (2000 * 1000) +/* Default compression thread count */ #define DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT 8/* Default decompression thread count, usually decompression is at @@ -843,10 +846,11 @@ void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp)return ; } if (params->has_downtime_limit && - (params->downtime_limit <0 || params->downtime_limit >2000000 )) {
Quoted 8 lines
migration/migration.c void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp) · line 853
Quoted 6 lines
migration/migration.c +3
-1+ (params->downtime_limit < 0 || + params->downtime_limit > MAX_MIGRATE_SET_DOWNTIME)) {error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"downtime_limit" , -"an integer in the range of 0 to 2000000 milliseconds" ); +"an integer in the range of 0 to 2000 seconds" );Perhaps you could use %d and set
MAX_MIGRATE_SET_DOWNTIMEto 2000? Though perhaps the migration maintainers are okay with the patch as is.
I did that at first but I got errors on "error_setg" about the extra parameter. I even considered using sprintf to format the string but I was afraid it would be a little overkill.
Daniel
Quoted 7 lines
Paolo
Quoted 4 lines
migration/migration.c +0
-0return ; }if (params->has_x_checkpoint_delay && (params->x_checkpoint_delay <0 )) {
Quoted 8 lines · Daniel Henrique Barboza
Quoted 8 lines
Quoted 8 lines
2000000)) {
migration/migration.c +2
-1+ (params->downtime_limit < 0 || + params->downtime_limit > MAX_MIGRATE_SET_DOWNTIME)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "downtime_limit", - "an integer in the range of 0 to 2000000milliseconds");
+ "an integer in the range of 0 to 2000 seconds");
Quoted 5 lines
Quoted 2 lines
Perhaps you could use %d and set
MAX_MIGRATE_SET_DOWNTIMEto 2000? Though perhaps the migration maintainers are okay with the patch as is.I did that at first but I got errors on "
error_setg" about the extra parameter.
Ah, right, because QERR_INVALID_PARAMETER_VALUE is a macro that expands to a fixed printf-style format string where you have to know how many exact arguments it further expects. The only way around that is to open-code the error message you want, instead of forcing the use of the awkward macro.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 13 lines · Eric Blake
Quoted 11 lines · Daniel Henrique Barboza
Quoted 10 lines
Quoted 8 lines
2000000)) {
migration/migration.c +2
-1+ (params->downtime_limit < 0 || + params->downtime_limit > MAX_MIGRATE_SET_DOWNTIME)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "downtime_limit", - "an integer in the range of 0 to 2000000milliseconds");
+ "an integer in the range of 0 to 2000 seconds");Perhaps you could use %d and set
MAX_MIGRATE_SET_DOWNTIMEto 2000? Though perhaps the migration maintainers are okay with the patch as is.
Quoted 8 lines
Quoted 2 lines
I did that at first but I got errors on "
error_setg" about the extra parameter.Ah, right, because
QERR_INVALID_PARAMETER_VALUEis a macro that expands to a fixed printf-style format string where you have to know how many exact arguments it further expects. The only way around that is to open-code the error message you want, instead of forcing the use of the awkward macro.
Go ahead and open-code whenever that results in better error messages.