Skip to contentSkip to conversation

Move max-bandwidth and downtime-limit into migrate_set_parameter for both hmp and qmp

PATCH Superseded Ashijeet Acharya 2 participants 4 messages Sep 5, 2016 – Sep 6, 2016

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Move max-bandwidth and downtime-limit into migrate_set_parameter for both hmp and qmp

Mark old-commands for speed and 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 and update the query part in both hmp and qmp qemu control interfaces.

---
 hmp-commands.hx               |   8 +--
 hmp.c                         |  29 +++++++++-
 include/migration/migration.h |   1 -
 migration/migration.c         | 122 +++++++++++++++++++++++++++++++-----------
 qapi-schema.json              |  37 ++++++++++---
 qmp-commands.hx               |  21 +++++---
 6 files changed, 169 insertions(+), 49 deletions(-)
hmp-commands.hx +4 -4
index 848efee..c7f1ef9 100644
@@ -980,16 +980,16 @@ ETEXI
 
     {
         .name       = "migrate_set_downtime",
-        .args_type  = "value:T",
+        .args_type  = "value:i",
         .params     = "value",
-        .help       = "set maximum tolerated downtime (in seconds) for migrations",
+        .help       = "set maximum tolerated downtime (in milliseconds) for migrations",
         .mhandler.cmd = hmp_migrate_set_downtime,
     },
 
 STEXI
-@item migrate_set_downtime @var{second}
+@item migrate_set_downtime @var{milliseconds}
 @findex migrate_set_downtime
-Set maximum tolerated downtime (in seconds) for migration.
+Set maximum tolerated downtime (in milliseconds) for migration.
 ETEXI
 
     {
hmp.c +28 -1
index cc2056e..e5effca 100644
@@ -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,9 +1199,10 @@ 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");
+    int64_t value = qdict_get_int(qdict, "value");
     qmp_migrate_set_downtime(value, NULL);
 }
 
@@ -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,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 has_compress_level = false;
     bool has_compress_threads = false;
@@ -1260,6 +1270,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 +1303,19 @@ 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;
+                use_int_value = true;
+                break;
             }
 
             if (use_int_value) {
@@ -1308,6 +1333,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, valueint,
                                        &err);
             break;
         }
include/migration/migration.h +0 -1
index 3c96623..a5429ee 100644
@@ -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 +92 -30

198 lines not on this page · raw message

qapi-schema.json +31 -6
index 5658723..66ed582 100644
@@ -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. (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
@@ -678,6 +685,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. (Since 2.8)
+#
+# @downtime-limit: set maximum tolerated downtime for migration. maximum downtime
+#                  in milliseconds (Since 2.8)
+#
 # Since: 2.4
 ##
 { 'command': 'migrate-set-parameters',
@@ -687,7 +700,9 @@
             '*cpu-throttle-initial': 'int',
             '*cpu-throttle-increment': 'int',
             '*tls-creds': 'str',
-            '*tls-hostname': 'str'} }
+            '*tls-hostname': 'str',
+            '*max-bandwidth': 'int',
+            '*downtime-limit': 'int'} }
 
 #
 # @MigrationParameters
@@ -721,6 +736,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. (Since 2.8)
+#
+# @downtime-limit: set maximum tolerated downtime for migration. maximum downtime
+#                  in milliseconds (Since 2.8)
+#
 # Since: 2.4
 ##
 { 'struct': 'MigrationParameters',
@@ -730,7 +751,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
 #
@@ -1808,13 +1831,15 @@
 #
 # Set maximum tolerated downtime for migration.
 #
-# @value: maximum downtime in seconds
+# @value: maximum downtime in milliseconds
 #
 # Returns: nothing on success
 #
+# Notes: This command is deprecated in favour of 'migrate-set-parameters'
+#
 # Since: 0.14.0
 ##
-{ 'command': 'migrate_set_downtime', 'data': {'value': 'number'} }
+{ 'command': 'migrate_set_downtime', 'data': {'value': 'int'} }
 
 ##
 # @migrate_set_speed
@@ -1825,7 +1850,7 @@
 #
 # Returns: nothing on success
 #
-# Notes: A value lesser than zero will be automatically round up to zero.
+# Notes: This command is deprecated in favour of 'migrate-set-parameters'
 #
 # Since: 0.14.0
 ##
qmp-commands.hx +14 -7
index 6866264..8416674 100644
@@ -808,7 +808,7 @@ EQMP
 
     {
         .name       = "migrate_set_downtime",
-        .args_type  = "value:T",
+        .args_type  = "value:i",
         .mhandler.cmd_new = qmp_marshal_migrate_set_downtime,
     },
 
@@ -816,15 +816,15 @@ SQMP
 migrate_set_downtime
 --------------------
 
-Set maximum tolerated downtime (in seconds) for migrations.
+Set maximum tolerated downtime (in milliseconds) for migrations.
 
 Arguments:
 
-- "value": maximum downtime (json-number)
+- "value": maximum downtime (json-int)
 
 Example:
 
--> { "execute": "migrate_set_downtime", "arguments": { "value": 0.1 } }
+-> { "execute": "migrate_set_downtime", "arguments": { "value": 100 } }
 <- { "return": {} }
 
 EQMP
@@ -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 (in bytes) (json-int)
+- "downtime-limit": set maximum tolerated downtime (in milliseconds) for
+                          migrations (json-int)
 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:i?",
         .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": 300
       }
    }
 
