migration: Add max-switchover-bandwidth parameter
v2 cover migration: Add max-switchover-bandwidth parameter
v2:
- Fix wordings, reindent qapi doc [Markus]
- Added a pre-requisite patch to dedup documents in qapi/migration
- Rename available-bandwidth to max-switchover-bandwidth [Dan]
This is the v2 series to add the new parameter to guide migration switchover calculations.
For more information on the new parameter and why we need it, please read commit message in patch 2.
Please have a look, thanks.
Peter Xu (2):
qapi/migration: Deduplicate migration parameter field comments
migration: Allow user to specify migration switchover bandwidth
qapi/migration.json | 297 +++------------------------------ migration/migration.h | 2 +- migration/options.h | 1 + migration/migration-hmp-cmds.c | 14 ++ migration/migration.c | 19 ++- migration/options.c | 28 ++++ migration/trace-events | 2 +- 7 files changed, 80 insertions(+), 283 deletions(-)
Signature · 1 line
2.41.0
PATCH v2 1/2 qapi/migration: Deduplicate migration parameter field comments
We used to have three objects that have always the same list of parameters and comments are always duplicated:
- @MigrationParameter
- @MigrationParameters
- @MigrateSetParameters
Before we can deduplicate the code, it's fairly straightforward to deduplicate the comments first, so for each time we add a new migration parameter we don't need to copy the same paragraphs three times.
Make the @MigrationParameter the major source of truth, while leaving the rest two to reference to it.
We do have a slight problem in the man/html pages generated, that for the latter two objects we'll get a list of Members but with all of them saying "Not documented":
Members
announce-initial: int (optional)
Not documented
announce-max: int (optional)
Not documented
announce-rounds: int (optional)
Not documented
[...]
Even though we'll have a reference there telling the reader to jump over to read the @MigrationParameter sections instead, for example:
MigrationParameters (Object)
The object structure to represent a list of migration parameters. The optional members aren't actually optional. For detailed explanation for each of the field, please refer to the documentation of MigrationParameter.
So hopefully that's not too bad.. and we can leave it for later to make it even better.
--- qapi/migration.json | 283 ++------------------------------------------ 1 file changed, 7 insertions(+), 276 deletions(-)
qapi/migration.json +7 -276
@@ -854,142 +854,9 @@ ## # @MigrateSetParameters: # -# @announce-initial: Initial delay (in milliseconds) before sending -# the first announce (Since 4.0) -# -# @announce-max: Maximum delay (in milliseconds) between packets in -# the announcement (Since 4.0) -# -# @announce-rounds: Number of self-announce packets sent after -# migration (Since 4.0) -# -# @announce-step: Increase in delay (in milliseconds) between -# subsequent packets in the announcement (Since 4.0) -# -# @compress-level: compression level -# -# @compress-threads: compression thread count -# -# @compress-wait-thread: Controls behavior when all compression -# threads are currently busy. If true (default), wait for a free -# compression thread to become available; otherwise, send the page -# uncompressed. (Since 3.1) -# -# @decompress-threads: decompression thread count -# -# @throttle-trigger-threshold: The ratio of bytes_dirty_period and -# bytes_xfer_period to trigger throttling. It is expressed as -# percentage. The default value is 50. (Since 5.0) -# -# @cpu-throttle-initial: Initial percentage of time guest cpus are -# throttled when migration auto-converge is activated. The -# default value is 20. (Since 2.7) -# -# @cpu-throttle-increment: throttle percentage increase each time -# auto-converge detects that migration is not making progress. -# The default value is 10. (Since 2.7) -# -# @cpu-throttle-tailslow: Make CPU throttling slower at tail stage At -# the tail stage of throttling, the Guest is very sensitive to CPU -# percentage while the @cpu-throttle -increment is excessive -# usually at tail stage. If this parameter is true, we will -# compute the ideal CPU percentage used by the Guest, which may -# exactly make the dirty rate match the dirty rate threshold. -# Then we will choose a smaller throttle increment between the one -# specified by @cpu-throttle-increment and the one generated by -# ideal CPU percentage. Therefore, it is compatible to -# traditional throttling, meanwhile the throttle increment won't -# be excessive at tail stage. The default value is false. (Since -# 5.1) -# -# @tls-creds: ID of the 'tls-creds' object that provides credentials -# for establishing a TLS connection over the migration data -# channel. On the outgoing side of the migration, the credentials -# must be for a 'client' endpoint, while for the incoming side the -# credentials must be for a 'server' endpoint. Setting this to a -# non-empty string enables TLS for all migrations. An empty -# string means that QEMU will use plain text mode for migration, -# rather than TLS (Since 2.9) Previously (since 2.7), this was -# reported by omitting tls-creds instead. -# -# @tls-hostname: hostname of the target host for the migration. This -# is required when using x509 based TLS credentials and the -# migration URI does not already include a hostname. For example -# if using fd: or exec: based migration, the hostname must be -# provided so that the server's x509 certificate identity can be -# validated. (Since 2.7) An empty string means that QEMU will use -# the hostname associated with the migration URI, if any. (Since -# 2.9) Previously (since 2.7), this was reported by omitting -# tls-hostname instead. -# -# @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) -# -# @x-checkpoint-delay: the delay time between two COLO checkpoints. -# (Since 2.8) -# -# @block-incremental: Affects how much storage is migrated when the -# block migration capability is enabled. When false, the entire -# storage backing chain is migrated into a flattened image at the -# destination; when true, only the active qcow2 layer is migrated -# and the destination must already have access to the same backing -# chain as was used on the source. (since 2.10) -# -# @multifd-channels: Number of channels used to migrate data in -# parallel. This is the same number that the number of sockets -# used for migration. The default value is 2 (since 4.0) -# -# @xbzrle-cache-size: cache size to be used by XBZRLE migration. It -# needs to be a multiple of the target page size and a power of 2 -# (Since 2.11) -# -# @max-postcopy-bandwidth: Background transfer bandwidth during -# postcopy. Defaults to 0 (unlimited). In bytes per second. -# (Since 3.0) -# -# @max-cpu-throttle: maximum cpu throttle percentage. The default -# value is 99. (Since 3.1) -# -# @multifd-compression: Which compression method to use. Defaults to -# none. (Since 5.0) -# -# @multifd-zlib-level: Set the compression level to be used in live -# migration, the compression level is an integer between 0 and 9, -# where 0 means no compression, 1 means the best compression -# speed, and 9 means best compression ratio which will consume -# more CPU. Defaults to 1. (Since 5.0) -# -# @multifd-zstd-level: Set the compression level to be used in live -# migration, the compression level is an integer between 0 and 20, -# where 0 means no compression, 1 means the best compression -# speed, and 20 means best compression ratio which will consume -# more CPU. Defaults to 1. (Since 5.0) -# -# @block-bitmap-mapping: Maps block nodes and bitmaps on them to -# aliases for the purpose of dirty bitmap migration. Such aliases -# may for example be the corresponding names on the opposite site. -# The mapping must be one-to-one, but not necessarily complete: On -# the source, unmapped bitmaps and all bitmaps on unmapped nodes -# will be ignored. On the destination, encountering an unmapped -# alias in the incoming migration stream will result in a report, -# and all further bitmap migration data will then be discarded. -# Note that the destination does not know about bitmaps it does -# not receive, so there is no limitation or requirement regarding -# the number of bitmaps received, or how they are named, or on -# which nodes they are placed. By default (when this parameter -# has never been set), bitmap names are mapped to themselves. -# Nodes are mapped to their block device name if there is one, and -# to their node name otherwise. (Since 5.2) -# -# @x-vcpu-dirty-limit-period: Periodic time (in milliseconds) of dirty -# limit during live migration. Should be in the range 1 to 1000ms. -# Defaults to 1000ms. (Since 8.1) -# -# @vcpu-dirty-limit: Dirtyrate limit (MB/s) during live migration. -# Defaults to 1. (Since 8.1) +# Object structure to set migration parameters. For detailed +# explanation of each of the field, please refer to the documentation +# of @MigrationParameter. # # Features: #
@@ -1053,146 +920,10 @@ ## # @MigrationParameters: # -# The optional members aren't actually optional. -# -# @announce-initial: Initial delay (in milliseconds) before sending -# the first announce (Since 4.0) -# -# @announce-max: Maximum delay (in milliseconds) between packets in -# the announcement (Since 4.0) -# -# @announce-rounds: Number of self-announce packets sent after -# migration (Since 4.0) -# -# @announce-step: Increase in delay (in milliseconds) between -# subsequent packets in the announcement (Since 4.0) -# -# @compress-level: compression level -# -# @compress-threads: compression thread count -# -# @compress-wait-thread: Controls behavior when all compression -# threads are currently busy. If true (default), wait for a free -# compression thread to become available; otherwise, send the page -# uncompressed. (Since 3.1) -# -# @decompress-threads: decompression thread count -# -# @throttle-trigger-threshold: The ratio of bytes_dirty_period and -# bytes_xfer_period to trigger throttling. It is expressed as -# percentage. The default value is 50. (Since 5.0) -# -# @cpu-throttle-initial: Initial percentage of time guest cpus are -# throttled when migration auto-converge is activated. (Since -# 2.7) -# -# @cpu-throttle-increment: throttle percentage increase each time -# auto-converge detects that migration is not making progress. -# (Since 2.7) -# -# @cpu-throttle-tailslow: Make CPU throttling slower at tail stage At -# the tail stage of throttling, the Guest is very sensitive to CPU -# percentage while the @cpu-throttle -increment is excessive -# usually at tail stage. If this parameter is true, we will -# compute the ideal CPU percentage used by the Guest, which may -# exactly make the dirty rate match the dirty rate threshold. -# Then we will choose a smaller throttle increment between the one -# specified by @cpu-throttle-increment and the one generated by -# ideal CPU percentage. Therefore, it is compatible to -# traditional throttling, meanwhile the throttle increment won't -# be excessive at tail stage. The default value is false. (Since -# 5.1) -# -# @tls-creds: ID of the 'tls-creds' object that provides credentials -# for establishing a TLS connection over the migration data -# channel. On the outgoing side of the migration, the credentials -# must be for a 'client' endpoint, while for the incoming side the -# credentials must be for a 'server' endpoint. An empty string -# means that QEMU will use plain text mode for migration, rather -# than TLS (Since 2.7) Note: 2.8 reports this by omitting -# tls-creds instead. -# -# @tls-hostname: hostname of the target host for the migration. This -# is required when using x509 based TLS credentials and the -# migration URI does not already include a hostname. For example -# if using fd: or exec: based migration, the hostname must be -# provided so that the server's x509 certificate identity can be -# validated. (Since 2.7) An empty string means that QEMU will use -# the hostname associated with the migration URI, if any. (Since -# 2.9) Note: 2.8 reports this by omitting tls-hostname instead. -# -# @tls-authz: ID of the 'authz' object subclass that provides access -# control checking of the TLS x509 certificate distinguished name. -# (Since 4.0) -# -# @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) -# -# @x-checkpoint-delay: the delay time between two COLO checkpoints. -# (Since 2.8) -# -# @block-incremental: Affects how much storage is migrated when the -# block migration capability is enabled. When false, the entire -# storage backing chain is migrated into a flattened image at the -# destination; when true, only the active qcow2 layer is migrated -# and the destination must already have access to the same backing -# chain as was used on the source. (since 2.10) -# -# @multifd-channels: Number of channels used to migrate data in -# parallel. This is the same number that the number of sockets -# used for migration. The default value is 2 (since 4.0) -# -# @xbzrle-cache-size: cache size to be used by XBZRLE migration. It -# needs to be a multiple of the target page size and a power of 2 -# (Since 2.11) -# -# @max-postcopy-bandwidth: Background transfer bandwidth during -# postcopy. Defaults to 0 (unlimited). In bytes per second. -# (Since 3.0) -# -# @max-cpu-throttle: maximum cpu throttle percentage. Defaults to 99. -# (Since 3.1) -# -# @multifd-compression: Which compression method to use. Defaults to -# none. (Since 5.0) -# -# @multifd-zlib-level: Set the compression level to be used in live -# migration, the compression level is an integer between 0 and 9, -# where 0 means no compression, 1 means the best compression -# speed, and 9 means best compression ratio which will consume -# more CPU. Defaults to 1. (Since 5.0) -# -# @multifd-zstd-level: Set the compression level to be used in live -# migration, the compression level is an integer between 0 and 20, -# where 0 means no compression, 1 means the best compression -# speed, and 20 means best compression ratio which will consume -# more CPU. Defaults to 1. (Since 5.0) -# -# @block-bitmap-mapping: Maps block nodes and bitmaps on them to -# aliases for the purpose of dirty bitmap migration. Such aliases -# may for example be the corresponding names on the opposite site. -# The mapping must be one-to-one, but not necessarily complete: On -# the source, unmapped bitmaps and all bitmaps on unmapped nodes -# will be ignored. On the destination, encountering an unmapped -# alias in the incoming migration stream will result in a report, -# and all further bitmap migration data will then be discarded. -# Note that the destination does not know about bitmaps it does -# not receive, so there is no limitation or requirement regarding -# the number of bitmaps received, or how they are named, or on -# which nodes they are placed. By default (when this parameter -# has never been set), bitmap names are mapped to themselves. -# Nodes are mapped to their block device name if there is one, and -# to their node name otherwise. (Since 5.2) -# -# @x-vcpu-dirty-limit-period: Periodic time (in milliseconds) of dirty -# limit during live migration. Should be in the range 1 to 1000ms. -# Defaults to 1000ms. (Since 8.1) -# -# @vcpu-dirty-limit: Dirtyrate limit (MB/s) during live migration. -# Defaults to 1. (Since 8.1) +# The object structure to represent a list of migration parameters. +# The optional members aren't actually optional. For detailed +# explanation for each of the field, please refer to the documentation +# of @MigrationParameter. # # Features: #
Signature · 1 line
2.41.0
Re: [PATCH for-8.2 v2 1/2] qapi/migration: Deduplicate migration parameter field comments
Quoted 1 line · Peter Xu
We used to have three objects that have always the same list of parameters
We have!
Quoted 9 lines
and comments are always duplicated:
- @MigrationParameter
- @MigrationParameters
- @MigrateSetParametersBefore we can deduplicate the code, it's fairly straightforward to deduplicate the comments first, so for each time we add a new migration parameter we don't need to copy the same paragraphs three times.
De-duplicating the code would be nice, but we haven't done so in years, which suggests it's hard enough not to be worth the trouble.
De-duplicating the documentation is certainly easier.
Is that what you're trying to say?
Our discussion pros and cons that is happening in review of v1 should be captured in the commit message, right here.
Quoted 2 lines
Make the @MigrationParameter the major source of truth, while leaving the rest two to reference to it.
Any particular reason for picking this one?
Quoted 21 lines
We do have a slight problem in the man/html pages generated, that for the latter two objects we'll get a list of Members but with all of them saying "Not documented":
Members
announce-initial: int (optional)
Not documentedannounce-max: int (optional)
Not documentedannounce-rounds: int (optional)
Not documented[...]
Even though we'll have a reference there telling the reader to jump over to read the @MigrationParameter sections instead, for example:
MigrationParameters (Object)
Quoted 7 lines
The object structure to represent a list of migration parameters. The optional members aren't actually optional. For detailed explanation for each of the field, please refer to the documentation of MigrationParameter.
So hopefully that's not too bad.. and we can leave it for later to make it even better.
It's plenty bad, I'm afraid. It comes out as a short paragraph "don't look here, look there", followed by screenfuls claiming "not documented." Embarrassing. Worse, *misleading*, because the short paragraph is easy to miss.
Also discussed in review of v1. Let's continue there, to avoid splitting the thread.
Quoted 1 line
Signed-off-by Peter Xu <[email protected]>
Re: [PATCH for-8.2 v2 1/2] qapi/migration: Deduplicate migration parameter field comments
Quoted 12 lines · Markus Armbruster
Quoted 1 line · Peter Xu
We used to have three objects that have always the same list of parameters
We have!
Quoted 6 lines
and comments are always duplicated:
- @MigrationParameter
- @MigrationParameters
- @MigrateSetParameters
Quoted 6 lines
Quoted 3 lines
Before we can deduplicate the code, it's fairly straightforward to deduplicate the comments first, so for each time we add a new migration parameter we don't need to copy the same paragraphs three times.
De-duplicating the code would be nice, but we haven't done so in years, which suggests it's hard enough not to be worth the trouble.
The "MigrationParameter" enumeration isn't actually used in QMP at all.
It is only used in HMP for hmp_migrate_set_parameter and hmp_info_migrate_parameters. So it is questionable documenting that enum in the QMP reference docs at all.
1c1
< { 'struct': 'MigrationParameters',
---
Quoted 1 line
{ 'struct': 'MigrateSetParameters',
14,16c14,16
< '*tls-creds': 'str', < '*tls-hostname': 'str', < '*tls-authz': 'str',
---
Quoted 3 lines
'*tls-creds': 'StrOrNull',
'*tls-hostname': 'StrOrNull',
'*tls-authz': 'StrOrNull',Is it not valid to use StrOrNull in both cases and thus delete the duplication here ?
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH for-8.2 v2 1/2] qapi/migration: Deduplicate migration parameter field comments
Quoted 35 lines · Daniel P. Berrangé
Quoted 12 lines · Markus Armbruster
Quoted 1 line · Peter Xu
We used to have three objects that have always the same list of parameters
We have!
Quoted 6 lines
and comments are always duplicated:
- @MigrationParameter
- @MigrationParameters
- @MigrateSetParametersQuoted 6 lines
Quoted 3 lines
Before we can deduplicate the code, it's fairly straightforward to deduplicate the comments first, so for each time we add a new migration parameter we don't need to copy the same paragraphs three times.
De-duplicating the code would be nice, but we haven't done so in years, which suggests it's hard enough not to be worth the trouble.
The "MigrationParameter" enumeration isn't actually used in QMP at all.
It is only used in HMP for
hmp_migrate_set_parameterandhmp_info_migrate_parameters. So it is questionable documenting that enum in the QMP reference docs at all.1c1
< { 'struct': 'MigrationParameters',
---Quoted 1 line
{ 'struct': 'MigrateSetParameters',
14,16c14,16
< '*tls-creds': 'str', < '*tls-hostname': 'str', < '*tls-authz': 'str',
Quoted 7 lines
---
Quoted 3 lines
'*tls-creds': 'StrOrNull', '*tls-hostname': 'StrOrNull', '*tls-authz': 'StrOrNull',Is it not valid to use StrOrNull in both cases and thus delete the duplication here ?
I tested removing MigrateSetParameters by replacing it with MigrationParameters and it looks all fine here... I manually tested qmp/hmp on set/query parameters, and qtests are all happy.
The only thing I see that may affect it is we used to logically allow taking things like '"tls-authz": null' in the json input, but now we won't allow that because we'll be asking for a string type only.
Since we have query-qmp-schema I suppose we're all fine, because logically the mgmt app (libvirt?) will still query that to understand the protocol, so now we'll have (response of query-qmp-schema):
{
"arg-type": "144",
"meta-type": "command",
"name": "migrate-set-parameters",
"ret-type": "0"
},Where 144 can start to point to MigrationParameters, rather than MigrateSetParameters.
Ok, then what if the mgmt app doesn't care and just used "null" in tls-* fields when setting? Funnily I tried it and actually anything that does migrate-set-parameters with a "null" passed over to tls-* fields will already crash qemu...
./migration/options.c:1333: migrate_params_apply: Assertion `params->tls_authz->type == QTYPE_QSTRING' failed.
#0 0x00007f72f4b2a844 in __pthread_kill_implementation () at /lib64/libc.so.6 #1 0x00007f72f4ad9abe in raise () at /lib64/libc.so.6 #2 0x00007f72f4ac287f in abort () at /lib64/libc.so.6 #3 0x00007f72f4ac279b in _nl_load_domain.cold () at /lib64/libc.so.6 #4 0x00007f72f4ad2147 in () at /lib64/libc.so.6 #5 0x00005573308740e6 in migrate_params_apply (params=0x7ffc74fd09d0, errp=0x7ffc74fd0998) at ../migration/options.c:1333 #6 0x0000557330874591 in qmp_migrate_set_parameters (params=0x7ffc74fd09d0, errp=0x7ffc74fd0998) at ../migration/options.c:1433 #7 0x0000557330cb9132 in qmp_marshal_migrate_set_parameters (args=0x7f72e00036d0, ret=0x7f72f133cd98, errp=0x7f72f133cd90) at qapi/qapi-commands-migration.c:214 #8 0x0000557330d07fab in do_qmp_dispatch_bh (opaque=0x7f72f133ce30) at ../qapi/qmp-dispatch.c:128 #9 0x0000557330d33bbb in aio_bh_call (bh=0x5573337d7920) at ../util/async.c:169
#10 0x0000557330d33cd8 in aio_bh_poll (ctx=0x55733356e7d0) at ../util/async.c:216
#11 0x0000557330d17a19 in aio_dispatch (ctx=0x55733356e7d0) at ../util/aio-posix.c:423
#12 0x0000557330d34117 in aio_ctx_dispatch (source=0x55733356e7d0, callback=0x0, user_data=0x0) at ../util/async.c:358 #13 0x00007f72f5a8848c in g_main_context_dispatch () at /lib64/libglib-2.0.so.0
#14 0x0000557330d358d4 in glib_pollfds_poll () at ../util/main-loop.c:290
#15 0x0000557330d35951 in os_host_main_loop_wait (timeout=0) at ../util/main-loop.c:313
#16 0x0000557330d35a5f in main_loop_wait (nonblocking=0) at ../util/main-loop.c:592
#17 0x000055733083aee0 in qemu_main_loop () at ../softmmu/runstate.c:732
#18 0x0000557330b0921b in qemu_default_main () at ../softmmu/main.c:37
#19 0x0000557330b09251 in main (argc=35, argv=0x7ffc74fd0ec8) at ../softmmu/main.c:48
Then I suppose it means all mgmt apps are not using "null" anyway, and it makes more sense to me to just remove MigrateSetParameters (by replacing it with MigrationParameters).
Then if we can also replace MigrationParameter enum with an internal enum (alongside with a _str[] array for it) it seems we're all fine to dedup the 3 objects into 1 in qapi schema.
Thanks,
Signature · 1 line
Peter Xu
Re: [PATCH for-8.2 v2 1/2] qapi/migration: Deduplicate migration parameter field comments
Quoted 41 lines · Peter Xu
Quoted 40 lines · Daniel P. Berrangé
Quoted 12 lines · Markus Armbruster
Quoted 1 line · Peter Xu
We used to have three objects that have always the same list of parameters
We have!
Quoted 6 lines
and comments are always duplicated:
- @MigrationParameter
- @MigrationParameters
- @MigrateSetParametersQuoted 6 lines
Quoted 3 lines
Before we can deduplicate the code, it's fairly straightforward to deduplicate the comments first, so for each time we add a new migration parameter we don't need to copy the same paragraphs three times.
De-duplicating the code would be nice, but we haven't done so in years, which suggests it's hard enough not to be worth the trouble.
The "MigrationParameter" enumeration isn't actually used in QMP at all.
It is only used in HMP for
hmp_migrate_set_parameterandhmp_info_migrate_parameters. So it is questionable documenting that enum in the QMP reference docs at all.1c1
< { 'struct': 'MigrationParameters',
---Quoted 1 line
{ 'struct': 'MigrateSetParameters',
14,16c14,16
< '*tls-creds': 'str', < '*tls-hostname': 'str', < '*tls-authz': 'str',---
Quoted 3 lines
'*tls-creds': 'StrOrNull', '*tls-hostname': 'StrOrNull', '*tls-authz': 'StrOrNull',
Quoted 6 lines
Quoted 2 lines
Is it not valid to use StrOrNull in both cases and thus delete the duplication here ?
I tested removing MigrateSetParameters by replacing it with MigrationParameters and it looks all fine here... I manually tested qmp/hmp on set/query parameters, and qtests are all happy.
I meant the other way around, such we would be using 'StrOrNull' in all scenarios.
Quoted 47 lines
The only thing I see that may affect it is we used to logically allow taking things like '"tls-authz": null' in the json input, but now we won't allow that because we'll be asking for a string type only.
Since we have query-qmp-schema I suppose we're all fine, because logically the mgmt app (libvirt?) will still query that to understand the protocol, so now we'll have (response of query-qmp-schema):
{ "arg-type": "144", "meta-type": "command", "name": "migrate-set-parameters", "ret-type": "0" },Where 144 can start to point to MigrationParameters, rather than MigrateSetParameters.
Ok, then what if the mgmt app doesn't care and just used "null" in tls-* fields when setting? Funnily I tried it and actually anything that does migrate-set-parameters with a "null" passed over to tls-* fields will already crash qemu...
./migration/options.c:1333:migrate_params_apply: Assertion `params->tls_authz->type ==QTYPE_QSTRING' failed.#0 0x00007f72f4b2a844 in __pthread_kill_implementation () at /lib64/libc.so.6 #1 0x00007f72f4ad9abe in raise () at /lib64/libc.so.6 #2 0x00007f72f4ac287f in abort () at /lib64/libc.so.6 #3 0x00007f72f4ac279b in _nl_load_domain.cold () at /lib64/libc.so.6 #4 0x00007f72f4ad2147 in () at /lib64/libc.so.6 #5 0x00005573308740e6 in migrate_params_apply (params=0x7ffc74fd09d0, errp=0x7ffc74fd0998) at ../migration/options.c:1333 #6 0x0000557330874591 in qmp_migrate_set_parameters (params=0x7ffc74fd09d0, errp=0x7ffc74fd0998) at ../migration/options.c:1433 #7 0x0000557330cb9132 in qmp_marshal_migrate_set_parameters (args=0x7f72e00036d0, ret=0x7f72f133cd98, errp=0x7f72f133cd90) at qapi/qapi-commands-migration.c:214 #8 0x0000557330d07fab in do_qmp_dispatch_bh (opaque=0x7f72f133ce30) at ../qapi/qmp-dispatch.c:128 #9 0x0000557330d33bbb in aio_bh_call (bh=0x5573337d7920) at ../util/async.c:169#10
0x0000557330d33cd8inaio_bh_poll(ctx=0x55733356e7d0) at../util/async.c:216
#110x0000557330d17a19inaio_dispatch(ctx=0x55733356e7d0) at../util/aio-posix.c:423
#120x0000557330d34117inaio_ctx_dispatch(source=0x55733356e7d0, callback=0x0, user_data=0x0) at../util/async.c:358#130x00007f72f5a8848cing_main_context_dispatch() at/lib64/libglib-2.0.so.0
#140x0000557330d358d4inglib_pollfds_poll() at../util/main-loop.c:290
#150x0000557330d35951inos_host_main_loop_wait(timeout=0) at../util/main-loop.c:313
#160x0000557330d35a5finmain_loop_wait(nonblocking=0) at../util/main-loop.c:592
#170x000055733083aee0inqemu_main_loop() at../softmmu/runstate.c:732
#180x0000557330b0921binqemu_default_main() at../softmmu/main.c:37
#190x0000557330b09251in main (argc=35, argv=0x7ffc74fd0ec8) at../softmmu/main.c:48
Quoted 3 lines
Then I suppose it means all mgmt apps are not using "null" anyway, and it makes more sense to me to just remove MigrateSetParameters (by replacing it with MigrationParameters).
It shouldn't be crashing, because qmp_migrate_set_parameters() is turning 'null' into "", which means the assert ought to never fire. Did you have a local modiification that caused this crash perhaps ?
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH for-8.2 v2 1/2] qapi/migration: Deduplicate migration parameter field comments
Quoted 45 lines · Daniel P. Berrangé
Quoted 44 lines · Peter Xu
Quoted 42 lines · Daniel P. Berrangé
Quoted 12 lines · Markus Armbruster
Quoted 1 line · Peter Xu
We used to have three objects that have always the same list of parameters
We have!
Quoted 6 lines
and comments are always duplicated:
- @MigrationParameter
- @MigrationParameters
- @MigrateSetParametersQuoted 6 lines
Quoted 3 lines
Before we can deduplicate the code, it's fairly straightforward to deduplicate the comments first, so for each time we add a new migration parameter we don't need to copy the same paragraphs three times.
De-duplicating the code would be nice, but we haven't done so in years, which suggests it's hard enough not to be worth the trouble.
The "MigrationParameter" enumeration isn't actually used in QMP at all.
It is only used in HMP for
hmp_migrate_set_parameterandhmp_info_migrate_parameters. So it is questionable documenting that enum in the QMP reference docs at all.1c1
< { 'struct': 'MigrationParameters',
---Quoted 1 line
{ 'struct': 'MigrateSetParameters',
14,16c14,16
< '*tls-creds': 'str', < '*tls-hostname': 'str', < '*tls-authz': 'str',---
Quoted 3 lines
'*tls-creds': 'StrOrNull', '*tls-hostname': 'StrOrNull', '*tls-authz': 'StrOrNull',Is it not valid to use StrOrNull in both cases and thus delete the duplication here ?
Quoted 6 lines
Quoted 3 lines
I tested removing MigrateSetParameters by replacing it with MigrationParameters and it looks all fine here... I manually tested qmp/hmp on set/query parameters, and qtests are all happy.
I meant the other way around, such we would be using 'StrOrNull' in all scenarios.
Yes, that should also work and even without worrying on nulls. I just took a random one replacing the other.
Quoted 48 lines
Quoted 48 lines
The only thing I see that may affect it is we used to logically allow taking things like '"tls-authz": null' in the json input, but now we won't allow that because we'll be asking for a string type only.
Since we have query-qmp-schema I suppose we're all fine, because logically the mgmt app (libvirt?) will still query that to understand the protocol, so now we'll have (response of query-qmp-schema):
{ "arg-type": "144", "meta-type": "command", "name": "migrate-set-parameters", "ret-type": "0" },Where 144 can start to point to MigrationParameters, rather than MigrateSetParameters.
Ok, then what if the mgmt app doesn't care and just used "null" in tls-* fields when setting? Funnily I tried it and actually anything that does migrate-set-parameters with a "null" passed over to tls-* fields will already crash qemu...
./migration/options.c:1333:migrate_params_apply: Assertion `params->tls_authz->type ==QTYPE_QSTRING' failed.#0 0x00007f72f4b2a844 in __pthread_kill_implementation () at /lib64/libc.so.6 #1 0x00007f72f4ad9abe in raise () at /lib64/libc.so.6 #2 0x00007f72f4ac287f in abort () at /lib64/libc.so.6 #3 0x00007f72f4ac279b in _nl_load_domain.cold () at /lib64/libc.so.6 #4 0x00007f72f4ad2147 in () at /lib64/libc.so.6 #5 0x00005573308740e6 in migrate_params_apply (params=0x7ffc74fd09d0, errp=0x7ffc74fd0998) at ../migration/options.c:1333 #6 0x0000557330874591 in qmp_migrate_set_parameters (params=0x7ffc74fd09d0, errp=0x7ffc74fd0998) at ../migration/options.c:1433 #7 0x0000557330cb9132 in qmp_marshal_migrate_set_parameters (args=0x7f72e00036d0, ret=0x7f72f133cd98, errp=0x7f72f133cd90) at qapi/qapi-commands-migration.c:214 #8 0x0000557330d07fab in do_qmp_dispatch_bh (opaque=0x7f72f133ce30) at ../qapi/qmp-dispatch.c:128 #9 0x0000557330d33bbb in aio_bh_call (bh=0x5573337d7920) at ../util/async.c:169#10
0x0000557330d33cd8inaio_bh_poll(ctx=0x55733356e7d0) at../util/async.c:216
#110x0000557330d17a19inaio_dispatch(ctx=0x55733356e7d0) at../util/aio-posix.c:423
#120x0000557330d34117inaio_ctx_dispatch(source=0x55733356e7d0, callback=0x0, user_data=0x0) at../util/async.c:358#130x00007f72f5a8848cing_main_context_dispatch() at/lib64/libglib-2.0.so.0
#140x0000557330d358d4inglib_pollfds_poll() at../util/main-loop.c:290
#150x0000557330d35951inos_host_main_loop_wait(timeout=0) at../util/main-loop.c:313
#160x0000557330d35a5finmain_loop_wait(nonblocking=0) at../util/main-loop.c:592
#170x000055733083aee0inqemu_main_loop() at../softmmu/runstate.c:732
#180x0000557330b0921binqemu_default_main() at../softmmu/main.c:37
#190x0000557330b09251in main (argc=35, argv=0x7ffc74fd0ec8) at../softmmu/main.c:48
Quoted 8 lines
Quoted 3 lines
Then I suppose it means all mgmt apps are not using "null" anyway, and it makes more sense to me to just remove MigrateSetParameters (by replacing it with MigrationParameters).
It shouldn't be crashing, because
qmp_migrate_set_parameters()is turning 'null' into "", which means the assert ought to never fire. Did you have a local modiification that caused this crash perhaps ?
I think it just got overlooked when introducing tls-authz to not have added that special code in qmp_migrate_set_parameters(), the other two are fine.
Thanks,
Signature · 1 line
Peter Xu
Re: [PATCH for-8.2 v2 1/2] qapi/migration: Deduplicate migration parameter field comments
Quoted 108 lines · Peter Xu
Quoted 45 lines · Daniel P. Berrangé
Quoted 44 lines · Peter Xu
Quoted 42 lines · Daniel P. Berrangé
Quoted 12 lines · Markus Armbruster
Quoted 1 line · Peter Xu
We used to have three objects that have always the same list of parameters
We have!
Quoted 6 lines
and comments are always duplicated:
- @MigrationParameter
- @MigrationParameters
- @MigrateSetParametersQuoted 6 lines
Quoted 3 lines
Before we can deduplicate the code, it's fairly straightforward to deduplicate the comments first, so for each time we add a new migration parameter we don't need to copy the same paragraphs three times.
De-duplicating the code would be nice, but we haven't done so in years, which suggests it's hard enough not to be worth the trouble.
The "MigrationParameter" enumeration isn't actually used in QMP at all.
It is only used in HMP for
hmp_migrate_set_parameterandhmp_info_migrate_parameters. So it is questionable documenting that enum in the QMP reference docs at all.1c1
< { 'struct': 'MigrationParameters',
---Quoted 1 line
{ 'struct': 'MigrateSetParameters',
14,16c14,16
< '*tls-creds': 'str', < '*tls-hostname': 'str', < '*tls-authz': 'str',---
Quoted 3 lines
'*tls-creds': 'StrOrNull', '*tls-hostname': 'StrOrNull', '*tls-authz': 'StrOrNull',Is it not valid to use StrOrNull in both cases and thus delete the duplication here ?
Quoted 6 lines
Quoted 3 lines
I tested removing MigrateSetParameters by replacing it with MigrationParameters and it looks all fine here... I manually tested qmp/hmp on set/query parameters, and qtests are all happy.
I meant the other way around, such we would be using 'StrOrNull' in all scenarios.
Yes, that should also work and even without worrying on nulls. I just took a random one replacing the other.
Quoted 52 lines
Quoted 51 lines
The only thing I see that may affect it is we used to logically allow taking things like '"tls-authz": null' in the json input, but now we won't allow that because we'll be asking for a string type only.
Since we have query-qmp-schema I suppose we're all fine, because logically the mgmt app (libvirt?) will still query that to understand the protocol, so now we'll have (response of query-qmp-schema):
{ "arg-type": "144", "meta-type": "command", "name": "migrate-set-parameters", "ret-type": "0" },Where 144 can start to point to MigrationParameters, rather than MigrateSetParameters.
Ok, then what if the mgmt app doesn't care and just used "null" in tls-* fields when setting? Funnily I tried it and actually anything that does migrate-set-parameters with a "null" passed over to tls-* fields will already crash qemu...
./migration/options.c:1333:migrate_params_apply: Assertion `params->tls_authz->type ==QTYPE_QSTRING' failed.#0 0x00007f72f4b2a844 in __pthread_kill_implementation () at /lib64/libc.so.6 #1 0x00007f72f4ad9abe in raise () at /lib64/libc.so.6 #2 0x00007f72f4ac287f in abort () at /lib64/libc.so.6 #3 0x00007f72f4ac279b in _nl_load_domain.cold () at /lib64/libc.so.6 #4 0x00007f72f4ad2147 in () at /lib64/libc.so.6 #5 0x00005573308740e6 in migrate_params_apply (params=0x7ffc74fd09d0, errp=0x7ffc74fd0998) at ../migration/options.c:1333 #6 0x0000557330874591 in qmp_migrate_set_parameters (params=0x7ffc74fd09d0, errp=0x7ffc74fd0998) at ../migration/options.c:1433 #7 0x0000557330cb9132 in qmp_marshal_migrate_set_parameters (args=0x7f72e00036d0, ret=0x7f72f133cd98, errp=0x7f72f133cd90) at qapi/qapi-commands-migration.c:214 #8 0x0000557330d07fab in do_qmp_dispatch_bh (opaque=0x7f72f133ce30) at ../qapi/qmp-dispatch.c:128 #9 0x0000557330d33bbb in aio_bh_call (bh=0x5573337d7920) at ../util/async.c:169#10
0x0000557330d33cd8inaio_bh_poll(ctx=0x55733356e7d0) at../util/async.c:216
#110x0000557330d17a19inaio_dispatch(ctx=0x55733356e7d0) at../util/aio-posix.c:423
#120x0000557330d34117inaio_ctx_dispatch(source=0x55733356e7d0, callback=0x0, user_data=0x0) at../util/async.c:358#130x00007f72f5a8848cing_main_context_dispatch() at/lib64/libglib-2.0.so.0
#140x0000557330d358d4inglib_pollfds_poll() at../util/main-loop.c:290
#150x0000557330d35951inos_host_main_loop_wait(timeout=0) at../util/main-loop.c:313
#160x0000557330d35a5finmain_loop_wait(nonblocking=0) at../util/main-loop.c:592
#170x000055733083aee0inqemu_main_loop() at../softmmu/runstate.c:732
#180x0000557330b0921binqemu_default_main() at../softmmu/main.c:37
#190x0000557330b09251in main (argc=35, argv=0x7ffc74fd0ec8) at../softmmu/main.c:48Then I suppose it means all mgmt apps are not using "null" anyway, and it makes more sense to me to just remove MigrateSetParameters (by replacing it with MigrationParameters).
Quoted 7 lines
Quoted 4 lines
It shouldn't be crashing, because
qmp_migrate_set_parameters()is turning 'null' into "", which means the assert ought to never fire. Did you have a local modiification that caused this crash perhaps ?I think it just got overlooked when introducing tls-authz to not have added that special code in
qmp_migrate_set_parameters(), the other two are fine.
Oh right yes, pre-existing bug.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH for-8.2 v2 1/2] qapi/migration: Deduplicate migration parameter field comments
Quoted 114 lines · Daniel P. Berrangé
Quoted 113 lines · Peter Xu
Quoted 45 lines · Daniel P. Berrangé
Quoted 44 lines · Peter Xu
Quoted 42 lines · Daniel P. Berrangé
Quoted 12 lines · Markus Armbruster
Quoted 1 line · Peter Xu
We used to have three objects that have always the same list of parameters
We have!
Quoted 6 lines
and comments are always duplicated:
- @MigrationParameter
- @MigrationParameters
- @MigrateSetParametersQuoted 6 lines
Quoted 3 lines
Before we can deduplicate the code, it's fairly straightforward to deduplicate the comments first, so for each time we add a new migration parameter we don't need to copy the same paragraphs three times.
De-duplicating the code would be nice, but we haven't done so in years, which suggests it's hard enough not to be worth the trouble.
The "MigrationParameter" enumeration isn't actually used in QMP at all.
It is only used in HMP for
hmp_migrate_set_parameterandhmp_info_migrate_parameters. So it is questionable documenting that enum in the QMP reference docs at all.1c1
< { 'struct': 'MigrationParameters',
---Quoted 1 line
{ 'struct': 'MigrateSetParameters',
14,16c14,16
< '*tls-creds': 'str', < '*tls-hostname': 'str', < '*tls-authz': 'str',---
Quoted 3 lines
'*tls-creds': 'StrOrNull', '*tls-hostname': 'StrOrNull', '*tls-authz': 'StrOrNull',Is it not valid to use StrOrNull in both cases and thus delete the duplication here ?
Quoted 6 lines
Quoted 3 lines
I tested removing MigrateSetParameters by replacing it with MigrationParameters and it looks all fine here... I manually tested qmp/hmp on set/query parameters, and qtests are all happy.
I meant the other way around, such we would be using 'StrOrNull' in all scenarios.
Yes, that should also work and even without worrying on nulls. I just took a random one replacing the other.
Quoted 56 lines
Quoted 48 lines
The only thing I see that may affect it is we used to logically allow taking things like '"tls-authz": null' in the json input, but now we won't allow that because we'll be asking for a string type only.
Since we have query-qmp-schema I suppose we're all fine, because logically the mgmt app (libvirt?) will still query that to understand the protocol, so now we'll have (response of query-qmp-schema):
{ "arg-type": "144", "meta-type": "command", "name": "migrate-set-parameters", "ret-type": "0" },Where 144 can start to point to MigrationParameters, rather than MigrateSetParameters.
Ok, then what if the mgmt app doesn't care and just used "null" in tls-* fields when setting? Funnily I tried it and actually anything that does migrate-set-parameters with a "null" passed over to tls-* fields will already crash qemu...
./migration/options.c:1333:migrate_params_apply: Assertion `params->tls_authz->type ==QTYPE_QSTRING' failed.#0 0x00007f72f4b2a844 in __pthread_kill_implementation () at /lib64/libc.so.6 #1 0x00007f72f4ad9abe in raise () at /lib64/libc.so.6 #2 0x00007f72f4ac287f in abort () at /lib64/libc.so.6 #3 0x00007f72f4ac279b in _nl_load_domain.cold () at /lib64/libc.so.6 #4 0x00007f72f4ad2147 in () at /lib64/libc.so.6 #5 0x00005573308740e6 in migrate_params_apply (params=0x7ffc74fd09d0, errp=0x7ffc74fd0998) at ../migration/options.c:1333 #6 0x0000557330874591 in qmp_migrate_set_parameters (params=0x7ffc74fd09d0, errp=0x7ffc74fd0998) at ../migration/options.c:1433 #7 0x0000557330cb9132 in qmp_marshal_migrate_set_parameters (args=0x7f72e00036d0, ret=0x7f72f133cd98, errp=0x7f72f133cd90) at qapi/qapi-commands-migration.c:214 #8 0x0000557330d07fab in do_qmp_dispatch_bh (opaque=0x7f72f133ce30) at ../qapi/qmp-dispatch.c:128 #9 0x0000557330d33bbb in aio_bh_call (bh=0x5573337d7920) at ../util/async.c:169#10
0x0000557330d33cd8inaio_bh_poll(ctx=0x55733356e7d0) at../util/async.c:216
#110x0000557330d17a19inaio_dispatch(ctx=0x55733356e7d0) at../util/aio-posix.c:423
#120x0000557330d34117inaio_ctx_dispatch(source=0x55733356e7d0, callback=0x0, user_data=0x0) at../util/async.c:358#130x00007f72f5a8848cing_main_context_dispatch() at/lib64/libglib-2.0.so.0
#140x0000557330d358d4inglib_pollfds_poll() at../util/main-loop.c:290
#150x0000557330d35951inos_host_main_loop_wait(timeout=0) at../util/main-loop.c:313
#160x0000557330d35a5finmain_loop_wait(nonblocking=0) at../util/main-loop.c:592
#170x000055733083aee0inqemu_main_loop() at../softmmu/runstate.c:732
#180x0000557330b0921binqemu_default_main() at../softmmu/main.c:37
#190x0000557330b09251in main (argc=35, argv=0x7ffc74fd0ec8) at../softmmu/main.c:48Quoted 3 lines
Then I suppose it means all mgmt apps are not using "null" anyway, and it makes more sense to me to just remove MigrateSetParameters (by replacing it with MigrationParameters).
It shouldn't be crashing, because
qmp_migrate_set_parameters()is turning 'null' into "", which means the assert ought to never fire. Did you have a local modiification that caused this crash perhaps ?
Quoted 4 lines
Quoted 2 lines
I think it just got overlooked when introducing tls-authz to not have added that special code in
qmp_migrate_set_parameters(), the other two are fine.Oh right yes, pre-existing bug.
So do we really care about "null" in any form over "" (empty str) here for tls-* parameters?
To fix this tls-authz bug we can add one more QTYPE_QNULL to QTYPE_QSTRING convertion, but I'd rather just use "str" for all tls* fields and remove the other two instead, if "null" is not important to anyone.
In all cases, I've appended with the two patches I'm currently testing with. It should also fix the tls-authz crash over 'null' by just rejecting that. But I'm open to anything - the patch (more than RFC) is more for reference of whether we can drop the two objects in qapi/migration.
Thanks,
===8<===
From cd07ae2c048fe2265845bcf3f1ef4529854b71a1 Mon Sep 17 00:00:00 2001
From: Peter Xu <[email protected]>
Date: Fri, 4 Aug 2023 11:02:26 -0400
Subject: [PATCH 1/2] migration/qapi: Replace @MigrateSetParameters with
@MigrationParameters
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
These two structs are mostly identical besides some fields (quote from Daniel P. Berrangé in his reply):
1c1
< { 'struct': 'MigrationParameters',
---
Quoted 1 line
{ 'struct': 'MigrateSetParameters',
14,16c14,16
< '*tls-creds': 'str', < '*tls-hostname': 'str', < '*tls-authz': 'str',
---
Quoted 3 lines
'*tls-creds': 'StrOrNull',
'*tls-hostname': 'StrOrNull',
'*tls-authz': 'StrOrNull',Here the difference is @MigrateSetParameters object would allow 'null' values for any tls-* fields passed in.
Is that really important? It seems not, because right now if anyone tries to pass over a 'null' value to any of them, QEMU will already crash:
./migration/options.c:1333: migrate_params_apply: Assertion `params->tls_authz->type == QTYPE_QSTRING' failed.
And it's actually important to fix this crash instead.
To fix it, we can either change the code to handle QTYPE_NULL, or rather we can directly replace all @MigrateSetParameters references with @MigrationParameters knowing that no user is anyway using 'null' as an input.
This greatly deduplicates the code not only in qapi/migration.json, but also in the generic migration code.
--- qapi/migration.json | 185 +-------------------------------- migration/migration-hmp-cmds.c | 16 +-- migration/options.c | 140 ++----------------------- 3 files changed, 12 insertions(+), 329 deletions(-)
qapi/migration.json +1 -184
@@ -851,189 +851,6 @@ { 'name': 'x-vcpu-dirty-limit-period', 'features': ['unstable'] }, 'vcpu-dirty-limit'] } -## -# @MigrateSetParameters: -# -# @announce-initial: Initial delay (in milliseconds) before sending -# the first announce (Since 4.0) -# -# @announce-max: Maximum delay (in milliseconds) between packets in -# the announcement (Since 4.0) -# -# @announce-rounds: Number of self-announce packets sent after -# migration (Since 4.0) -# -# @announce-step: Increase in delay (in milliseconds) between -# subsequent packets in the announcement (Since 4.0) -# -# @compress-level: compression level -# -# @compress-threads: compression thread count -# -# @compress-wait-thread: Controls behavior when all compression -# threads are currently busy. If true (default), wait for a free -# compression thread to become available; otherwise, send the page -# uncompressed. (Since 3.1) -# -# @decompress-threads: decompression thread count -# -# @throttle-trigger-threshold: The ratio of bytes_dirty_period and -# bytes_xfer_period to trigger throttling. It is expressed as -# percentage. The default value is 50. (Since 5.0) -# -# @cpu-throttle-initial: Initial percentage of time guest cpus are -# throttled when migration auto-converge is activated. The -# default value is 20. (Since 2.7) -# -# @cpu-throttle-increment: throttle percentage increase each time -# auto-converge detects that migration is not making progress. -# The default value is 10. (Since 2.7) -# -# @cpu-throttle-tailslow: Make CPU throttling slower at tail stage At -# the tail stage of throttling, the Guest is very sensitive to CPU -# percentage while the @cpu-throttle -increment is excessive -# usually at tail stage. If this parameter is true, we will -# compute the ideal CPU percentage used by the Guest, which may -# exactly make the dirty rate match the dirty rate threshold. -# Then we will choose a smaller throttle increment between the one -# specified by @cpu-throttle-increment and the one generated by -# ideal CPU percentage. Therefore, it is compatible to -# traditional throttling, meanwhile the throttle increment won't -# be excessive at tail stage. The default value is false. (Since -# 5.1) -# -# @tls-creds: ID of the 'tls-creds' object that provides credentials -# for establishing a TLS connection over the migration data -# channel. On the outgoing side of the migration, the credentials -# must be for a 'client' endpoint, while for the incoming side the -# credentials must be for a 'server' endpoint. Setting this to a -# non-empty string enables TLS for all migrations. An empty -# string means that QEMU will use plain text mode for migration, -# rather than TLS (Since 2.9) Previously (since 2.7), this was -# reported by omitting tls-creds instead. -# -# @tls-hostname: hostname of the target host for the migration. This -# is required when using x509 based TLS credentials and the -# migration URI does not already include a hostname. For example -# if using fd: or exec: based migration, the hostname must be -# provided so that the server's x509 certificate identity can be -# validated. (Since 2.7) An empty string means that QEMU will use -# the hostname associated with the migration URI, if any. (Since -# 2.9) Previously (since 2.7), this was reported by omitting -# tls-hostname instead. -# -# @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) -# -# @x-checkpoint-delay: the delay time between two COLO checkpoints. -# (Since 2.8) -# -# @block-incremental: Affects how much storage is migrated when the -# block migration capability is enabled. When false, the entire -# storage backing chain is migrated into a flattened image at the -# destination; when true, only the active qcow2 layer is migrated -# and the destination must already have access to the same backing -# chain as was used on the source. (since 2.10) -# -# @multifd-channels: Number of channels used to migrate data in -# parallel. This is the same number that the number of sockets -# used for migration. The default value is 2 (since 4.0) -# -# @xbzrle-cache-size: cache size to be used by XBZRLE migration. It -# needs to be a multiple of the target page size and a power of 2 -# (Since 2.11) -# -# @max-postcopy-bandwidth: Background transfer bandwidth during -# postcopy. Defaults to 0 (unlimited). In bytes per second. -# (Since 3.0) -# -# @max-cpu-throttle: maximum cpu throttle percentage. The default -# value is 99. (Since 3.1) -# -# @multifd-compression: Which compression method to use. Defaults to -# none. (Since 5.0) -# -# @multifd-zlib-level: Set the compression level to be used in live -# migration, the compression level is an integer between 0 and 9, -# where 0 means no compression, 1 means the best compression -# speed, and 9 means best compression ratio which will consume -# more CPU. Defaults to 1. (Since 5.0) -# -# @multifd-zstd-level: Set the compression level to be used in live -# migration, the compression level is an integer between 0 and 20, -# where 0 means no compression, 1 means the best compression -# speed, and 20 means best compression ratio which will consume -# more CPU. Defaults to 1. (Since 5.0) -# -# @block-bitmap-mapping: Maps block nodes and bitmaps on them to -# aliases for the purpose of dirty bitmap migration. Such aliases -# may for example be the corresponding names on the opposite site. -# The mapping must be one-to-one, but not necessarily complete: On -# the source, unmapped bitmaps and all bitmaps on unmapped nodes -# will be ignored. On the destination, encountering an unmapped -# alias in the incoming migration stream will result in a report, -# and all further bitmap migration data will then be discarded. -# Note that the destination does not know about bitmaps it does -# not receive, so there is no limitation or requirement regarding -# the number of bitmaps received, or how they are named, or on -# which nodes they are placed. By default (when this parameter -# has never been set), bitmap names are mapped to themselves. -# Nodes are mapped to their block device name if there is one, and -# to their node name otherwise. (Since 5.2) -# -# @x-vcpu-dirty-limit-period: Periodic time (in milliseconds) of dirty -# limit during live migration. Should be in the range 1 to 1000ms. -# Defaults to 1000ms. (Since 8.1) -# -# @vcpu-dirty-limit: Dirtyrate limit (MB/s) during live migration. -# Defaults to 1. (Since 8.1) -# -# Features: -# -# @unstable: Members @x-checkpoint-delay and @x-vcpu-dirty-limit-period -# are experimental. -# -# TODO: either fuse back into MigrationParameters, or make -# MigrationParameters members mandatory -# -# Since: 2.4 -## -{ 'struct': 'MigrateSetParameters', - 'data': { '*announce-initial': 'size', - '*announce-max': 'size', - '*announce-rounds': 'size', - '*announce-step': 'size', - '*compress-level': 'uint8', - '*compress-threads': 'uint8', - '*compress-wait-thread': 'bool', - '*decompress-threads': 'uint8', - '*throttle-trigger-threshold': 'uint8', - '*cpu-throttle-initial': 'uint8', - '*cpu-throttle-increment': 'uint8', - '*cpu-throttle-tailslow': 'bool', - '*tls-creds': 'StrOrNull', - '*tls-hostname': 'StrOrNull', - '*tls-authz': 'StrOrNull', - '*max-bandwidth': 'size', - '*downtime-limit': 'uint64', - '*x-checkpoint-delay': { 'type': 'uint32', - 'features': [ 'unstable' ] }, - '*block-incremental': 'bool', - '*multifd-channels': 'uint8', - '*xbzrle-cache-size': 'size', - '*max-postcopy-bandwidth': 'size', - '*max-cpu-throttle': 'uint8', - '*multifd-compression': 'MultiFDCompression', - '*multifd-zlib-level': 'uint8', - '*multifd-zstd-level': 'uint8', - '*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ], - '*x-vcpu-dirty-limit-period': { 'type': 'uint64', - 'features': [ 'unstable' ] }, - '*vcpu-dirty-limit': 'uint64'} } - ## # @migrate-set-parameters: #
@@ -1048,7 +865,7 @@ # <- { "return": {} } ## { 'command': 'migrate-set-parameters', 'boxed': true, - 'data': 'MigrateSetParameters' } + 'data': 'MigrationParameters' } ## # @MigrationParameters:
migration/migration-hmp-cmds.c +5 -11
@@ -497,7 +497,7 @@ 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" );Visitor *v =string_input_visitor_new (valuestr); -MigrateSetParameters *p =g_new0 (MigrateSetParameters,1 ); +MigrationParameters *p =g_new0 (MigrationParameters,1 );uint64_t valuebw =0 ;uint64_t cache_size;Error *err =NULL ;
@@ -546,19 +546,13 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)visit_type_uint8 (v, param, &p->max_cpu_throttle, &err);break ;case MIGRATION_PARAMETER_TLS_CREDS : - p->tls_creds =g_new0 (StrOrNull,1 ); - p->tls_creds->type =QTYPE_QSTRING ; -visit_type_str (v, param, &p->tls_creds->u.s, &err); +visit_type_str (v, param, &p->tls_creds, &err);break ;case MIGRATION_PARAMETER_TLS_HOSTNAME : - p->tls_hostname =g_new0 (StrOrNull,1 ); - p->tls_hostname->type =QTYPE_QSTRING ; -visit_type_str (v, param, &p->tls_hostname->u.s, &err); +visit_type_str (v, param, &p->tls_hostname, &err);break ;case MIGRATION_PARAMETER_TLS_AUTHZ : - p->tls_authz =g_new0 (StrOrNull,1 ); - p->tls_authz->type =QTYPE_QSTRING ; -visit_type_str (v, param, &p->tls_authz->u.s, &err); +visit_type_str (v, param, &p->tls_authz, &err);break ;case MIGRATION_PARAMETER_MAX_BANDWIDTH : p->has_max_bandwidth = true;
@@ -657,7 +651,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)qmp_migrate_set_parameters (p, &err); cleanup: -qapi_free_MigrateSetParameters (p); +qapi_free_MigrationParameters (p);visit_free (v);hmp_handle_error (mon, err); }
migration/options.c +6 -134
167 lines not on this page · raw message
Signature · 20 lines
2.41.0 ===8<=== From 4d0661be6be85631f64c6bcb8cec9f30a49bc805 Mon Sep 17 00:00:00 2001 From: Peter Xu <[email protected]> Date: Fri, 4 Aug 2023 12:32:21 -0400 Subject: [PATCH 2/2] migration/qapi: Drop @MigrationParameter enum Drop the enum in qapi because it is never used in QMP APIs. Instead making it an internal definition for QEMU so that we can decouple it from QAPI, and also we can deduplicate the QAPI documentations. Signed-off-by: Peter Xu <[email protected]> --- qapi/migration.json | 179 --------------------------------- migration/options.h | 47 +++++++++ migration/migration-hmp-cmds.c | 3 +- migration/options.c | 51 ++++++++++ 4 files changed, 100 insertions(+), 180 deletions(-)
qapi/migration.json +0 -179
185 lines not on this page · raw message
migration/options.h +47 -0
53 lines not on this page · raw message
migration/migration-hmp-cmds.c +2 -1
@@ -31,6 +31,7 @@#include "ui/qemu-spice.h" #include "sysemu/sysemu.h" #include "migration.h" +#include "migration/options.h" static void migration_global_dump (Monitor *mon) {
@@ -503,7 +504,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)Error *err =NULL ;int val, ret; - val =qapi_enum_parse (&MigrationParameter_lookup, param,-1 , &err); + val =MigrationParameter_from_str (param, &err);if (val <0 ) { goto cleanup; }
migration/options.c +51 -0
57 lines not on this page · raw message
Signature · 6 lines
2.41.0 ===8<=== -- Peter Xu
Re: [PATCH for-8.2 v2 1/2] qapi/migration: Deduplicate migration parameter field comments
Quoted 115 lines · Peter Xu
Quoted 114 lines · Daniel P. Berrangé
Quoted 113 lines · Peter Xu
Quoted 45 lines · Daniel P. Berrangé
Quoted 44 lines · Peter Xu
Quoted 42 lines · Daniel P. Berrangé
Quoted 12 lines · Markus Armbruster
Quoted 1 line · Peter Xu
We used to have three objects that have always the same list of parameters
We have!
Quoted 6 lines
and comments are always duplicated:
- @MigrationParameter
- @MigrationParameters
- @MigrateSetParametersQuoted 6 lines
Quoted 3 lines
Before we can deduplicate the code, it's fairly straightforward to deduplicate the comments first, so for each time we add a new migration parameter we don't need to copy the same paragraphs three times.
De-duplicating the code would be nice, but we haven't done so in years, which suggests it's hard enough not to be worth the trouble.
The "MigrationParameter" enumeration isn't actually used in QMP at all.
It is only used in HMP for
hmp_migrate_set_parameterandhmp_info_migrate_parameters. So it is questionable documenting that enum in the QMP reference docs at all.1c1
< { 'struct': 'MigrationParameters',
---Quoted 1 line
{ 'struct': 'MigrateSetParameters',
14,16c14,16
< '*tls-creds': 'str', < '*tls-hostname': 'str', < '*tls-authz': 'str',---
Quoted 3 lines
'*tls-creds': 'StrOrNull', '*tls-hostname': 'StrOrNull', '*tls-authz': 'StrOrNull',Is it not valid to use StrOrNull in both cases and thus delete the duplication here ?
Quoted 6 lines
Quoted 3 lines
I tested removing MigrateSetParameters by replacing it with MigrationParameters and it looks all fine here... I manually tested qmp/hmp on set/query parameters, and qtests are all happy.
I meant the other way around, such we would be using 'StrOrNull' in all scenarios.
Yes, that should also work and even without worrying on nulls. I just took a random one replacing the other.
Quoted 56 lines
Quoted 48 lines
The only thing I see that may affect it is we used to logically allow taking things like '"tls-authz": null' in the json input, but now we won't allow that because we'll be asking for a string type only.
Since we have query-qmp-schema I suppose we're all fine, because logically the mgmt app (libvirt?) will still query that to understand the protocol, so now we'll have (response of query-qmp-schema):
{ "arg-type": "144", "meta-type": "command", "name": "migrate-set-parameters", "ret-type": "0" },Where 144 can start to point to MigrationParameters, rather than MigrateSetParameters.
Ok, then what if the mgmt app doesn't care and just used "null" in tls-* fields when setting? Funnily I tried it and actually anything that does migrate-set-parameters with a "null" passed over to tls-* fields will already crash qemu...
./migration/options.c:1333:migrate_params_apply: Assertion `params->tls_authz->type ==QTYPE_QSTRING' failed.#0 0x00007f72f4b2a844 in __pthread_kill_implementation () at /lib64/libc.so.6 #1 0x00007f72f4ad9abe in raise () at /lib64/libc.so.6 #2 0x00007f72f4ac287f in abort () at /lib64/libc.so.6 #3 0x00007f72f4ac279b in _nl_load_domain.cold () at /lib64/libc.so.6 #4 0x00007f72f4ad2147 in () at /lib64/libc.so.6 #5 0x00005573308740e6 in migrate_params_apply (params=0x7ffc74fd09d0, errp=0x7ffc74fd0998) at ../migration/options.c:1333 #6 0x0000557330874591 in qmp_migrate_set_parameters (params=0x7ffc74fd09d0, errp=0x7ffc74fd0998) at ../migration/options.c:1433 #7 0x0000557330cb9132 in qmp_marshal_migrate_set_parameters (args=0x7f72e00036d0, ret=0x7f72f133cd98, errp=0x7f72f133cd90) at qapi/qapi-commands-migration.c:214 #8 0x0000557330d07fab in do_qmp_dispatch_bh (opaque=0x7f72f133ce30) at ../qapi/qmp-dispatch.c:128 #9 0x0000557330d33bbb in aio_bh_call (bh=0x5573337d7920) at ../util/async.c:169#10
0x0000557330d33cd8inaio_bh_poll(ctx=0x55733356e7d0) at../util/async.c:216
#110x0000557330d17a19inaio_dispatch(ctx=0x55733356e7d0) at../util/aio-posix.c:423
#120x0000557330d34117inaio_ctx_dispatch(source=0x55733356e7d0, callback=0x0, user_data=0x0) at../util/async.c:358#130x00007f72f5a8848cing_main_context_dispatch() at/lib64/libglib-2.0.so.0
#140x0000557330d358d4inglib_pollfds_poll() at../util/main-loop.c:290
#150x0000557330d35951inos_host_main_loop_wait(timeout=0) at../util/main-loop.c:313
#160x0000557330d35a5finmain_loop_wait(nonblocking=0) at../util/main-loop.c:592
#170x000055733083aee0inqemu_main_loop() at../softmmu/runstate.c:732
#180x0000557330b0921binqemu_default_main() at../softmmu/main.c:37
#190x0000557330b09251in main (argc=35, argv=0x7ffc74fd0ec8) at../softmmu/main.c:48Quoted 3 lines
Then I suppose it means all mgmt apps are not using "null" anyway, and it makes more sense to me to just remove MigrateSetParameters (by replacing it with MigrationParameters).
It shouldn't be crashing, because
qmp_migrate_set_parameters()is turning 'null' into "", which means the assert ought to never fire. Did you have a local modiification that caused this crash perhaps ?
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
I think it just got overlooked when introducing tls-authz to not have added that special code in
qmp_migrate_set_parameters(), the other two are fine.Oh right yes, pre-existing bug.
So do we really care about "null" in any form over "" (empty str) here for tls-* parameters?
In my opinion, the use of "" was a design mistake. Here's my argument:
commit 01fa55982692fb51a16049b63b571651a1053989
Author: Markus Armbruster <[email protected]> Date: Tue Jul 18 14:42:04 2017 +0200
migration: Use JSON null instead of "" to reset parameter to default
migrate-set-parameters sets migration parameters according to is arguments like this:
* Present means "set the parameter to this value"
* Absent means "leave the parameter unchanged"
* Except for parameters tls_creds and tls_hostname, "" means "reset the parameter to its default value
The first two are perfectly normal: presence of the parameter makes the command do something.
The third one overloads the parameter with a second meaning. The overloading is *implicit*, i.e. it's not visible in the types. Works here, because "" is neither a valid TLS credentials ID, nor a valid host name.
Pressing argument values the schema accepts, but are semantically invalid, into service to mean "reset to default" is not general, as suitable invalid values need not exist. I also find it ugly.
To clean this up, we could add a separate flag argument to ask for "reset to default", or add a distinct value to @tls_creds and @tls_hostname. This commit implements the latter: add JSON null to the values of @tls_creds and @tls_hostname, deprecate "".
Because we're so close to the 2.10 freeze, implement it in the stupidest way possible: have qmp_migrate_set_parameters() rewrite null to "" before anything else can see the null. The proper way to do it would be rewriting "" to null, but that requires fixing up code to work with null. Add TODO comments for that.
Quoted 3 lines
To fix this tls-authz bug we can add one more
QTYPE_QNULLtoQTYPE_QSTRINGconvertion, but I'd rather just use "str" for all tls* fields and remove the other two instead, if "null" is not important to anyone.
"Important" sounds too much like absolutes :)
I think we have a tradeoff here. If perpetuating the unclean and ugly use of "" is what it takes to de-triplicate migration parameters, we may decide to accept that.
Quoted 6 lines
In all cases, I've appended with the two patches I'm currently testing with. It should also fix the tls-authz crash over 'null' by just rejecting that. But I'm open to anything - the patch (more than RFC) is more for reference of whether we can drop the two objects in qapi/migration.
Thanks,
Re: [PATCH for-8.2 v2 1/2] qapi/migration: Deduplicate migration parameter field comments
Quoted 166 lines · Markus Armbruster
Quoted 115 lines · Peter Xu
Quoted 114 lines · Daniel P. Berrangé
Quoted 113 lines · Peter Xu
Quoted 45 lines · Daniel P. Berrangé
Quoted 44 lines · Peter Xu
Quoted 42 lines · Daniel P. Berrangé
Quoted 12 lines · Markus Armbruster
Quoted 1 line · Peter Xu
We used to have three objects that have always the same list of parameters
We have!
Quoted 6 lines
and comments are always duplicated:
- @MigrationParameter
- @MigrationParameters
- @MigrateSetParametersQuoted 6 lines
Quoted 3 lines
Before we can deduplicate the code, it's fairly straightforward to deduplicate the comments first, so for each time we add a new migration parameter we don't need to copy the same paragraphs three times.
De-duplicating the code would be nice, but we haven't done so in years, which suggests it's hard enough not to be worth the trouble.
The "MigrationParameter" enumeration isn't actually used in QMP at all.
It is only used in HMP for
hmp_migrate_set_parameterandhmp_info_migrate_parameters. So it is questionable documenting that enum in the QMP reference docs at all.1c1
< { 'struct': 'MigrationParameters',
---Quoted 1 line
{ 'struct': 'MigrateSetParameters',
14,16c14,16
< '*tls-creds': 'str', < '*tls-hostname': 'str', < '*tls-authz': 'str',---
Quoted 3 lines
'*tls-creds': 'StrOrNull', '*tls-hostname': 'StrOrNull', '*tls-authz': 'StrOrNull',Is it not valid to use StrOrNull in both cases and thus delete the duplication here ?
Quoted 6 lines
Quoted 3 lines
I tested removing MigrateSetParameters by replacing it with MigrationParameters and it looks all fine here... I manually tested qmp/hmp on set/query parameters, and qtests are all happy.
I meant the other way around, such we would be using 'StrOrNull' in all scenarios.
Yes, that should also work and even without worrying on nulls. I just took a random one replacing the other.
Quoted 56 lines
Quoted 48 lines
The only thing I see that may affect it is we used to logically allow taking things like '"tls-authz": null' in the json input, but now we won't allow that because we'll be asking for a string type only.
Since we have query-qmp-schema I suppose we're all fine, because logically the mgmt app (libvirt?) will still query that to understand the protocol, so now we'll have (response of query-qmp-schema):
{ "arg-type": "144", "meta-type": "command", "name": "migrate-set-parameters", "ret-type": "0" },Where 144 can start to point to MigrationParameters, rather than MigrateSetParameters.
Ok, then what if the mgmt app doesn't care and just used "null" in tls-* fields when setting? Funnily I tried it and actually anything that does migrate-set-parameters with a "null" passed over to tls-* fields will already crash qemu...
./migration/options.c:1333:migrate_params_apply: Assertion `params->tls_authz->type ==QTYPE_QSTRING' failed.#0 0x00007f72f4b2a844 in __pthread_kill_implementation () at /lib64/libc.so.6 #1 0x00007f72f4ad9abe in raise () at /lib64/libc.so.6 #2 0x00007f72f4ac287f in abort () at /lib64/libc.so.6 #3 0x00007f72f4ac279b in _nl_load_domain.cold () at /lib64/libc.so.6 #4 0x00007f72f4ad2147 in () at /lib64/libc.so.6 #5 0x00005573308740e6 in migrate_params_apply (params=0x7ffc74fd09d0, errp=0x7ffc74fd0998) at ../migration/options.c:1333 #6 0x0000557330874591 in qmp_migrate_set_parameters (params=0x7ffc74fd09d0, errp=0x7ffc74fd0998) at ../migration/options.c:1433 #7 0x0000557330cb9132 in qmp_marshal_migrate_set_parameters (args=0x7f72e00036d0, ret=0x7f72f133cd98, errp=0x7f72f133cd90) at qapi/qapi-commands-migration.c:214 #8 0x0000557330d07fab in do_qmp_dispatch_bh (opaque=0x7f72f133ce30) at ../qapi/qmp-dispatch.c:128 #9 0x0000557330d33bbb in aio_bh_call (bh=0x5573337d7920) at ../util/async.c:169#10
0x0000557330d33cd8inaio_bh_poll(ctx=0x55733356e7d0) at../util/async.c:216
#110x0000557330d17a19inaio_dispatch(ctx=0x55733356e7d0) at../util/aio-posix.c:423
#120x0000557330d34117inaio_ctx_dispatch(source=0x55733356e7d0, callback=0x0, user_data=0x0) at../util/async.c:358#130x00007f72f5a8848cing_main_context_dispatch() at/lib64/libglib-2.0.so.0
#140x0000557330d358d4inglib_pollfds_poll() at../util/main-loop.c:290
#150x0000557330d35951inos_host_main_loop_wait(timeout=0) at../util/main-loop.c:313
#160x0000557330d35a5finmain_loop_wait(nonblocking=0) at../util/main-loop.c:592
#170x000055733083aee0inqemu_main_loop() at../softmmu/runstate.c:732
#180x0000557330b0921binqemu_default_main() at../softmmu/main.c:37
#190x0000557330b09251in main (argc=35, argv=0x7ffc74fd0ec8) at../softmmu/main.c:48Quoted 3 lines
Then I suppose it means all mgmt apps are not using "null" anyway, and it makes more sense to me to just remove MigrateSetParameters (by replacing it with MigrationParameters).
It shouldn't be crashing, because
qmp_migrate_set_parameters()is turning 'null' into "", which means the assert ought to never fire. Did you have a local modiification that caused this crash perhaps ?Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
I think it just got overlooked when introducing tls-authz to not have added that special code in
qmp_migrate_set_parameters(), the other two are fine.Oh right yes, pre-existing bug.
So do we really care about "null" in any form over "" (empty str) here for tls-* parameters?
In my opinion, the use of "" was a design mistake. Here's my argument:
commit
01fa55982692fb51a16049b63b571651a1053989Author: Markus Armbruster <[email protected]> Date: Tue Jul 18 14:42:04 2017 +0200migration: Use JSON null instead of "" to reset parameter to default
migrate-set-parameters sets migration parameters according to is arguments like this:
* Present means "set the parameter to this value"
* Absent means "leave the parameter unchanged"
* Except for parameters
tls_credsandtls_hostname, "" means "reset the parameter to its default valueThe first two are perfectly normal: presence of the parameter makes the command do something.
The third one overloads the parameter with a second meaning. The overloading is *implicit*, i.e. it's not visible in the types. Works here, because "" is neither a valid TLS credentials ID, nor a valid host name.
Pressing argument values the schema accepts, but are semantically invalid, into service to mean "reset to default" is not general, as suitable invalid values need not exist. I also find it ugly.
To clean this up, we could add a separate flag argument to ask for "reset to default", or add a distinct value to @tls_creds and @tls_hostname. This commit implements the latter: add JSON null to the values of @tls_creds and @tls_hostname, deprecate "".
Because we're so close to the 2.10 freeze, implement it in the stupidest way possible: have
qmp_migrate_set_parameters()rewrite null to "" before anything else can see the null. The proper way to do it would be rewriting "" to null, but that requires fixing up code to work with null. Add TODO comments for that.
Quoted 3 lines
Signed-off-by Markus Armbruster <[email protected]>Reviewed-by Daniel P. Berrange <[email protected]>Reviewed-by Eric Blake <[email protected]>
I see. Personally I think as long as the interface is 100% clear I'll be all fine (say, no possible misuse of ""). But keeping StrOrNull may definitely be cleaner I guess.
Quoted 10 lines
Quoted 4 lines
To fix this tls-authz bug we can add one more
QTYPE_QNULLtoQTYPE_QSTRINGconvertion, but I'd rather just use "str" for all tls* fields and remove the other two instead, if "null" is not important to anyone."Important" sounds too much like absolutes :)
I think we have a tradeoff here. If perpetuating the unclean and ugly use of "" is what it takes to de-triplicate migration parameters, we may decide to accept that.
I don't think it's a must. As Dan raised, we can convert str -> StrOrNull for MigrationParameters. I assume it won't affect query-migrate-parameters anyway OTOH.
I assume it means there's nothing yet obvious that we overlooked on the whole idea. Let me propose the formal patchset early next week. It'll be mostly the patch I attached but just add those extra logics for StrOrNull, so the diffstat might be less attractive but hopefully still good enough to be accepted.
Thanks,
Signature · 1 line
Peter Xu
Re: [PATCH for-8.2 v2 1/2] qapi/migration: Deduplicate migration parameter field comments
Quoted 8 lines · Peter Xu
Quoted 3 lines
I think we have a tradeoff here. If perpetuating the unclean and ugly use of "" is what it takes to de-triplicate migration parameters, we may decide to accept that.
I don't think it's a must. As Dan raised, we can convert str -> StrOrNull for MigrationParameters. I assume it won't affect query-migrate-parameters anyway OTOH.
Quoted 5 lines
I assume it means there's nothing yet obvious that we overlooked on the whole idea. Let me propose the formal patchset early next week. It'll be mostly the patch I attached but just add those extra logics for StrOrNull, so the diffstat might be less attractive but hopefully still good enough to be accepted.
The new StrOrNull approach doesn't work with current migration object properties.. as StrOrNull must be a pointer for @MigrationParameters not static, and it stops working with offsetof():
../migration/options.c:218:5: error: cannot apply ‘offsetof’ to a non constant address
218 | DEFINE_PROP_STRING("tls-creds", MigrationState, parameters.tls_creds->u.s),
| ^~~~~~~~~~~~~~~~~~
../migration/options.c:219:5: error: cannot apply ‘offsetof’ to a non constant address
219 | DEFINE_PROP_STRING("tls-hostname", MigrationState, parameters.tls_hostname->u.s),
| ^~~~~~~~~~~~~~~~~~
../migration/options.c:220:5: error: cannot apply ‘offsetof’ to a non constant address
220 | DEFINE_PROP_STRING("tls-authz", MigrationState, parameters.tls_authz->u.s),
| ^~~~~~~~~~~~~~~~~~Any easy way to fix this? I.e., is there a way to declare StrOrNull (in MigrationParameters of qapi/migration.json) to be statically allocated rather than a pointer (just like default behavior of any uint* types)?
Thanks,
Signature · 1 line
Peter Xu
Re: [PATCH for-8.2 v2 1/2] qapi/migration: Deduplicate migration parameter field comments
Quoted 29 lines · Peter Xu
Quoted 8 lines · Peter Xu
Quoted 3 lines
I think we have a tradeoff here. If perpetuating the unclean and ugly use of "" is what it takes to de-triplicate migration parameters, we may decide to accept that.
I don't think it's a must. As Dan raised, we can convert str -> StrOrNull for MigrationParameters. I assume it won't affect query-migrate-parameters anyway OTOH.
Quoted 5 lines
I assume it means there's nothing yet obvious that we overlooked on the whole idea. Let me propose the formal patchset early next week. It'll be mostly the patch I attached but just add those extra logics for StrOrNull, so the diffstat might be less attractive but hopefully still good enough to be accepted.
The new StrOrNull approach doesn't work with current migration object properties.. as StrOrNull must be a pointer for @MigrationParameters not static, and it stops working with
offsetof():
../migration/options.c:218:5: error: cannot apply ‘offsetof’ to a non constant address218 | DEFINE_PROP_STRING("tls-creds", MigrationState, parameters.tls_creds->u.s), | ^~~~~~~~~~~~~~~~~~ ../migration/options.c:219:5: error: cannot apply ‘offsetof’ to a non constant address 219 | DEFINE_PROP_STRING("tls-hostname", MigrationState, parameters.tls_hostname->u.s), | ^~~~~~~~~~~~~~~~~~ ../migration/options.c:220:5: error: cannot apply ‘offsetof’ to a non constant address 220 | DEFINE_PROP_STRING("tls-authz", MigrationState, parameters.tls_authz->u.s), | ^~~~~~~~~~~~~~~~~~
Quoted 3 lines
Any easy way to fix this? I.e., is there a way to declare StrOrNull (in MigrationParameters of
qapi/migration.json) to be statically allocated rather than a pointer (just like default behavior of any uint* types)?
Posted a version with 'str' replacing 'StrOrNull'. Let's move the discussion there:
https://lore.kernel.org/r/[email protected]
Signature · 1 line
Peter Xu
PATCH v2 2/2 migration: Allow user to specify migration switchover bandwidth
In reply to Peter XuMigration bandwidth is a very important value to live migration. It's because it's one of the major factors that we'll make decision on when to switchover to destination in a precopy process.
This value is currently estimated by QEMU during the whole live migration process by monitoring how fast we were sending the data. This can be the most accurate bandwidth if in the ideal world, where we're always feeding unlimited data to the migration channel, and then it'll be limited to the bandwidth that is available.
However in reality it may be very different, e.g., over a 10Gbps network we can see query-migrate showing migration bandwidth of only a few tens of MB/s just because there are plenty of other things the migration thread might be doing. For example, the migration thread can be busy scanning zero pages, or it can be fetching dirty bitmap from other external dirty sources (like vhost or KVM). It means we may not be pushing data as much as possible to migration channel, so the bandwidth estimated from "how many data we sent in the channel" can be dramatically inaccurate sometimes, e.g., that a few tens of MB/s even if 10Gbps available, and then the decision to switchover will be further affected by this.
The migration may not even converge at all with the downtime specified, with that wrong estimation of bandwidth.
The issue is QEMU itself may not be able to avoid those uncertainties on measuing the real "available migration bandwidth". At least not something I can think of so far.
One way to fix this is when the user is fully aware of the available bandwidth, then we can allow the user to help providing an accurate value.
For example, if the user has a dedicated channel of 10Gbps for migration for this specific VM, the user can specify this bandwidth so QEMU can always do the calculation based on this fact, trusting the user as long as specified.
A new parameter "max-switchover-bandwidth" is introduced just for this. So when the user specified this parameter, instead of trusting the estimated value from QEMU itself (based on the QEMUFile send speed), let's trust the user more by using this value to decide when to switchover, assuming that we'll have such bandwidth available then.
When the user wants to have migration only use 5Gbps out of that 10Gbps, one can set max-bandwidth to 5Gbps, along with max-switchover-bandwidth to 5Gbps so it'll never use over 5Gbps too (so the user can have the rest 5Gbps for other things). So it can be useful even if the network is not dedicated, but as long as the user can know a solid value.
This can resolve issues like "unconvergence migration" which is caused by hilarious low "migration bandwidth" detected for whatever reason.
--- qapi/migration.json | 14 +++++++++++++- migration/migration.h | 2 +- migration/options.h | 1 + migration/migration-hmp-cmds.c | 14 ++++++++++++++ migration/migration.c | 19 +++++++++++++++---- migration/options.c | 28 ++++++++++++++++++++++++++++ migration/trace-events | 2 +- 7 files changed, 73 insertions(+), 7 deletions(-)
qapi/migration.json +13 -1
@@ -759,6 +759,16 @@ # @max-bandwidth: to set maximum speed for migration. maximum speed # in bytes per second. (Since 2.8) # +# @max-switchover-bandwidth: to set available bandwidth for migration. +# By default, this value is zero, means the user is not aware of +# the available bandwidth that can be used by QEMU migration, so +# QEMU will estimate the bandwidth automatically. This can be set +# when the estimated value is not accurate, while the user is able +# to guarantee such bandwidth is available for migration purpose +# during the migration procedure. When specified correctly, this +# can make the switchover decision much more accurate, which will +# also be based on the max downtime specified. (Since 8.2) +# # @downtime-limit: set maximum tolerated downtime for migration. # maximum downtime in milliseconds (Since 2.8) #
@@ -840,7 +850,7 @@ 'cpu-throttle-initial', 'cpu-throttle-increment', 'cpu-throttle-tailslow', 'tls-creds', 'tls-hostname', 'tls-authz', 'max-bandwidth', - 'downtime-limit', + 'max-switchover-bandwidth', 'downtime-limit', { 'name': 'x-checkpoint-delay', 'features': [ 'unstable' ] }, 'block-incremental', 'multifd-channels',
@@ -885,6 +895,7 @@ '*tls-hostname': 'StrOrNull', '*tls-authz': 'StrOrNull', '*max-bandwidth': 'size', + '*max-switchover-bandwidth': 'size', '*downtime-limit': 'uint64', '*x-checkpoint-delay': { 'type': 'uint32', 'features': [ 'unstable' ] },
@@ -949,6 +960,7 @@ '*tls-hostname': 'str', '*tls-authz': 'str', '*max-bandwidth': 'size', + '*max-switchover-bandwidth': 'size', '*downtime-limit': 'uint64', '*x-checkpoint-delay': { 'type': 'uint32', 'features': [ 'unstable' ] },
migration/migration.h +1 -1
@@ -283,7 +283,7 @@ struct MigrationState {/* * The final stage happens when the remaining data is smaller than * this threshold; it's calculated from the requested downtime and -* measured bandwidth +* measured bandwidth, or max-switchover-bandwidth if specified. */ int64_t threshold_size;
migration/options.h +1 -0
@@ -80,6 +80,7 @@ int migrate_decompress_threads(void);uint64_t migrate_downtime_limit (void );uint8_t migrate_max_cpu_throttle (void );uint64_t migrate_max_bandwidth (void ); +uint64_t migrate_max_switchover_bandwidth (void );uint64_t migrate_max_postcopy_bandwidth (void );int migrate_multifd_channels (void );MultiFDCompression migrate_multifd_compression (void );
migration/migration-hmp-cmds.c +14 -0
@@ -321,6 +321,10 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)monitor_printf (mon,"%s: %" PRIu64" bytes/second\n" ,MigrationParameter_str (MIGRATION_PARAMETER_MAX_BANDWIDTH ), params->max_bandwidth); +assert (params->has_max_switchover_bandwidth); +monitor_printf (mon,"%s: %" PRIu64" bytes/second\n" , +MigrationParameter_str (MIGRATION_PARAMETER_MAX_SWITCHOVER_BANDWIDTH ), + params->max_switchover_bandwidth);assert (params->has_downtime_limit); monitor_printf(mon, "%s: %" PRIu64 " ms\n", MigrationParameter_str(MIGRATION_PARAMETER_DOWNTIME_LIMIT),
@@ -574,6 +578,16 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) } p->max_bandwidth = valuebw;break ; +case MIGRATION_PARAMETER_MAX_SWITCHOVER_BANDWIDTH : + p->has_max_switchover_bandwidth = true; + ret =qemu_strtosz_MiB (valuestr,NULL , &valuebw); +if (ret <0 || valuebw >INT64_MAX + || (size_t )valuebw != valuebw) { +error_setg (&err,"Invalid size %s" , valuestr); +break ; + } + p->max_switchover_bandwidth = valuebw; +break ;case MIGRATION_PARAMETER_DOWNTIME_LIMIT : p->has_downtime_limit = true;visit_type_size (v, param, &p->downtime_limit, &err);
migration/migration.c +15 -4
@@ -2684,7 +2684,7 @@ static void migration_update_counters(MigrationState *s, {uint64_t transferred, transferred_pages, time_spent;uint64_t current_bytes;/* bytes transferred since the beginning */ -double bandwidth; +double bandwidth, avail_bw;if (current_time < s->iteration_start_time +BUFFER_DELAY ) {return ;
@@ -2694,7 +2694,17 @@ static void migration_update_counters(MigrationState *s, transferred = current_bytes - s->iteration_initial_bytes; time_spent = current_time - s->iteration_start_time; bandwidth = (double )transferred / time_spent; - s->threshold_size = bandwidth *migrate_downtime_limit (); +if (migrate_max_switchover_bandwidth ()) { +/* +* If the user specified an available bandwidth, let's trust the +* user so that can be more accurate than what we estimated. +*/ + avail_bw =migrate_max_switchover_bandwidth (); + }else { +/* If the user doesn't specify bandwidth, we use the estimated */ + avail_bw = bandwidth; + } + s->threshold_size = avail_bw *migrate_downtime_limit (); s->mbps = (((double ) transferred *8.0 ) / ((double ) time_spent /1000.0 )) /1000.0 /1000.0 ;
@@ -2711,7 +2721,7 @@ static void migration_update_counters(MigrationState *s,if (stat64_get (&mig_stats.dirty_pages_rate) && transferred >10000 ) { s->expected_downtime = -stat64_get (&mig_stats.dirty_bytes_last_sync) / bandwidth; +stat64_get (&mig_stats.dirty_bytes_last_sync) / avail_bw; }migration_rate_reset (s->to_dst_file);
@@ -2719,7 +2729,8 @@ static void migration_update_counters(MigrationState *s,update_iteration_initial_status (s);trace_migrate_transferred (transferred, time_spent, - bandwidth, s->threshold_size); + bandwidth,migrate_max_switchover_bandwidth (), + s->threshold_size); }static bool migration_can_switchover (MigrationState *s)
migration/options.c +28 -0
@@ -125,6 +125,8 @@ Property migration_properties[] = { parameters.cpu_throttle_tailslow, false),DEFINE_PROP_SIZE ("x-max-bandwidth" , MigrationState, parameters.max_bandwidth,MAX_THROTTLE ), +DEFINE_PROP_SIZE ("max-switchover-bandwidth" , MigrationState, + parameters.max_switchover_bandwidth,0 ),DEFINE_PROP_UINT64 ("x-downtime-limit" , MigrationState, parameters.downtime_limit, DEFAULT_MIGRATE_SET_DOWNTIME),
@@ -780,6 +782,13 @@ uint64_t migrate_max_bandwidth(void)return s->parameters.max_bandwidth; } +uint64_t migrate_max_switchover_bandwidth (void ) +{ +MigrationState *s =migrate_get_current (); + +return s->parameters.max_switchover_bandwidth; +} +uint64_t migrate_max_postcopy_bandwidth (void ) {MigrationState *s =migrate_get_current ();
@@ -917,6 +926,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) s->parameters.tls_authz : ""); params->has_max_bandwidth = true; params->max_bandwidth = s->parameters.max_bandwidth; + params->has_max_switchover_bandwidth = true; + params->max_switchover_bandwidth = s->parameters.max_switchover_bandwidth; params->has_downtime_limit = true; params->downtime_limit = s->parameters.downtime_limit; params->has_x_checkpoint_delay = true;
@@ -1056,6 +1067,15 @@ bool migrate_params_check(MigrationParameters *params, Error **errp)return false; } +if (params->has_max_switchover_bandwidth && + (params->max_switchover_bandwidth >SIZE_MAX )) { +error_setg (errp,QERR_INVALID_PARAMETER_VALUE , +"max_switchover_bandwidth" , + "an integer in the range of 0 to "stringify(SIZE_MAX) +" bytes/second" ); +return false; + } +if (params->has_downtime_limit && (params->downtime_limit >MAX_MIGRATE_DOWNTIME )) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
@@ -1225,6 +1245,10 @@ static void migrate_params_test_apply(MigrateSetParameters *params, dest->max_bandwidth = params->max_bandwidth; } +if (params->has_max_switchover_bandwidth) { + dest->max_switchover_bandwidth = params->max_switchover_bandwidth; + } +if (params->has_downtime_limit) { dest->downtime_limit = params->downtime_limit; }
@@ -1341,6 +1365,10 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp) } } +if (params->has_max_switchover_bandwidth) { + s->parameters.max_switchover_bandwidth = params->max_switchover_bandwidth; + } +if (params->has_downtime_limit) { s->parameters.downtime_limit = params->downtime_limit; }
migration/trace-events +1 -1
@@ -185,7 +185,7 @@ source_return_path_thread_shut(uint32_t val) "0x%x" source_return_path_thread_resume_ack(uint32_t v) "%"PRIu32 source_return_path_thread_switchover_acked(void) "" migration_thread_low_pending(uint64_t pending) "%" PRIu64 -migrate_transferred(uint64_t transferred, uint64_t time_spent, uint64_t bandwidth, uint64_t size) "transferred %" PRIu64 " time_spent %" PRIu64 " bandwidth %" PRIu64 " max_size %" PRId64 +migrate_transferred(uint64_t transferred, uint64_t time_spent, uint64_t bandwidth, uint64_t avail_bw, uint64_t size) "transferred %" PRIu64 " time_spent %" PRIu64 " bandwidth %" PRIu64 " avail_bw %" PRIu64 " max_size %" PRId64 process_incoming_migration_co_end(int ret, int ps) "ret=%d postcopy-state=%d" process_incoming_migration_co_postcopy_end_main(void) "" postcopy_preempt_enabled(bool value) "%d"
Signature · 1 line
2.41.0
Re: [PATCH for-8.2 v2 2/2] migration: Allow user to specify migration switchover bandwidth
Quoted 8 lines · Peter Xu
migration/migration.c +2
-1@@ -2719,7 +2729,8 @@ static void migration_update_counters(MigrationState *s,update_iteration_initial_status (s);trace_migrate_transferred (transferred, time_spent, - bandwidth, s->threshold_size); + bandwidth,migrate_max_switchover_bandwidth (), + s->threshold_size); }
(...)
migration/trace-events source_return_path_thread_shut(uint32_t val) "0x%x" · line 188
Quoted 10 lines
migration/trace-events +1
-1@@ -185,7 +185,7 @@ source_return_path_thread_shut(uint32_t val) "0x%x" source_return_path_thread_resume_ack(uint32_t v) "%"PRIu32 source_return_path_thread_switchover_acked(void) "" migration_thread_low_pending(uint64_t pending) "%" PRIu64 -migrate_transferred(uint64_t transferred, uint64_t time_spent, uint64_t bandwidth, uint64_t size) "transferred %" PRIu64 " time_spent %" PRIu64 " bandwidth %" PRIu64 " max_size %" PRId64 +migrate_transferred(uint64_t transferred, uint64_t time_spent, uint64_t bandwidth, uint64_t avail_bw, uint64_t size) "transferred %" PRIu64 " time_spent %" PRIu64 " bandwidth %" PRIu64 " avail_bw %" PRIu64 " max_size %" PRId64
Given your previous snippet, perhaps you meant to introduce 'max_switchover_bandwidth' arg, unless of course you meant in the callpath of the tracepoint to instead use @avail_bw as the variable to use?
Re: [PATCH for-8.2 v2 2/2] migration: Allow user to specify migration switchover bandwidth
Quoted 12 lines · Joao Martins
Quoted 8 lines · Peter Xu
migration/migration.c +2
-1@@ -2719,7 +2729,8 @@ static void migration_update_counters(MigrationState *s,update_iteration_initial_status (s);trace_migrate_transferred (transferred, time_spent, - bandwidth, s->threshold_size); + bandwidth,migrate_max_switchover_bandwidth (), + s->threshold_size); }(...)
Quoted 14 lines
migration/trace-events source_return_path_thread_shut(uint32_t val) "0x%x" · line 188
Quoted 10 lines
migration/trace-events +1
-1@@ -185,7 +185,7 @@ source_return_path_thread_shut(uint32_t val) "0x%x" source_return_path_thread_resume_ack(uint32_t v) "%"PRIu32 source_return_path_thread_switchover_acked(void) "" migration_thread_low_pending(uint64_t pending) "%" PRIu64 -migrate_transferred(uint64_t transferred, uint64_t time_spent, uint64_t bandwidth, uint64_t size) "transferred %" PRIu64 " time_spent %" PRIu64 " bandwidth %" PRIu64 " max_size %" PRId64 +migrate_transferred(uint64_t transferred, uint64_t time_spent, uint64_t bandwidth, uint64_t avail_bw, uint64_t size) "transferred %" PRIu64 " time_spent %" PRIu64 " bandwidth %" PRIu64 " avail_bw %" PRIu64 " max_size %" PRId64Given your previous snippet, perhaps you meant to introduce '
max_switchover_bandwidth' arg, unless of course you meant in the callpath of the tracepoint to instead use @avail_bw as the variable to use?
Yeah, got it overlooked... I'll fix that when repost, thanks.
Signature · 1 line
Peter Xu
Re: [PATCH for-8.2 v2 2/2] migration: Allow user to specify migration switchover bandwidth
In reply to Peter XuQuoted 42 lines · Peter Xu
Migration bandwidth is a very important value to live migration. It's because it's one of the major factors that we'll make decision on when to switchover to destination in a precopy process.
This value is currently estimated by QEMU during the whole live migration process by monitoring how fast we were sending the data. This can be the most accurate bandwidth if in the ideal world, where we're always feeding unlimited data to the migration channel, and then it'll be limited to the bandwidth that is available.
However in reality it may be very different, e.g., over a 10Gbps network we can see query-migrate showing migration bandwidth of only a few tens of MB/s just because there are plenty of other things the migration thread might be doing. For example, the migration thread can be busy scanning zero pages, or it can be fetching dirty bitmap from other external dirty sources (like vhost or KVM). It means we may not be pushing data as much as possible to migration channel, so the bandwidth estimated from "how many data we sent in the channel" can be dramatically inaccurate sometimes, e.g., that a few tens of MB/s even if 10Gbps available, and then the decision to switchover will be further affected by this.
The migration may not even converge at all with the downtime specified, with that wrong estimation of bandwidth.
The issue is QEMU itself may not be able to avoid those uncertainties on measuing the real "available migration bandwidth". At least not something I can think of so far.
One way to fix this is when the user is fully aware of the available bandwidth, then we can allow the user to help providing an accurate value.
For example, if the user has a dedicated channel of 10Gbps for migration for this specific VM, the user can specify this bandwidth so QEMU can always do the calculation based on this fact, trusting the user as long as specified.
A new parameter "max-switchover-bandwidth" is introduced just for this. So when the user specified this parameter, instead of trusting the estimated value from QEMU itself (based on the QEMUFile send speed), let's trust the user more by using this value to decide when to switchover, assuming that we'll have such bandwidth available then.
Quoted 3 lines
When the user wants to have migration only use 5Gbps out of that 10Gbps, one can set max-bandwidth to 5Gbps, along with max-switchover-bandwidth to 5Gbps so it'll never use over 5Gbps too (so the user can have the rest
Hi Peter. I'm curious if we specify max-switchover-bandwidth to 5Gbps over a 10Gbps network, in the completion stage will it send the remaining data in 5Gbps using downtime_limit time or in 10Gbps (saturate the network) using the downtime_limit / 2 time? Seems this parameter won't rate limit the final stage:)
Quoted 259 lines
5Gbps for other things). So it can be useful even if the network is not dedicated, but as long as the user can know a solid value.
This can resolve issues like "unconvergence migration" which is caused by hilarious low "migration bandwidth" detected for whatever reason.
Reported-by Zhiyi Guo <[email protected]>Signed-off-by Peter Xu <[email protected]>--- qapi/migration.json | 14 +++++++++++++- migration/migration.h | 2 +- migration/options.h | 1 + migration/migration-hmp-cmds.c | 14 ++++++++++++++ migration/migration.c | 19 +++++++++++++++---- migration/options.c | 28 ++++++++++++++++++++++++++++ migration/trace-events | 2 +- 7 files changed, 73 insertions(+), 7 deletions(-)qapi/migration.json +13
-1@@ -759,6 +759,16 @@ # @max-bandwidth: to set maximum speed for migration. maximum speed # in bytes per second. (Since 2.8) # +# @max-switchover-bandwidth: to set available bandwidth for migration. +# By default, this value is zero, means the user is not aware of +# the available bandwidth that can be used by QEMU migration, so +# QEMU will estimate the bandwidth automatically. This can be set +# when the estimated value is not accurate, while the user is able +# to guarantee such bandwidth is available for migration purpose +# during the migration procedure. When specified correctly, this +# can make the switchover decision much more accurate, which will +# also be based on the max downtime specified. (Since 8.2) +# # @downtime-limit: set maximum tolerated downtime for migration. # maximum downtime in milliseconds (Since 2.8) #@@ -840,7 +850,7 @@ 'cpu-throttle-initial', 'cpu-throttle-increment', 'cpu-throttle-tailslow', 'tls-creds', 'tls-hostname', 'tls-authz', 'max-bandwidth', - 'downtime-limit', + 'max-switchover-bandwidth', 'downtime-limit', { 'name': 'x-checkpoint-delay', 'features': [ 'unstable' ] }, 'block-incremental', 'multifd-channels',@@ -885,6 +895,7 @@ '*tls-hostname': 'StrOrNull', '*tls-authz': 'StrOrNull', '*max-bandwidth': 'size', + '*max-switchover-bandwidth': 'size', '*downtime-limit': 'uint64', '*x-checkpoint-delay': { 'type': 'uint32', 'features': [ 'unstable' ] },@@ -949,6 +960,7 @@ '*tls-hostname': 'str', '*tls-authz': 'str', '*max-bandwidth': 'size', + '*max-switchover-bandwidth': 'size', '*downtime-limit': 'uint64', '*x-checkpoint-delay': { 'type': 'uint32', 'features': [ 'unstable' ] },migration/migration.h +1
-1@@ -283,7 +283,7 @@ struct MigrationState {/* * The final stage happens when the remaining data is smaller than * this threshold; it's calculated from the requested downtime and -* measured bandwidth +* measured bandwidth, or max-switchover-bandwidth if specified. */ int64_t threshold_size;migration/options.h +1
-0@@ -80,6 +80,7 @@ int migrate_decompress_threads(void);uint64_t migrate_downtime_limit (void );uint8_t migrate_max_cpu_throttle (void );uint64_t migrate_max_bandwidth (void ); +uint64_t migrate_max_switchover_bandwidth (void );uint64_t migrate_max_postcopy_bandwidth (void );int migrate_multifd_channels (void );MultiFDCompression migrate_multifd_compression (void );migration/migration-hmp-cmds.c +14
-0@@ -321,6 +321,10 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)monitor_printf (mon,"%s: %" PRIu64" bytes/second\n" ,MigrationParameter_str (MIGRATION_PARAMETER_MAX_BANDWIDTH ), params->max_bandwidth); +assert (params->has_max_switchover_bandwidth); +monitor_printf (mon,"%s: %" PRIu64" bytes/second\n" , +MigrationParameter_str (MIGRATION_PARAMETER_MAX_SWITCHOVER_BANDWIDTH ), + params->max_switchover_bandwidth);assert (params->has_downtime_limit); monitor_printf(mon, "%s: %" PRIu64 " ms\n", MigrationParameter_str(MIGRATION_PARAMETER_DOWNTIME_LIMIT),@@ -574,6 +578,16 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) } p->max_bandwidth = valuebw;break ; +case MIGRATION_PARAMETER_MAX_SWITCHOVER_BANDWIDTH : + p->has_max_switchover_bandwidth = true; + ret =qemu_strtosz_MiB (valuestr,NULL , &valuebw); +if (ret <0 || valuebw >INT64_MAX + || (size_t )valuebw != valuebw) { +error_setg (&err,"Invalid size %s" , valuestr); +break ; + } + p->max_switchover_bandwidth = valuebw; +break ;case MIGRATION_PARAMETER_DOWNTIME_LIMIT : p->has_downtime_limit = true;visit_type_size (v, param, &p->downtime_limit, &err);migration/migration.c +15
-4@@ -2684,7 +2684,7 @@ static void migration_update_counters(MigrationState *s, {uint64_t transferred, transferred_pages, time_spent;uint64_t current_bytes;/* bytes transferred since the beginning */ -double bandwidth; +double bandwidth, avail_bw;if (current_time < s->iteration_start_time +BUFFER_DELAY ) {return ;@@ -2694,7 +2694,17 @@ static void migration_update_counters(MigrationState *s, transferred = current_bytes - s->iteration_initial_bytes; time_spent = current_time - s->iteration_start_time; bandwidth = (double )transferred / time_spent; - s->threshold_size = bandwidth *migrate_downtime_limit (); +if (migrate_max_switchover_bandwidth ()) { +/* +* If the user specified an available bandwidth, let's trust the +* user so that can be more accurate than what we estimated. +*/ + avail_bw =migrate_max_switchover_bandwidth (); + }else { +/* If the user doesn't specify bandwidth, we use the estimated */ + avail_bw = bandwidth; + } + s->threshold_size = avail_bw *migrate_downtime_limit (); s->mbps = (((double ) transferred *8.0 ) / ((double ) time_spent /1000.0 )) /1000.0 /1000.0 ;@@ -2711,7 +2721,7 @@ static void migration_update_counters(MigrationState *s,if (stat64_get (&mig_stats.dirty_pages_rate) && transferred >10000 ) { s->expected_downtime = -stat64_get (&mig_stats.dirty_bytes_last_sync) / bandwidth; +stat64_get (&mig_stats.dirty_bytes_last_sync) / avail_bw; }migration_rate_reset (s->to_dst_file);@@ -2719,7 +2729,8 @@ static void migration_update_counters(MigrationState *s,update_iteration_initial_status (s);trace_migrate_transferred (transferred, time_spent, - bandwidth, s->threshold_size); + bandwidth,migrate_max_switchover_bandwidth (), + s->threshold_size); }static bool migration_can_switchover (MigrationState *s)migration/options.c +28
-0@@ -125,6 +125,8 @@ Property migration_properties[] = { parameters.cpu_throttle_tailslow, false),DEFINE_PROP_SIZE ("x-max-bandwidth" , MigrationState, parameters.max_bandwidth,MAX_THROTTLE ), +DEFINE_PROP_SIZE ("max-switchover-bandwidth" , MigrationState, + parameters.max_switchover_bandwidth,0 ),DEFINE_PROP_UINT64 ("x-downtime-limit" , MigrationState, parameters.downtime_limit, DEFAULT_MIGRATE_SET_DOWNTIME),@@ -780,6 +782,13 @@ uint64_t migrate_max_bandwidth(void)return s->parameters.max_bandwidth; } +uint64_t migrate_max_switchover_bandwidth (void ) +{ +MigrationState *s =migrate_get_current (); + +return s->parameters.max_switchover_bandwidth; +} +uint64_t migrate_max_postcopy_bandwidth (void ) {MigrationState *s =migrate_get_current ();@@ -917,6 +926,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) s->parameters.tls_authz : ""); params->has_max_bandwidth = true; params->max_bandwidth = s->parameters.max_bandwidth; + params->has_max_switchover_bandwidth = true; + params->max_switchover_bandwidth = s->parameters.max_switchover_bandwidth; params->has_downtime_limit = true; params->downtime_limit = s->parameters.downtime_limit; params->has_x_checkpoint_delay = true;@@ -1056,6 +1067,15 @@ bool migrate_params_check(MigrationParameters *params, Error **errp)return false; } +if (params->has_max_switchover_bandwidth && + (params->max_switchover_bandwidth >SIZE_MAX )) { +error_setg (errp,QERR_INVALID_PARAMETER_VALUE , +"max_switchover_bandwidth" , + "an integer in the range of 0 to "stringify(SIZE_MAX) +" bytes/second" ); +return false; + } +if (params->has_downtime_limit && (params->downtime_limit >MAX_MIGRATE_DOWNTIME )) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE,@@ -1225,6 +1245,10 @@ static void migrate_params_test_apply(MigrateSetParameters *params, dest->max_bandwidth = params->max_bandwidth; } +if (params->has_max_switchover_bandwidth) { + dest->max_switchover_bandwidth = params->max_switchover_bandwidth; + } +if (params->has_downtime_limit) { dest->downtime_limit = params->downtime_limit; }@@ -1341,6 +1365,10 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp) } } +if (params->has_max_switchover_bandwidth) { + s->parameters.max_switchover_bandwidth = params->max_switchover_bandwidth; + } +if (params->has_downtime_limit) { s->parameters.downtime_limit = params->downtime_limit; }migration/trace-events +1
-1@@ -185,7 +185,7 @@ source_return_path_thread_shut(uint32_t val) "0x%x" source_return_path_thread_resume_ack(uint32_t v) "%"PRIu32 source_return_path_thread_switchover_acked(void) "" migration_thread_low_pending(uint64_t pending) "%" PRIu64 -migrate_transferred(uint64_t transferred, uint64_t time_spent, uint64_t bandwidth, uint64_t size) "transferred %" PRIu64 " time_spent %" PRIu64 " bandwidth %" PRIu64 " max_size %" PRId64 +migrate_transferred(uint64_t transferred, uint64_t time_spent, uint64_t bandwidth, uint64_t avail_bw, uint64_t size) "transferred %" PRIu64 " time_spent %" PRIu64 " bandwidth %" PRIu64 " avail_bw %" PRIu64 " max_size %" PRId64 process_incoming_migration_co_end(int ret, int ps) "ret=%d postcopy-state=%d" process_incoming_migration_co_postcopy_end_main(void) "" postcopy_preempt_enabled(bool value) "%d"
Re: [PATCH for-8.2 v2 2/2] migration: Allow user to specify migration switchover bandwidth
Quoted 43 lines · Lei
Quoted 42 lines · Peter Xu
Migration bandwidth is a very important value to live migration. It's because it's one of the major factors that we'll make decision on when to switchover to destination in a precopy process.
This value is currently estimated by QEMU during the whole live migration process by monitoring how fast we were sending the data. This can be the most accurate bandwidth if in the ideal world, where we're always feeding unlimited data to the migration channel, and then it'll be limited to the bandwidth that is available.
However in reality it may be very different, e.g., over a 10Gbps network we can see query-migrate showing migration bandwidth of only a few tens of MB/s just because there are plenty of other things the migration thread might be doing. For example, the migration thread can be busy scanning zero pages, or it can be fetching dirty bitmap from other external dirty sources (like vhost or KVM). It means we may not be pushing data as much as possible to migration channel, so the bandwidth estimated from "how many data we sent in the channel" can be dramatically inaccurate sometimes, e.g., that a few tens of MB/s even if 10Gbps available, and then the decision to switchover will be further affected by this.
The migration may not even converge at all with the downtime specified, with that wrong estimation of bandwidth.
The issue is QEMU itself may not be able to avoid those uncertainties on measuing the real "available migration bandwidth". At least not something I can think of so far.
One way to fix this is when the user is fully aware of the available bandwidth, then we can allow the user to help providing an accurate value.
For example, if the user has a dedicated channel of 10Gbps for migration for this specific VM, the user can specify this bandwidth so QEMU can always do the calculation based on this fact, trusting the user as long as specified.
A new parameter "max-switchover-bandwidth" is introduced just for this. So when the user specified this parameter, instead of trusting the estimated value from QEMU itself (based on the QEMUFile send speed), let's trust the user more by using this value to decide when to switchover, assuming that we'll have such bandwidth available then.
Quoted 8 lines
Quoted 3 lines
When the user wants to have migration only use 5Gbps out of that 10Gbps, one can set max-bandwidth to 5Gbps, along with max-switchover-bandwidth to 5Gbps so it'll never use over 5Gbps too (so the user can have the rest
Hi Peter. I'm curious if we specify max-switchover-bandwidth to 5Gbps over a 10Gbps network, in the completion stage will it send the remaining data in 5Gbps using
downtime_limittime or in 10Gbps (saturate the network) using thedowntime_limit/ 2 time? Seems this parameter won't rate limit the final stage:)
Effectively the mgmt app is telling QEMU to assume that this much bandwidth is available for use during switchover. If QEMU determines that, given this available bandwidth, the remaining data can be sent over the link within the downtime limit, it will perform the switchover. When sending this sitchover data, it will actually transmit the data at full line rate IIUC.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH for-8.2 v2 2/2] migration: Allow user to specify migration switchover bandwidth
Quoted 11 lines · Daniel P. Berrangé
Quoted 4 lines
Hi Peter. I'm curious if we specify max-switchover-bandwidth to 5Gbps over a 10Gbps network, in the completion stage will it send the remaining data in 5Gbps using
downtime_limittime or in 10Gbps (saturate the network) using thedowntime_limit/ 2 time? Seems this parameter won't rate limit the final stage:)Effectively the mgmt app is telling QEMU to assume that this much bandwidth is available for use during switchover. If QEMU determines that, given this available bandwidth, the remaining data can be sent over the link within the downtime limit, it will perform the switchover. When sending this sitchover data, it will actually transmit the data at full line rate IIUC.
Right, currently it's only a way for QEMU to do more accurate calculations on the switchover decision, while we always use full speed to transfer during switchover.
The old name "available-bandwidth" might reflect more on that side (telling qemu the available bandwidth QEMU can use only), but it might be unclear on when the value will be used (only during making decisions for switchover). So it seems there's no ideal name for it.
To be explicit, see migration_completion() has a call there with:
migration_rate_set(RATE_LIMIT_DISABLED);
And this patch won't change that behavior (to use full line speed).
Interestingly this question let me also notice that when switchover for postcopy we did it slightly different. I believe postcopy also use line speed because we put mostly everything needed in the package, and flushed in qemu_savevm_send_packaged() with line speed too.
Thanks,
Signature · 1 line
Peter Xu
Re: [PATCH for-8.2 v2 2/2] migration: Allow user to specify migration switchover bandwidth
In reply to Daniel P. BerrangéQuoted 9 lines · Daniel P. Berrangé
Quoted 8 lines
Quoted 3 lines
When the user wants to have migration only use 5Gbps out of that 10Gbps, one can set max-bandwidth to 5Gbps, along with max-switchover-bandwidth to 5Gbps so it'll never use over 5Gbps too (so the user can have the rest
Hi Peter. I'm curious if we specify max-switchover-bandwidth to 5Gbps over a 10Gbps network, in the completion stage will it send the remaining data in 5Gbps using
downtime_limittime or in 10Gbps (saturate the network) using thedowntime_limit/ 2 time? Seems this parameter won't rate limit the final stage:)
Quoted 6 lines
Effectively the mgmt app is telling QEMU to assume that this much bandwidth is available for use during switchover. If QEMU determines that, given this available bandwidth, the remaining data can be sent over the link within the downtime limit, it will perform the switchover. When sending this sitchover data, it will actually transmit the data at full line rate IIUC.
I'm right at reposting this patch, but then I found that the max-available-bandwidth is indeed confusing (as Lei's question shows).
We do have all the bandwidth throttling values in the pattern of max-*-bandwidth and this one will start to be the outlier that it won't really throttle the network.
If the old name "available-bandwidth" is too general, I'm now considering "avail-switchover-bandwidth" just to leave max- out of the name to differenciate, if some day we want to add a real throttle for switchover we can still have a sane name.
Any objections before I repost?
Thanks,
Signature · 1 line
Peter Xu
Re: [PATCH for-8.2 v2 2/2] migration: Allow user to specify migration switchover bandwidth
Quoted 24 lines · Peter Xu
Quoted 9 lines · Daniel P. Berrangé
Quoted 8 lines
Quoted 3 lines
When the user wants to have migration only use 5Gbps out of that 10Gbps, one can set max-bandwidth to 5Gbps, along with max-switchover-bandwidth to 5Gbps so it'll never use over 5Gbps too (so the user can have the rest
Hi Peter. I'm curious if we specify max-switchover-bandwidth to 5Gbps over a 10Gbps network, in the completion stage will it send the remaining data in 5Gbps using
downtime_limittime or in 10Gbps (saturate the network) using thedowntime_limit/ 2 time? Seems this parameter won't rate limit the final stage:)Quoted 6 lines
Effectively the mgmt app is telling QEMU to assume that this much bandwidth is available for use during switchover. If QEMU determines that, given this available bandwidth, the remaining data can be sent over the link within the downtime limit, it will perform the switchover. When sending this sitchover data, it will actually transmit the data at full line rate IIUC.
I'm right at reposting this patch, but then I found that the max-available-bandwidth is indeed confusing (as Lei's question shows).
We do have all the bandwidth throttling values in the pattern of max-*-bandwidth and this one will start to be the outlier that it won't really throttle the network.
Quoted 6 lines
If the old name "available-bandwidth" is too general, I'm now considering "avail-switchover-bandwidth" just to leave max- out of the name to differenciate, if some day we want to add a real throttle for switchover we can still have a sane name.
Any objections before I repost?
I think the 'avail-' prefix is good given the confusion Lei pointed out.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH for-8.2 v2 2/2] migration: Allow user to specify migration switchover bandwidth
In reply to Peter XuQuoted 24 lines · Peter Xu
Quoted 9 lines · Daniel P. Berrangé
Quoted 8 lines
Quoted 3 lines
When the user wants to have migration only use 5Gbps out of that 10Gbps, one can set max-bandwidth to 5Gbps, along with max-switchover-bandwidth to 5Gbps so it'll never use over 5Gbps too (so the user can have the rest
Hi Peter. I'm curious if we specify max-switchover-bandwidth to 5Gbps over a 10Gbps network, in the completion stage will it send the remaining data in 5Gbps using
downtime_limittime or in 10Gbps (saturate the network) using thedowntime_limit/ 2 time? Seems this parameter won't rate limit the final stage:)Quoted 6 lines
Effectively the mgmt app is telling QEMU to assume that this much bandwidth is available for use during switchover. If QEMU determines that, given this available bandwidth, the remaining data can be sent over the link within the downtime limit, it will perform the switchover. When sending this sitchover data, it will actually transmit the data at full line rate IIUC.
I'm right at reposting this patch, but then I found that the max-available-bandwidth is indeed confusing (as Lei's question shows).
We do have all the bandwidth throttling values in the pattern of max-*-bandwidth and this one will start to be the outlier that it won't really throttle the network.
Quoted 6 lines
If the old name "available-bandwidth" is too general, I'm now considering "avail-switchover-bandwidth" just to leave max- out of the name to differenciate, if some day we want to add a real throttle for switchover we can still have a sane name.
Any objections before I repost?
I'm also OK with it. "avail" has semantics that we have a lower bound of the bandwidth when switchover so we can promise at least those amount of bandwidth can be used, so it can cover both the throttling and non-throuttling case. "switchover" means this parameter only works in the switchover phase rather than the bulk stage.
Quoted 3 lines
Thanks,
Re: [PATCH for-8.2 v2 2/2] migration: Allow user to specify migration switchover bandwidth
In reply to Peter XuQuoted 7 lines · Peter Xu
migration/migration.c +2
-1@@ -2694,7 +2694,17 @@ static void migration_update_counters(MigrationState *s, transferred = current_bytes - s->iteration_initial_bytes; time_spent = current_time - s->iteration_start_time; bandwidth = (double )transferred / time_spent; - s->threshold_size = bandwidth *migrate_downtime_limit (); +if (migrate_max_switchover_bandwidth ()) { +/*
migration/migration.c static void migration_update_counters(MigrationState *s, · line 2708
Quoted 10 lines
migration/migration.c +9
-0+* If the user specified an available bandwidth, let's trust the +* user so that can be more accurate than what we estimated. +*/ + avail_bw =migrate_max_switchover_bandwidth (); + }else { +/* If the user doesn't specify bandwidth, we use the estimated */ + avail_bw = bandwidth; + } + s->threshold_size = avail_bw *migrate_downtime_limit ();
[ sorry for giving review comments in piecemeal :/ ]
There might be something odd with the calculation. It would be right if downtime_limit was in seconds. But we are multipling a value that is in bytes/sec with a time unit that is in miliseconds. When avail_bw is set to switchover_bandwidth, it sounds to me this should be a:
/* bytes/msec; @max-switchover-bandwidth is per-seconds */ avail_bw = migrate_max_switchover_bandwidth() / 1000.0;
Otherwise it looks like that we end up overestimating how much we can still send during switchover? If this is correct and I am not missing some assumption, then same is applicable to the threshold_size calculation in general without switchover-bandwidth but likely in a different way:
/* bytes/msec; but @bandwidth is calculated in 100msec quantas */ avail_bw = bandwidth / 100.0;
There's a very good chance I'm missing details, so apologies beforehand on wasting your time if I didn't pick up on it through the code.
Joao
Re: [PATCH for-8.2 v2 2/2] migration: Allow user to specify migration switchover bandwidth
Quoted 31 lines · Joao Martins
Quoted 7 lines · Peter Xu
migration/migration.c +2
-1@@ -2694,7 +2694,17 @@ static void migration_update_counters(MigrationState *s, transferred = current_bytes - s->iteration_initial_bytes; time_spent = current_time - s->iteration_start_time; bandwidth = (double )transferred / time_spent; - s->threshold_size = bandwidth *migrate_downtime_limit (); +if (migrate_max_switchover_bandwidth ()) { +/* migration/migration.c static void migration_update_counters(MigrationState *s, · line 2708
Quoted 10 lines
migration/migration.c +9
-0+* If the user specified an available bandwidth, let's trust the +* user so that can be more accurate than what we estimated. +*/ + avail_bw =migrate_max_switchover_bandwidth (); + }else { +/* If the user doesn't specify bandwidth, we use the estimated */ + avail_bw = bandwidth; + } + s->threshold_size = avail_bw *migrate_downtime_limit ();[ sorry for giving review comments in piecemeal :/ ]
There might be something odd with the calculation. It would be right if
downtime_limitwas in seconds. But we are multipling a value that is in bytes/sec with a time unit that is in miliseconds. Whenavail_bwis set toswitchover_bandwidth, it sounds to me this should be a:/* bytes/msec; @max-switchover-bandwidth is per-seconds */ avail_bw = migrate_max_switchover_bandwidth() / 1000.0;Otherwise it looks like that we end up overestimating how much we can still send during switchover? If this is correct and I am not missing some assumption,
(...)
Quoted 7 lines
then
same is applicable to thethreshold_sizecalculation in general without switchover-bandwidth but likely in a different way:/* bytes/msec; but @bandwidth is calculated in 100msec quantas */ avail_bw = bandwidth / 100.0;
Nevermind this part. I was wrong in the @bandwidth adjustment as it is already calculated in bytes/ms. It's max_switchover_bandwidth that needs an adjustment it seems.
Quoted 5 lines
There's a very good chance I'm missing details, so apologies beforehand on wasting your time if I didn't pick up on it through the code.
Joao
Re: [PATCH for-8.2 v2 2/2] migration: Allow user to specify migration switchover bandwidth
Quoted 15 lines · Joao Martins
Quoted 12 lines · Joao Martins
Quoted 11 lines · Peter Xu
migration/migration.c +6
-1@@ -2694,7 +2694,17 @@ static void migration_update_counters(MigrationState *s, transferred = current_bytes - s->iteration_initial_bytes; time_spent = current_time - s->iteration_start_time; bandwidth = (double )transferred / time_spent; - s->threshold_size = bandwidth *migrate_downtime_limit (); +if (migrate_max_switchover_bandwidth ()) { +/* +* If the user specified an available bandwidth, let's trust the +* user so that can be more accurate than what we estimated. +*/ + avail_bw =migrate_max_switchover_bandwidth ();
Quoted 8 lines
Quoted 8 lines
migration/migration.c static void migration_update_counters(MigrationState *s, · line 2708
Quoted 6 lines
migration/migration.c +5
-0+ }else { +/* If the user doesn't specify bandwidth, we use the estimated */ + avail_bw = bandwidth; + } + s->threshold_size = avail_bw *migrate_downtime_limit ();[ sorry for giving review comments in piecemeal :/ ]
This is never a problem.
Quoted 18 lines
Quoted 11 lines
There might be something odd with the calculation. It would be right if
downtime_limitwas in seconds. But we are multipling a value that is in bytes/sec with a time unit that is in miliseconds. Whenavail_bwis set toswitchover_bandwidth, it sounds to me this should be a:/* bytes/msec; @max-switchover-bandwidth is per-seconds */ avail_bw = migrate_max_switchover_bandwidth() / 1000.0;Otherwise it looks like that we end up overestimating how much we can still send during switchover? If this is correct and I am not missing some assumption,
(...)
Quoted 4 lines
then
same is applicable to thethreshold_sizecalculation in general without switchover-bandwidth but likely in a different way:
Quoted 10 lines
Quoted 3 lines
/* bytes/msec; but @bandwidth is calculated in 100msec quantas */ avail_bw = bandwidth / 100.0;Nevermind this part. I was wrong in the @bandwidth adjustment as it is already calculated in bytes/ms. It's
max_switchover_bandwidththat needs an adjustment it seems.Quoted 2 lines
There's a very good chance I'm missing details, so apologies beforehand on wasting your time if I didn't pick up on it through the code.
My fault, thanks for catching this. So it seems even if the test will switchover with this patch, it might be too aggresive if we calculate with a number 1000x larger than the real bandwidth provided..
I'll rename this to expected_bw_per_ms to be clear when repost, too.
Thanks,
Signature · 1 line
Peter Xu