Allow to enable multifd and postcopy migration together
v6 cover Allow to enable multifd and postcopy migration together
From: Prasad Pandit <[email protected]>
Hello,
* This series (v6) shuts down Multifd threads before starting Postcopy migration. It helps to avoid an issue of multifd pages arriving late at the destination during Postcopy phase and corrupting the vCPU state. It also reorders the qtest patches and does some refactoring changes as suggested in previous review.
===
67/67 qemu:qtest+qtest-x86_64 / qtest-x86_64/migration-test OK 161.35s 73 subtests passed
===
v5: https://lore.kernel.org/qemu-devel/[email protected]/T/#t
* This series (v5) consolidates migration capabilities setting in one 'set_migration_capabilities()' function, thus simplifying test sources. It passes all migration tests.
===
66/66 qemu:qtest+qtest-x86_64 / qtest-x86_64/migration-test OK 143.66s 71 subtests passed
===
v4: https://lore.kernel.org/qemu-devel/[email protected]/T/#t
* This series (v4) adds more 'multifd+postcopy' qtests which test Precopy migration with 'postcopy-ram' attribute set. And run
Postcopy migrations with 'multifd' channels enabled.
===
$ ../qtest/migration-test --tap -k -r '/x86_64/migration/multifd+postcopy' | grep -i 'slow test' # slow test /x86_64/migration/multifd+postcopy/plain executed in 1.29 secs # slow test /x86_64/migration/multifd+postcopy/recovery/tls/psk executed in 2.48 secs # slow test /x86_64/migration/multifd+postcopy/preempt/plain executed in 1.49 secs # slow test /x86_64/migration/multifd+postcopy/preempt/recovery/tls/psk executed in 2.52 secs # slow test /x86_64/migration/multifd+postcopy/tcp/tls/psk/match executed in 3.62 secs # slow test /x86_64/migration/multifd+postcopy/tcp/plain/zstd executed in 1.34 secs # slow test /x86_64/migration/multifd+postcopy/tcp/plain/cancel executed in 2.24 secs ... 66/66 qemu:qtest+qtest-x86_64 / qtest-x86_64/migration-test OK 148.41s 71 subtests passed ===
v3: https://lore.kernel.org/qemu-devel/[email protected]/T/#t
* This series (v3) passes all existing 'tests/qtest/migration/*' tests and adds a new one to enable multifd channels with postcopy migration.
v2: https://lore.kernel.org/qemu-devel/[email protected]/T/#u
* This series (v2) further refactors the 'ram_save_target_page' function to make it independent of the multifd & postcopy change.
v1: https://lore.kernel.org/qemu-devel/[email protected]/T/#u
* This series removes magic value (4-bytes) introduced in the
previous series for the Postcopy channel.
v0: https://lore.kernel.org/qemu-devel/[email protected]/T/#u
* Currently Multifd and Postcopy migration can not be used together.
QEMU shows "Postcopy is not yet compatible with multifd" message.
When migrating guests with large (100's GB) RAM, Multifd threads help to accelerate migration, but inability to use it with the Postcopy mode delays guest start up on the destination side.
* This patch series allows to enable both Multifd and Postcopy migration together. Precopy and Multifd threads work during the initial guest (RAM) transfer. When migration moves to the Postcopy phase, Multifd threads are restrained and the Postcopy threads start to request pages from the source side.
* This series introduces magic value (4-bytes) to be sent on the Postcopy channel. It helps to differentiate channels and properly setup incoming connections on the destination side.
Thank you.
---
Prasad Pandit (4):
migration/multifd: move macros to multifd header
migration: enable multifd and postcopy together tests/qtest/migration: consolidate set capabilities tests/qtest/migration: add postcopy tests with multifd
migration/migration.c | 107 ++++++++++++---------- migration/multifd-nocomp.c | 3 +- migration/multifd.c | 9 +- migration/multifd.h | 5 + migration/options.c | 5 - migration/ram.c | 7 +- tests/qtest/migration/compression-tests.c | 23 ++++- tests/qtest/migration/cpr-tests.c | 4 +- tests/qtest/migration/file-tests.c | 44 +++------ tests/qtest/migration/framework.c | 58 +++++++++--- tests/qtest/migration/framework.h | 4 +- tests/qtest/migration/postcopy-tests.c | 27 +++++- tests/qtest/migration/precopy-tests.c | 38 +++++--- tests/qtest/migration/tls-tests.c | 51 ++++++++++- 14 files changed, 247 insertions(+), 138 deletions(-)
--
2.48.1
PATCH v6 1/4 migration/multifd: move macros to multifd header
From: Prasad Pandit <[email protected]>
Move MULTIFD_ macros to the header file so that
they are accessible from other source files.
--- migration/multifd.c | 5 ----- migration/multifd.h | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-)
v5: no change
- https://lore.kernel.org/qemu-devel/[email protected]/T/#t
migration/multifd.c +0 -5
@@ -33,11 +33,6 @@#include "io/channel-socket.h" #include "yank_functions.h" -/* Multiple fd's */ - -#define MULTIFD_MAGIC 0x11223344U -#define MULTIFD_VERSION 1 - typedef struct { uint32_t magic; uint32_t version;
migration/multifd.h +5 -0
@@ -49,6 +49,11 @@ bool multifd_queue_page(RAMBlock *block, ram_addr_t offset);bool multifd_recv (void );MultiFDRecvData *multifd_get_recv_data (void ); +/* Multiple fd's */ + +#define MULTIFD_MAGIC 0x11223344U +#define MULTIFD_VERSION 1 +/* Multifd Compression flags */ #define MULTIFD_FLAG_SYNC (1 << 0)
--
2.48.1
PATCH v6 2/4 migration: enable multifd and postcopy together
In reply to Prasad PanditFrom: Prasad Pandit <[email protected]>
Enable Multifd and Postcopy migration together. The migration_ioc_process_incoming() routine checks magic value sent on each channel and helps to properly setup multifd and postcopy channels.
The Precopy and Multifd threads work during the initial guest RAM transfer. When migration moves to the Postcopy phase, the multifd threads are shutdown and Postcopy threads on the destination request/pull data from the source side.
--- migration/migration.c | 107 ++++++++++++++++++++----------------- migration/multifd-nocomp.c | 3 +- migration/multifd.c | 4 +- migration/options.c | 5 -- migration/ram.c | 7 ++- 5 files changed, 64 insertions(+), 62 deletions(-)
v6:
- Shutdown multifd threads before postcopy_start()
- Reorder tests/qtest/migration/ patches
- Some refactoring of functions
v5:
- https://lore.kernel.org/qemu-devel/[email protected]/T/#t
migration/migration.c +58 -49
@@ -95,6 +95,9 @@ enum mig_rp_message_type { MIG_RP_MSG_MAX }; +/* Migration channel types */ +enum {CH_MAIN ,CH_MULTIFD ,CH_POSTCOPY }; +/* When we add fault tolerance, we could have several migrations at once. For now we don't need to add dynamic creation of migration */
@@ -959,28 +962,19 @@ void migration_fd_process_incoming(QEMUFile *f)migration_incoming_process (); } -/* -* Returns true when we want to start a new incoming migration process, -* false otherwise. -*/ -static bool migration_should_start_incoming (bool main_channel) +static bool migration_has_main_and_multifd_channels (void ) { -/* Multifd doesn't start unless all channels are established */ -if (migrate_multifd ()) { -return migration_has_all_channels (); +MigrationIncomingState *mis =migration_incoming_get_current (); +if (!mis->from_src_file) { +/* main channel not established */ +return false; } -/* Preempt channel only starts when the main channel is created */ -if (migrate_postcopy_preempt ()) { -return main_channel; +if (migrate_multifd () && !multifd_recv_all_channels_created ()) { +return false; } -/* -* For all the rest types of migration, we should only reach here when -* it's the main channel that's being created, and we should always -* proceed with this channel. -*/ -assert (main_channel); +/* main channel and all multifd channels are established */ return true; }
@@ -989,13 +983,12 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)MigrationIncomingState *mis =migration_incoming_get_current ();Error *local_err =NULL ;QEMUFile *f; -bool default_channel = true;uint32_t channel_magic =0 ; +uint8_t channel =CH_MAIN ;int ret =0 ; -if (migrate_multifd () && !migrate_mapped_ram () && - !migrate_postcopy_ram () && -qio_channel_has_feature (ioc,QIO_CHANNEL_FEATURE_READ_MSG_PEEK )) { +if (!migration_has_main_and_multifd_channels ()) { +if (qio_channel_has_feature (ioc,QIO_CHANNEL_FEATURE_READ_MSG_PEEK )) {/* * With multiple channels, it is possible that we receive channels * out of order on destination side, causing incorrect mapping of
@@ -1006,42 +999,58 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)* tls handshake while initializing main channel so with tls this * issue is not possible. */ - ret =migration_channel_read_peek (ioc, (void *)&channel_magic, -sizeof (channel_magic), errp); + ret =migration_channel_read_peek (ioc, (void *)&channel_magic, +sizeof (channel_magic), errp); +if (ret !=0 ) { +return ; + } -if (ret !=0 ) { -return ; +if (channel_magic ==cpu_to_be32 (QEMU_VM_FILE_MAGIC )) { + channel =CH_MAIN ; + }else if (channel_magic ==cpu_to_be32 (MULTIFD_MAGIC )) { + channel =CH_MULTIFD ; + }else if (!mis->from_src_file + && mis->state ==MIGRATION_STATUS_POSTCOPY_PAUSED ) { +/* reconnect default channel for postcopy recovery */ + channel =CH_MAIN ; + }else { +error_report ("%s: unknown channel magic: %u" , + __func__, channel_magic); +return ; + } + }else if (mis->from_src_file + && (!strcmp (ioc->name,"migration-tls-incoming" ) + || !strcmp (ioc->name,"migration-file-incoming" ))) { + channel =CH_MULTIFD ; } - - default_channel = (channel_magic ==cpu_to_be32 (QEMU_VM_FILE_MAGIC )); - }else { - default_channel = !mis->from_src_file; + }else if (mis->from_src_file) { + channel =CH_POSTCOPY ; }if (multifd_recv_setup (errp) !=0 ) {return ; } -if (default_channel) { +if (channel ==CH_MAIN ) { f =qemu_file_new_input (ioc);migration_incoming_setup (f); - }else { + }else if (channel ==CH_MULTIFD ) {/* Multiple connections */ -assert (migration_needs_multiple_sockets ());if (migrate_multifd ()) {multifd_recv_new_channel (ioc, &local_err); - }else { -assert (migrate_postcopy_preempt ()); - f =qemu_file_new_input (ioc); -postcopy_preempt_new_channel (mis, f); }if (local_err) {error_propagate (errp, local_err);return ; } + }else if (channel ==CH_POSTCOPY ) { +assert (migrate_postcopy_preempt ()); +assert (!mis->postcopy_qemufile_dst); + f =qemu_file_new_input (ioc); +postcopy_preempt_new_channel (mis, f); } -if (migration_should_start_incoming (default_channel)) { +if (channel !=CH_POSTCOPY &&migration_has_main_and_multifd_channels ()) {/* If it's a recovery, we're done */ if (postcopy_try_recover ()) {return ;
@@ -1058,20 +1067,15 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)*/ bool migration_has_all_channels (void ) { +if (!migration_has_main_and_multifd_channels ()) { +return false; + } +MigrationIncomingState *mis =migration_incoming_get_current (); - -if (!mis->from_src_file) { +if (migrate_postcopy_preempt () && !mis->postcopy_qemufile_dst) {return false; } -if (migrate_multifd ()) { -return multifd_recv_all_channels_created (); - } - -if (migrate_postcopy_preempt ()) { -return mis->postcopy_qemufile_dst !=NULL ; - } -return true; }
@@ -1482,6 +1486,8 @@ static void migrate_fd_cleanup(MigrationState *s)assert (!migration_is_active ()); +file_cleanup_outgoing_migration (); +socket_cleanup_outgoing_migration ();if (s->state ==MIGRATION_STATUS_CANCELLING ) {migrate_set_state (&s->state,MIGRATION_STATUS_CANCELLING ,MIGRATION_STATUS_CANCELLED );
@@ -3373,8 +3379,11 @@ static MigIterateState migration_iteration_run(MigrationState *s) }/* Still a significant amount to transfer */ -if (!in_postcopy && must_precopy <= s->threshold_size && can_switchover && -qatomic_read (&s->start_postcopy)) { +if (!in_postcopy && must_precopy <= s->threshold_size + && can_switchover &&qatomic_read (&s->start_postcopy)) { +if (migrate_multifd ()) { +multifd_send_shutdown (); + }if (postcopy_start (s, &local_err)) {migrate_set_error (s, local_err);error_report_err (local_err);
migration/multifd-nocomp.c +2 -1
@@ -16,6 +16,7 @@#include "file.h" #include "multifd.h" #include "options.h" +#include "migration.h" #include "qapi/error.h" #include "qemu/cutils.h" #include "qemu/error-report.h"
@@ -391,7 +392,7 @@ int multifd_ram_flush_and_sync(QEMUFile *f)MultiFDSyncReq req;int ret; -if (!migrate_multifd ()) { +if (!migrate_multifd () ||migration_in_postcopy ()) {return 0 ; }
migration/multifd.c +1 -3
@@ -467,8 +467,6 @@ static bool multifd_send_cleanup_channel(MultiFDSendParams *p, Error **errp)static void multifd_send_cleanup_state (void ) { -file_cleanup_outgoing_migration (); -socket_cleanup_outgoing_migration ();qemu_sem_destroy (&multifd_send_state->channels_created);qemu_sem_destroy (&multifd_send_state->channels_ready);g_free (multifd_send_state->params);
@@ -481,7 +479,7 @@ void multifd_send_shutdown(void) {int i; -if (!migrate_multifd ()) { +if (!migrate_multifd () || !multifd_send_state) {return ; }
migration/options.c +0 -5
@@ -480,11 +480,6 @@ bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp)error_setg (errp,"Postcopy is not compatible with ignore-shared" );return false; } - -if (new_caps[MIGRATION_CAPABILITY_MULTIFD ]) { -error_setg (errp,"Postcopy is not yet compatible with multifd" ); -return false; - } }if (new_caps[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT ]) {
migration/ram.c +3 -4
@@ -1297,7 +1297,7 @@ static int find_dirty_block(RAMState *rs, PageSearchStatus *pss) pss->page =0 ; pss->block =QLIST_NEXT_RCU (pss->block, next);if (!pss->block) { -if (multifd_ram_sync_per_round ()) { +if (multifd_ram_sync_per_round () && !migration_in_postcopy ()) {QEMUFile *f = rs->pss[RAM_CHANNEL_PRECOPY ].pss_channel;int ret =multifd_ram_flush_and_sync (f);if (ret <0 ) {
@@ -1971,9 +1971,8 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss) } } -if (migrate_multifd ()) { -RAMBlock *block = pss->block; -return ram_save_multifd_page (block, offset); +if (migrate_multifd () && !migration_in_postcopy ()) { +return ram_save_multifd_page (pss->block, offset); }if (control_save_page (pss, offset, &res)) {
--
2.48.1
Re: [PATCH v6 2/4] migration: enable multifd and postcopy together
Quoted 71 lines · Prasad Pandit
From: Prasad Pandit <[email protected]>
Enable Multifd and Postcopy migration together. The
migration_ioc_process_incoming()routine checks magic value sent on each channel and helps to properly setup multifd and postcopy channels.The Precopy and Multifd threads work during the initial guest RAM transfer. When migration moves to the Postcopy phase, the multifd threads are shutdown and Postcopy threads on the destination request/pull data from the source side.
Signed-off-by Prasad Pandit <[email protected]>--- migration/migration.c | 107 ++++++++++++++++++++----------------- migration/multifd-nocomp.c | 3 +- migration/multifd.c | 4 +- migration/options.c | 5 -- migration/ram.c | 7 ++- 5 files changed, 64 insertions(+), 62 deletions(-)v6:
- Shutdown multifd threads beforepostcopy_start()
- Reorder tests/qtest/migration/ patches
- Some refactoring of functionsv5:
- https://lore.kernel.org/qemu-devel/[email protected]/T/#tmigration/migration.c +10
-11@@ -95,6 +95,9 @@ enum mig_rp_message_type { MIG_RP_MSG_MAX }; +/* Migration channel types */ +enum {CH_MAIN ,CH_MULTIFD ,CH_POSTCOPY }; +/* When we add fault tolerance, we could have several migrations at once. For now we don't need to add dynamic creation of migration */ @@ -959,28 +962,19 @@ void migration_fd_process_incoming(QEMUFile *f)migration_incoming_process (); } -/* -* Returns true when we want to start a new incoming migration process, -* false otherwise. -*/ -static bool migration_should_start_incoming (bool main_channel) +static bool migration_has_main_and_multifd_channels (void ) { -/* Multifd doesn't start unless all channels are established */ -if (migrate_multifd ()) { -return migration_has_all_channels (); +MigrationIncomingState *mis =migration_incoming_get_current (); +if (!mis->from_src_file) { +/* main channel not established */ +return false; } -/* Preempt channel only starts when the main channel is created */ -if (migrate_postcopy_preempt ()) { -return main_channel; +if (migrate_multifd () && !multifd_recv_all_channels_created ()) { +return false; }
migration/migration.c void migration_fd_process_incoming(QEMUFile *f) · line 979
Quoted 10 lines
migration/migration.c +1
-6-/* -* For all the rest types of migration, we should only reach here when -* it's the main channel that's being created, and we should always -* proceed with this channel. -*/ -assert (main_channel); +/* main channel and all multifd channels are established */ return true; }
How will this avoid peeking the preempt channel? You're assuming preempt is mutually exclusive with multifd it seems. Otherwise you could get the preempt channel creation racing with multifd channels creation.
Quoted 4 lines
migration/migration.c +0
-0@@ -989,13 +983,12 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)MigrationIncomingState *mis =migration_incoming_get_current ();Error *local_err =NULL ;
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 990
Quoted 10 lines
migration/migration.c +2
-4QEMUFile *f; -bool default_channel = true;uint32_t channel_magic =0 ; +uint8_t channel =CH_MAIN ;int ret =0 ; -if (migrate_multifd () && !migrate_mapped_ram () && - !migrate_postcopy_ram () && -qio_channel_has_feature (ioc,QIO_CHANNEL_FEATURE_READ_MSG_PEEK )) { +if (!migration_has_main_and_multifd_channels ()) {
I'm not entirely sure we need these checks here. They will happen anyway later. Could this be replaced by migration_needs_multiple_sockets() instead?
And I'd put this whole channel discovery business in channel.c since it's encoding several assumptions about channels. Some helpers used here might need to be exported, but that's ok.
Also, please make a separate patch, we need to be really confident that changing the discovery code around won't introduce any regression, and if it does, we'll want it separate from the postcopy+multifd enablement. It's ok if you have the patch assume that multifd+postcopy will happen later in the series.
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1001
Quoted 8 lines
migration/migration.c +1
-0+if (qio_channel_has_feature (ioc,QIO_CHANNEL_FEATURE_READ_MSG_PEEK )) {/* * With multiple channels, it is possible that we receive channels * out of order on destination side, causing incorrect mapping of @@ -1006,42 +999,58 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)* tls handshake while initializing main channel so with tls this * issue is not possible. */
This comment block needs to be indented properly.
Quoted 6 lines
migration/migration.c +4
-2- ret =migration_channel_read_peek (ioc, (void *)&channel_magic, -sizeof (channel_magic), errp); + ret =migration_channel_read_peek (ioc, (void *)&channel_magic, +sizeof (channel_magic), errp); +if (ret !=0 ) { +return ;
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1013
Quoted 10 lines
migration/migration.c +7
-2+ } -if (ret !=0 ) { -return ; +if (channel_magic ==cpu_to_be32 (QEMU_VM_FILE_MAGIC )) { + channel =CH_MAIN ; + }else if (channel_magic ==cpu_to_be32 (MULTIFD_MAGIC )) { + channel =CH_MULTIFD ; + }else if (!mis->from_src_file + && mis->state ==MIGRATION_STATUS_POSTCOPY_PAUSED ) {
The usual style is to keep the && on the previous line.
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1014
Quoted 1 line
migration/migration.c +1
-0+/* reconnect default channel for postcopy recovery */
s/default/main/
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1019
Quoted 5 lines
migration/migration.c +5
-0+ channel =CH_MAIN ; + }else { +error_report ("%s: unknown channel magic: %u" , + __func__, channel_magic); +return ;
This needs to set errp instead of reporting.
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1024
Quoted 5 lines
migration/migration.c +5
-0+ } + }else if (mis->from_src_file + && (!strcmp (ioc->name,"migration-tls-incoming" ) + || !strcmp (ioc->name,"migration-file-incoming" ))) { + channel =CH_MULTIFD ;
This is quite misleading. These channels are used without multifd as well. For instance, file-backed fd migration goes past this because !mis->from_src_file but it still uses the file channel.
I agree with Peter that checking for channel names is not ideal. I don't see an alternative at the moment (hiding the assumption is of course not a fix). Maybe check migrate_multifd() here and explain in a comment that at the moment, the non-peekable channels happen to be used with multifd only.
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1025
Quoted 1 line
migration/migration.c +0
-0}
No else clause here and in the rest of the patch makes this is as opaque as the previous version, IMO. We need to define what's supposed to happen whenever the conditionals don't match. Is it an error, g_assert_not_reached(), a fallthrough? Better to set CH_MAIN explicitly wherenever that's the case.
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1028
Quoted 7 lines
migration/migration.c +2
-4- - default_channel = (channel_magic ==cpu_to_be32 (QEMU_VM_FILE_MAGIC )); - }else { - default_channel = !mis->from_src_file; + }else if (mis->from_src_file) { + channel =CH_POSTCOPY ; }
Same here.
Quoted 20 lines
migration/migration.c +2
-7if (multifd_recv_setup (errp) !=0 ) {return ; } -if (default_channel) { +if (channel ==CH_MAIN ) { f =qemu_file_new_input (ioc);migration_incoming_setup (f); - }else { + }else if (channel ==CH_MULTIFD ) {/* Multiple connections */ -assert (migration_needs_multiple_sockets ());if (migrate_multifd ()) {multifd_recv_new_channel (ioc, &local_err); - }else { -assert (migrate_postcopy_preempt ()); - f =qemu_file_new_input (ioc); -postcopy_preempt_new_channel (mis, f); }
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1051
Quoted 10 lines
migration/migration.c +5
-0if (local_err) {error_propagate (errp, local_err);return ; } + }else if (channel ==CH_POSTCOPY ) { +assert (migrate_postcopy_preempt ()); +assert (!mis->postcopy_qemufile_dst); + f =qemu_file_new_input (ioc); +postcopy_preempt_new_channel (mis, f); }
else {
g_assert_not_reached();
}
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1053
Quoted 3 lines
migration/migration.c +1
-1-if (migration_should_start_incoming (default_channel)) { +if (channel !=CH_POSTCOPY &&migration_has_main_and_multifd_channels ()) {
You could check CH_POSTCOPY first in the block above this one and return early.
Quoted 138 lines
migration/migration.c +12
-12/* If it's a recovery, we're done */ if (postcopy_try_recover ()) {return ;@@ -1058,20 +1067,15 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)*/ bool migration_has_all_channels (void ) { +if (!migration_has_main_and_multifd_channels ()) { +return false; + } +MigrationIncomingState *mis =migration_incoming_get_current (); - -if (!mis->from_src_file) { +if (migrate_postcopy_preempt () && !mis->postcopy_qemufile_dst) {return false; } -if (migrate_multifd ()) { -return multifd_recv_all_channels_created (); - } - -if (migrate_postcopy_preempt ()) { -return mis->postcopy_qemufile_dst !=NULL ; - } -return true; }@@ -1482,6 +1486,8 @@ static void migrate_fd_cleanup(MigrationState *s)assert (!migration_is_active ()); +file_cleanup_outgoing_migration (); +socket_cleanup_outgoing_migration ();if (s->state ==MIGRATION_STATUS_CANCELLING ) {migrate_set_state (&s->state,MIGRATION_STATUS_CANCELLING ,MIGRATION_STATUS_CANCELLED );@@ -3373,8 +3379,11 @@ static MigIterateState migration_iteration_run(MigrationState *s) }/* Still a significant amount to transfer */ -if (!in_postcopy && must_precopy <= s->threshold_size && can_switchover && -qatomic_read (&s->start_postcopy)) { +if (!in_postcopy && must_precopy <= s->threshold_size + && can_switchover &&qatomic_read (&s->start_postcopy)) { +if (migrate_multifd ()) { +multifd_send_shutdown (); + }if (postcopy_start (s, &local_err)) {migrate_set_error (s, local_err);error_report_err (local_err);migration/multifd-nocomp.c +2
-1@@ -16,6 +16,7 @@#include "file.h" #include "multifd.h" #include "options.h" +#include "migration.h" #include "qapi/error.h" #include "qemu/cutils.h" #include "qemu/error-report.h" @@ -391,7 +392,7 @@ int multifd_ram_flush_and_sync(QEMUFile *f)MultiFDSyncReq req;int ret; -if (!migrate_multifd ()) { +if (!migrate_multifd () ||migration_in_postcopy ()) {return 0 ; }migration/multifd.c +1
-3@@ -467,8 +467,6 @@ static bool multifd_send_cleanup_channel(MultiFDSendParams *p, Error **errp)static void multifd_send_cleanup_state (void ) { -file_cleanup_outgoing_migration (); -socket_cleanup_outgoing_migration ();qemu_sem_destroy (&multifd_send_state->channels_created);qemu_sem_destroy (&multifd_send_state->channels_ready);g_free (multifd_send_state->params);@@ -481,7 +479,7 @@ void multifd_send_shutdown(void) {int i; -if (!migrate_multifd ()) { +if (!migrate_multifd () || !multifd_send_state) {return ; }migration/options.c +0
-5@@ -480,11 +480,6 @@ bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp)error_setg (errp,"Postcopy is not compatible with ignore-shared" );return false; } - -if (new_caps[MIGRATION_CAPABILITY_MULTIFD ]) { -error_setg (errp,"Postcopy is not yet compatible with multifd" ); -return false; - } }if (new_caps[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT ]) {migration/ram.c +3
-5@@ -1297,7 +1297,7 @@ static int find_dirty_block(RAMState *rs, PageSearchStatus *pss) pss->page =0 ; pss->block =QLIST_NEXT_RCU (pss->block, next);if (!pss->block) { -if (multifd_ram_sync_per_round ()) { +if (multifd_ram_sync_per_round () && !migration_in_postcopy ()) {QEMUFile *f = rs->pss[RAM_CHANNEL_PRECOPY ].pss_channel;int ret =multifd_ram_flush_and_sync (f);if (ret <0 ) {@@ -1971,9 +1971,8 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss) } } -if (migrate_multifd ()) { -RAMBlock *block = pss->block; -return ram_save_multifd_page (block, offset); +if (migrate_multifd () && !migration_in_postcopy ()) { +return ram_save_multifd_page (pss->block, offset); }if (control_save_page (pss, offset, &res)) { --2.48.1
Re: [PATCH v6 2/4] migration: enable multifd and postcopy together
Hello Fabiano,
Quoted 3 lines · Fabiano Rosas
Quoted 3 lines
migration/migration.c +1
-1-static bool migration_should_start_incoming (bool main_channel) +static bool migration_has_main_and_multifd_channels (void ) {
...
Quoted 7 lines
Quoted 3 lines
+ /* main channel and all multifd channels are established */
return true;}
How will this avoid peeking the preempt channel? You're assuming preempt is mutually exclusive with multifd it seems. Otherwise you could get the preempt channel creation racing with multifd channels creation.
* IIUC postcopy preempt channel is created towards the end of the migration when the Postcopy phase starts. At that time, the 'main' and 'multifd' channels are already established and working. Having the 'main' and when multifd is enabled 'multifd' channels in place is a requirement for starting new migration. So when both the 'main' and 'multifd' channels are established, the new incoming connection is seen as the 'postcopy' one; And it falls to the 'else' block of the 'if' conditional -> if (!migration_has_main_and_multifd_channels()) {
* When does postcopy preempt channel creation race with the multifd channel creation?
Quoted 5 lines
Review void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 983
Quoted 2 lines
(quoted diff) +1
-0@@ -989,13 +983,12 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) + if (!migration_has_main_and_multifd_channels()) {I'm not entirely sure we need these checks here. They will happen anyway later. Could this be replaced by
migration_needs_multiple_sockets()instead?
* migration_needs_multiple_sockets() => return migrate_multifd() || migrate_postcopy_preempt();
* That logical OR should have been AND, no? It returns true even when one of them is true. That's not multiple types (multifd/postcopy) of sockets. I don't think it helps much.
* Let's try this:
- First differentiation: peekable Vs non-peekable channels
- Peekable channels
- Main
- Multifd
- Non-peekable channels
- Postcopy preempt
- TLS
- File/mapped_ram
if (qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_READ_MSG_PEEK))
{
if (channel_magic == cpu_to_be32(QEMU_VM_FILE_MAGIC)) {
channel = CH_MAIN;
} else if (channel_magic == cpu_to_be32(MULTIFD_MAGIC)) {
channel = CH_MULTIFD;
} else {
if (!strcmp(ioc->name, "migration-tls-incoming")
|| !strcmp(ioc->name, "migration-file-incoming"))) {
channel = CH_MULTIFD;
} else {
channel = CH_POSTCOPY;
}
}* With above, the 'main' channel shall have to send 'magic value' even for reconnection during the postcopy recovery phase. If all channels were consistent and sent a magic value, this code would be much simpler and we may not have to care/worry about the _order_ in which these connections are made.
if (channel == 'main')
process_main_channel()
else if (channel == 'multifd')
process_multifd_channel()
else if (channel == 'tls')
process_tls_channel()
else if (channel == 'file')
process_file_channel()
else if (channel == 'postcopy')
process_postcopy_channel()Quoted 9 lines
And I'd put this whole channel discovery business in
channel.csince it's encoding several assumptions about channels. Some helpers used here might need to be exported, but that's ok.Also, please make a separate patch, we need to be really confident that changing the discovery code around won't introduce any regression, and if it does, we'll want it separate from the postcopy+multifd enablement. It's ok if you have the patch assume that multifd+postcopy will happen later in the series.
* TBH, I think we have complicated this whole thing with multiple channel types, their inconsistent behaviour and dependence on the _order_ in which connections are made. Do we really need channel types? Could we consider rationalising them?
Quoted 28 lines
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1001
Quoted 8 lines
migration/migration.c +1
-0+if (qio_channel_has_feature (ioc,QIO_CHANNEL_FEATURE_READ_MSG_PEEK )) {/* * With multiple channels, it is possible that we receive channels * out of order on destination side, causing incorrect mapping of @@ -1006,42 +999,58 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)* tls handshake while initializing main channel so with tls this * issue is not possible. */ This comment block needs to be indented properly.
Quoted 6 lines
migration/migration.c +4
-2- ret =migration_channel_read_peek (ioc, (void *)&channel_magic, -sizeof (channel_magic), errp); + ret =migration_channel_read_peek (ioc, (void *)&channel_magic, +sizeof (channel_magic), errp); +if (ret !=0 ) { +return ;migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1013
Quoted 10 lines
migration/migration.c +7
-2+ } -if (ret !=0 ) { -return ; +if (channel_magic ==cpu_to_be32 (QEMU_VM_FILE_MAGIC )) { + channel =CH_MAIN ; + }else if (channel_magic ==cpu_to_be32 (MULTIFD_MAGIC )) { + channel =CH_MULTIFD ; + }else if (!mis->from_src_file + && mis->state ==MIGRATION_STATUS_POSTCOPY_PAUSED ) {
Quoted 5 lines
The usual style is to keep the && on the previous line.
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1014
Quoted 1 line
migration/migration.c +1
-0+/* reconnect default channel for postcopy recovery */ s/default/main/
* Okay, will fix these.
Quoted 7 lines
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1019
Quoted 5 lines
migration/migration.c +5
-0+ channel =CH_MAIN ; + }else { +error_report ("%s: unknown channel magic: %u" , + __func__, channel_magic); +return ;This needs to set errp instead of reporting.
* Okay.
Quoted 10 lines
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1024
Quoted 5 lines
migration/migration.c +5
-0+ } + }else if (mis->from_src_file + && (!strcmp (ioc->name,"migration-tls-incoming" ) + || !strcmp (ioc->name,"migration-file-incoming" ))) { + channel =CH_MULTIFD ;This is quite misleading. These channels are used without multifd as well. For instance, file-backed fd migration goes past this because !mis->from_src_file but it still uses the file channel.
Quoted 5 lines
I agree with Peter that checking for channel names is not ideal. I don't see an alternative at the moment (hiding the assumption is of course not a fix). Maybe check
migrate_multifd()here and explain in a comment that at the moment, the non-peekable channels happen to be used with multifd only.
* The first paragraph says these channels are used without migrate_multifd(); And the second paragraph says they are used with migrate_multifd() only....??
===
} else {
/* Multiple connections */
assert(migration_needs_multiple_sockets());
if (migrate_multifd()) {
multifd_recv_new_channel(ioc, &local_err);
} else {
assert(migrate_postcopy_preempt());
f = qemu_file_new_input(ioc);
postcopy_preempt_new_channel(mis, f);
}===
* IIUC in the current code, when migrate_multifd() is true, these channels get processed via - multifd_recv_new_channel(). And when migrate_multifd() is false, it falls to postcopy_preempt_new_channel() part. Not sure if/how that works really. It is possible that currently these (tls/file) channels are used only with migrate_multifd() enabled and so are processed with multifd_recv_new_channel() function. The current patch handles them the same way.
* About checking channel names, in the non-peekable category above, how do we differentiate between 'TLS', 'File' and 'Postcopy' channels? Without magic values, we don't have much choice really. And seeing those names in the code also tells the reader that 'TLS' and 'File' channels are processed as CH_MULTIFD via - multifd_recv_new_channel().
Quoted 5 lines
No else clause here and in the rest of the patch makes this is as opaque as the previous version, IMO. We need to define what's supposed to happen whenever the conditionals don't match. Is it an error,
g_assert_not_reached(), a fallthrough? Better to setCH_MAINexplicitly wherenever that's the case.
* I'd say let's treat unmatched conditions as an error and return.
Quoted 8 lines
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1028
Quoted 6 lines
migration/migration.c +2
-3- default_channel = (channel_magic ==cpu_to_be32 (QEMU_VM_FILE_MAGIC )); - }else { - default_channel = !mis->from_src_file; + }else if (mis->from_src_file) { + channel =CH_POSTCOPY ; }Same here.
* Here final else means the main channel (mis->from_src_file) is not established, so it defaults to CH_MAIN.
Quoted 4 lines
You could check
CH_POSTCOPYfirst in the block above this one and return early.
* Okay.
* My request is the same - let's think about having consistent channel behaviour. The restructuring and overhauling of the channel processing part could be done separately, outside the current scope of enabling multifd+postcopy together with this series. Let's not try to fix everything in one go, in one series.
Thank you.
---
- Prasad
Re: [PATCH v6 2/4] migration: enable multifd and postcopy together
Quoted 15 lines · Prasad Pandit
Hello Fabiano,
Quoted 3 lines · Fabiano Rosas
Quoted 3 lines
migration/migration.c +1
-1-static bool migration_should_start_incoming (bool main_channel) +static bool migration_has_main_and_multifd_channels (void ) {...
Quoted 7 lines
Quoted 3 lines
+ /* main channel and all multifd channels are established */
return true;}
How will this avoid peeking the preempt channel? You're assuming preempt is mutually exclusive with multifd it seems. Otherwise you could get the preempt channel creation racing with multifd channels creation.
Quoted 9 lines
* IIUC postcopy preempt channel is created towards the end of the migration when the Postcopy phase starts. At that time, the 'main' and 'multifd' channels are already established and working. Having the 'main' and when multifd is enabled 'multifd' channels in place is a requirement for starting new migration. So when both the 'main' and 'multifd' channels are established, the new incoming connection is seen as the 'postcopy' one; And it falls to the 'else' block of the 'if' conditional -> if (!migration_has_main_and_multifd_channels()) {
Do you concede that this code has a hidden assumption? Either that migrate_multifd() != migrate_postcopy_preempt() or that multifd channels must be set up before postcopy preempt channel? Because that is enough for us to have to do something about it. Either restructuring or a comment explaining.
Quoted 3 lines
* When does postcopy preempt channel creation race with the multifd channel creation?
Well, taking that this is the destination side, I don't think we can predict when the other end of the migration will open a channel, can we? For instance, postcopy_do_resume() has this comment:
/*
* If preempt is enabled, re-establish the preempt channel. Note that
* we do it after resume prepare to make sure the main channel will be
* created before the preempt channel. E.g. with weak network, the
* dest QEMU may get messed up with the preempt and main channels on
* the order of connection setup. This guarantees the correct order. */
It looks like if the main channel can race, so do the multifd channels, no?
In any case, I'm fine with just documenting any assumption for now.
Quoted 6 lines
Quoted 5 lines
Review void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 983
Quoted 2 lines
(quoted diff) +1
-0@@ -989,13 +983,12 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) + if (!migration_has_main_and_multifd_channels()) {I'm not entirely sure we need these checks here. They will happen anyway later. Could this be replaced by
migration_needs_multiple_sockets()instead?
Quoted 7 lines
*
migration_needs_multiple_sockets()=> returnmigrate_multifd()||migrate_postcopy_preempt();* That logical OR should have been AND, no? It returns true even when one of them is true. That's not multiple types (multifd/postcopy) of sockets. I don't think it helps much.
Nope, this is just saying whether a single channel is expected, or more than one. That's why I think it would be a good gate for this peeking code. Since postcopy preempt could be a peekable channel, it's misleading to put it all behind QIO_CHANNEL_FEATURE_READ_MSG_PEEK only. This is a time-bomb for the next person to refactor this code.
Quoted 2 lines
* Let's try this:
- First differentiation: peekable Vs non-peekable channels
As I said above, this is not entirely what we're doing.
Quoted 23 lines
- Peekable channels
- Main
- Multifd
- Non-peekable channels
- Postcopy preempt
- TLS
- File/mapped_ram
if (qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_READ_MSG_PEEK))
{
if (channel_magic == cpu_to_be32(QEMU_VM_FILE_MAGIC)) {
channel = CH_MAIN;
} else if (channel_magic == cpu_to_be32(MULTIFD_MAGIC)) {
channel = CH_MULTIFD;
} else {
if (!strcmp(ioc->name, "migration-tls-incoming")
|| !strcmp(ioc->name, "migration-file-incoming"))) {
channel = CH_MULTIFD;
} else {
channel = CH_POSTCOPY;
}
}Quoted 6 lines
* With above, the 'main' channel shall have to send 'magic value' even for reconnection during the postcopy recovery phase. If all channels were consistent and sent a magic value, this code would be much simpler and we may not have to care/worry about the _order_ in which these connections are made.
Right, but that's not what we have today. Changing this requires figuring out how to keep the stream compatible when channels now start sending extra stuff at the start. It's not trivial. There's also mapped-ram which is asynchronous and there might be something special to be done about the TLS handshake, I'm not sure.
Quoted 21 lines
if (channel == 'main') process_main_channel() else if (channel == 'multifd') process_multifd_channel() else if (channel == 'tls') process_tls_channel() else if (channel == 'file') process_file_channel() else if (channel == 'postcopy') process_postcopy_channel()Quoted 9 lines
And I'd put this whole channel discovery business in
channel.csince it's encoding several assumptions about channels. Some helpers used here might need to be exported, but that's ok.Also, please make a separate patch, we need to be really confident that changing the discovery code around won't introduce any regression, and if it does, we'll want it separate from the postcopy+multifd enablement. It's ok if you have the patch assume that multifd+postcopy will happen later in the series.
Quoted 5 lines
* TBH, I think we have complicated this whole thing with multiple channel types, their inconsistent behaviour and dependence on the _order_ in which connections are made. Do we really need channel types? Could we consider rationalising them?
Well, aside from preempt, they're *not* dependent on the order. That's the point of having to do all of this dance. In fact we might be better off if we could serialize the connections somehow.
I havent't followed this series closely, could you point me to the discussion that led to the channels concept being introduced?
Quoted 63 lines
Quoted 28 lines
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1001
Quoted 8 lines
migration/migration.c +1
-0+if (qio_channel_has_feature (ioc,QIO_CHANNEL_FEATURE_READ_MSG_PEEK )) {/* * With multiple channels, it is possible that we receive channels * out of order on destination side, causing incorrect mapping of @@ -1006,42 +999,58 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)* tls handshake while initializing main channel so with tls this * issue is not possible. */ This comment block needs to be indented properly.
Quoted 6 lines
migration/migration.c +4
-2- ret =migration_channel_read_peek (ioc, (void *)&channel_magic, -sizeof (channel_magic), errp); + ret =migration_channel_read_peek (ioc, (void *)&channel_magic, +sizeof (channel_magic), errp); +if (ret !=0 ) { +return ;migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1013
Quoted 10 lines
migration/migration.c +7
-2+ } -if (ret !=0 ) { -return ; +if (channel_magic ==cpu_to_be32 (QEMU_VM_FILE_MAGIC )) { + channel =CH_MAIN ; + }else if (channel_magic ==cpu_to_be32 (MULTIFD_MAGIC )) { + channel =CH_MULTIFD ; + }else if (!mis->from_src_file + && mis->state ==MIGRATION_STATUS_POSTCOPY_PAUSED ) {Quoted 5 lines
The usual style is to keep the && on the previous line.
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1014
Quoted 1 line
migration/migration.c +1
-0+/* reconnect default channel for postcopy recovery */ s/default/main/
* Okay, will fix these.
Quoted 7 lines
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1019
Quoted 5 lines
migration/migration.c +5
-0+ channel =CH_MAIN ; + }else { +error_report ("%s: unknown channel magic: %u" , + __func__, channel_magic); +return ;This needs to set errp instead of reporting.
* Okay.
Quoted 10 lines
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1024
Quoted 5 lines
migration/migration.c +5
-0+ } + }else if (mis->from_src_file + && (!strcmp (ioc->name,"migration-tls-incoming" ) + || !strcmp (ioc->name,"migration-file-incoming" ))) { + channel =CH_MULTIFD ;This is quite misleading. These channels are used without multifd as well. For instance, file-backed fd migration goes past this because !mis->from_src_file but it still uses the file channel.
Quoted 5 lines
I agree with Peter that checking for channel names is not ideal. I don't see an alternative at the moment (hiding the assumption is of course not a fix). Maybe check
migrate_multifd()here and explain in a comment that at the moment, the non-peekable channels happen to be used with multifd only.
Quoted 3 lines
* The first paragraph says these channels are used without
migrate_multifd(); And the second paragraph says they are used withmigrate_multifd()only....??
Yes. They *can* be used without multifd. The comment would explain that at that point in the code, these are the only types possible. So as to not mislead future readers that whenever tls/file, then multifd must be used.
Quoted 11 lines
===
} else { /* Multiple connections */ assert(migration_needs_multiple_sockets()); if (migrate_multifd()) { multifd_recv_new_channel(ioc, &local_err); } else { assert(migrate_postcopy_preempt()); f = qemu_file_new_input(ioc); postcopy_preempt_new_channel(mis, f); }
See? Multifd mutually exclusive with postcopy preempt. You carried that assumption (well done), but made it more subtle (not good), since if/else is by definition showing the relationship between the two while migration_has_main_and_multifd_channels() makes it hidden under the multifd check allowing the last return true to happen.
If we're enabling multifd along with postcopy, we need to be aware that the relationship with preempt might not hold true anymore.
Quoted 5 lines
===
* IIUC in the current code, whenmigrate_multifd()is true, these channels get processed via -multifd_recv_new_channel(). And whenmigrate_multifd()is false, it falls topostcopy_preempt_new_channel()part.
This relies on the fact that the management layer will certainly have set multifd on both sides of the migration and that multifd will not be used with postcopy.
Quoted 5 lines
Not sure if/how that works really. It is possible that currently these (tls/file) channels are used only with
migrate_multifd()enabled and so are processed withmultifd_recv_new_channel()function. The current patch handles them the same way.
That's the entire point I'm making when I ask to not omit the else clauses. The tls and file channels can be the main channel as well, but that is never explicit in the code. That uint8 channel = CH_MAIN up there is doing some heavy-lifting.
Quoted 3 lines
* About checking channel names, in the non-peekable category above, how do we differentiate between 'TLS', 'File' and 'Postcopy' channels? Without magic values, we don't have much choice really.
Indeed.
Quoted 3 lines
And seeing
those names in the code also tells the reader that 'TLS' and 'File' channels are processed asCH_MULTIFDvia -multifd_recv_new_channel().
We shouldn't rely on the underlying iochannel type. That's why they expose the QIO_CHANNEL_FEATUREs. It's fine if we double check at that point that the channels are either file/tls, but that cannot be the algorithm. The current code can work without relying on it after all and I don't think your postcopy enablement affects that particular part.
Quoted 16 lines
Quoted 6 lines
No else clause here and in the rest of the patch makes this is as opaque as the previous version, IMO. We need to define what's supposed to happen whenever the conditionals don't match. Is it an error,
g_assert_not_reached(), a fallthrough? Better to setCH_MAINexplicitly wherenever that's the case.* I'd say let's treat unmatched conditions as an error and return.
Quoted 7 lines
Quoted 6 lines
migration/migration.c +2
-3- default_channel = (channel_magic ==cpu_to_be32 (QEMU_VM_FILE_MAGIC )); - }else { - default_channel = !mis->from_src_file; + }else if (mis->from_src_file) { + channel =CH_POSTCOPY ; }
Quoted 5 lines
Quoted 1 line
Same here.
* Here final else means the main channel (
mis->from_src_file) is not established, so it defaults toCH_MAIN.
Yes, but let's make it explicit. We have this thing in our minds now. In 6 months time no one remembers anything anymore.
Quoted 5 lines
Quoted 4 lines
You could check
CH_POSTCOPYfirst in the block above this one and return early.
Quoted 8 lines
* Okay.
* My request is the same - let's think about having consistent channel behaviour. The restructuring and overhauling of the channel processing part could be done separately, outside the current scope of enabling multifd+postcopy together with this series. Let's not try to fix everything in one go, in one series.
Ok, no one is asking for this to be done in one go. You're free to split any side efforts into a new series and proceed with that. Having to do prerequisite work is pretty common.
Do you think this series can work without touching the channel discovery code? As I said earlier, I'm missing a bit of context, but to me it seems it cannot.
If instead of this refactoring you want to start working on a model for consistent channel advertisement, then that's fine. But we'll have to put this series on hold (which is also fine). It also looks like it could be considerably more work, although I haven't looked at it in detail. Granted, it's work that makes sense, instead of the heuristics we have today.
Quoted 4 lines
Thank you.
---
- Prasad
Re: [PATCH v6 2/4] migration: enable multifd and postcopy together
Hello Fabiano,
Quoted 5 lines · Fabiano Rosas
Do you concede that this code has a hidden assumption? Either that
migrate_multifd()!=migrate_postcopy_preempt()or that multifd channels must be set up before postcopy preempt channel? Because that is enough for us to have to do something about it. Either restructuring or a comment explaining.
* Not a hidden assumption, but it is an observation that 'main' and 'multifd' channels are established before 'postcopy' ones. And for new migration to start, it is necessary that 'main' and 'multifd' channels (when enabled) are established before migration starts.
Quoted 13 lines
Quoted 2 lines
* When does postcopy preempt channel creation race with the multifd channel creation?
For instance,
postcopy_do_resume()has this comment:
/*
* If preempt is enabled, re-establish the preempt channel. Note that
* we do it after resume prepare to make sure the main channel will be
* created before the preempt channel. E.g. with weak network, the
* dest QEMU may get messed up with the preempt and main channels on
* the order of connection setup. This guarantees the correct order. */
It looks like if the main channel can race, so do the multifd channels, no? In any case, I'm fine with just documenting any assumption for now.
* The first requirement for this race to occur is that two types of channels are created together at the same time. Let's see:
* Postcopy migration: without multifd enabled
- 'main' channel is created before the migration starts. And
'postcopy' channels are created towards the end of precopy migration, when the Postcopy phase starts. So in this scenario the race does not happen.
* Postcopy resume: without multifd enabled
- As described in the comment above, preempt channel is created
_after_ the 'main' channel to avoid the race condition.
* Postcopy migration: with multifd enabled
- 'main' and 'multifd' channels are created before migration
starts. And 'postcopy' channels are created towards the end of precopy migration, when the Postcopy phase starts. No race occurs.
* Postcopy resume: with multifd enabled
- 'multifd' channels are shutdown before Postcopy starts, ie. no
'multifd' channels exist during Postcopy resume. So no race between 'postcopy' and 'multifd' channels.
- And 'postcopy' channels are created after the 'main' channel
to avoid the race between them.
- postcopy_do_resume() does not seem to create 'multifd' channels.
* Multifd migration: without Postcopy enabled
- 'main' and 'multifd' channels are created before the migration
starts. They both send 'magic value' bytes, so are easier to differentiate. No race occurs.
Quoted 5 lines
Quoted 3 lines
*
migration_needs_multiple_sockets()=> returnmigrate_multifd()||migrate_postcopy_preempt();Nope, this is just saying whether a single channel is expected, or more than one.
* If we read it as a question:
- migration_needs_multiple_sockets() ? True => Yes, migration
needs multiple sockets.
- migration_needs_multiple_sockets() ? False => No, migration does
not need multiple sockets.
Then it should return 'True' when both migrate_multifd() and postcopy_preempt() are enabled.
Quoted 4 lines
That's why I think it would be a good gate for this peeking code. Since postcopy preempt could be a peekable channel, it's misleading to put it all behind
QIO_CHANNEL_FEATURE_READ_MSG_PEEKonly. This is a time-bomb for the next person to refactor this code.
* Postcopy preempt could be a peekable channel ? Currently it does not send magic value, does it?
Quoted 5 lines
Right, but that's not what we have today. Changing this requires figuring out how to keep the stream compatible when channels now start sending extra stuff at the start. It's not trivial. There's also mapped-ram which is asynchronous and there might be something special to be done about the TLS handshake, I'm not sure.
* True, it's not trivial.
Quoted 6 lines
Well, aside from preempt, they're *not* dependent on the order. That's the point of having to do all of this dance. In fact we might be better off if we could serialize the connections somehow.
I havent't followed this series closely, could you point me to the discussion that led to the channels concept being introduced?
* Channels concept was not introduced in this series. It has been there since the beginning, no?
Quoted 4 lines
Yes. They *can* be used without multifd. The comment would explain that at that point in the code, these are the only types possible. So as to not mislead future readers that whenever tls/file, then multifd must be used.
....
Quoted 8 lines
See? Multifd mutually exclusive with postcopy preempt. You carried that assumption (well done), but made it more subtle (not good), since if/else is by definition showing the relationship between the two while
migration_has_main_and_multifd_channels()makes it hidden under the multifd check allowing the last return true to happen.If we're enabling multifd along with postcopy, we need to be aware that the relationship with preempt might not hold true anymore.
* Sorry, I did not get that. Enabling them together means that they are _not_ exclusive, no? It is not Either 'multifd' OR 'postcopy' case, anymore.
Quoted 7 lines
Quoted 4 lines
Not sure if/how that works really. It is possible that currently these (tls/file) channels are used only with
migrate_multifd()enabled and so are processed withmultifd_recv_new_channel()function. The current patch handles them the same way.That's the entire point I'm making when I ask to not omit the else clauses.
* ie. we set 'channel = CH_MAIN' in the final else clause as well? - Okay.
Quoted 3 lines
Do you think this series can work without touching the channel discovery code? As I said earlier, I'm missing a bit of context, but to me it seems it cannot.
* The reason we need to touch the channel discovery part is: with 'multifd' and 'postcopy' both enabled, towards the end of migration, when 'postcopy' connection comes in
migration_ioc_process_incoming(...)
{
if (migrate_multifd() && !migrate_mapped_ram() &&
!migrate_postcopy_ram() &&
qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_READ_MSG_PEEK)) {
...
} else {
default_channel = !mis->from_src_file;
}
...
if (migrate_multifd()) {
multifd_recv_new_channel(ioc, &local_err);
} else {
postcopy_preempt_new_channel(mis, f);
}
}* The first 'if (migrate_multifd() ... !migrate_postcopy_ram()') evaluates to false, in the else part 'default_channel' also evaluates to false, because the 'main' channel is established. Now the new incoming connection falls in the second migrate_multifd() block and gets processed via - multifd_recv_new_channel(ioc, &local_err); call and migration would not complete/finish.
* To identify the incoming postcopy connection, in the very first version of this series, a magic value for the postcopy channel was introduced and everything else remained the same.
* Would that be an acceptable solution for now?
Quoted 6 lines
If instead of this refactoring you want to start working on a model for consistent channel advertisement, then that's fine. But we'll have to put this series on hold (which is also fine). It also looks like it could be considerably more work, although I haven't looked at it in detail. Granted, it's work that makes sense, instead of the heuristics we have today.
* IMHO, we need not put this series on hold, for now we could go ahead with the postcopy magic value patch if that works. And the larger overhaul of the channel discovery part could be done as a separate series of its own.
Thank you.
---
- Prasad
Re: [PATCH v6 2/4] migration: enable multifd and postcopy together
Quoted 54 lines · Prasad Pandit
Hello Fabiano,
Quoted 5 lines · Fabiano Rosas
Do you concede that this code has a hidden assumption? Either that
migrate_multifd()!=migrate_postcopy_preempt()or that multifd channels must be set up before postcopy preempt channel? Because that is enough for us to have to do something about it. Either restructuring or a comment explaining.* Not a hidden assumption, but it is an observation that 'main' and 'multifd' channels are established before 'postcopy' ones. And for new migration to start, it is necessary that 'main' and 'multifd' channels (when enabled) are established before migration starts.
Quoted 13 lines
Quoted 2 lines
* When does postcopy preempt channel creation race with the multifd channel creation?
For instance,
postcopy_do_resume()has this comment:
/*
* If preempt is enabled, re-establish the preempt channel. Note that
* we do it after resume prepare to make sure the main channel will be
* created before the preempt channel. E.g. with weak network, the
* dest QEMU may get messed up with the preempt and main channels on
* the order of connection setup. This guarantees the correct order. */
It looks like if the main channel can race, so do the multifd channels, no? In any case, I'm fine with just documenting any assumption for now.* The first requirement for this race to occur is that two types of channels are created together at the same time. Let's see:
* Postcopy migration: without multifd enabled
- 'main' channel is created before the migration starts. And
'postcopy' channels are created towards the end of precopy migration, when the Postcopy phase starts. So in this scenario the race does not happen.* Postcopy resume: without multifd enabled
- As described in the comment above, preempt channel is created
_after_ the 'main' channel to avoid the race condition.* Postcopy migration: with multifd enabled
- 'main' and 'multifd' channels are created before migration
starts. And 'postcopy' channels are created towards the end of precopy migration, when the Postcopy phase starts. No race occurs.* Postcopy resume: with multifd enabled
- 'multifd' channels are shutdown before Postcopy starts, ie. no
'multifd' channels exist during Postcopy resume. So no race between 'postcopy' and 'multifd' channels.
- And 'postcopy' channels are created after the 'main' channel
to avoid the race between them.
-postcopy_do_resume()does not seem to create 'multifd' channels.
Quoted 5 lines
* Multifd migration: without Postcopy enabled
- 'main' and 'multifd' channels are created before the migration
starts. They both send 'magic value' bytes, so are easier to differentiate. No race occurs.
I don't see anything stopping postcopy_start() from being called in the source in relation to multifd recv threads being setup in the destination. So far it seems possible that the source is opening the preempt channel while multifd still hasn't seen all threads. There's also pre-7.2 machines which create the postcopy channel early.
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
*
migration_needs_multiple_sockets()=> returnmigrate_multifd()||migrate_postcopy_preempt();Nope, this is just saying whether a single channel is expected, or more than one.
Quoted 9 lines
* If we read it as a question:
-migration_needs_multiple_sockets()? True => Yes, migration
needs multiple sockets.
-migration_needs_multiple_sockets()? False => No, migration does
not need multiple sockets.Then it should return 'True' when both
migrate_multifd()andpostcopy_preempt()are enabled.
Why?
Quoted 8 lines
Quoted 4 lines
That's why I think it would be a good gate for this peeking code. Since postcopy preempt could be a peekable channel, it's misleading to put it all behind
QIO_CHANNEL_FEATURE_READ_MSG_PEEKonly. This is a time-bomb for the next person to refactor this code.* Postcopy preempt could be a peekable channel ? Currently it does not send magic value, does it?
Peekable means it can read ahead and rollback without consuming that part of the stream. We need it because there's code later on that will validate the MAGIC.
Quoted 12 lines
Quoted 5 lines
Right, but that's not what we have today. Changing this requires figuring out how to keep the stream compatible when channels now start sending extra stuff at the start. It's not trivial. There's also mapped-ram which is asynchronous and there might be something special to be done about the TLS handshake, I'm not sure.
* True, it's not trivial.
Quoted 4 lines
Well, aside from preempt, they're *not* dependent on the order. That's the point of having to do all of this dance. In fact we might be better off if we could serialize the connections somehow.
Quoted 6 lines
Quoted 2 lines
I havent't followed this series closely, could you point me to the discussion that led to the channels concept being introduced?
* Channels concept was not introduced in this series. It has been there since the beginning, no?
I thought you meant the CH_MAIN stuff. So now I don't know what you mean. You want to do away with multifd?
Quoted 11 lines
Quoted 4 lines
Yes. They *can* be used without multifd. The comment would explain that at that point in the code, these are the only types possible. So as to not mislead future readers that whenever tls/file, then multifd must be used.
....
Quoted 6 lines
See? Multifd mutually exclusive with postcopy preempt. You carried that assumption (well done), but made it more subtle (not good), since if/else is by definition showing the relationship between the two while
migration_has_main_and_multifd_channels()makes it hidden under the multifd check allowing the last return true to happen.
Quoted 7 lines
Quoted 2 lines
If we're enabling multifd along with postcopy, we need to be aware that the relationship with preempt might not hold true anymore.
* Sorry, I did not get that. Enabling them together means that they are _not_ exclusive, no? It is not Either 'multifd' OR 'postcopy' case, anymore.
Yes, as we're seeing, there's this assumption that multifd is never enabled along with postcopy_preempt. Now with multifd+postcopy we need to be careful to stop the places where that assumption was made.
Quoted 41 lines
Quoted 7 lines
Quoted 4 lines
Not sure if/how that works really. It is possible that currently these (tls/file) channels are used only with
migrate_multifd()enabled and so are processed withmultifd_recv_new_channel()function. The current patch handles them the same way.That's the entire point I'm making when I ask to not omit the else clauses.
* ie. we set 'channel =
CH_MAIN' in the final else clause as well? - Okay.Quoted 3 lines
Do you think this series can work without touching the channel discovery code? As I said earlier, I'm missing a bit of context, but to me it seems it cannot.
* The reason we need to touch the channel discovery part is: with 'multifd' and 'postcopy' both enabled, towards the end of migration, when 'postcopy' connection comes in
migration_ioc_process_incoming(...) { if (migrate_multifd() && !migrate_mapped_ram() && !migrate_postcopy_ram() && qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_READ_MSG_PEEK)) { ... } else { default_channel = !mis->from_src_file; } ... if (migrate_multifd()) { multifd_recv_new_channel(ioc, &local_err); } else { postcopy_preempt_new_channel(mis, f); } }* The first 'if (
migrate_multifd()... !migrate_postcopy_ram()') evaluates to false, in the else part 'default_channel' also evaluates to false, because the 'main' channel is established. Now the new incoming connection falls in the secondmigrate_multifd()block and gets processed via -multifd_recv_new_channel(ioc, &local_err); call and migration would not complete/finish.
Quoted 6 lines
* To identify the incoming postcopy connection, in the very first version of this series, a magic value for the postcopy channel was introduced and everything else remained the same.
* Would that be an acceptable solution for now?
Continue with this patch and fix the stuff I mentioned. You can ignore the first two paragraphs of that reply.
https://lore.kernel.org/r/[email protected]
I still think we need to test that preempt + multifd scenario, but it should be easy to write a test for that once the series is in more of a final shape.
Quoted 7 lines
Quoted 6 lines
If instead of this refactoring you want to start working on a model for consistent channel advertisement, then that's fine. But we'll have to put this series on hold (which is also fine). It also looks like it could be considerably more work, although I haven't looked at it in detail. Granted, it's work that makes sense, instead of the heuristics we have today.
Quoted 5 lines
* IMHO, we need not put this series on hold, for now we could go ahead with the postcopy magic value patch if that works. And the larger overhaul of the channel discovery part could be done as a separate series of its own.
We can't add magic values, as we've discussed.
Quoted 3 lines
Thank you.
---
- Prasad
Re: [PATCH v6 2/4] migration: enable multifd and postcopy together
Hello,
Quoted 5 lines · Fabiano Rosas
I don't see anything stopping
postcopy_start()from being called in the source in relation to multifd recv threads being setup in the destination. So far it seems possible that the source is opening the preempt channel while multifd still hasn't seen all threads. There's also pre-7.2 machines which create the postcopy channel early.
* If we can not predict the sequence/timings of when different types of connections are initiated and processed, maybe source and destination QEMUs could work in tandem. ie. before initiating a connection, source QEMU could send an 'initiate' message saying I'm initiating 'X' connection. Only when destination QEMU says 'okay', source QEMU could proceed with actual connection.
QEMU-A -> Initiate connection type X -> QEMU-B
QEMU-A <- okay <- <- QEMU-B
QEMU-A -> connect type X -> QEMU-B(thinking out loud)
Quoted 3 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
*
migration_needs_multiple_sockets()Then it should return 'True' when both
migrate_multifd()andpostcopy_preempt()are enabled.Why?
* I was thinking multiple_sockets is multiple types of sockets:
multifd & postcopy. But it seems here multiple sockets is any type of multiple sockets.
Quoted 2 lines
I thought you meant the
CH_MAINstuff. So now I don't know what you mean. You want to do away with multifd?
* Yes, CH_DEFAULT -> CH_MAIN was introduced in this series to identify channels and accordingly call relevant functions.
* Not to do away with multifd, but more of making it same as the main channel, ex: virsh migrate --threads <N> N = 1...255. All precopy threads/connections behave the same. Differentiation of precopy and postcopy shall still exist, because they operate/work in opposite directions.
Quoted 8 lines
Continue with this patch and fix the stuff I mentioned. You can ignore the first two paragraphs of that reply.
https://lore.kernel.org/r/[email protected]
I still think we need to test that preempt + multifd scenario, but it should be easy to write a test for that once the series is in more of a final shape.
* Okay.
Quoted 1 line
We can't add magic values, as we've discussed.
Okay.
Thank you.
---
- Prasad
Re: [PATCH v6 2/4] migration: enable multifd and postcopy together
Quoted 16 lines · Prasad Pandit
Hello,
Quoted 5 lines · Fabiano Rosas
I don't see anything stopping
postcopy_start()from being called in the source in relation to multifd recv threads being setup in the destination. So far it seems possible that the source is opening the preempt channel while multifd still hasn't seen all threads. There's also pre-7.2 machines which create the postcopy channel early.* If we can not predict the sequence/timings of when different types of connections are initiated and processed, maybe source and destination QEMUs could work in tandem. ie. before initiating a connection, source QEMU could send an 'initiate' message saying I'm initiating 'X' connection. Only when destination QEMU says 'okay', source QEMU could proceed with actual connection.
Quoted 6 lines
QEMU-A -> Initiate connection type X -> QEMU-B QEMU-A <- okay <- <- QEMU-B QEMU-A -> connect type X -> QEMU-B(thinking out loud)
This is more or less the handshake idea. Or at least it could be included in that work.
I have parked the handshake idea for now because I'm not seeing an immediate need for it and there are more pressing issues to be dealt with first such as bugs and coordinating the new features (and their possible outcomings) that IMO need to be looked at first.
Quoted 8 lines
Quoted 3 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
*
migration_needs_multiple_sockets()Then it should return 'True' when both
migrate_multifd()andpostcopy_preempt()are enabled.Why?
* I was thinking
multiple_socketsis multiple types of sockets:
multifd & postcopy. But it seems here multiple sockets is any type of multiple sockets.
Yes this means main channel + others.
Quoted 12 lines
Quoted 2 lines
I thought you meant the
CH_MAINstuff. So now I don't know what you mean. You want to do away with multifd?* Yes,
CH_DEFAULT->CH_MAINwas introduced in this series to identify channels and accordingly call relevant functions.* Not to do away with multifd, but more of making it same as the main channel, ex: virsh migrate --threads <N> N = 1...255. All precopy threads/connections behave the same. Differentiation of precopy and postcopy shall still exist, because they operate/work in opposite directions.
I'm not opposed to that idea. When I started working with migration I had the impression that was the direction and that we could put every workload in a pool of multifd threads. Now, knowing the code better, I'm not sure that's feasible. Specially the dependence on a "main" channel seems difficult to do away with. It's also somewhat convenient to have a maint thread. But we could still attempt to group extra threads, such as what we're doing with the new thread pool in the device state series. At least thread management could be done entirely in a separate pool, main channel and all.
Quoted 18 lines
Quoted 8 lines
Continue with this patch and fix the stuff I mentioned. You can ignore the first two paragraphs of that reply.
https://lore.kernel.org/r/[email protected]
I still think we need to test that preempt + multifd scenario, but it should be easy to write a test for that once the series is in more of a final shape.
* Okay.
Quoted 1 line
We can't add magic values, as we've discussed.
Okay.
Thank you.
---
- Prasad
Re: [PATCH v6 2/4] migration: enable multifd and postcopy together
Hello Fabiano,
Quoted 7 lines · Fabiano Rosas
This is more or less the handshake idea. Or at least it could be included in that work.
I have parked the handshake idea for now because I'm not seeing an immediate need for it and there are more pressing issues to be dealt with first such as bugs and coordinating the new features (and their possible outcomings) that IMO need to be looked at first.
* I see, okay.
Quoted 10 lines
I'm not opposed to that idea. When I started working with migration I had the impression that was the direction and that we could put every workload in a pool of multifd threads. Now, knowing the code better, I'm not sure that's feasible. Specially the dependence on a "main" channel seems difficult to do away with. It's also somewhat convenient to have a maint thread. But we could still attempt to group extra threads, such as what we're doing with the new thread pool in the device state series. At least thread management could be done entirely in a separate pool, main channel and all.
* True. To extend the two QEMUs working in tandem OR the handshake idea further with the 'main' channel, let's say a user invokes command:
$ virsh migrate --threads 4 --postcopy --postcopy-after-precopy ...
0) Channel = TCP socket connection between two machines.
1) The 'main' channel is the dedicated _control_ channel; And other channels are dedicated _data_ channels. So with '--threads 4' option, QEMU creates a total of 5 (main + 4) channels.
QEMU-A -> 'main' channel -> QEMU-B
QEMU-A -> 'data' channel-1 -> QEMU-B
QEMU-A -> 'data' channel-2 -> QEMU-B
QEMU-A -> 'data' channel-3 -> QEMU-B
QEMU-A -> 'data' channel-4 -> QEMU-B
* Each channel is used by a thread of its own.2) All channels are created _before_ the migration starts and stay till the end of the migration. No asynchronous channels popping up during migration, like a 'postcopy' channel now.
3) In the beginning source says 'Let's Precopy' to the destination on the 'main' channel
QEMU-A -> main: Let's precopy -> QEMU-B
QEMU-A <- main: Okay <- QEMU-B
And migration data flows from QEMU-A -> to -> QEMU-B on the'data' channels.
QEMU-A -> 'data' -> -> -> QEMU-B
QEMU-A -> 'data' -> -> -> QEMU-B
QEMU-A -> 'data' -> -> -> QEMU-B
QEMU-A -> 'data' -> -> -> QEMU-B4) When it's time to switch to Postcopy, source says 'Let's Postcopy' to the destination on the 'main' channel
QEMU-A -> main: Let's postcopy -> QEMU-B
QEMU-A <- main: Okay <- QEMU-B
And migration page requests/data use the same 'data' channels.
QEMU-A <- <- 'request/data' -> -> QEMU-B
QEMU-A <- <- 'request/data' -> -> QEMU-B
QEMU-A <- <- 'request/data' -> -> QEMU-B
QEMU-A <- <- 'request/data' -> -> QEMU-B5) This way:
- 'main' channel could be used to co-ordinate actions of two QEMUs.
- All data channels may be used during Postcopy too, instead of
one channel now.
- There may not be race conditions while creating channels.
- No differentiation of precopy/multifd/postcopy/preempt etc. channels.
(thinking out loud if that sounds workable)
Thank you.
---
- Prasad
Re: [PATCH v6 2/4] migration: enable multifd and postcopy together
In reply to Prasad PanditHi Prasad,
Quoted 114 lines · Prasad Pandit
From: Prasad Pandit <[email protected]>
Enable Multifd and Postcopy migration together. The
migration_ioc_process_incoming()routine checks magic value sent on each channel and helps to properly setup multifd and postcopy channels.The Precopy and Multifd threads work during the initial guest RAM transfer. When migration moves to the Postcopy phase, the multifd threads are shutdown and Postcopy threads on the destination request/pull data from the source side.
Signed-off-by Prasad Pandit <[email protected]>--- migration/migration.c | 107 ++++++++++++++++++++----------------- migration/multifd-nocomp.c | 3 +- migration/multifd.c | 4 +- migration/options.c | 5 -- migration/ram.c | 7 ++- 5 files changed, 64 insertions(+), 62 deletions(-)v6:
- Shutdown multifd threads beforepostcopy_start()
- Reorder tests/qtest/migration/ patches
- Some refactoring of functionsv5:
- https://lore.kernel.org/qemu-devel/[email protected]/T/#tmigration/migration.c +20
-25@@ -95,6 +95,9 @@ enum mig_rp_message_type { MIG_RP_MSG_MAX }; +/* Migration channel types */ +enum {CH_MAIN ,CH_MULTIFD ,CH_POSTCOPY }; +/* When we add fault tolerance, we could have several migrations at once. For now we don't need to add dynamic creation of migration */ @@ -959,28 +962,19 @@ void migration_fd_process_incoming(QEMUFile *f)migration_incoming_process (); } -/* -* Returns true when we want to start a new incoming migration process, -* false otherwise. -*/ -static bool migration_should_start_incoming (bool main_channel) +static bool migration_has_main_and_multifd_channels (void ) { -/* Multifd doesn't start unless all channels are established */ -if (migrate_multifd ()) { -return migration_has_all_channels (); +MigrationIncomingState *mis =migration_incoming_get_current (); +if (!mis->from_src_file) { +/* main channel not established */ +return false; } -/* Preempt channel only starts when the main channel is created */ -if (migrate_postcopy_preempt ()) { -return main_channel; +if (migrate_multifd () && !multifd_recv_all_channels_created ()) { +return false; } -/* -* For all the rest types of migration, we should only reach here when -* it's the main channel that's being created, and we should always -* proceed with this channel. -*/ -assert (main_channel); +/* main channel and all multifd channels are established */ return true; }@@ -989,13 +983,12 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)MigrationIncomingState *mis =migration_incoming_get_current ();Error *local_err =NULL ;QEMUFile *f; -bool default_channel = true;uint32_t channel_magic =0 ; +uint8_t channel =CH_MAIN ;int ret =0 ; -if (migrate_multifd () && !migrate_mapped_ram () && - !migrate_postcopy_ram () && -qio_channel_has_feature (ioc,QIO_CHANNEL_FEATURE_READ_MSG_PEEK )) { +if (!migration_has_main_and_multifd_channels ()) { +if (qio_channel_has_feature (ioc,QIO_CHANNEL_FEATURE_READ_MSG_PEEK )) {/* * With multiple channels, it is possible that we receive channels * out of order on destination side, causing incorrect mapping of @@ -1006,42 +999,58 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)* tls handshake while initializing main channel so with tls this * issue is not possible. */ - ret =migration_channel_read_peek (ioc, (void *)&channel_magic, -sizeof (channel_magic), errp); + ret =migration_channel_read_peek (ioc, (void *)&channel_magic, +sizeof (channel_magic), errp); +if (ret !=0 ) { +return ; + } -if (ret !=0 ) { -return ; +if (channel_magic ==cpu_to_be32 (QEMU_VM_FILE_MAGIC )) {
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1018
Quoted 10 lines
migration/migration.c +10
-0+ channel =CH_MAIN ; + }else if (channel_magic ==cpu_to_be32 (MULTIFD_MAGIC )) { + channel =CH_MULTIFD ; + }else if (!mis->from_src_file + && mis->state ==MIGRATION_STATUS_POSTCOPY_PAUSED ) { +/* reconnect default channel for postcopy recovery */ + channel =CH_MAIN ; + }else { +error_report ("%s: unknown channel magic: %u" , + __func__, channel_magic);
Here, the number reported in the error will have incorrect endianness on a non-BE system. I think it would be better to convert channel_magic to the system endianness right after reading it. On top of that, then there is no need to convert constants with magic numbers when comparing.
Quoted 187 lines
migration/migration.c +28
-24+return ; + } + }else if (mis->from_src_file + && (!strcmp (ioc->name,"migration-tls-incoming" ) + || !strcmp (ioc->name,"migration-file-incoming" ))) { + channel =CH_MULTIFD ; } - - default_channel = (channel_magic ==cpu_to_be32 (QEMU_VM_FILE_MAGIC )); - }else { - default_channel = !mis->from_src_file; + }else if (mis->from_src_file) { + channel =CH_POSTCOPY ; }if (multifd_recv_setup (errp) !=0 ) {return ; } -if (default_channel) { +if (channel ==CH_MAIN ) { f =qemu_file_new_input (ioc);migration_incoming_setup (f); - }else { + }else if (channel ==CH_MULTIFD ) {/* Multiple connections */ -assert (migration_needs_multiple_sockets ());if (migrate_multifd ()) {multifd_recv_new_channel (ioc, &local_err); - }else { -assert (migrate_postcopy_preempt ()); - f =qemu_file_new_input (ioc); -postcopy_preempt_new_channel (mis, f); }if (local_err) {error_propagate (errp, local_err);return ; } + }else if (channel ==CH_POSTCOPY ) { +assert (migrate_postcopy_preempt ()); +assert (!mis->postcopy_qemufile_dst); + f =qemu_file_new_input (ioc); +postcopy_preempt_new_channel (mis, f); } -if (migration_should_start_incoming (default_channel)) { +if (channel !=CH_POSTCOPY &&migration_has_main_and_multifd_channels ()) {/* If it's a recovery, we're done */ if (postcopy_try_recover ()) {return ;@@ -1058,20 +1067,15 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)*/ bool migration_has_all_channels (void ) { +if (!migration_has_main_and_multifd_channels ()) { +return false; + } +MigrationIncomingState *mis =migration_incoming_get_current (); - -if (!mis->from_src_file) { +if (migrate_postcopy_preempt () && !mis->postcopy_qemufile_dst) {return false; } -if (migrate_multifd ()) { -return multifd_recv_all_channels_created (); - } - -if (migrate_postcopy_preempt ()) { -return mis->postcopy_qemufile_dst !=NULL ; - } -return true; }@@ -1482,6 +1486,8 @@ static void migrate_fd_cleanup(MigrationState *s)assert (!migration_is_active ()); +file_cleanup_outgoing_migration (); +socket_cleanup_outgoing_migration ();if (s->state ==MIGRATION_STATUS_CANCELLING ) {migrate_set_state (&s->state,MIGRATION_STATUS_CANCELLING ,MIGRATION_STATUS_CANCELLED );@@ -3373,8 +3379,11 @@ static MigIterateState migration_iteration_run(MigrationState *s) }/* Still a significant amount to transfer */ -if (!in_postcopy && must_precopy <= s->threshold_size && can_switchover && -qatomic_read (&s->start_postcopy)) { +if (!in_postcopy && must_precopy <= s->threshold_size + && can_switchover &&qatomic_read (&s->start_postcopy)) { +if (migrate_multifd ()) { +multifd_send_shutdown (); + }if (postcopy_start (s, &local_err)) {migrate_set_error (s, local_err);error_report_err (local_err);migration/multifd-nocomp.c +2
-1@@ -16,6 +16,7 @@#include "file.h" #include "multifd.h" #include "options.h" +#include "migration.h" #include "qapi/error.h" #include "qemu/cutils.h" #include "qemu/error-report.h" @@ -391,7 +392,7 @@ int multifd_ram_flush_and_sync(QEMUFile *f)MultiFDSyncReq req;int ret; -if (!migrate_multifd ()) { +if (!migrate_multifd () ||migration_in_postcopy ()) {return 0 ; }migration/multifd.c +1
-3@@ -467,8 +467,6 @@ static bool multifd_send_cleanup_channel(MultiFDSendParams *p, Error **errp)static void multifd_send_cleanup_state (void ) { -file_cleanup_outgoing_migration (); -socket_cleanup_outgoing_migration ();qemu_sem_destroy (&multifd_send_state->channels_created);qemu_sem_destroy (&multifd_send_state->channels_ready);g_free (multifd_send_state->params);@@ -481,7 +479,7 @@ void multifd_send_shutdown(void) {int i; -if (!migrate_multifd ()) { +if (!migrate_multifd () || !multifd_send_state) {return ; }migration/options.c +0
-5@@ -480,11 +480,6 @@ bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp)error_setg (errp,"Postcopy is not compatible with ignore-shared" );return false; } - -if (new_caps[MIGRATION_CAPABILITY_MULTIFD ]) { -error_setg (errp,"Postcopy is not yet compatible with multifd" ); -return false; - } }if (new_caps[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT ]) {migration/ram.c +3
-5@@ -1297,7 +1297,7 @@ static int find_dirty_block(RAMState *rs, PageSearchStatus *pss) pss->page =0 ; pss->block =QLIST_NEXT_RCU (pss->block, next);if (!pss->block) { -if (multifd_ram_sync_per_round ()) { +if (multifd_ram_sync_per_round () && !migration_in_postcopy ()) {QEMUFile *f = rs->pss[RAM_CHANNEL_PRECOPY ].pss_channel;int ret =multifd_ram_flush_and_sync (f);if (ret <0 ) {@@ -1971,9 +1971,8 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss) } } -if (migrate_multifd ()) { -RAMBlock *block = pss->block; -return ram_save_multifd_page (block, offset); +if (migrate_multifd () && !migration_in_postcopy ()) { +return ram_save_multifd_page (pss->block, offset); }if (control_save_page (pss, offset, &res)) { --2.48.1
Re: [PATCH v6 2/4] migration: enable multifd and postcopy together
Quoted 7 lines · Juraj Marcin
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1018
Quoted 2 lines
migration/migration.c +2
-0+error_report ("%s: unknown channel magic: %u" , + __func__, channel_magic);Here, the number reported in the error will have incorrect endianness on a non-BE system. I think it would be better to convert
channel_magicto the system endianness right after reading it. On top of that, then there is no need to convert constants with magic numbers when comparing.
* Okay.
Thank you.
---
- Prasad
PATCH v6 3/4 tests/qtest/migration: consolidate set capabilities
In reply to Prasad PanditFrom: Prasad Pandit <[email protected]>
Migration capabilities are set in multiple '.start_hook' functions for various tests. Instead, consolidate setting capabilities in 'set_migration_capabilities()' function which is called from various 'test_*_common()' functions. While simplifying the capabilities setting, it helps to declutter the qtest sources.
--- tests/qtest/migration/compression-tests.c | 10 ++-- tests/qtest/migration/cpr-tests.c | 4 +- tests/qtest/migration/file-tests.c | 44 +++++------------- tests/qtest/migration/framework.c | 56 +++++++++++++++++------ tests/qtest/migration/framework.h | 4 +- tests/qtest/migration/postcopy-tests.c | 4 +- tests/qtest/migration/precopy-tests.c | 19 +++----- tests/qtest/migration/tls-tests.c | 11 ++++- 8 files changed, 80 insertions(+), 72 deletions(-)
v6:
- Reorder, make this the first qtest patch in this series.
v5:
- https://lore.kernel.org/qemu-devel/[email protected]/T/#t
tests/qtest/migration/compression-tests.c +6 -4
@@ -35,6 +35,7 @@ static void test_multifd_tcp_zstd(void) {MigrateCommon args = { .listen_uri ="defer" , + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, .start_hook = migrate_hook_start_precopy_tcp_multifd_zstd, };test_precopy_common (&args);
@@ -56,6 +57,7 @@ static void test_multifd_tcp_qatzip(void) {MigrateCommon args = { .listen_uri ="defer" , + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, .start_hook = migrate_hook_start_precopy_tcp_multifd_qatzip, };test_precopy_common (&args);
@@ -74,6 +76,7 @@ static void test_multifd_tcp_qpl(void) {MigrateCommon args = { .listen_uri ="defer" , + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, .start_hook = migrate_hook_start_precopy_tcp_multifd_qpl, };test_precopy_common (&args);
@@ -92,6 +95,7 @@ static void test_multifd_tcp_uadk(void) {MigrateCommon args = { .listen_uri ="defer" , + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, .start_hook = migrate_hook_start_precopy_tcp_multifd_uadk, };test_precopy_common (&args);
@@ -103,10 +107,6 @@ migrate_hook_start_xbzrle(QTestState *from, QTestState *to) {migrate_set_parameter_int (from,"xbzrle-cache-size" ,33554432 ); - -migrate_set_capability (from,"xbzrle" , true); -migrate_set_capability (to,"xbzrle" , true); -return NULL ; }
@@ -118,6 +118,7 @@ static void test_precopy_unix_xbzrle(void) .listen_uri = uri, .start_hook = migrate_hook_start_xbzrle, .iterations = 2, + .caps[MIGRATION_CAPABILITY_XBZRLE] = true,/* * XBZRLE needs pages to be modified when doing the 2nd+ round * iteration to have real data pushed to the stream.
@@ -146,6 +147,7 @@ static void test_multifd_tcp_zlib(void) {MigrateCommon args = { .listen_uri ="defer" , + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, .start_hook = migrate_hook_start_precopy_tcp_multifd_zlib, };test_precopy_common (&args);
tests/qtest/migration/cpr-tests.c +1 -3
@@ -24,9 +24,6 @@ static void *migrate_hook_start_mode_reboot(QTestState *from, QTestState *to)migrate_set_parameter_str (from,"mode" ,"cpr-reboot" );migrate_set_parameter_str (to,"mode" ,"cpr-reboot" ); -migrate_set_capability (from,"x-ignore-shared" , true); -migrate_set_capability (to,"x-ignore-shared" , true); -return NULL ; }
@@ -39,6 +36,7 @@ static void test_mode_reboot(void) .connect_uri = uri, .listen_uri = "defer", .start_hook = migrate_hook_start_mode_reboot, + .caps[MIGRATION_CAPABILITY_X_IGNORE_SHARED] = true, };test_file_common (&args, true);
tests/qtest/migration/file-tests.c +12 -32
115 lines not on this page · raw message
tests/qtest/migration/framework.c +41 -15
91 lines not on this page · raw message
tests/qtest/migration/framework.h +3 -1
@@ -12,6 +12,7 @@#define TEST_FRAMEWORK_H #include "libqtest.h" +#include <qapi/qapi-types-migration.h> #define FILE_TEST_FILENAME "migfile"#define FILE_TEST_OFFSET 0x1000
@@ -207,8 +208,9 @@ typedef struct {/* Postcopy specific fields */ void *postcopy_data; -bool postcopy_preempt;PostcopyRecoveryFailStage postcopy_recovery_fail_stage; + +bool caps[MIGRATION_CAPABILITY__MAX ]; } MigrateCommon;void wait_for_serial (const char *side);
tests/qtest/migration/postcopy-tests.c +2 -2
@@ -39,7 +39,7 @@ static void test_postcopy_suspend(void)static void test_postcopy_preempt (void ) {MigrateCommon args = { - .postcopy_preempt = true, + .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT ] = true, };test_postcopy_common (&args);
@@ -73,7 +73,7 @@ static void test_postcopy_recovery_fail_reconnect(void)static void test_postcopy_preempt_recovery (void ) {MigrateCommon args = { - .postcopy_preempt = true, + .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT ] = true, };test_postcopy_recovery_common (&args);
tests/qtest/migration/precopy-tests.c +6 -13
@@ -107,23 +107,12 @@ static void test_precopy_tcp_plain(void)test_precopy_common (&args); } -static void *migrate_hook_start_switchover_ack (QTestState *from,QTestState *to) -{ - -migrate_set_capability (from,"return-path" , true); -migrate_set_capability (to,"return-path" , true); - -migrate_set_capability (from,"switchover-ack" , true); -migrate_set_capability (to,"switchover-ack" , true); - -return NULL ; -} -static void test_precopy_tcp_switchover_ack (void ) {MigrateCommon args = { .listen_uri ="tcp:127.0.0.1:0" , - .start_hook = migrate_hook_start_switchover_ack, + .caps[MIGRATION_CAPABILITY_RETURN_PATH ] = true, + .caps[MIGRATION_CAPABILITY_SWITCHOVER_ACK ] = true,/* * Source VM must be running in order to consider the switchover ACK * when deciding to do switchover or not.
@@ -392,6 +381,7 @@ static void test_multifd_tcp_uri_none(void)MigrateCommon args = { .listen_uri ="defer" , .start_hook = migrate_hook_start_precopy_tcp_multifd, + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true,/* * Multifd is more complicated than most of the features, it * directly takes guest page buffers when sending, make sure
@@ -407,6 +397,7 @@ static void test_multifd_tcp_zero_page_legacy(void)MigrateCommon args = { .listen_uri ="defer" , .start_hook = migrate_hook_start_precopy_tcp_multifd_zero_page_legacy, + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true,/* * Multifd is more complicated than most of the features, it * directly takes guest page buffers when sending, make sure
@@ -422,6 +413,7 @@ static void test_multifd_tcp_no_zero_page(void)MigrateCommon args = { .listen_uri ="defer" , .start_hook = migrate_hook_start_precopy_tcp_multifd_no_zero_page, + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true,/* * Multifd is more complicated than most of the features, it * directly takes guest page buffers when sending, make sure
@@ -438,6 +430,7 @@ static void test_multifd_tcp_channels_none(void) .listen_uri = "defer", .start_hook = migrate_hook_start_precopy_tcp_multifd, .live = true, + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, .connect_channels = ("[ { 'channel-type': 'main'," " 'addr': { 'transport': 'socket'," " 'type': 'inet',"
tests/qtest/migration/tls-tests.c +9 -2
@@ -375,9 +375,9 @@ static void test_postcopy_tls_psk(void)static void test_postcopy_preempt_tls_psk (void ) {MigrateCommon args = { - .postcopy_preempt = true, .start_hook = migrate_hook_start_tls_psk_match, .end_hook = migrate_hook_end_tls_psk, + .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT ] = true, };test_postcopy_common (&args);
@@ -397,9 +397,9 @@ static void test_postcopy_recovery_tls_psk(void)static void test_postcopy_preempt_all (void ) {MigrateCommon args = { - .postcopy_preempt = true, .start_hook = migrate_hook_start_tls_psk_match, .end_hook = migrate_hook_end_tls_psk, + .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT ] = true, };test_postcopy_recovery_common (&args);
@@ -631,6 +631,7 @@ static void test_multifd_tcp_tls_psk_match(void) .listen_uri = "defer", .start_hook = migrate_hook_start_multifd_tcp_tls_psk_match, .end_hook = migrate_hook_end_tls_psk, + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, };test_precopy_common (&args); }
@@ -645,6 +646,7 @@ static void test_multifd_tcp_tls_psk_mismatch(void) .start_hook = migrate_hook_start_multifd_tcp_tls_psk_mismatch, .end_hook = migrate_hook_end_tls_psk, .result = MIG_TEST_FAIL, + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, };test_precopy_common (&args); }
@@ -656,6 +658,7 @@ static void test_multifd_tcp_tls_x509_default_host(void) .listen_uri = "defer", .start_hook = migrate_hook_start_multifd_tls_x509_default_host, .end_hook = migrate_hook_end_tls_x509, + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, };test_precopy_common (&args); }
@@ -666,6 +669,7 @@ static void test_multifd_tcp_tls_x509_override_host(void) .listen_uri = "defer", .start_hook = migrate_hook_start_multifd_tls_x509_override_host, .end_hook = migrate_hook_end_tls_x509, + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, };test_precopy_common (&args); }
@@ -693,6 +697,7 @@ static void test_multifd_tcp_tls_x509_mismatch_host(void) .start_hook = migrate_hook_start_multifd_tls_x509_mismatch_host, .end_hook = migrate_hook_end_tls_x509, .result = MIG_TEST_FAIL, + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, };test_precopy_common (&args); }
@@ -703,6 +708,7 @@ static void test_multifd_tcp_tls_x509_allow_anon_client(void) .listen_uri = "defer", .start_hook = migrate_hook_start_multifd_tls_x509_allow_anon_client, .end_hook = migrate_hook_end_tls_x509, + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, };test_precopy_common (&args); }
@@ -717,6 +723,7 @@ static void test_multifd_tcp_tls_x509_reject_anon_client(void) .start_hook = migrate_hook_start_multifd_tls_x509_reject_anon_client, .end_hook = migrate_hook_end_tls_x509, .result = MIG_TEST_FAIL, + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, };test_precopy_common (&args); }
--
2.48.1
Re: [PATCH v6 3/4] tests/qtest/migration: consolidate set capabilities
Quoted 356 lines · Prasad Pandit
From: Prasad Pandit <[email protected]>
Migration capabilities are set in multiple '.start_hook' functions for various tests. Instead, consolidate setting capabilities in '
set_migration_capabilities()' function which is called from various 'test_*_common()' functions. While simplifying the capabilities setting, it helps to declutter the qtest sources.Suggested-by Fabiano Rosas <[email protected]>Signed-off-by Prasad Pandit <[email protected]>--- tests/qtest/migration/compression-tests.c | 10 ++-- tests/qtest/migration/cpr-tests.c | 4 +- tests/qtest/migration/file-tests.c | 44 +++++------------- tests/qtest/migration/framework.c | 56 +++++++++++++++++------ tests/qtest/migration/framework.h | 4 +- tests/qtest/migration/postcopy-tests.c | 4 +- tests/qtest/migration/precopy-tests.c | 19 +++----- tests/qtest/migration/tls-tests.c | 11 ++++- 8 files changed, 80 insertions(+), 72 deletions(-)v6:
- Reorder, make this the first qtest patch in this series.v5:
- https://lore.kernel.org/qemu-devel/[email protected]/T/#ttests/qtest/migration/compression-tests.c +6
-4@@ -35,6 +35,7 @@ static void test_multifd_tcp_zstd(void) {MigrateCommon args = { .listen_uri ="defer" , + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, .start_hook = migrate_hook_start_precopy_tcp_multifd_zstd, };test_precopy_common (&args);@@ -56,6 +57,7 @@ static void test_multifd_tcp_qatzip(void) {MigrateCommon args = { .listen_uri ="defer" , + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, .start_hook = migrate_hook_start_precopy_tcp_multifd_qatzip, };test_precopy_common (&args);@@ -74,6 +76,7 @@ static void test_multifd_tcp_qpl(void) {MigrateCommon args = { .listen_uri ="defer" , + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, .start_hook = migrate_hook_start_precopy_tcp_multifd_qpl, };test_precopy_common (&args);@@ -92,6 +95,7 @@ static void test_multifd_tcp_uadk(void) {MigrateCommon args = { .listen_uri ="defer" , + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, .start_hook = migrate_hook_start_precopy_tcp_multifd_uadk, };test_precopy_common (&args);@@ -103,10 +107,6 @@ migrate_hook_start_xbzrle(QTestState *from, QTestState *to) {migrate_set_parameter_int (from,"xbzrle-cache-size" ,33554432 ); - -migrate_set_capability (from,"xbzrle" , true); -migrate_set_capability (to,"xbzrle" , true); -return NULL ; }@@ -118,6 +118,7 @@ static void test_precopy_unix_xbzrle(void) .listen_uri = uri, .start_hook = migrate_hook_start_xbzrle, .iterations = 2, + .caps[MIGRATION_CAPABILITY_XBZRLE] = true,/* * XBZRLE needs pages to be modified when doing the 2nd+ round * iteration to have real data pushed to the stream. @@ -146,6 +147,7 @@ static void test_multifd_tcp_zlib(void) {MigrateCommon args = { .listen_uri ="defer" , + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, .start_hook = migrate_hook_start_precopy_tcp_multifd_zlib, };test_precopy_common (&args);tests/qtest/migration/cpr-tests.c +1
-3@@ -24,9 +24,6 @@ static void *migrate_hook_start_mode_reboot(QTestState *from, QTestState *to)migrate_set_parameter_str (from,"mode" ,"cpr-reboot" );migrate_set_parameter_str (to,"mode" ,"cpr-reboot" ); -migrate_set_capability (from,"x-ignore-shared" , true); -migrate_set_capability (to,"x-ignore-shared" , true); -return NULL ; }@@ -39,6 +36,7 @@ static void test_mode_reboot(void) .connect_uri = uri, .listen_uri = "defer", .start_hook = migrate_hook_start_mode_reboot, + .caps[MIGRATION_CAPABILITY_X_IGNORE_SHARED] = true, };test_file_common (&args, true);tests/qtest/migration/file-tests.c +12
-32@@ -107,15 +107,6 @@ static void test_precopy_file_offset_bad(void)test_file_common (&args, false); } -static void *migrate_hook_start_mapped_ram (QTestState *from, -QTestState *to) -{ -migrate_set_capability (from,"mapped-ram" , true); -migrate_set_capability (to,"mapped-ram" , true); - -return NULL ; -} -static void test_precopy_file_mapped_ram_live (void ) { g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs,@@ -123,7 +114,7 @@ static void test_precopy_file_mapped_ram_live(void)MigrateCommon args = { .connect_uri = uri, .listen_uri ="defer" , - .start_hook = migrate_hook_start_mapped_ram, + .caps[MIGRATION_CAPABILITY_MAPPED_RAM ] = true, };test_file_common (&args, false);@@ -136,26 +127,12 @@ static void test_precopy_file_mapped_ram(void)MigrateCommon args = { .connect_uri = uri, .listen_uri ="defer" , - .start_hook = migrate_hook_start_mapped_ram, + .caps[MIGRATION_CAPABILITY_MAPPED_RAM ] = true, };test_file_common (&args, true); } -static void *migrate_hook_start_multifd_mapped_ram (QTestState *from, -QTestState *to) -{ -migrate_hook_start_mapped_ram (from, to); - -migrate_set_parameter_int (from,"multifd-channels" ,4 ); -migrate_set_parameter_int (to,"multifd-channels" ,4 ); - -migrate_set_capability (from,"multifd" , true); -migrate_set_capability (to,"multifd" , true); - -return NULL ; -} -static void test_multifd_file_mapped_ram_live (void ) { g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs,@@ -163,7 +140,8 @@ static void test_multifd_file_mapped_ram_live(void)MigrateCommon args = { .connect_uri = uri, .listen_uri ="defer" , - .start_hook = migrate_hook_start_multifd_mapped_ram, + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + .caps[MIGRATION_CAPABILITY_MAPPED_RAM ] = true, };test_file_common (&args, false);@@ -176,7 +154,8 @@ static void test_multifd_file_mapped_ram(void)MigrateCommon args = { .connect_uri = uri, .listen_uri ="defer" , - .start_hook = migrate_hook_start_multifd_mapped_ram, + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + .caps[MIGRATION_CAPABILITY_MAPPED_RAM ] = true, };test_file_common (&args, true);@@ -185,8 +164,6 @@ static void test_multifd_file_mapped_ram(void)static void *migrate_hook_start_multifd_mapped_ram_dio (QTestState *from,QTestState *to) { -migrate_hook_start_multifd_mapped_ram (from, to); -migrate_set_parameter_bool (from,"direct-io" , true);migrate_set_parameter_bool (to,"direct-io" , true);@@ -201,6 +178,8 @@ static void test_multifd_file_mapped_ram_dio(void) .connect_uri = uri, .listen_uri = "defer", .start_hook = migrate_hook_start_multifd_mapped_ram_dio, + .caps[MIGRATION_CAPABILITY_MAPPED_RAM] = true, + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, };if (!probe_o_direct_support (tmpfs)) {@@ -246,7 +225,6 @@ static void *migrate_hook_start_multifd_mapped_ram_fdset_dio(QTestState *from,fdset_add_fds (from, file,O_WRONLY ,2 , true);fdset_add_fds (to, file,O_RDONLY ,2 , true); -migrate_hook_start_multifd_mapped_ram (from, to);migrate_set_parameter_bool (from,"direct-io" , true);migrate_set_parameter_bool (to,"direct-io" , true);@@ -261,8 +239,6 @@ static void *migrate_hook_start_multifd_mapped_ram_fdset(QTestState *from,fdset_add_fds (from, file,O_WRONLY ,2 , false);fdset_add_fds (to, file,O_RDONLY ,2 , false); -migrate_hook_start_multifd_mapped_ram (from, to); -return NULL ; }@@ -275,6 +251,8 @@ static void test_multifd_file_mapped_ram_fdset(void) .listen_uri = "defer", .start_hook = migrate_hook_start_multifd_mapped_ram_fdset, .end_hook = migrate_hook_end_multifd_mapped_ram_fdset, + .caps[MIGRATION_CAPABILITY_MAPPED_RAM] = true, + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, };test_file_common (&args, true);@@ -289,6 +267,8 @@ static void test_multifd_file_mapped_ram_fdset_dio(void) .listen_uri = "defer", .start_hook = migrate_hook_start_multifd_mapped_ram_fdset_dio, .end_hook = migrate_hook_end_multifd_mapped_ram_fdset, + .caps[MIGRATION_CAPABILITY_MAPPED_RAM] = true, + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, };if (!probe_o_direct_support (tmpfs)) {tests/qtest/migration/framework.c +41
-15@@ -207,6 +207,31 @@ static QList *migrate_start_get_qmp_capabilities(const MigrateStart *args)return capabilities; } +static void set_migration_capabilities (QTestState *from, +QTestState *to,MigrateCommon *args) +{ +/* +* MigrationCapability_lookup and MIGRATION_CAPABILITY_ constants +* are from qapi-types-migration.h. +*/ +for (uint8_t i =0 ; i <MIGRATION_CAPABILITY__MAX ; i++) + { +if (!args->caps[i]) { +continue ; + } +if (from) { +migrate_set_capability (from, + MigrationCapability_lookup.array[i], true); + } +if (to) { +migrate_set_capability (to, + MigrationCapability_lookup.array[i], true); + } + } + +return ; +} +int migrate_start (QTestState **from,QTestState **to,const char *uri,MigrateStart *args) {@@ -440,17 +465,12 @@ static int migrate_postcopy_prepare(QTestState **from_ptr, args->postcopy_data = args->start_hook (from, to); } -migrate_set_capability (from,"postcopy-ram" , true); -migrate_set_capability (to,"postcopy-ram" , true); -migrate_set_capability (to,"postcopy-blocktime" , true); - -if (args->postcopy_preempt) { -migrate_set_capability (from,"postcopy-preempt" , true); -migrate_set_capability (to,"postcopy-preempt" , true); - } +/* set postcopy capabilities */ + args->caps[MIGRATION_CAPABILITY_POSTCOPY_BLOCKTIME ] = true; + args->caps[MIGRATION_CAPABILITY_POSTCOPY_RAM ] = true; +set_migration_capabilities (from, to, args);migrate_ensure_non_converge (from); -migrate_prepare_for_dirty_mem (from);qtest_qmp_assert_success (to,"{ 'execute': 'migrate-incoming'," " 'arguments': { "@@ -717,6 +737,12 @@ void test_precopy_common(MigrateCommon *args)return ; } +set_migration_capabilities (from, to, args); +if (args->caps[MIGRATION_CAPABILITY_MULTIFD ]) { +migrate_set_parameter_int (from,"multifd-channels" ,16 ); +migrate_set_parameter_int (to,"multifd-channels" ,16 ); + } +if (args->start_hook) { data_hook = args->start_hook (from, to); }@@ -888,6 +914,12 @@ void test_file_common(MigrateCommon *args, bool stop_src)*/ g_assert_false (args->live); +set_migration_capabilities (from, to, args); +if (args->caps[MIGRATION_CAPABILITY_MULTIFD ]) { +migrate_set_parameter_int (from,"multifd-channels" ,4 ); +migrate_set_parameter_int (to,"multifd-channels" ,4 ); + } +if (g_strrstr (args->connect_uri,"offset=" )) { check_offset = true;/* @@ -948,15 +980,9 @@ void *migrate_hook_start_precopy_tcp_multifd_common(QTestState *from,QTestState *to, const char *method) { - migrate_set_parameter_int(from, "multifd-channels", 16); -migrate_set_parameter_int (to,"multifd-channels" ,16 ); - migrate_set_parameter_str(from, "multifd-compression", method);migrate_set_parameter_str (to,"multifd-compression" , method); -migrate_set_capability (from,"multifd" , true); -migrate_set_capability (to,"multifd" , true); -/* Start incoming migration from the 1st socket */ migrate_incoming_qmp (to,"tcp:127.0.0.1:0" ,NULL ,"{}" );tests/qtest/migration/framework.h +1
-0@@ -12,6 +12,7 @@#define TEST_FRAMEWORK_H #include "libqtest.h" +#include <qapi/qapi-types-migration.h> #define FILE_TEST_FILENAME "migfile"#define FILE_TEST_OFFSET 0x1000
tests/qtest/migration/framework.h typedef struct { · line 213
Quoted 7 lines
tests/qtest/migration/framework.h +2
-1@@ -207,8 +208,9 @@ typedef struct {/* Postcopy specific fields */ void *postcopy_data; -bool postcopy_preempt;PostcopyRecoveryFailStage postcopy_recovery_fail_stage; + +bool caps[MIGRATION_CAPABILITY__MAX ];
I just noticed this is way more suited to be at MigrateStart instead, because then we can make the set_capabilities as part of migrate_start() and move the events setting in there as well.
I also think we could just pick a default for multifd channels and avoid setting it in most places. 4 is probably a good number.
-- >8 --
From 811eca2a333c98df7dd6ffe9af0c9ce81aef8731 Mon Sep 17 00:00:00 2001
From: Fabiano Rosas <[email protected]>
Date: Mon, 17 Feb 2025 11:55:56 -0300
Subject: [PATCH] fixup! tests/qtest/migration: consolidate set capabilities
--- tests/qtest/migration/compression-tests.c | 24 +++++++--- tests/qtest/migration/cpr-tests.c | 4 +- tests/qtest/migration/file-tests.c | 38 ++++++++++----- tests/qtest/migration/framework.c | 56 ++++++++++++----------- tests/qtest/migration/framework.h | 9 +++- tests/qtest/migration/misc-tests.c | 4 +- tests/qtest/migration/postcopy-tests.c | 8 +++- tests/qtest/migration/precopy-tests.c | 22 ++++++--- tests/qtest/migration/tls-tests.c | 30 ++++++++---- 9 files changed, 127 insertions(+), 68 deletions(-)
tests/qtest/migration/compression-tests.c +18 -6
@@ -35,7 +35,9 @@ static void test_multifd_tcp_zstd(void) {MigrateCommon args = { .listen_uri ="defer" , - .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + }, .start_hook = migrate_hook_start_precopy_tcp_multifd_zstd, };test_precopy_common (&args);
@@ -57,7 +59,9 @@ static void test_multifd_tcp_qatzip(void) {MigrateCommon args = { .listen_uri ="defer" , - .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + }, .start_hook = migrate_hook_start_precopy_tcp_multifd_qatzip, };test_precopy_common (&args);
@@ -76,7 +80,9 @@ static void test_multifd_tcp_qpl(void) {MigrateCommon args = { .listen_uri ="defer" , - .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + }, .start_hook = migrate_hook_start_precopy_tcp_multifd_qpl, };test_precopy_common (&args);
@@ -95,7 +101,9 @@ static void test_multifd_tcp_uadk(void) {MigrateCommon args = { .listen_uri ="defer" , - .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + }, .start_hook = migrate_hook_start_precopy_tcp_multifd_uadk, };test_precopy_common (&args);
@@ -118,7 +126,9 @@ static void test_precopy_unix_xbzrle(void) .listen_uri = uri, .start_hook = migrate_hook_start_xbzrle, .iterations = 2, - .caps[MIGRATION_CAPABILITY_XBZRLE] = true, + .start = { + .caps[MIGRATION_CAPABILITY_XBZRLE] = true, + },/* * XBZRLE needs pages to be modified when doing the 2nd+ round * iteration to have real data pushed to the stream.
@@ -147,7 +157,9 @@ static void test_multifd_tcp_zlib(void) {MigrateCommon args = { .listen_uri ="defer" , - .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + }, .start_hook = migrate_hook_start_precopy_tcp_multifd_zlib, };test_precopy_common (&args);
tests/qtest/migration/cpr-tests.c +3 -1
@@ -36,7 +36,9 @@ static void test_mode_reboot(void) .connect_uri = uri, .listen_uri = "defer", .start_hook = migrate_hook_start_mode_reboot, - .caps[MIGRATION_CAPABILITY_X_IGNORE_SHARED] = true, + .start = { + .caps[MIGRATION_CAPABILITY_X_IGNORE_SHARED] = true, + }, };test_file_common (&args, true);
tests/qtest/migration/file-tests.c +26 -12
@@ -114,7 +114,9 @@ static void test_precopy_file_mapped_ram_live(void)MigrateCommon args = { .connect_uri = uri, .listen_uri ="defer" , - .caps[MIGRATION_CAPABILITY_MAPPED_RAM ] = true, + .start = { + .caps[MIGRATION_CAPABILITY_MAPPED_RAM ] = true, + }, };test_file_common (&args, false);
@@ -127,7 +129,9 @@ static void test_precopy_file_mapped_ram(void)MigrateCommon args = { .connect_uri = uri, .listen_uri ="defer" , - .caps[MIGRATION_CAPABILITY_MAPPED_RAM ] = true, + .start = { + .caps[MIGRATION_CAPABILITY_MAPPED_RAM ] = true, + }, };test_file_common (&args, true);
@@ -140,8 +144,10 @@ static void test_multifd_file_mapped_ram_live(void)MigrateCommon args = { .connect_uri = uri, .listen_uri ="defer" , - .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, - .caps[MIGRATION_CAPABILITY_MAPPED_RAM ] = true, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + .caps[MIGRATION_CAPABILITY_MAPPED_RAM ] = true, + }, };test_file_common (&args, false);
@@ -154,8 +160,10 @@ static void test_multifd_file_mapped_ram(void)MigrateCommon args = { .connect_uri = uri, .listen_uri ="defer" , - .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, - .caps[MIGRATION_CAPABILITY_MAPPED_RAM ] = true, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + .caps[MIGRATION_CAPABILITY_MAPPED_RAM ] = true, + }, };test_file_common (&args, true);
@@ -178,8 +186,10 @@ static void test_multifd_file_mapped_ram_dio(void) .connect_uri = uri, .listen_uri = "defer", .start_hook = migrate_hook_start_multifd_mapped_ram_dio, - .caps[MIGRATION_CAPABILITY_MAPPED_RAM] = true, - .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + .start = { + .caps[MIGRATION_CAPABILITY_MAPPED_RAM] = true, + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + }, };if (!probe_o_direct_support (tmpfs)) {
@@ -251,8 +261,10 @@ static void test_multifd_file_mapped_ram_fdset(void) .listen_uri = "defer", .start_hook = migrate_hook_start_multifd_mapped_ram_fdset, .end_hook = migrate_hook_end_multifd_mapped_ram_fdset, - .caps[MIGRATION_CAPABILITY_MAPPED_RAM] = true, - .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + .start = { + .caps[MIGRATION_CAPABILITY_MAPPED_RAM] = true, + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + }, };test_file_common (&args, true);
@@ -267,8 +279,10 @@ static void test_multifd_file_mapped_ram_fdset_dio(void) .listen_uri = "defer", .start_hook = migrate_hook_start_multifd_mapped_ram_fdset_dio, .end_hook = migrate_hook_end_multifd_mapped_ram_fdset, - .caps[MIGRATION_CAPABILITY_MAPPED_RAM] = true, - .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + .start = { + .caps[MIGRATION_CAPABILITY_MAPPED_RAM] = true, + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + }, };if (!probe_o_direct_support (tmpfs)) {
tests/qtest/migration/framework.c +29 -27
104 lines not on this page · raw message
tests/qtest/migration/framework.h +7 -2
@@ -121,6 +121,13 @@ typedef struct {/* Do not connect to target monitor and qtest sockets in qtest_init */ bool defer_target_connect; + +/* +* Migration capabilities to be set in both source and +* destination. For unilateral capabilities, use +* migration_set_capabilities(). +*/ +bool caps[MIGRATION_CAPABILITY__MAX ]; } MigrateStart; typedef enum PostcopyRecoveryFailStage {
@@ -209,8 +216,6 @@ typedef struct {/* Postcopy specific fields */ void *postcopy_data;PostcopyRecoveryFailStage postcopy_recovery_fail_stage; - -bool caps[MIGRATION_CAPABILITY__MAX ]; } MigrateCommon;void wait_for_serial (const char *side);
tests/qtest/migration/misc-tests.c +1 -3
@@ -98,6 +98,7 @@ static void test_ignore_shared(void)QTestState *from, *to;MigrateStart args = { .use_shmem = true, + .caps[MIGRATION_CAPABILITY_X_IGNORE_SHARED ] = true, };if (migrate_start (&from, &to, uri, &args)) {
@@ -107,9 +108,6 @@ static void test_ignore_shared(void)migrate_ensure_non_converge (from);migrate_prepare_for_dirty_mem (from); -migrate_set_capability (from,"x-ignore-shared" , true); -migrate_set_capability (to,"x-ignore-shared" , true); -/* Wait for the first serial output from the source */ wait_for_serial ("src_serial" );
tests/qtest/migration/postcopy-tests.c +6 -2
@@ -39,7 +39,9 @@ static void test_postcopy_suspend(void)static void test_postcopy_preempt (void ) {MigrateCommon args = { - .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT ] = true, + .start = { + .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT ] = true, + }, };test_postcopy_common (&args);
@@ -73,7 +75,9 @@ static void test_postcopy_recovery_fail_reconnect(void)static void test_postcopy_preempt_recovery (void ) {MigrateCommon args = { - .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT ] = true, + .start = { + .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT ] = true, + }, };test_postcopy_recovery_common (&args);
tests/qtest/migration/precopy-tests.c +16 -6
@@ -112,8 +112,10 @@ static void test_precopy_tcp_switchover_ack(void) {MigrateCommon args = { .listen_uri ="tcp:127.0.0.1:0" , - .caps[MIGRATION_CAPABILITY_RETURN_PATH ] = true, - .caps[MIGRATION_CAPABILITY_SWITCHOVER_ACK ] = true, + .start = { + .caps[MIGRATION_CAPABILITY_RETURN_PATH ] = true, + .caps[MIGRATION_CAPABILITY_SWITCHOVER_ACK ] = true, + },/* * Source VM must be running in order to consider the switchover ACK * when deciding to do switchover or not.
@@ -382,7 +384,9 @@ static void test_multifd_tcp_uri_none(void)MigrateCommon args = { .listen_uri ="defer" , .start_hook = migrate_hook_start_precopy_tcp_multifd, - .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + },/* * Multifd is more complicated than most of the features, it * directly takes guest page buffers when sending, make sure
@@ -398,7 +402,9 @@ static void test_multifd_tcp_zero_page_legacy(void)MigrateCommon args = { .listen_uri ="defer" , .start_hook = migrate_hook_start_precopy_tcp_multifd_zero_page_legacy, - .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + },/* * Multifd is more complicated than most of the features, it * directly takes guest page buffers when sending, make sure
@@ -414,7 +420,9 @@ static void test_multifd_tcp_no_zero_page(void)MigrateCommon args = { .listen_uri ="defer" , .start_hook = migrate_hook_start_precopy_tcp_multifd_no_zero_page, - .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + },/* * Multifd is more complicated than most of the features, it * directly takes guest page buffers when sending, make sure
@@ -431,7 +439,9 @@ static void test_multifd_tcp_channels_none(void) .listen_uri = "defer", .start_hook = migrate_hook_start_precopy_tcp_multifd, .live = true, - .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + }, .connect_channels = ("[ { 'channel-type': 'main'," " 'addr': { 'transport': 'socket'," " 'type': 'inet',"
tests/qtest/migration/tls-tests.c +21 -9
@@ -377,7 +377,9 @@ static void test_postcopy_preempt_tls_psk(void)MigrateCommon args = { .start_hook = migrate_hook_start_tls_psk_match, .end_hook = migrate_hook_end_tls_psk, - .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT ] = true, + .start = { + .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT ] = true, + }, };test_postcopy_common (&args);
@@ -399,7 +401,9 @@ static void test_postcopy_preempt_all(void)MigrateCommon args = { .start_hook = migrate_hook_start_tls_psk_match, .end_hook = migrate_hook_end_tls_psk, - .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT ] = true, + .start = { + .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT ] = true, + }, };test_postcopy_recovery_common (&args);
@@ -631,7 +635,9 @@ static void test_multifd_tcp_tls_psk_match(void) .listen_uri = "defer", .start_hook = migrate_hook_start_multifd_tcp_tls_psk_match, .end_hook = migrate_hook_end_tls_psk, - .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + }, };test_precopy_common (&args); }
@@ -641,12 +647,12 @@ static void test_multifd_tcp_tls_psk_mismatch(void)MigrateCommon args = { .start = { .hide_stderr = true, + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, }, .listen_uri ="defer" , .start_hook = migrate_hook_start_multifd_tcp_tls_psk_mismatch, .end_hook = migrate_hook_end_tls_psk, .result =MIG_TEST_FAIL , - .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, };test_precopy_common (&args); }
@@ -658,7 +664,9 @@ static void test_multifd_tcp_tls_x509_default_host(void) .listen_uri = "defer", .start_hook = migrate_hook_start_multifd_tls_x509_default_host, .end_hook = migrate_hook_end_tls_x509, - .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + }, };test_precopy_common (&args); }
@@ -669,7 +677,9 @@ static void test_multifd_tcp_tls_x509_override_host(void) .listen_uri = "defer", .start_hook = migrate_hook_start_multifd_tls_x509_override_host, .end_hook = migrate_hook_end_tls_x509, - .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + }, };test_precopy_common (&args); }
@@ -692,12 +702,12 @@ static void test_multifd_tcp_tls_x509_mismatch_host(void)MigrateCommon args = { .start = { .hide_stderr = true, + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, }, .listen_uri ="defer" , .start_hook = migrate_hook_start_multifd_tls_x509_mismatch_host, .end_hook = migrate_hook_end_tls_x509, .result =MIG_TEST_FAIL , - .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, };test_precopy_common (&args); }
@@ -708,7 +718,9 @@ static void test_multifd_tcp_tls_x509_allow_anon_client(void) .listen_uri = "defer", .start_hook = migrate_hook_start_multifd_tls_x509_allow_anon_client, .end_hook = migrate_hook_end_tls_x509, - .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + }, };test_precopy_common (&args); }
@@ -718,12 +730,12 @@ static void test_multifd_tcp_tls_x509_reject_anon_client(void)MigrateCommon args = { .start = { .hide_stderr = true, + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, }, .listen_uri ="defer" , .start_hook = migrate_hook_start_multifd_tls_x509_reject_anon_client, .end_hook = migrate_hook_end_tls_x509, .result =MIG_TEST_FAIL , - .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, };test_precopy_common (&args); }
Signature · 1 line
2.35.3
Re: [PATCH v6 3/4] tests/qtest/migration: consolidate set capabilities
Quoted 6 lines · Fabiano Rosas
I just noticed this is way more suited to be at MigrateStart instead, because then we can make the
set_capabilitiesas part ofmigrate_start()and move the events setting in there as well.I also think we could just pick a default for multifd channels and avoid setting it in most places. 4 is probably a good number.
* Okay, sounds reasonable. I was thinking of setting multifd channels to 8 as default, but didn't want to deviate from current code so kept all values of 4/8/16.
Thank you.
---
- Prasad
PATCH v6 4/4 tests/qtest/migration: add postcopy tests with multifd
In reply to Prasad PanditFrom: Prasad Pandit <[email protected]>
Add new qtests to run postcopy migration with multifd channels enabled.
--- tests/qtest/migration/compression-tests.c | 13 ++++++++ tests/qtest/migration/framework.c | 4 +++ tests/qtest/migration/postcopy-tests.c | 23 +++++++++++++ tests/qtest/migration/precopy-tests.c | 19 +++++++++++ tests/qtest/migration/tls-tests.c | 40 +++++++++++++++++++++++ 5 files changed, 99 insertions(+)
v6:
- Reorder, make this the second patch in this series.
v5:
- https://lore.kernel.org/qemu-devel/[email protected]/T/#t
tests/qtest/migration/compression-tests.c +13 -0
@@ -40,6 +40,17 @@ static void test_multifd_tcp_zstd(void) };test_precopy_common (&args); } + +static void test_multifd_postcopy_tcp_zstd (void ) +{ +MigrateCommon args = { + .listen_uri ="defer" , + .caps[MIGRATION_CAPABILITY_POSTCOPY_RAM ] = true, + .start_hook = migrate_hook_start_precopy_tcp_multifd_zstd, + }; + +test_precopy_common (&args); +}#endif /* CONFIG_ZSTD */ #ifdef CONFIG_QATZIP
@@ -172,6 +183,8 @@ void migration_test_add_compression(MigrationTestEnv *env)#ifdef CONFIG_ZSTD migration_test_add ("/migration/multifd/tcp/plain/zstd" , test_multifd_tcp_zstd); +migration_test_add ("/migration/multifd+postcopy/tcp/plain/zstd" , + test_multifd_postcopy_tcp_zstd);#endif #ifdef CONFIG_QATZIP
tests/qtest/migration/framework.c +4 -0
@@ -469,6 +469,10 @@ static int migrate_postcopy_prepare(QTestState **from_ptr, args->caps[MIGRATION_CAPABILITY_POSTCOPY_BLOCKTIME ] = true; args->caps[MIGRATION_CAPABILITY_POSTCOPY_RAM ] = true;set_migration_capabilities (from, to, args); +if (args->caps[MIGRATION_CAPABILITY_MULTIFD ]) { +migrate_set_parameter_int (from,"multifd-channels" ,8 ); +migrate_set_parameter_int (to,"multifd-channels" ,8 ); + }migrate_ensure_non_converge (from);migrate_prepare_for_dirty_mem (from);
tests/qtest/migration/postcopy-tests.c +23 -0
@@ -90,6 +90,25 @@ static void migration_test_add_postcopy_smoke(MigrationTestEnv *env) } } +static void test_multifd_postcopy (void ) +{ +MigrateCommon args = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + }; + +test_postcopy_common (&args); +} + +static void test_multifd_postcopy_preempt (void ) +{ +MigrateCommon args = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT ] = true, + }; + +test_postcopy_common (&args); +} +void migration_test_add_postcopy (MigrationTestEnv *env) {migration_test_add_postcopy_smoke (env);
@@ -110,6 +129,10 @@ void migration_test_add_postcopy(MigrationTestEnv *env)"/migration/postcopy/recovery/double-failures/reconnect" , test_postcopy_recovery_fail_reconnect); +migration_test_add ("/migration/multifd+postcopy/plain" , + test_multifd_postcopy); +migration_test_add ("/migration/multifd+postcopy/preempt/plain" , + test_multifd_postcopy_preempt);if (env->is_x86) {migration_test_add ("/migration/postcopy/suspend" , test_postcopy_suspend);
tests/qtest/migration/precopy-tests.c +19 -0
@@ -33,6 +33,7 @@#define DIRTYLIMIT_TOLERANCE_RANGE 25/* MB/s */ static char *tmpfs; +static bool postcopy_ram = false;static void test_precopy_unix_plain (void ) {
@@ -465,6 +466,11 @@ static void test_multifd_tcp_cancel(void)migrate_ensure_non_converge (from);migrate_prepare_for_dirty_mem (from); +if (postcopy_ram) { +migrate_set_capability (from,"postcopy-ram" , true); +migrate_set_capability (to,"postcopy-ram" , true); + } +migrate_set_parameter_int (from,"multifd-channels" ,16 );migrate_set_parameter_int (to,"multifd-channels" ,16 );
@@ -506,6 +512,10 @@ static void test_multifd_tcp_cancel(void)return ; } +if (postcopy_ram) { +migrate_set_capability (to2,"postcopy-ram" , true); + } +migrate_set_parameter_int (to2,"multifd-channels" ,16 );migrate_set_capability (to2,"multifd" , true);
@@ -529,6 +539,13 @@ static void test_multifd_tcp_cancel(void)migrate_end (from, to2, true); } +static void test_multifd_postcopy_tcp_cancel (void ) +{ + postcopy_ram = true; +test_multifd_tcp_cancel (); + postcopy_ram = false; +} +static void calc_dirty_rate (QTestState *who,uint64_t calc_time) { qtest_qmp_assert_success(who,
@@ -1001,6 +1018,8 @@ void migration_test_add_precopy(MigrationTestEnv *env) test_multifd_tcp_zero_page_legacy);migration_test_add ("/migration/multifd/tcp/plain/zero-page/none" , test_multifd_tcp_no_zero_page); +migration_test_add ("migration/multifd+postcopy/tcp/plain/cancel" , + test_multifd_postcopy_tcp_cancel);if (g_str_equal (env->arch,"x86_64" ) && env->has_kvm && env->has_dirty_ring) {
tests/qtest/migration/tls-tests.c +40 -0
@@ -393,6 +393,17 @@ static void test_postcopy_recovery_tls_psk(void)test_postcopy_recovery_common (&args); } +static void test_multifd_postcopy_recovery_tls_psk (void ) +{ +MigrateCommon args = { + .start_hook = migrate_hook_start_tls_psk_match, + .end_hook = migrate_hook_end_tls_psk, + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + }; + +test_postcopy_recovery_common (&args); +} +/* This contains preempt+recovery+tls test altogether */ static void test_postcopy_preempt_all (void ) {
@@ -405,6 +416,17 @@ static void test_postcopy_preempt_all(void)test_postcopy_recovery_common (&args); } +static void test_multifd_postcopy_preempt_recovery_tls_psk (void ) +{ +MigrateCommon args = { + .start_hook = migrate_hook_start_tls_psk_match, + .end_hook = migrate_hook_end_tls_psk, + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + }; + +test_postcopy_recovery_common (&args); +} +static void test_precopy_unix_tls_psk (void ) { g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
@@ -651,6 +673,18 @@ static void test_multifd_tcp_tls_psk_mismatch(void)test_precopy_common (&args); } +static void test_multifd_postcopy_tcp_tls_psk_match (void ) +{ +MigrateCommon args = { + .listen_uri ="defer" , + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + .start_hook = migrate_hook_start_multifd_tcp_tls_psk_match, + .end_hook = migrate_hook_end_tls_psk, + }; + +test_precopy_common (&args); +} +#ifdef CONFIG_TASN1 static void test_multifd_tcp_tls_x509_default_host (void ) {
@@ -762,6 +796,10 @@ void migration_test_add_tls(MigrationTestEnv *env) test_postcopy_preempt_tls_psk);migration_test_add ("/migration/postcopy/preempt/recovery/tls/psk" , test_postcopy_preempt_all); +migration_test_add ("/migration/multifd+postcopy/recovery/tls/psk" , + test_multifd_postcopy_recovery_tls_psk); +migration_test_add ("/migration/multifd+postcopy/preempt/recovery/tls/psk" , + test_multifd_postcopy_preempt_recovery_tls_psk); }#ifdef CONFIG_TASN1 migration_test_add("/migration/precopy/unix/tls/x509/default-host",
@@ -793,6 +831,8 @@ void migration_test_add_tls(MigrationTestEnv *env) test_multifd_tcp_tls_psk_match);migration_test_add ("/migration/multifd/tcp/tls/psk/mismatch" , test_multifd_tcp_tls_psk_mismatch); +migration_test_add ("/migration/multifd+postcopy/tcp/tls/psk/match" , + test_multifd_postcopy_tcp_tls_psk_match);#ifdef CONFIG_TASN1 migration_test_add ("/migration/multifd/tcp/tls/x509/default-host" , test_multifd_tcp_tls_x509_default_host);
--
2.48.1
Re: [PATCH v6 4/4] tests/qtest/migration: add postcopy tests with multifd
Quoted 97 lines · Prasad Pandit
From: Prasad Pandit <[email protected]>
Add new qtests to run postcopy migration with multifd channels enabled.
Signed-off-by Prasad Pandit <[email protected]>--- tests/qtest/migration/compression-tests.c | 13 ++++++++ tests/qtest/migration/framework.c | 4 +++ tests/qtest/migration/postcopy-tests.c | 23 +++++++++++++ tests/qtest/migration/precopy-tests.c | 19 +++++++++++ tests/qtest/migration/tls-tests.c | 40 +++++++++++++++++++++++ 5 files changed, 99 insertions(+)v6:
- Reorder, make this the second patch in this series.v5:
- https://lore.kernel.org/qemu-devel/[email protected]/T/#ttests/qtest/migration/compression-tests.c +13
-0@@ -40,6 +40,17 @@ static void test_multifd_tcp_zstd(void) };test_precopy_common (&args); } + +static void test_multifd_postcopy_tcp_zstd (void ) +{ +MigrateCommon args = { + .listen_uri ="defer" , + .caps[MIGRATION_CAPABILITY_POSTCOPY_RAM ] = true, + .start_hook = migrate_hook_start_precopy_tcp_multifd_zstd, + }; + +test_precopy_common (&args); +}#endif /* CONFIG_ZSTD */ #ifdef CONFIG_QATZIP @@ -172,6 +183,8 @@ void migration_test_add_compression(MigrationTestEnv *env)#ifdef CONFIG_ZSTD migration_test_add ("/migration/multifd/tcp/plain/zstd" , test_multifd_tcp_zstd); +migration_test_add ("/migration/multifd+postcopy/tcp/plain/zstd" , + test_multifd_postcopy_tcp_zstd);#endif #ifdef CONFIG_QATZIP tests/qtest/migration/framework.c +4
-0@@ -469,6 +469,10 @@ static int migrate_postcopy_prepare(QTestState **from_ptr, args->caps[MIGRATION_CAPABILITY_POSTCOPY_BLOCKTIME ] = true; args->caps[MIGRATION_CAPABILITY_POSTCOPY_RAM ] = true;set_migration_capabilities (from, to, args); +if (args->caps[MIGRATION_CAPABILITY_MULTIFD ]) { +migrate_set_parameter_int (from,"multifd-channels" ,8 ); +migrate_set_parameter_int (to,"multifd-channels" ,8 ); + }migrate_ensure_non_converge (from);migrate_prepare_for_dirty_mem (from);tests/qtest/migration/postcopy-tests.c +19
-0@@ -90,6 +90,25 @@ static void migration_test_add_postcopy_smoke(MigrationTestEnv *env) } } +static void test_multifd_postcopy (void ) +{ +MigrateCommon args = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + }; + +test_postcopy_common (&args); +} + +static void test_multifd_postcopy_preempt (void ) +{ +MigrateCommon args = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT ] = true, + }; + +test_postcopy_common (&args); +} +void migration_test_add_postcopy (MigrationTestEnv *env) {migration_test_add_postcopy_smoke (env);
tests/qtest/migration/postcopy-tests.c void migration_test_add_postcopy(MigrationTestEnv *env) · line 135
Quoted 7 lines
tests/qtest/migration/postcopy-tests.c +4
-0@@ -110,6 +129,10 @@ void migration_test_add_postcopy(MigrationTestEnv *env)"/migration/postcopy/recovery/double-failures/reconnect" , test_postcopy_recovery_fail_reconnect); +migration_test_add ("/migration/multifd+postcopy/plain" , + test_multifd_postcopy); +migration_test_add ("/migration/multifd+postcopy/preempt/plain" , + test_multifd_postcopy_preempt);
For postcopy-tests.c I'd use /migration/postcopy/multifd so we can run them all via command-line. These are also the only ones actually doing postcopy migration. We need to distinguish multifd+postcopy proper from merely postcopy-ram=true.
Quoted 39 lines
tests/qtest/migration/postcopy-tests.c +0
-0if (env->is_x86) {migration_test_add ("/migration/postcopy/suspend" , test_postcopy_suspend);tests/qtest/migration/precopy-tests.c +10
-0@@ -33,6 +33,7 @@#define DIRTYLIMIT_TOLERANCE_RANGE 25/* MB/s */ static char *tmpfs; +static bool postcopy_ram = false;static void test_precopy_unix_plain (void ) {@@ -465,6 +466,11 @@ static void test_multifd_tcp_cancel(void)migrate_ensure_non_converge (from);migrate_prepare_for_dirty_mem (from); +if (postcopy_ram) { +migrate_set_capability (from,"postcopy-ram" , true); +migrate_set_capability (to,"postcopy-ram" , true); + } +migrate_set_parameter_int (from,"multifd-channels" ,16 );migrate_set_parameter_int (to,"multifd-channels" ,16 );@@ -506,6 +512,10 @@ static void test_multifd_tcp_cancel(void)return ; } +if (postcopy_ram) { +migrate_set_capability (to2,"postcopy-ram" , true); + } +migrate_set_parameter_int (to2,"multifd-channels" ,16 );migrate_set_capability (to2,"multifd" , true);
tests/qtest/migration/precopy-tests.c static void test_multifd_tcp_cancel(void) · line 546
Quoted 8 lines
tests/qtest/migration/precopy-tests.c +5
-0@@ -529,6 +539,13 @@ static void test_multifd_tcp_cancel(void)migrate_end (from, to2, true); } +static void test_multifd_postcopy_tcp_cancel (void ) +{ + postcopy_ram = true; +test_multifd_tcp_cancel (); + postcopy_ram = false;
You could pass this in, there's just one other caller.
Quoted 95 lines
tests/qtest/migration/precopy-tests.c +4
-0+} +static void calc_dirty_rate (QTestState *who,uint64_t calc_time) { qtest_qmp_assert_success(who,@@ -1001,6 +1018,8 @@ void migration_test_add_precopy(MigrationTestEnv *env) test_multifd_tcp_zero_page_legacy);migration_test_add ("/migration/multifd/tcp/plain/zero-page/none" , test_multifd_tcp_no_zero_page); +migration_test_add ("migration/multifd+postcopy/tcp/plain/cancel" , + test_multifd_postcopy_tcp_cancel);if (g_str_equal (env->arch,"x86_64" ) && env->has_kvm && env->has_dirty_ring) {tests/qtest/migration/tls-tests.c +40
-1@@ -393,6 +393,17 @@ static void test_postcopy_recovery_tls_psk(void)test_postcopy_recovery_common (&args); } +static void test_multifd_postcopy_recovery_tls_psk (void ) +{ +MigrateCommon args = { + .start_hook = migrate_hook_start_tls_psk_match, + .end_hook = migrate_hook_end_tls_psk, + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + }; + +test_postcopy_recovery_common (&args); +} +/* This contains preempt+recovery+tls test altogether */ static void test_postcopy_preempt_all (void ) {@@ -405,6 +416,17 @@ static void test_postcopy_preempt_all(void)test_postcopy_recovery_common (&args); } +static void test_multifd_postcopy_preempt_recovery_tls_psk (void ) +{ +MigrateCommon args = { + .start_hook = migrate_hook_start_tls_psk_match, + .end_hook = migrate_hook_end_tls_psk, + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + }; + +test_postcopy_recovery_common (&args); +} +static void test_precopy_unix_tls_psk (void ) { g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);@@ -651,6 +673,18 @@ static void test_multifd_tcp_tls_psk_mismatch(void)test_precopy_common (&args); } +static void test_multifd_postcopy_tcp_tls_psk_match (void ) +{ +MigrateCommon args = { + .listen_uri ="defer" , + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + .start_hook = migrate_hook_start_multifd_tcp_tls_psk_match, + .end_hook = migrate_hook_end_tls_psk, + }; + +test_precopy_common (&args); +} +#ifdef CONFIG_TASN1 static void test_multifd_tcp_tls_x509_default_host (void ) {@@ -762,6 +796,10 @@ void migration_test_add_tls(MigrationTestEnv *env) test_postcopy_preempt_tls_psk);migration_test_add ("/migration/postcopy/preempt/recovery/tls/psk" , test_postcopy_preempt_all); +migration_test_add ("/migration/multifd+postcopy/recovery/tls/psk" , + test_multifd_postcopy_recovery_tls_psk); +migration_test_add ("/migration/multifd+postcopy/preempt/recovery/tls/psk" , + test_multifd_postcopy_preempt_recovery_tls_psk); }#ifdef CONFIG_TASN1 migration_test_add("/migration/precopy/unix/tls/x509/default-host",@@ -793,6 +831,8 @@ void migration_test_add_tls(MigrationTestEnv *env) test_multifd_tcp_tls_psk_match);migration_test_add ("/migration/multifd/tcp/tls/psk/mismatch" , test_multifd_tcp_tls_psk_mismatch); +migration_test_add ("/migration/multifd+postcopy/tcp/tls/psk/match" , + test_multifd_postcopy_tcp_tls_psk_match);#ifdef CONFIG_TASN1 migration_test_add ("/migration/multifd/tcp/tls/x509/default-host" , test_multifd_tcp_tls_x509_default_host); --2.48.1
Re: [PATCH v6 4/4] tests/qtest/migration: add postcopy tests with multifd
Quoted 4 lines · Fabiano Rosas
Quoted 4 lines
tests/qtest/migration/postcopy-tests.c +0
-0@@ -110,6 +129,10 @@ void migration_test_add_postcopy(MigrationTestEnv *env)"/migration/postcopy/recovery/double-failures/reconnect" , test_postcopy_recovery_fail_reconnect);
Quoted 9 lines
tests/qtest/migration/postcopy-tests.c void migration_test_add_postcopy(MigrationTestEnv *env) · line 135
Quoted 4 lines
tests/qtest/migration/postcopy-tests.c +4
-0+migration_test_add ("/migration/multifd+postcopy/plain" , + test_multifd_postcopy); +migration_test_add ("/migration/multifd+postcopy/preempt/plain" , + test_multifd_postcopy_preempt);For
postcopy-tests.cI'd use /migration/postcopy/multifd so we can run them all via command-line. These are also the only ones actually doing postcopy migration. We need to distinguish multifd+postcopy proper from merely postcopy-ram=true.
* ie. repalce 'multifd+postcopy' with '../postcopy/multifd/' only in postcopy-tests.c? And keep other instances unchanged?
...
Quoted 8 lines
tests/qtest/migration/precopy-tests.c static void test_multifd_tcp_cancel(void) · line 546
Quoted 6 lines
tests/qtest/migration/precopy-tests.c +5
-0+static void test_multifd_postcopy_tcp_cancel (void ) +{ + postcopy_ram = true; +test_multifd_tcp_cancel (); + postcopy_ram = false;You could pass this in, there's just one other caller.
* Sorry, what do you mean here?
Thank you.
---
- Prasad
Re: [PATCH v6 4/4] tests/qtest/migration: add postcopy tests with multifd
Quoted 15 lines · Prasad Pandit
Quoted 4 lines · Fabiano Rosas
Quoted 4 lines
tests/qtest/migration/postcopy-tests.c +0
-0@@ -110,6 +129,10 @@ void migration_test_add_postcopy(MigrationTestEnv *env)"/migration/postcopy/recovery/double-failures/reconnect" , test_postcopy_recovery_fail_reconnect);Quoted 9 lines
tests/qtest/migration/postcopy-tests.c void migration_test_add_postcopy(MigrationTestEnv *env) · line 135
Quoted 4 lines
tests/qtest/migration/postcopy-tests.c +4
-0+migration_test_add ("/migration/multifd+postcopy/plain" , + test_multifd_postcopy); +migration_test_add ("/migration/multifd+postcopy/preempt/plain" , + test_multifd_postcopy_preempt);For
postcopy-tests.cI'd use /migration/postcopy/multifd so we can run them all via command-line. These are also the only ones actually doing postcopy migration. We need to distinguish multifd+postcopy proper from merely postcopy-ram=true.
Quoted 3 lines
* ie. repalce 'multifd+postcopy' with '../postcopy/multifd/' only in
postcopy-tests.c? And keep other instances unchanged?
Yes. Or do someting else for the others, I don't have a preference. But we need to have this be different in a way that people expecting to test postcopy can do that along with the rest of the postcopy tests and we also make it more clear that postcopy is not actually being tested in the precopy tests.
These would actually do postcopy:
postcopy/multifd
multifd/postcopy
These just enable the postcopy cap:
precopy/postcopy-ram/
multifd/postcopy-ram/
The exact names could change...
Quoted 11 lines
...
Quoted 8 lines
tests/qtest/migration/precopy-tests.c static void test_multifd_tcp_cancel(void) · line 546
Quoted 6 lines
tests/qtest/migration/precopy-tests.c +5
-0+static void test_multifd_postcopy_tcp_cancel (void ) +{ + postcopy_ram = true; +test_multifd_tcp_cancel (); + postcopy_ram = false;You could pass this in, there's just one other caller.
* Sorry, what do you mean here?
To make postcopy_ram be passed in as an argument to test_multifd_tcp_cancel(). Having globals tend to get in the way of refactoring stuff later. We already had issues with tmpfs being global all over the place.
Quoted 4 lines
Thank you.
---
- Prasad
Re: [PATCH v6 4/4] tests/qtest/migration: add postcopy tests with multifd
Hello Fabiano,
Quoted 8 lines · Fabiano Rosas
Quoted 7 lines
Quoted 7 lines
tests/qtest/migration/precopy-tests.c static void test_multifd_tcp_cancel(void) · line 546
Quoted 5 lines
tests/qtest/migration/precopy-tests.c +5
-0+static void test_multifd_postcopy_tcp_cancel (void ) +{ + postcopy_ram = true; +test_multifd_tcp_cancel (); + postcopy_ram = false;You could pass this in, there's just one other caller.
Quoted 4 lines
To make
postcopy_rambe passed in as an argument totest_multifd_tcp_cancel(). Having globals tend to get in the way of refactoring stuff later. We already had issues with tmpfs being global all over the place.
* This looks tricky to do. test_multifd_tcp_cancel() is called via migration_test_add(), which expects a function pointer of type => void (*fn)(void). Changing 'migration_test_add' signature would entail adding a parameter to all functions called by it.
Thank you.
---
- Prasad
Re: [PATCH v6 4/4] tests/qtest/migration: add postcopy tests with multifd
Quoted 16 lines · Prasad Pandit
Hello Fabiano,
Quoted 8 lines · Fabiano Rosas
Quoted 7 lines
Quoted 7 lines
tests/qtest/migration/precopy-tests.c static void test_multifd_tcp_cancel(void) · line 546
Quoted 5 lines
tests/qtest/migration/precopy-tests.c +5
-0+static void test_multifd_postcopy_tcp_cancel (void ) +{ + postcopy_ram = true; +test_multifd_tcp_cancel (); + postcopy_ram = false;You could pass this in, there's just one other caller.
Quoted 4 lines
To make
postcopy_rambe passed in as an argument totest_multifd_tcp_cancel(). Having globals tend to get in the way of refactoring stuff later. We already had issues with tmpfs being global all over the place.
Quoted 5 lines
* This looks tricky to do.
test_multifd_tcp_cancel()is called viamigration_test_add(), which expects a function pointer of type => void (*fn)(void). Changing 'migration_test_add' signature would entail adding a parameter to all functions called by it.
Indeed. Leave it then. If I think of something I'll let you know.
Quoted 3 lines
Thank you.
---
- Prasad