Signature · 1 line
2.6.2
#1 lore raw
Quoted 30 lines · Ashijeet Acharya

Mark old-commands for speed and 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 and update the query part in both hmp and qmp qemu control interfaces.

---
 hmp-commands.hx               |   8 +--
 hmp.c                         |  29 +++++++++-
 include/migration/migration.h |   1 -
 migration/migration.c         | 122 +++++++++++++++++++++++++++++++-----------
 qapi-schema.json              |  37 ++++++++++---
 qmp-commands.hx               |  21 +++++---
 6 files changed, 169 insertions(+), 49 deletions(-)
hmp-commands.hx +2 -2
index 848efee..c7f1ef9 100644
@@ -980,16 +980,16 @@ ETEXI
 
     {
         .name       = "migrate_set_downtime",
-        .args_type  = "value:T",
+        .args_type  = "value:i",
         .params     = "value",
-        .help       = "set maximum tolerated downtime (in seconds) for migrations",
+        .help       = "set maximum tolerated downtime (in milliseconds) for migrations",

hmp-commands.hx ETEXI · line 993

Quoted 10 lines
hmp-commands.hx +2 -2
         .mhandler.cmd = hmp_migrate_set_downtime,
     },
 
 STEXI
-@item migrate_set_downtime @var{second}
+@item migrate_set_downtime @var{milliseconds}
 @findex migrate_set_downtime
-Set maximum tolerated downtime (in seconds) for migration.
+Set maximum tolerated downtime (in milliseconds) for migration.
 ETEXI

Sorry, you misunderstood - while we should use 'milliseconds' for downtime in the 'migrate_set_parameters' command, we cannot change the existing 'migrate_set_downtime' command. Changing that would break compatibility with existing apps.

qapi-schema.json line 641

Quoted 10 lines
qapi-schema.json +2 -0
index 5658723..66ed582 100644
@@ -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. (Since 2.8)

s/bytes/bytes per second/ (and elsewhere in this patch)

qapi-schema.json line 645

Quoted 4 lines
qapi-schema.json +4 -0
+#
+# @downtime-limit: set maximum tolerated downtime for migration. maximum downtime
+#                  in milliseconds (Since 2.8)
+#

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 :|
#2 lore raw
Quoted 34 lines · Daniel P. Berrange
Quoted 33 lines · Ashijeet Acharya

Mark old-commands for speed and 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 and update the query part in both hmp and qmp qemu control interfaces.

---
 hmp-commands.hx               |   8 +--
 hmp.c                         |  29 +++++++++-
 include/migration/migration.h |   1 -
 migration/migration.c         | 122 +++++++++++++++++++++++++++++++-----------
 qapi-schema.json              |  37 ++++++++++---
 qmp-commands.hx               |  21 +++++---
 6 files changed, 169 insertions(+), 49 deletions(-)
hmp-commands.hx +2 -2
index 848efee..c7f1ef9 100644
@@ -980,16 +980,16 @@ ETEXI
 
     {
         .name       = "migrate_set_downtime",
-        .args_type  = "value:T",
+        .args_type  = "value:i",
         .params     = "value",
-        .help       = "set maximum tolerated downtime (in seconds) for migrations",
+        .help       = "set maximum tolerated downtime (in milliseconds) for migrations",
         .mhandler.cmd = hmp_migrate_set_downtime,
     },
 
