[Qemu-devel] [PULL 14/15] migrate: move max-bandwidth and downtime-limit to migrate_set_parameter

2016-10-14 Thread Juan Quintela
From: 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 
Reviewed-by: Eric Blake 
Reviewed-by: Juan Quintela 
Signed-off-by: Juan Quintela 
---
 docs/qmp-commands.txt | 13 +--
 hmp.c | 27 ++
 include/migration/migration.h |  1 -
 migration/migration.c | 83 ++-
 qapi-schema.json  | 23 ++--
 5 files changed, 107 insertions(+), 40 deletions(-)

diff --git a/docs/qmp-commands.txt b/docs/qmp-commands.txt
index 7f652e0..3220fb1 100644
--- a/docs/qmp-commands.txt
+++ b/docs/qmp-commands.txt
@@ -2910,7 +2910,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:
@@ -2931,7 +2933,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:

 Example:
@@ -2943,7 +2948,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
   }
}

diff --git a/hmp.c b/hmp.c
index 4c0f600..80f7f1f 100644
--- a/hmp.c
+++ b/hmp.c
@@ -310,6 +310,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");
 }

@@ -1265,6 +1273,7 @@ void hmp_migrate_incoming(Monitor *mon, const QDict 
*qdict)
 hmp_handle_error(mon, );
 }

+/* Kept for backwards compatibility */
 void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict)
 {
 double value = qdict_get_double(qdict, "value");
@@ -1283,6 +1292,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");
@@ -1323,7 +1333,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;
@@ -1360,6 +1372,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, );
+if (valuebw < 0 || (size_t)valuebw != valuebw
+|| *endp != '\0') {
+error_setg(, "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) {
@@ 

[Qemu-devel] [PULL 14/15] migrate: move max-bandwidth and downtime-limit to migrate_set_parameter

2016-10-05 Thread Juan Quintela
From: 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 
Reviewed-by: Eric Blake 
Reviewed-by: Juan Quintela 
Signed-off-by: Juan Quintela 
---
 docs/qmp-commands.txt | 13 +--
 hmp.c | 27 ++
 include/migration/migration.h |  1 -
 migration/migration.c | 83 ++-
 qapi-schema.json  | 23 ++--
 5 files changed, 107 insertions(+), 40 deletions(-)

diff --git a/docs/qmp-commands.txt b/docs/qmp-commands.txt
index e0adceb..4f4c156 100644
--- a/docs/qmp-commands.txt
+++ b/docs/qmp-commands.txt
@@ -2910,7 +2910,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:
@@ -2931,7 +2933,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:

 Example:
@@ -2943,7 +2948,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
   }
}

diff --git a/hmp.c b/hmp.c
index 5f52ee2..147f439 100644
--- a/hmp.c
+++ b/hmp.c
@@ -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, );
 }

+/* 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, );
+if (valuebw < 0 || (size_t)valuebw != valuebw
+|| *endp != '\0') {
+error_setg(, "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) {
@@