Quoted 12 lines

hmp-commands.hx ETEXI · line 993

Quoted 7 lines
hmp-commands.hx +2 -2
 STEXI
-@item migrate_set_downtime @var{second}
+@item migrate_set_downtime @var{milliseconds}
 @findex migrate_set_downtime
-Set maximum tolerated downtime (in seconds) for migration.
+Set maximum tolerated downtime (in milliseconds) for migration.
 ETEXI

Sorry, you misunderstood - while we should use 'milliseconds' for downtime in the 'migrate_set_parameters' command, we cannot change the existing 'migrate_set_downtime' command. Changing that would break compatibility with existing apps.

Oh, so that means the calculations of downtime for both the parts will be separate at the moment and i cannot glue them together. Unfortunately I will only be able send the updated patch by tomorrow now. It's really late here.

Thanks
Ashijeet

Quoted 27 lines

qapi-schema.json line 641

Quoted 12 lines
qapi-schema.json +2 -0
index 5658723..66ed582 100644
@@ -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. (Since 2.8)

s/bytes/bytes per second/ (and elsewhere in this patch)

qapi-schema.json line 645

Quoted 4 lines
qapi-schema.json +4 -0
+#
+# @downtime-limit: set maximum tolerated downtime for migration. maximum downtime
+#                  in milliseconds (Since 2.8)
+#

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 :|
#3 lore raw
Quoted 48 lines · Ashijeet Acharya
Quoted 34 lines · Daniel P. Berrange
Quoted 33 lines · Ashijeet Acharya

Mark old-commands for speed and 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 and update the query part in both hmp and qmp qemu control interfaces.

---
 hmp-commands.hx               |   8 +--
 hmp.c                         |  29 +++++++++-
 include/migration/migration.h |   1 -
 migration/migration.c         | 122 +++++++++++++++++++++++++++++++-----------
 qapi-schema.json              |  37 ++++++++++---
 qmp-commands.hx               |  21 +++++---
 6 files changed, 169 insertions(+), 49 deletions(-)
hmp-commands.hx +2 -2
index 848efee..c7f1ef9 100644
@@ -980,16 +980,16 @@ ETEXI
 
     {
         .name       = "migrate_set_downtime",
-        .args_type  = "value:T",
+        .args_type  = "value:i",
         .params     = "value",
-        .help       = "set maximum tolerated downtime (in seconds) for migrations",
+        .help       = "set maximum tolerated downtime (in milliseconds) for migrations",
         .mhandler.cmd = hmp_migrate_set_downtime,
     },
 
Quoted 12 lines

hmp-commands.hx ETEXI · line 993

Quoted 7 lines
hmp-commands.hx +2 -2
 STEXI
-@item migrate_set_downtime @var{second}
+@item migrate_set_downtime @var{milliseconds}
 @findex migrate_set_downtime
-Set maximum tolerated downtime (in seconds) for migration.
+Set maximum tolerated downtime (in milliseconds) for migration.
 ETEXI

Sorry, you misunderstood - while we should use 'milliseconds' for downtime in the 'migrate_set_parameters' command, we cannot change the existing 'migrate_set_downtime' command. Changing that would break compatibility with existing apps.

Quoted 7 lines

Oh, so that means the calculations of downtime for both the parts will be separate at the moment and i cannot glue them together. Unfortunately I will only be able send the updated patch by tomorrow now. It's really late here.

Thanks
Ashijeet

I had one more query since you mentioned the backwards compatibility issue, regarding the bandwidth part.
Should I drop the rounding of -ve speed values to zero for both or just the new-commands.

Ashijeet

Quoted 27 lines
Quoted 27 lines

qapi-schema.json line 641

Quoted 12 lines
qapi-schema.json +2 -0
index 5658723..66ed582 100644
@@ -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. (Since 2.8)

s/bytes/bytes per second/ (and elsewhere in this patch)

qapi-schema.json line 645

Quoted 4 lines
qapi-schema.json +4 -0
+#
+# @downtime-limit: set maximum tolerated downtime for migration. maximum downtime
+#                  in milliseconds (Since 2.8)
+#

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 :|