migration: Cleanup early connection code
cover migration: Cleanup early connection code
Based-on: <[email protected]>
[PULL 00/31] Next patches
https://lore.kernel.org/r/[email protected]
--
Address some of the issues that make the early connection code a bit too idiosyncratic. By "early connection" I mean from qmp_migrate[_incoming] until the start of the migration thread|coroutine.
(IOW, the whole dance of going into socket code, starting an async routine, calling back to migration code, checking TLS, going back again, coming back once more, etc. All while passing an error_in and hostname string that eventually gets (maybe) ignored in tls code, along with some is_resume checks along the way)
This series is mostly inspired by the work Markus and Peter did recently in organizing some of the error handling code. The new migration_connect_error_propagate() function seems like a good place to centralize the error handling and call migration_cleanup() during this early connection phase when everything is still fairly linear. (apologies if I'm dirtying your design =)
Aside from the initial patches that are a bit disruptive, most of the series is just refactoring to make the code easier to navigate, names more consistent and some general cleanups.
- patches 1-8:
General cleanups, could be applied standalone, although they are prerequisites for the rest of the series.
- patches 9-12:
Changes to allow calling migration_cleanup() frommigration_connect_error_propagate().
The idea here is to make sure error propagation and cleanup happen when the error is detected, without calling into non-error-path functions.
This is the more risky change because it will cause cleanup to run in places where it didn't before.
- patch 13 & 19:
The main change of this series, simplifying the qmp-migrate --> migration_connect path. Stops calling the connection functions when an error happens in the transport code, adds clarification around which paths have asynchronous completion and makes the synchronous path return to their caller to start the migration instead of initiating it themselves.
- patches 14-18, 20-22:
Moves code out of migration.c and into channel.c. Now that the code is more compartmentalized, move it to a more appropriate source file.
- patches 23-25:
BONUS CONTENT, wrap the uri/channels parsing and move it to channel.c as well.
- future work?
I think we could move all QMP command functions to a QAPI-specific file, but I don't see any standardization in the tree, there's block/qapi.c, various instances of foo-qmp-cmds.c and many more just laying along with the rest of the code. So I left this for another moment.
CI run: https://gitlab.com/farosas/qemu/-/pipelines/2233810778
Fabiano Rosas (25):
migration: Remove redundant state change
migration: Fix state change at migration_channel_process_incoming migration/tls: Remove unused parameter
migration: Move multifd_recv_setup call
migration: Cleanup TLS handshake hostname passing
migration: Move postcopy_try_recover into migration_incoming_process
migration: Use migrate_mode() to query for cpr-transfer
migration: Free the error earlier in the resume case
migration: Move error reporting out of migration_cleanup
migration: Expand migration_connect_error_propagate to cover
cancelling
migration: yank: Move register instance earlier
migration: Fold migration_cleanup() into
migration_connect_error_propagate()
migration: Handle error in the early async paths
migration: Remove QEMUFile from channel.c migration/channel: Rename migration_channel_connect
migration: Rename instances of start
migration: Move channel code to channel.c
migration: Move transport connection code into channel.c migration/channel: Make synchronous calls evident migration/channel: Use switch statements in outgoing code migration/channel: Cleanup early passing of MigrationState migration/channel: Merge both sides of the connection initiation code
migration: Move channel parsing to channel.c
migration: Move URI parsing to channel.c
migration: Remove qmp_migrate_finish
migration/channel.c | 410 +++++++++++++++++++++++++---- migration/channel.h | 36 ++- migration/exec.c | 10 +- migration/exec.h | 7 +- migration/fd.c | 14 +- migration/fd.h | 8 +- migration/file.c | 19 +- migration/file.h | 6 +- migration/migration.c | 540 ++++++++++----------------------------- migration/migration.h | 11 +- migration/multifd.c | 16 +- migration/multifd.h | 2 +- migration/options.c | 5 + migration/postcopy-ram.c | 2 +- migration/rdma.c | 52 ++-- migration/rdma.h | 5 +- migration/socket.c | 54 ++-- migration/socket.h | 5 +- migration/tls.c | 39 +-- migration/tls.h | 10 +- migration/trace-events | 20 +- 21 files changed, 654 insertions(+), 617 deletions(-)
Signature · 1 line
2.51.0
RFC PATCH 1/25 migration: Remove redundant state change
If local_err is set, migration_connect_error_propagate() will be called and that function already has a state transtion from SETUP to FAILED.
--- migration/migration.c | 2 -- 1 file changed, 2 deletions(-)
migration/migration.c +0 -2
@@ -2326,8 +2326,6 @@ static void qmp_migrate_finish(MigrationAddress *addr, bool resume_requested,file_start_outgoing_migration (s, &addr->u.file, &local_err); }else {error_setg (&local_err,"uri is not a valid migration protocol" ); -migrate_set_state (&s->state,MIGRATION_STATUS_SETUP , -MIGRATION_STATUS_FAILED ); }if (local_err) {
Signature · 1 line
2.51.0
Re: [RFC PATCH 01/25] migration: Remove redundant state change
Quoted 5 lines · Fabiano Rosas
If
local_erris set,migration_connect_error_propagate()will be called and that function already has a state transtion from SETUP to FAILED.Signed-off-by Fabiano Rosas <[email protected]>
Signature · 1 line
Peter Xu
RFC PATCH 2/25 migration: Fix state change at migration_channel_process_incoming
In reply to Fabiano RosasWhen the incoming migration fails during the channel connection phase, the state transition to FAILED is currently being done in the MigrationState->state, but the MigrationIncomingState->state is the one that should be used.
--- migration/channel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
migration/channel.c +1 -1
@@ -48,7 +48,7 @@ void migration_channel_process_incoming(QIOChannel *ioc)if (local_err) {error_report_err (local_err); -migrate_set_state (&s->state, s->state,MIGRATION_STATUS_FAILED ); +migrate_set_state (&mis->state, mis->state,MIGRATION_STATUS_FAILED );if (mis->exit_on_error) {exit (EXIT_FAILURE ); }
Signature · 1 line
2.51.0
Re: [RFC PATCH 02/25] migration: Fix state change at migration_channel_process_incoming
Quoted 6 lines · Fabiano Rosas
When the incoming migration fails during the channel connection phase, the state transition to FAILED is currently being done in the
MigrationState->state, but theMigrationIncomingState->stateis the one that should be used.Signed-off-by Fabiano Rosas <[email protected]>
Signature · 1 line
Peter Xu
RFC PATCH 3/25 migration/tls: Remove unused parameter
In reply to Fabiano RosasMigrationState is not used at migration_tls_channel_process_incoming().
The last usage was removed by commit 3f461a0c0b ("migration: Drop unused parameter for migration_tls_get_creds()")
--- migration/channel.c | 3 +-- migration/tls.c | 4 +--- migration/tls.h | 4 +--- 3 files changed, 3 insertions(+), 8 deletions(-)
migration/channel.c +1 -2
@@ -32,7 +32,6 @@*/ void migration_channel_process_incoming (QIOChannel *ioc) { -MigrationState *s =migrate_get_current ();MigrationIncomingState *mis =migration_incoming_get_current ();Error *local_err =NULL ;
@@ -40,7 +39,7 @@ void migration_channel_process_incoming(QIOChannel *ioc) ioc, object_get_typename(OBJECT(ioc)));if (migrate_channel_requires_tls_upgrade (ioc)) { -migration_tls_channel_process_incoming (s, ioc, &local_err); +migration_tls_channel_process_incoming (ioc, &local_err); }else {migration_ioc_register_yank (ioc);migration_ioc_process_incoming (ioc, &local_err);
migration/tls.c +1 -3
@@ -71,9 +71,7 @@ static void migration_tls_incoming_handshake(QIOTask *task,object_unref (OBJECT (ioc)); } -void migration_tls_channel_process_incoming (MigrationState *s, -QIOChannel *ioc, -Error **errp) +void migration_tls_channel_process_incoming (QIOChannel *ioc,Error **errp) {QCryptoTLSCreds *creds;QIOChannelTLS *tioc;
migration/tls.h +1 -3
@@ -24,9 +24,7 @@#include "io/channel.h" #include "io/channel-tls.h" -void migration_tls_channel_process_incoming (MigrationState *s, -QIOChannel *ioc, -Error **errp); +void migration_tls_channel_process_incoming (QIOChannel *ioc,Error **errp); QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc, const char *hostname,
Signature · 1 line
2.51.0
Re: [RFC PATCH 03/25] migration/tls: Remove unused parameter
Quoted 6 lines · Fabiano Rosas
MigrationState is not used at
migration_tls_channel_process_incoming().The last usage was removed by commit
3f461a0c0b("migration: Drop unused parameter formigration_tls_get_creds()")Signed-off-by Fabiano Rosas <[email protected]>
Signature · 1 line
Peter Xu
RFC PATCH 4/25 migration: Move multifd_recv_setup call
In reply to Fabiano RosasThe multifd_recv_setup() call is currently in a place where it will be called for every channel that appears. That doesn't make much sense.
It seems it was moved when the channel discovery mechanism was added back at commit 6720c2b327 (migration: check magic value for deciding the mapping of channels, 2022-12-20). The original place was migration_incoming_setup() which would run for just the main channel, but it was discovered that the main channel might arrive after a multifd channel.
Move the call back to a place where it will be called only once.
With respect to cleanup, this new location at qemu_start_incoming_migration() has the same issue as the previous callsite at migration_ioc_process_incoming(): no cleanup ever happens.
The error message goes from being emitted via error_report_err(), to being returned to the qmp_migrate_incoming() incoming command, which is arguably better, since this is setup code.
--- migration/migration.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
migration/migration.c +4 -4
@@ -786,6 +786,10 @@ static void qemu_start_incoming_migration(const char *uri, bool has_channels,return ; } +if (multifd_recv_setup (errp) !=0 ) { +return ; + } +if (addr->transport ==MIGRATION_ADDRESS_TYPE_SOCKET ) {SocketAddress *saddr = &addr->u.socket; if (saddr->type == SOCKET_ADDRESS_TYPE_INET ||
@@ -1065,10 +1069,6 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) channel =CH_POSTCOPY ; } -if (multifd_recv_setup (errp) !=0 ) { -return ; - } -if (channel ==CH_MAIN ) { f =qemu_file_new_input (ioc);migration_incoming_setup (f);
Signature · 1 line
2.51.0
Re: [RFC PATCH 04/25] migration: Move multifd_recv_setup call
Quoted 13 lines · Fabiano Rosas
The
multifd_recv_setup()call is currently in a place where it will be called for every channel that appears. That doesn't make much sense.It seems it was moved when the channel discovery mechanism was added back at commit
6720c2b327(migration: check magic value for deciding the mapping of channels, 2022-12-20). The original place wasmigration_incoming_setup()which would run for just the main channel, but it was discovered that the main channel might arrive after a multifd channel.Move the call back to a place where it will be called only once.
Quoted 7 lines
With respect to cleanup, this new location at
qemu_start_incoming_migration()has the same issue as the previous callsite atmigration_ioc_process_incoming(): no cleanup ever happens.The error message goes from being emitted via
error_report_err(), to being returned to theqmp_migrate_incoming()incoming command, which is arguably better, since this is setup code.
This is not the only and real reason that you moved it, right?
Neither should it be the reason that you want it to be called only exactly once; after all the function will be no-op in the 2nd+ calls.
I'll keep reading.. I'm guessing I'll find it later, but IMHO it'll always be good to mention the real motivation in the commit log.
Quoted 35 lines
Signed-off-by Fabiano Rosas <[email protected]>--- migration/migration.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)migration/migration.c +4
-4@@ -786,6 +786,10 @@ static void qemu_start_incoming_migration(const char *uri, bool has_channels,return ; } +if (multifd_recv_setup (errp) !=0 ) { +return ; + } +if (addr->transport ==MIGRATION_ADDRESS_TYPE_SOCKET ) {SocketAddress *saddr = &addr->u.socket; if (saddr->type == SOCKET_ADDRESS_TYPE_INET ||@@ -1065,10 +1069,6 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) channel =CH_POSTCOPY ; } -if (multifd_recv_setup (errp) !=0 ) { -return ; - } -if (channel ==CH_MAIN ) { f =qemu_file_new_input (ioc);migration_incoming_setup (f);Signature · 1 line
2.51.0
Signature · 1 line
Peter Xu
Re: [RFC PATCH 04/25] migration: Move multifd_recv_setup call
Quoted 18 lines · Peter Xu
Quoted 17 lines · Fabiano Rosas
The
multifd_recv_setup()call is currently in a place where it will be called for every channel that appears. That doesn't make much sense.It seems it was moved when the channel discovery mechanism was added back at commit
6720c2b327(migration: check magic value for deciding the mapping of channels, 2022-12-20). The original place wasmigration_incoming_setup()which would run for just the main channel, but it was discovered that the main channel might arrive after a multifd channel.Move the call back to a place where it will be called only once.
With respect to cleanup, this new location at
qemu_start_incoming_migration()has the same issue as the previous callsite atmigration_ioc_process_incoming(): no cleanup ever happens.
Quoted 6 lines
Quoted 3 lines
The error message goes from being emitted via
error_report_err(), to being returned to theqmp_migrate_incoming()incoming command, which is arguably better, since this is setup code.This is not the only and real reason that you moved it, right?
It was odd where it was and I just moved it. It could probably remain there even after the rest of the series, I didn't check.
I think it would then need to move to channel.c which would make that file access multifd code, so maybe it's a layering argument.
Quoted 3 lines
Neither should it be the reason that you want it to be called only exactly once; after all the function will be no-op in the 2nd+ calls.
It's not a no-op. But yes, it returns early on subsequent calls.
Quoted 38 lines
I'll keep reading.. I'm guessing I'll find it later, but IMHO it'll always be good to mention the real motivation in the commit log.
Quoted 35 lines
Signed-off-by Fabiano Rosas <[email protected]>--- migration/migration.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)migration/migration.c +4
-4@@ -786,6 +786,10 @@ static void qemu_start_incoming_migration(const char *uri, bool has_channels,return ; } +if (multifd_recv_setup (errp) !=0 ) { +return ; + } +if (addr->transport ==MIGRATION_ADDRESS_TYPE_SOCKET ) {SocketAddress *saddr = &addr->u.socket; if (saddr->type == SOCKET_ADDRESS_TYPE_INET ||@@ -1065,10 +1069,6 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) channel =CH_POSTCOPY ; } -if (multifd_recv_setup (errp) !=0 ) { -return ; - } -if (channel ==CH_MAIN ) { f =qemu_file_new_input (ioc);migration_incoming_setup (f);Signature · 1 line
2.51.0
RFC PATCH 5/25 migration: Cleanup TLS handshake hostname passing
In reply to Fabiano RosasThe TLS hostname is doing a tour around the world just to be cached into s->hostname. We're already abusing MigrationState by doing that, so incorporate the s->hostname into migration_tls_hostname() and stop passing the string around.
The old route was roughly:
-transport code (socket.c, fd.c, etc):
if (SOCKET_ADDRESS_TYPE_INET)
hostname = saddr->u.inet.host
else
hostname = NULL
migration_channel_connect(..., hostname)
s->hostname = hostname;
migration_tls_client_create(..., hostname)
if (migrate_tls_hostname())
qio_channel_tls_new_client(migrate_tls_hostname())
else
qio_channel_tls_new_client(hostname)-postcopy_preempt_setup:
postcopy_preempt_send_channel_new
migration_tls_client_create(..., s->hostname)New route is:
-socket.c only:
if SOCKET_ADDRESS_TYPE_INET
s->hostname = saddr->u.inet.host
migration_channel_connect()
migration_tls_client_create()
qio_channel_tls_new_client(migrate_tls_hostname())
-postcopy_preempt_setup:
postcopy_preempt_send_channel_new
migration_tls_client_create()
qio_channel_tls_new_client(migrate_tls_hostname())
--- migration/channel.c | 6 ++---- migration/channel.h | 1 - migration/exec.c | 2 +- migration/fd.c | 2 +- migration/file.c | 2 +- migration/multifd.c | 9 +++------ migration/options.c | 5 +++++ migration/postcopy-ram.c | 2 +- migration/socket.c | 9 +++------ migration/tls.c | 17 ++++------------- migration/tls.h | 2 -- migration/trace-events | 10 +++++----- 12 files changed, 26 insertions(+), 41 deletions(-)
migration/channel.c +2 -4
@@ -60,20 +60,18 @@ void migration_channel_process_incoming(QIOChannel *ioc)* * @s: Current migration state * @ioc: Channel to which we are connecting -* @hostname: Where we want to connect * @error: Error indicating failure to connect, free'd here */ void migration_channel_connect (MigrationState *s,QIOChannel *ioc, -const char *hostname,Error *error) {trace_migration_set_outgoing_channel ( - ioc,object_get_typename (OBJECT (ioc)), hostname, error); + ioc,object_get_typename (OBJECT (ioc)), error);if (!error) {if (migrate_channel_requires_tls_upgrade (ioc)) { -migration_tls_channel_connect (s, ioc, hostname, &error); +migration_tls_channel_connect (s, ioc, &error);if (!error) {/* tls_channel_connect will call back to this
migration/channel.h +0 -1
@@ -22,7 +22,6 @@ void migration_channel_process_incoming(QIOChannel *ioc);void migration_channel_connect (MigrationState *s,QIOChannel *ioc, -const char *hostname,Error *error_in); int migration_channel_read_peek(QIOChannel *ioc,
migration/exec.c +1 -1
@@ -55,7 +55,7 @@ void exec_start_outgoing_migration(MigrationState *s, strList *command, }qio_channel_set_name (ioc,"migration-exec-outgoing" ); -migration_channel_connect (s, ioc,NULL ,NULL ); +migration_channel_connect (s, ioc,NULL );object_unref (OBJECT (ioc)); }
migration/fd.c +1 -1
@@ -70,7 +70,7 @@ void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error ** }qio_channel_set_name (ioc,"migration-fd-outgoing" ); -migration_channel_connect (s, ioc,NULL ,NULL ); +migration_channel_connect (s, ioc,NULL );object_unref (OBJECT (ioc)); }
migration/file.c +1 -1
@@ -122,7 +122,7 @@ void file_start_outgoing_migration(MigrationState *s,return ; }qio_channel_set_name (ioc,"migration-file-outgoing" ); -migration_channel_connect (s, ioc,NULL ,NULL ); +migration_channel_connect (s, ioc,NULL ); } static gboolean file_accept_incoming_migration(QIOChannel *ioc,
migration/multifd.c +3 -6
@@ -814,12 +814,10 @@ static bool multifd_tls_channel_connect(MultiFDSendParams *p, QIOChannel *ioc, Error **errp) { -MigrationState *s =migrate_get_current (); -const char *hostname = s->hostname;MultiFDTLSThreadArgs *args;QIOChannelTLS *tioc; - tioc =migration_tls_client_create (ioc, hostname, errp); + tioc =migration_tls_client_create (ioc, errp);if (!tioc) {return false; }
@@ -829,7 +827,7 @@ static bool multifd_tls_channel_connect(MultiFDSendParams *p,* created TLS channel, which has already taken a reference. */ object_unref (OBJECT (ioc)); -trace_multifd_tls_outgoing_handshake_start (ioc, tioc, hostname); +trace_multifd_tls_outgoing_handshake_start (ioc, tioc);qio_channel_set_name (QIO_CHANNEL (tioc),"multifd-tls-outgoing" ); args =g_new0 (MultiFDTLSThreadArgs,1 );
@@ -876,8 +874,7 @@ static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque) goto out; } -trace_multifd_set_outgoing_channel (ioc,object_get_typename (OBJECT (ioc)), -migrate_get_current ()->hostname); +trace_multifd_set_outgoing_channel (ioc,object_get_typename (OBJECT (ioc)));if (migrate_channel_requires_tls_upgrade (ioc)) { ret =multifd_tls_channel_connect (p, ioc, &local_err);
migration/options.c +5 -0
@@ -956,6 +956,11 @@ const char *migrate_tls_hostname(void)return s->parameters.tls_hostname->u.s; } +/* hostname saved from a previously connected channel */ +if (s->hostname) { +return s->hostname; + } +return NULL ; }
migration/postcopy-ram.c +1 -1
@@ -1966,7 +1966,7 @@ postcopy_preempt_send_channel_new(QIOTask *task, gpointer opaque) }if (migrate_channel_requires_tls_upgrade (ioc)) { - tioc =migration_tls_client_create (ioc, s->hostname, &local_err); + tioc =migration_tls_client_create (ioc, &local_err);if (!tioc) { goto out; }
migration/socket.c +3 -6
@@ -44,7 +44,6 @@ void socket_send_channel_create(QIOTaskFunc f, void *data)struct SocketConnectData {MigrationState *s; -char *hostname; };static void socket_connect_data_free (void *opaque)
@@ -53,7 +52,6 @@ static void socket_connect_data_free(void *opaque)if (!data) {return ; } -g_free (data->hostname);g_free (data); }
@@ -69,7 +67,7 @@ static void socket_outgoing_migration(QIOTask *task, goto out; } -trace_migration_socket_outgoing_connected (data->hostname); +trace_migration_socket_outgoing_connected ();if (migrate_zero_copy_send () && !qio_channel_has_feature (sioc,QIO_CHANNEL_FEATURE_WRITE_ZERO_COPY )) {
@@ -77,7 +75,7 @@ static void socket_outgoing_migration(QIOTask *task, } out: -migration_channel_connect (data->s, sioc, data->hostname, err); +migration_channel_connect (data->s, sioc, err);object_unref (OBJECT (sioc)); }
@@ -96,7 +94,7 @@ void socket_start_outgoing_migration(MigrationState *s, outgoing_args.saddr = addr;if (saddr->type ==SOCKET_ADDRESS_TYPE_INET ) { - data->hostname =g_strdup (saddr->u.inet.host); + s->hostname =g_strdup (saddr->u.inet.host); }qio_channel_set_name (QIO_CHANNEL (sioc),"migration-socket-outgoing" );
@@ -180,4 +178,3 @@ void socket_start_incoming_migration(SocketAddress *saddr,qapi_free_SocketAddress (address); } } -
migration/tls.c +4 -13
@@ -112,12 +112,11 @@ static void migration_tls_outgoing_handshake(QIOTask *task, }else {trace_migration_tls_outgoing_handshake_complete (); } -migration_channel_connect (s, ioc,NULL , err); +migration_channel_connect (s, ioc, err);object_unref (OBJECT (ioc)); }QIOChannelTLS *migration_tls_client_create (QIOChannel *ioc, -const char *hostname,Error **errp) {QCryptoTLSCreds *creds;
@@ -127,29 +126,21 @@ QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc,return NULL ; } -const char *tls_hostname =migrate_tls_hostname (); -if (tls_hostname) { - hostname = tls_hostname; - } - -return qio_channel_tls_new_client (ioc, creds, hostname, errp); +return qio_channel_tls_new_client (ioc, creds,migrate_tls_hostname (), errp); }void migration_tls_channel_connect (MigrationState *s,QIOChannel *ioc, -const char *hostname,Error **errp) {QIOChannelTLS *tioc; - tioc =migration_tls_client_create (ioc, hostname, errp); + tioc =migration_tls_client_create (ioc, errp);if (!tioc) {return ; } -/* Save hostname into MigrationState for handshake */ - s->hostname =g_strdup (hostname); -trace_migration_tls_outgoing_handshake_start (hostname); +trace_migration_tls_outgoing_handshake_start ();qio_channel_set_name (QIO_CHANNEL (tioc),"migration-tls-outgoing" );if (migrate_postcopy_ram () ||migrate_return_path ()) {
migration/tls.h +0 -2
@@ -27,12 +27,10 @@void migration_tls_channel_process_incoming (QIOChannel *ioc,Error **errp);QIOChannelTLS *migration_tls_client_create (QIOChannel *ioc, -const char *hostname,Error **errp);void migration_tls_channel_connect (MigrationState *s,QIOChannel *ioc, -const char *hostname,Error **errp);void migration_tls_channel_end (QIOChannel *ioc,Error **errp);/* Whether the QIO channel requires further TLS handshake? */
migration/trace-events +5 -5
@@ -149,10 +149,10 @@ multifd_send_sync_main_wait(uint8_t id) "channel %u" multifd_send_terminate_threads(void) "" multifd_send_thread_end(uint8_t id, uint64_t packets) "channel %u packets %" PRIu64 multifd_send_thread_start(uint8_t id) "%u" -multifd_tls_outgoing_handshake_start(void *ioc, void *tioc, const char *hostname) "ioc=%p tioc=%p hostname=%s" +multifd_tls_outgoing_handshake_start(void *ioc, void *tioc) "ioc=%p tioc=%p" multifd_tls_outgoing_handshake_error(void *ioc, const char *err) "ioc=%p err=%s" multifd_tls_outgoing_handshake_complete(void *ioc) "ioc=%p" -multifd_set_outgoing_channel(void *ioc, const char *ioctype, const char *hostname) "ioc=%p ioctype=%s hostname=%s" +multifd_set_outgoing_channel(void *ioc, const char *ioctype) "ioc=%p ioctype=%s" # migration.c migrate_set_state(const char *new_state) "new state %s"
@@ -204,7 +204,7 @@ migration_transferred_bytes(uint64_t qemu_file, uint64_t multifd, uint64_t rdma) # channel.c migration_set_incoming_channel(void *ioc, const char *ioctype) "ioc=%p ioctype=%s" -migration_set_outgoing_channel(void *ioc, const char *ioctype, const char *hostname, void *err) "ioc=%p ioctype=%s hostname=%s err=%p" +migration_set_outgoing_channel(void *ioc, const char *ioctype, void *err) "ioc=%p ioctype=%s err=%p" # global_state.c migrate_state_too_big(void) ""
@@ -328,11 +328,11 @@ migration_file_incoming(const char *filename) "filename=%s" # socket.c migration_socket_incoming_accepted(void) "" -migration_socket_outgoing_connected(const char *hostname) "hostname=%s" +migration_socket_outgoing_connected(void) "" migration_socket_outgoing_error(const char *err) "error=%s" # tls.c -migration_tls_outgoing_handshake_start(const char *hostname) "hostname=%s" +migration_tls_outgoing_handshake_start(void) "" migration_tls_outgoing_handshake_error(const char *err) "err=%s" migration_tls_outgoing_handshake_complete(void) "" migration_tls_incoming_handshake_start(void) ""
Signature · 1 line
2.51.0
Re: [RFC PATCH 05/25] migration: Cleanup TLS handshake hostname passing
Quoted 33 lines · Fabiano Rosas
The TLS hostname is doing a tour around the world just to be cached into
s->hostname. We're already abusing MigrationState by doing that, so incorporate thes->hostnameintomigration_tls_hostname()and stop passing the string around.The old route was roughly:
-transport code (
socket.c,fd.c, etc):if (SOCKET_ADDRESS_TYPE_INET) hostname = saddr->u.inet.host else hostname = NULL migration_channel_connect(..., hostname) s->hostname = hostname; migration_tls_client_create(..., hostname) if (migrate_tls_hostname()) qio_channel_tls_new_client(migrate_tls_hostname()) else qio_channel_tls_new_client(hostname)-postcopy_preempt_setup:
postcopy_preempt_send_channel_new migration_tls_client_create(..., s->hostname)New route is:
-socket.conly:if SOCKET_ADDRESS_TYPE_INET s->hostname = saddr->u.inet.host migration_channel_connect() migration_tls_client_create() qio_channel_tls_new_client(migrate_tls_hostname())
Quoted 6 lines
-postcopy_preempt_setup:
postcopy_preempt_send_channel_new
migration_tls_client_create()
qio_channel_tls_new_client(migrate_tls_hostname())Signed-off-by Fabiano Rosas <[email protected]>
I suggest let's still copy Dan on all tls changes, though. I've done it here.
Looks alright to me:
Two trivial comments on top..
- Maybe, we can get rid of SocketConnectData altogether now
- Maybe, we want to keep at least one tracepoint that would dump the hostname used
Quoted 322 lines
--- migration/channel.c | 6 ++---- migration/channel.h | 1 - migration/exec.c | 2 +- migration/fd.c | 2 +- migration/file.c | 2 +- migration/multifd.c | 9 +++------ migration/options.c | 5 +++++ migration/postcopy-ram.c | 2 +- migration/socket.c | 9 +++------ migration/tls.c | 17 ++++------------- migration/tls.h | 2 -- migration/trace-events | 10 +++++----- 12 files changed, 26 insertions(+), 41 deletions(-)migration/channel.c +2
-4@@ -60,20 +60,18 @@ void migration_channel_process_incoming(QIOChannel *ioc)* * @s: Current migration state * @ioc: Channel to which we are connecting -* @hostname: Where we want to connect * @error: Error indicating failure to connect, free'd here */ void migration_channel_connect (MigrationState *s,QIOChannel *ioc, -const char *hostname,Error *error) {trace_migration_set_outgoing_channel ( - ioc,object_get_typename (OBJECT (ioc)), hostname, error); + ioc,object_get_typename (OBJECT (ioc)), error);if (!error) {if (migrate_channel_requires_tls_upgrade (ioc)) { -migration_tls_channel_connect (s, ioc, hostname, &error); +migration_tls_channel_connect (s, ioc, &error);if (!error) {/* tls_channel_connect will call back to this migration/channel.h +0
-1@@ -22,7 +22,6 @@ void migration_channel_process_incoming(QIOChannel *ioc);void migration_channel_connect (MigrationState *s,QIOChannel *ioc, -const char *hostname,Error *error_in); int migration_channel_read_peek(QIOChannel *ioc,migration/exec.c +1
-1@@ -55,7 +55,7 @@ void exec_start_outgoing_migration(MigrationState *s, strList *command, }qio_channel_set_name (ioc,"migration-exec-outgoing" ); -migration_channel_connect (s, ioc,NULL ,NULL ); +migration_channel_connect (s, ioc,NULL );object_unref (OBJECT (ioc)); }migration/fd.c +1
-1@@ -70,7 +70,7 @@ void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error ** }qio_channel_set_name (ioc,"migration-fd-outgoing" ); -migration_channel_connect (s, ioc,NULL ,NULL ); +migration_channel_connect (s, ioc,NULL );object_unref (OBJECT (ioc)); }migration/file.c +1
-1@@ -122,7 +122,7 @@ void file_start_outgoing_migration(MigrationState *s,return ; }qio_channel_set_name (ioc,"migration-file-outgoing" ); -migration_channel_connect (s, ioc,NULL ,NULL ); +migration_channel_connect (s, ioc,NULL ); } static gboolean file_accept_incoming_migration(QIOChannel *ioc,migration/multifd.c +3
-6@@ -814,12 +814,10 @@ static bool multifd_tls_channel_connect(MultiFDSendParams *p, QIOChannel *ioc, Error **errp) { -MigrationState *s =migrate_get_current (); -const char *hostname = s->hostname;MultiFDTLSThreadArgs *args;QIOChannelTLS *tioc; - tioc =migration_tls_client_create (ioc, hostname, errp); + tioc =migration_tls_client_create (ioc, errp);if (!tioc) {return false; }@@ -829,7 +827,7 @@ static bool multifd_tls_channel_connect(MultiFDSendParams *p,* created TLS channel, which has already taken a reference. */ object_unref (OBJECT (ioc)); -trace_multifd_tls_outgoing_handshake_start (ioc, tioc, hostname); +trace_multifd_tls_outgoing_handshake_start (ioc, tioc);qio_channel_set_name (QIO_CHANNEL (tioc),"multifd-tls-outgoing" ); args =g_new0 (MultiFDTLSThreadArgs,1 );@@ -876,8 +874,7 @@ static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque) goto out; } -trace_multifd_set_outgoing_channel (ioc,object_get_typename (OBJECT (ioc)), -migrate_get_current ()->hostname); +trace_multifd_set_outgoing_channel (ioc,object_get_typename (OBJECT (ioc)));if (migrate_channel_requires_tls_upgrade (ioc)) { ret =multifd_tls_channel_connect (p, ioc, &local_err);migration/options.c +5
-0@@ -956,6 +956,11 @@ const char *migrate_tls_hostname(void)return s->parameters.tls_hostname->u.s; } +/* hostname saved from a previously connected channel */ +if (s->hostname) { +return s->hostname; + } +return NULL ; }migration/postcopy-ram.c +1
-1@@ -1966,7 +1966,7 @@ postcopy_preempt_send_channel_new(QIOTask *task, gpointer opaque) }if (migrate_channel_requires_tls_upgrade (ioc)) { - tioc =migration_tls_client_create (ioc, s->hostname, &local_err); + tioc =migration_tls_client_create (ioc, &local_err);if (!tioc) { goto out; }migration/socket.c +3
-6@@ -44,7 +44,6 @@ void socket_send_channel_create(QIOTaskFunc f, void *data)struct SocketConnectData {MigrationState *s; -char *hostname; };static void socket_connect_data_free (void *opaque)@@ -53,7 +52,6 @@ static void socket_connect_data_free(void *opaque)if (!data) {return ; } -g_free (data->hostname);g_free (data); }@@ -69,7 +67,7 @@ static void socket_outgoing_migration(QIOTask *task, goto out; } -trace_migration_socket_outgoing_connected (data->hostname); +trace_migration_socket_outgoing_connected ();if (migrate_zero_copy_send () && !qio_channel_has_feature (sioc,QIO_CHANNEL_FEATURE_WRITE_ZERO_COPY )) {@@ -77,7 +75,7 @@ static void socket_outgoing_migration(QIOTask *task, } out: -migration_channel_connect (data->s, sioc, data->hostname, err); +migration_channel_connect (data->s, sioc, err);object_unref (OBJECT (sioc)); }@@ -96,7 +94,7 @@ void socket_start_outgoing_migration(MigrationState *s, outgoing_args.saddr = addr;if (saddr->type ==SOCKET_ADDRESS_TYPE_INET ) { - data->hostname =g_strdup (saddr->u.inet.host); + s->hostname =g_strdup (saddr->u.inet.host); }qio_channel_set_name (QIO_CHANNEL (sioc),"migration-socket-outgoing" );@@ -180,4 +178,3 @@ void socket_start_incoming_migration(SocketAddress *saddr,qapi_free_SocketAddress (address); } } -migration/tls.c +4
-13@@ -112,12 +112,11 @@ static void migration_tls_outgoing_handshake(QIOTask *task, }else {trace_migration_tls_outgoing_handshake_complete (); } -migration_channel_connect (s, ioc,NULL , err); +migration_channel_connect (s, ioc, err);object_unref (OBJECT (ioc)); }QIOChannelTLS *migration_tls_client_create (QIOChannel *ioc, -const char *hostname,Error **errp) {QCryptoTLSCreds *creds;@@ -127,29 +126,21 @@ QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc,return NULL ; } -const char *tls_hostname =migrate_tls_hostname (); -if (tls_hostname) { - hostname = tls_hostname; - } - -return qio_channel_tls_new_client (ioc, creds, hostname, errp); +return qio_channel_tls_new_client (ioc, creds,migrate_tls_hostname (), errp); }void migration_tls_channel_connect (MigrationState *s,QIOChannel *ioc, -const char *hostname,Error **errp) {QIOChannelTLS *tioc; - tioc =migration_tls_client_create (ioc, hostname, errp); + tioc =migration_tls_client_create (ioc, errp);if (!tioc) {return ; } -/* Save hostname into MigrationState for handshake */ - s->hostname =g_strdup (hostname); -trace_migration_tls_outgoing_handshake_start (hostname); +trace_migration_tls_outgoing_handshake_start ();qio_channel_set_name (QIO_CHANNEL (tioc),"migration-tls-outgoing" );if (migrate_postcopy_ram () ||migrate_return_path ()) {migration/tls.h +0
-2@@ -27,12 +27,10 @@void migration_tls_channel_process_incoming (QIOChannel *ioc,Error **errp);QIOChannelTLS *migration_tls_client_create (QIOChannel *ioc, -const char *hostname,Error **errp);void migration_tls_channel_connect (MigrationState *s,QIOChannel *ioc, -const char *hostname,Error **errp);void migration_tls_channel_end (QIOChannel *ioc,Error **errp);/* Whether the QIO channel requires further TLS handshake? */ migration/trace-events +5
-5@@ -149,10 +149,10 @@ multifd_send_sync_main_wait(uint8_t id) "channel %u" multifd_send_terminate_threads(void) "" multifd_send_thread_end(uint8_t id, uint64_t packets) "channel %u packets %" PRIu64 multifd_send_thread_start(uint8_t id) "%u" -multifd_tls_outgoing_handshake_start(void *ioc, void *tioc, const char *hostname) "ioc=%p tioc=%p hostname=%s" +multifd_tls_outgoing_handshake_start(void *ioc, void *tioc) "ioc=%p tioc=%p" multifd_tls_outgoing_handshake_error(void *ioc, const char *err) "ioc=%p err=%s" multifd_tls_outgoing_handshake_complete(void *ioc) "ioc=%p" -multifd_set_outgoing_channel(void *ioc, const char *ioctype, const char *hostname) "ioc=%p ioctype=%s hostname=%s" +multifd_set_outgoing_channel(void *ioc, const char *ioctype) "ioc=%p ioctype=%s" # migration.c migrate_set_state(const char *new_state) "new state %s"@@ -204,7 +204,7 @@ migration_transferred_bytes(uint64_t qemu_file, uint64_t multifd, uint64_t rdma) # channel.c migration_set_incoming_channel(void *ioc, const char *ioctype) "ioc=%p ioctype=%s" -migration_set_outgoing_channel(void *ioc, const char *ioctype, const char *hostname, void *err) "ioc=%p ioctype=%s hostname=%s err=%p" +migration_set_outgoing_channel(void *ioc, const char *ioctype, void *err) "ioc=%p ioctype=%s err=%p" # global_state.c migrate_state_too_big(void) ""@@ -328,11 +328,11 @@ migration_file_incoming(const char *filename) "filename=%s" # socket.c migration_socket_incoming_accepted(void) "" -migration_socket_outgoing_connected(const char *hostname) "hostname=%s" +migration_socket_outgoing_connected(void) "" migration_socket_outgoing_error(const char *err) "error=%s" # tls.c -migration_tls_outgoing_handshake_start(const char *hostname) "hostname=%s" +migration_tls_outgoing_handshake_start(void) "" migration_tls_outgoing_handshake_error(const char *err) "err=%s" migration_tls_outgoing_handshake_complete(void) "" migration_tls_incoming_handshake_start(void) ""Signature · 1 line
2.51.0
Signature · 1 line
Peter Xu
Re: [RFC PATCH 05/25] migration: Cleanup TLS handshake hostname passing
Quoted 39 lines · Peter Xu
Quoted 38 lines · Fabiano Rosas
The TLS hostname is doing a tour around the world just to be cached into
s->hostname. We're already abusing MigrationState by doing that, so incorporate thes->hostnameintomigration_tls_hostname()and stop passing the string around.The old route was roughly:
-transport code (
socket.c,fd.c, etc):if (SOCKET_ADDRESS_TYPE_INET) hostname = saddr->u.inet.host else hostname = NULL migration_channel_connect(..., hostname) s->hostname = hostname; migration_tls_client_create(..., hostname) if (migrate_tls_hostname()) qio_channel_tls_new_client(migrate_tls_hostname()) else qio_channel_tls_new_client(hostname)-postcopy_preempt_setup:
postcopy_preempt_send_channel_new migration_tls_client_create(..., s->hostname)New route is:
-socket.conly:if SOCKET_ADDRESS_TYPE_INET s->hostname = saddr->u.inet.host migration_channel_connect() migration_tls_client_create() qio_channel_tls_new_client(migrate_tls_hostname())-postcopy_preempt_setup:
postcopy_preempt_send_channel_new
migration_tls_client_create()
qio_channel_tls_new_client(migrate_tls_hostname())
Quoted 5 lines
Quoted 1 line
Signed-off-by Fabiano Rosas <[email protected]>I suggest let's still copy Dan on all tls changes, though. I've done it here.
Thanks
Quoted 8 lines
Looks alright to me:
Reviewed-by Peter Xu <[email protected]>Two trivial comments on top..
- Maybe, we can get rid of SocketConnectData altogether now
It goes away voluntarily on patch 21.
Quoted 3 lines
- Maybe, we want to keep at least one tracepoint that would dump the hostname used
I can add one just in case.
Quoted 322 lines
Quoted 322 lines
--- migration/channel.c | 6 ++---- migration/channel.h | 1 - migration/exec.c | 2 +- migration/fd.c | 2 +- migration/file.c | 2 +- migration/multifd.c | 9 +++------ migration/options.c | 5 +++++ migration/postcopy-ram.c | 2 +- migration/socket.c | 9 +++------ migration/tls.c | 17 ++++------------- migration/tls.h | 2 -- migration/trace-events | 10 +++++----- 12 files changed, 26 insertions(+), 41 deletions(-)migration/channel.c +2
-4@@ -60,20 +60,18 @@ void migration_channel_process_incoming(QIOChannel *ioc)* * @s: Current migration state * @ioc: Channel to which we are connecting -* @hostname: Where we want to connect * @error: Error indicating failure to connect, free'd here */ void migration_channel_connect (MigrationState *s,QIOChannel *ioc, -const char *hostname,Error *error) {trace_migration_set_outgoing_channel ( - ioc,object_get_typename (OBJECT (ioc)), hostname, error); + ioc,object_get_typename (OBJECT (ioc)), error);if (!error) {if (migrate_channel_requires_tls_upgrade (ioc)) { -migration_tls_channel_connect (s, ioc, hostname, &error); +migration_tls_channel_connect (s, ioc, &error);if (!error) {/* tls_channel_connect will call back to this migration/channel.h +0
-1@@ -22,7 +22,6 @@ void migration_channel_process_incoming(QIOChannel *ioc);void migration_channel_connect (MigrationState *s,QIOChannel *ioc, -const char *hostname,Error *error_in); int migration_channel_read_peek(QIOChannel *ioc,migration/exec.c +1
-1@@ -55,7 +55,7 @@ void exec_start_outgoing_migration(MigrationState *s, strList *command, }qio_channel_set_name (ioc,"migration-exec-outgoing" ); -migration_channel_connect (s, ioc,NULL ,NULL ); +migration_channel_connect (s, ioc,NULL );object_unref (OBJECT (ioc)); }migration/fd.c +1
-1@@ -70,7 +70,7 @@ void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error ** }qio_channel_set_name (ioc,"migration-fd-outgoing" ); -migration_channel_connect (s, ioc,NULL ,NULL ); +migration_channel_connect (s, ioc,NULL );object_unref (OBJECT (ioc)); }migration/file.c +1
-1@@ -122,7 +122,7 @@ void file_start_outgoing_migration(MigrationState *s,return ; }qio_channel_set_name (ioc,"migration-file-outgoing" ); -migration_channel_connect (s, ioc,NULL ,NULL ); +migration_channel_connect (s, ioc,NULL ); } static gboolean file_accept_incoming_migration(QIOChannel *ioc,migration/multifd.c +3
-6@@ -814,12 +814,10 @@ static bool multifd_tls_channel_connect(MultiFDSendParams *p, QIOChannel *ioc, Error **errp) { -MigrationState *s =migrate_get_current (); -const char *hostname = s->hostname;MultiFDTLSThreadArgs *args;QIOChannelTLS *tioc; - tioc =migration_tls_client_create (ioc, hostname, errp); + tioc =migration_tls_client_create (ioc, errp);if (!tioc) {return false; }@@ -829,7 +827,7 @@ static bool multifd_tls_channel_connect(MultiFDSendParams *p,* created TLS channel, which has already taken a reference. */ object_unref (OBJECT (ioc)); -trace_multifd_tls_outgoing_handshake_start (ioc, tioc, hostname); +trace_multifd_tls_outgoing_handshake_start (ioc, tioc);qio_channel_set_name (QIO_CHANNEL (tioc),"multifd-tls-outgoing" ); args =g_new0 (MultiFDTLSThreadArgs,1 );@@ -876,8 +874,7 @@ static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque) goto out; } -trace_multifd_set_outgoing_channel (ioc,object_get_typename (OBJECT (ioc)), -migrate_get_current ()->hostname); +trace_multifd_set_outgoing_channel (ioc,object_get_typename (OBJECT (ioc)));if (migrate_channel_requires_tls_upgrade (ioc)) { ret =multifd_tls_channel_connect (p, ioc, &local_err);migration/options.c +5
-0@@ -956,6 +956,11 @@ const char *migrate_tls_hostname(void)return s->parameters.tls_hostname->u.s; } +/* hostname saved from a previously connected channel */ +if (s->hostname) { +return s->hostname; + } +return NULL ; }migration/postcopy-ram.c +1
-1@@ -1966,7 +1966,7 @@ postcopy_preempt_send_channel_new(QIOTask *task, gpointer opaque) }if (migrate_channel_requires_tls_upgrade (ioc)) { - tioc =migration_tls_client_create (ioc, s->hostname, &local_err); + tioc =migration_tls_client_create (ioc, &local_err);if (!tioc) { goto out; }migration/socket.c +3
-6@@ -44,7 +44,6 @@ void socket_send_channel_create(QIOTaskFunc f, void *data)struct SocketConnectData {MigrationState *s; -char *hostname; };static void socket_connect_data_free (void *opaque)@@ -53,7 +52,6 @@ static void socket_connect_data_free(void *opaque)if (!data) {return ; } -g_free (data->hostname);g_free (data); }@@ -69,7 +67,7 @@ static void socket_outgoing_migration(QIOTask *task, goto out; } -trace_migration_socket_outgoing_connected (data->hostname); +trace_migration_socket_outgoing_connected ();if (migrate_zero_copy_send () && !qio_channel_has_feature (sioc,QIO_CHANNEL_FEATURE_WRITE_ZERO_COPY )) {@@ -77,7 +75,7 @@ static void socket_outgoing_migration(QIOTask *task, } out: -migration_channel_connect (data->s, sioc, data->hostname, err); +migration_channel_connect (data->s, sioc, err);object_unref (OBJECT (sioc)); }@@ -96,7 +94,7 @@ void socket_start_outgoing_migration(MigrationState *s, outgoing_args.saddr = addr;if (saddr->type ==SOCKET_ADDRESS_TYPE_INET ) { - data->hostname =g_strdup (saddr->u.inet.host); + s->hostname =g_strdup (saddr->u.inet.host); }qio_channel_set_name (QIO_CHANNEL (sioc),"migration-socket-outgoing" );@@ -180,4 +178,3 @@ void socket_start_incoming_migration(SocketAddress *saddr,qapi_free_SocketAddress (address); } } -migration/tls.c +4
-13@@ -112,12 +112,11 @@ static void migration_tls_outgoing_handshake(QIOTask *task, }else {trace_migration_tls_outgoing_handshake_complete (); } -migration_channel_connect (s, ioc,NULL , err); +migration_channel_connect (s, ioc, err);object_unref (OBJECT (ioc)); }QIOChannelTLS *migration_tls_client_create (QIOChannel *ioc, -const char *hostname,Error **errp) {QCryptoTLSCreds *creds;@@ -127,29 +126,21 @@ QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc,return NULL ; } -const char *tls_hostname =migrate_tls_hostname (); -if (tls_hostname) { - hostname = tls_hostname; - } - -return qio_channel_tls_new_client (ioc, creds, hostname, errp); +return qio_channel_tls_new_client (ioc, creds,migrate_tls_hostname (), errp); }void migration_tls_channel_connect (MigrationState *s,QIOChannel *ioc, -const char *hostname,Error **errp) {QIOChannelTLS *tioc; - tioc =migration_tls_client_create (ioc, hostname, errp); + tioc =migration_tls_client_create (ioc, errp);if (!tioc) {return ; } -/* Save hostname into MigrationState for handshake */ - s->hostname =g_strdup (hostname); -trace_migration_tls_outgoing_handshake_start (hostname); +trace_migration_tls_outgoing_handshake_start ();qio_channel_set_name (QIO_CHANNEL (tioc),"migration-tls-outgoing" );if (migrate_postcopy_ram () ||migrate_return_path ()) {migration/tls.h +0
-2@@ -27,12 +27,10 @@void migration_tls_channel_process_incoming (QIOChannel *ioc,Error **errp);QIOChannelTLS *migration_tls_client_create (QIOChannel *ioc, -const char *hostname,Error **errp);void migration_tls_channel_connect (MigrationState *s,QIOChannel *ioc, -const char *hostname,Error **errp);void migration_tls_channel_end (QIOChannel *ioc,Error **errp);/* Whether the QIO channel requires further TLS handshake? */ migration/trace-events +5
-5@@ -149,10 +149,10 @@ multifd_send_sync_main_wait(uint8_t id) "channel %u" multifd_send_terminate_threads(void) "" multifd_send_thread_end(uint8_t id, uint64_t packets) "channel %u packets %" PRIu64 multifd_send_thread_start(uint8_t id) "%u" -multifd_tls_outgoing_handshake_start(void *ioc, void *tioc, const char *hostname) "ioc=%p tioc=%p hostname=%s" +multifd_tls_outgoing_handshake_start(void *ioc, void *tioc) "ioc=%p tioc=%p" multifd_tls_outgoing_handshake_error(void *ioc, const char *err) "ioc=%p err=%s" multifd_tls_outgoing_handshake_complete(void *ioc) "ioc=%p" -multifd_set_outgoing_channel(void *ioc, const char *ioctype, const char *hostname) "ioc=%p ioctype=%s hostname=%s" +multifd_set_outgoing_channel(void *ioc, const char *ioctype) "ioc=%p ioctype=%s" # migration.c migrate_set_state(const char *new_state) "new state %s"@@ -204,7 +204,7 @@ migration_transferred_bytes(uint64_t qemu_file, uint64_t multifd, uint64_t rdma) # channel.c migration_set_incoming_channel(void *ioc, const char *ioctype) "ioc=%p ioctype=%s" -migration_set_outgoing_channel(void *ioc, const char *ioctype, const char *hostname, void *err) "ioc=%p ioctype=%s hostname=%s err=%p" +migration_set_outgoing_channel(void *ioc, const char *ioctype, void *err) "ioc=%p ioctype=%s err=%p" # global_state.c migrate_state_too_big(void) ""@@ -328,11 +328,11 @@ migration_file_incoming(const char *filename) "filename=%s" # socket.c migration_socket_incoming_accepted(void) "" -migration_socket_outgoing_connected(const char *hostname) "hostname=%s" +migration_socket_outgoing_connected(void) "" migration_socket_outgoing_error(const char *err) "error=%s" # tls.c -migration_tls_outgoing_handshake_start(const char *hostname) "hostname=%s" +migration_tls_outgoing_handshake_start(void) "" migration_tls_outgoing_handshake_error(const char *err) "err=%s" migration_tls_outgoing_handshake_complete(void) "" migration_tls_incoming_handshake_start(void) ""Signature · 1 line
2.51.0
RFC PATCH 6/25 migration: Move postcopy_try_recover into migration_incoming_process
In reply to Fabiano RosasThe postcopy_try_recover() call doesn't need to be duplicated, move it into migration_incoming_process().
This removes code from migration_fd_process_incoming() so it can be removed in the near future.
(the diff is a bit strange because migration_incoming_process() was moved after postcopy_try_recover())
--- migration/migration.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
migration/migration.c +10 -13
@@ -947,12 +947,6 @@ static void migration_incoming_setup(QEMUFile *f)qemu_file_set_blocking (f, false, &error_abort); } -void migration_incoming_process (void ) -{ -Coroutine *co =qemu_coroutine_create (process_incoming_migration_co,NULL ); -qemu_coroutine_enter (co); -} -/* Returns true if recovered from a paused migration, otherwise false */ static bool postcopy_try_recover (void ) {
@@ -986,12 +980,19 @@ static bool postcopy_try_recover(void)return false; } +void migration_incoming_process (void ) +{ +if (postcopy_try_recover ()) { +return ; + } + +Coroutine *co =qemu_coroutine_create (process_incoming_migration_co,NULL ); +qemu_coroutine_enter (co); +} +void migration_fd_process_incoming (QEMUFile *f) {migration_incoming_setup (f); -if (postcopy_try_recover ()) { -return ; - }migration_incoming_process (); }
@@ -1087,10 +1088,6 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) }if (migration_has_main_and_multifd_channels ()) { -/* If it's a recovery, we're done */ -if (postcopy_try_recover ()) { -return ; - }migration_incoming_process (); } }
Signature · 1 line
2.51.0
Re: [RFC PATCH 06/25] migration: Move postcopy_try_recover into migration_incoming_process
Quoted 10 lines · Fabiano Rosas
The
postcopy_try_recover()call doesn't need to be duplicated, move it intomigration_incoming_process().This removes code from
migration_fd_process_incoming()so it can be removed in the near future.(the diff is a bit strange because
migration_incoming_process()was moved afterpostcopy_try_recover())Signed-off-by Fabiano Rosas <[email protected]>
Signature · 1 line
Peter Xu
RFC PATCH 7/25 migration: Use migrate_mode() to query for cpr-transfer
In reply to Fabiano Rosascpr_set_incoming_mode() is only called on the target side, so migrate_mode() on the source side is the same as s->parameters.mode.
Use the function to reduce explicit access to s->parameters, we have options.c for that.
--- migration/migration.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
migration/migration.c +2 -2
@@ -2252,7 +2252,7 @@ void qmp_migrate(const char *uri, bool has_channels,return ; } -if (s->parameters.mode ==MIG_MODE_CPR_TRANSFER && !cpr_channel) { +if (migrate_mode () ==MIG_MODE_CPR_TRANSFER && !cpr_channel) {error_setg (errp,"missing 'cpr' migration channel" );return ; }
@@ -2277,7 +2277,7 @@ void qmp_migrate(const char *uri, bool has_channels,* in which case the target will not listen for the incoming migration * connection, so qmp_migrate_finish will fail to connect, and then recover. */ -if (s->parameters.mode ==MIG_MODE_CPR_TRANSFER ) { +if (migrate_mode () ==MIG_MODE_CPR_TRANSFER ) {migrate_hup_add (s,cpr_state_ioc (), (GSourceFunc )qmp_migrate_finish_cb,QAPI_CLONE (MigrationAddress, addr));
Signature · 1 line
2.51.0
Re: [RFC PATCH 07/25] migration: Use migrate_mode() to query for cpr-transfer
Quoted 7 lines · Fabiano Rosas
cpr_set_incoming_mode()is only called on the target side, somigrate_mode()on the source side is the same ass->parameters.mode.Use the function to reduce explicit access to
s->parameters, we haveoptions.cfor that.Signed-off-by Fabiano Rosas <[email protected]>
Said that, we have three more users outside options.c. Wanna do it together? They are:
migration_call_notifiers, migrate_mode_is_cpr, migrate_prepare.
Quoted 29 lines
--- migration/migration.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)migration/migration.c +2
-2@@ -2252,7 +2252,7 @@ void qmp_migrate(const char *uri, bool has_channels,return ; } -if (s->parameters.mode ==MIG_MODE_CPR_TRANSFER && !cpr_channel) { +if (migrate_mode () ==MIG_MODE_CPR_TRANSFER && !cpr_channel) {error_setg (errp,"missing 'cpr' migration channel" );return ; }@@ -2277,7 +2277,7 @@ void qmp_migrate(const char *uri, bool has_channels,* in which case the target will not listen for the incoming migration * connection, so qmp_migrate_finish will fail to connect, and then recover. */ -if (s->parameters.mode ==MIG_MODE_CPR_TRANSFER ) { +if (migrate_mode () ==MIG_MODE_CPR_TRANSFER ) {migrate_hup_add (s,cpr_state_ioc (), (GSourceFunc )qmp_migrate_finish_cb,QAPI_CLONE (MigrationAddress, addr));Signature · 1 line
2.51.0
Signature · 1 line
Peter Xu
Re: [RFC PATCH 07/25] migration: Use migrate_mode() to query for cpr-transfer
Quoted 7 lines · Peter Xu
Quoted 6 lines · Fabiano Rosas
cpr_set_incoming_mode()is only called on the target side, somigrate_mode()on the source side is the same ass->parameters.mode.Use the function to reduce explicit access to
s->parameters, we haveoptions.cfor that.
Quoted 9 lines
Quoted 1 line
Signed-off-by Fabiano Rosas <[email protected]>Reviewed-by Peter Xu <[email protected]>Said that, we have three more users outside
options.c. Wanna do it together? They are:
migration_call_notifiers,migrate_mode_is_cpr,migrate_prepare.
Yep
RFC PATCH 8/25 migration: Free the error earlier in the resume case
In reply to Fabiano RosasFreeing the error at migration_connect() is redundant in the normal migration case. The freeing already happened at migrate_init():
qmp_migrate()
-> migrate_prepare()
-> migrate_init()
-> qmp_migrate_finish()
-> *_start_outgoing_migration()
-> migration_channel_connect()
-> migration_connect()
For the resume case, migrate_prepare() returns early and doesn't reach migrate_init(). Move the extra migrate_error_free() call to migrate_prepare() along with the resume check.
--- migration/migration.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
migration/migration.c +7 -7
@@ -2088,6 +2088,13 @@ static bool migrate_prepare(MigrationState *s, bool resume, Error **errp)migrate_set_state (&s->state,MIGRATION_STATUS_POSTCOPY_PAUSED ,MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP ); +/* +* If there's a previous error, free it and prepare for +* another one. For the non-resume case, this happens at +* migrate_init() below. +*/ +migrate_error_free (s); +/* This is a resume, skip init status */ return true; }
@@ -4016,13 +4023,6 @@ void migration_connect(MigrationState *s, Error *error_in)bool resume = (s->state ==MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP );int ret; -/* -* If there's a previous error, free it and prepare for another one. -* Meanwhile if migration completes successfully, there won't have an error -* dumped when calling migration_cleanup(). -*/ -migrate_error_free (s); - s->expected_downtime =migrate_downtime_limit ();if (error_in) {migration_connect_error_propagate (s, error_in);
Signature · 1 line
2.51.0
Re: [RFC PATCH 08/25] migration: Free the error earlier in the resume case'
Quoted 9 lines · Fabiano Rosas
Freeing the error at
migration_connect()is redundant in the normal migration case. The freeing already happened atmigrate_init():
qmp_migrate()
->migrate_prepare()
->migrate_init()
->qmp_migrate_finish()
->*_start_outgoing_migration()
->migration_channel_connect()
Quoted 7 lines
-> migration_connect()For the resume case,
migrate_prepare()returns early and doesn't reachmigrate_init(). Move the extramigrate_error_free()call tomigrate_prepare()along with the resume check.Signed-off-by Fabiano Rosas <[email protected]>
We could also use migrate_error_free() in migrate_init(), to be clear on when the error can be erased.
Quoted 39 lines
--- migration/migration.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)migration/migration.c +7
-7@@ -2088,6 +2088,13 @@ static bool migrate_prepare(MigrationState *s, bool resume, Error **errp)migrate_set_state (&s->state,MIGRATION_STATUS_POSTCOPY_PAUSED ,MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP ); +/* +* If there's a previous error, free it and prepare for +* another one. For the non-resume case, this happens at +* migrate_init() below. +*/ +migrate_error_free (s); +/* This is a resume, skip init status */ return true; }@@ -4016,13 +4023,6 @@ void migration_connect(MigrationState *s, Error *error_in)bool resume = (s->state ==MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP );int ret; -/* -* If there's a previous error, free it and prepare for another one. -* Meanwhile if migration completes successfully, there won't have an error -* dumped when calling migration_cleanup(). -*/ -migrate_error_free (s); - s->expected_downtime =migrate_downtime_limit ();if (error_in) {migration_connect_error_propagate (s, error_in);Signature · 1 line
2.51.0
Signature · 1 line
Peter Xu
RFC PATCH 9/25 migration: Move error reporting out of migration_cleanup
In reply to Fabiano RosasIn the next patches migration_cleanup() will be used in qmp_migrate(), which currently does not show an error message. Move the error reporting out of migration_cleanup() to avoid duplicated messages.
--- migration/migration.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
migration/migration.c +13 -15
@@ -1528,10 +1528,6 @@ static void migration_cleanup(MigrationState *s) MIGRATION_STATUS_CANCELLED); } -if (s->error) { -/* It is used on info migrate. We can't free it */ -error_report_err (error_copy (s->error)); - } type =migration_has_failed (s) ?MIG_EVENT_PRECOPY_FAILED :MIG_EVENT_PRECOPY_DONE ;migration_call_notifiers (s, type,NULL );
@@ -1540,7 +1536,12 @@ static void migration_cleanup(MigrationState *s)static void migration_cleanup_bh (void *opaque) { -migration_cleanup (opaque); +MigrationState *s = opaque; + +migration_cleanup (s); +if (s->error) { +error_report_err (error_copy (s->error)); + } }/*
@@ -4026,18 +4027,12 @@ void migration_connect(MigrationState *s, Error *error_in) s->expected_downtime =migrate_downtime_limit ();if (error_in) {migration_connect_error_propagate (s, error_in); -if (resume) { -/* -* Don't do cleanup for resume if channel is invalid, but only dump -* the error. We wait for another channel connect from the user. -* The error_report still gives HMP user a hint on what failed. -* It's normally done in migration_cleanup(), but call it here -* explicitly. -*/ -error_report_err (error_copy (s->error)); - }else { +if (!resume) {migration_cleanup (s); } +if (s->error) { +error_report_err (error_copy (s->error)); + }return ; }
@@ -4118,6 +4113,9 @@ fail: }error_report_err (local_err);migration_cleanup (s); +if (s->error) { +error_report_err (error_copy (s->error)); + } }static void migration_class_init (ObjectClass *klass,const void *data)
Signature · 1 line
2.51.0
Re: [RFC PATCH 09/25] migration: Move error reporting out of migration_cleanup
Quoted 5 lines · Fabiano Rosas
In the next patches
migration_cleanup()will be used inqmp_migrate(), which currently does not show an error message. Move the error reporting out ofmigration_cleanup()to avoid duplicated messages.Signed-off-by Fabiano Rosas <[email protected]>
With one comment on top below:
Quoted 57 lines
--- migration/migration.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)migration/migration.c +10
-15@@ -1528,10 +1528,6 @@ static void migration_cleanup(MigrationState *s) MIGRATION_STATUS_CANCELLED); } -if (s->error) { -/* It is used on info migrate. We can't free it */ -error_report_err (error_copy (s->error)); - } type =migration_has_failed (s) ?MIG_EVENT_PRECOPY_FAILED :MIG_EVENT_PRECOPY_DONE ;migration_call_notifiers (s, type,NULL );@@ -1540,7 +1536,12 @@ static void migration_cleanup(MigrationState *s)static void migration_cleanup_bh (void *opaque) { -migration_cleanup (opaque); +MigrationState *s = opaque; + +migration_cleanup (s); +if (s->error) { +error_report_err (error_copy (s->error)); + } }/* @@ -4026,18 +4027,12 @@ void migration_connect(MigrationState *s, Error *error_in) s->expected_downtime =migrate_downtime_limit ();if (error_in) {migration_connect_error_propagate (s, error_in); -if (resume) { -/* -* Don't do cleanup for resume if channel is invalid, but only dump -* the error. We wait for another channel connect from the user. -* The error_report still gives HMP user a hint on what failed. -* It's normally done in migration_cleanup(), but call it here -* explicitly. -*/ -error_report_err (error_copy (s->error)); - }else { +if (!resume) {migration_cleanup (s); } +if (s->error) { +error_report_err (error_copy (s->error)); + }return ; }
migration/migration.c fail: · line 4114
Quoted 2 lines
migration/migration.c +0
-0@@ -4118,6 +4113,9 @@ fail: }error_report_err (local_err);
[1]
migration/migration.c void migration_connect(MigrationState *s, Error *error_in) · line 4035
Quoted 4 lines
migration/migration.c +3
-0migration_cleanup (s); +if (s->error) { +error_report_err (error_copy (s->error)); + }
This should keep no functional difference, which looks correct from that regard.
Said that, I wonder if we can drop [1] above, because when reaching here error_in must not be set, so I don't yet see how s->error can be different from local_err.
Quoted 6 lines
migration/migration.c +0
-0}static void migration_class_init (ObjectClass *klass,const void *data)Signature · 1 line
2.51.0
Signature · 1 line
Peter Xu
RFC PATCH 10/25 migration: Expand migration_connect_error_propagate to cover cancelling
In reply to Fabiano RosasCover the CANCELLING state in migration_connect_error_propagate() and use it to funnel errors from migrate_prepare() until the end of migration_connect().
(add some line breaks for legibility)
--- migration/migration.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
migration/migration.c +15 -9
@@ -1575,18 +1575,25 @@ static void migrate_error_free(MigrationState *s)static void migration_connect_error_propagate (MigrationState *s,Error *error) {MigrationStatus current = s->state; -MigrationStatus next; - -assert (s->to_dst_file ==NULL ); +MigrationStatus next =MIGRATION_STATUS_NONE ;switch (current) {case MIGRATION_STATUS_SETUP : next =MIGRATION_STATUS_FAILED ;break ; +case MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP :/* Never fail a postcopy migration; switch back to PAUSED instead */ next =MIGRATION_STATUS_POSTCOPY_PAUSED ;break ; + +case MIGRATION_STATUS_CANCELLING : +/* +* Don't move out of CANCELLING, the only valid transition is to +* CANCELLED, at migration_cleanup(). +*/ +break ; +default :/* * This really shouldn't happen. Just be careful to not crash a VM
@@ -1597,7 +1604,10 @@ static void migration_connect_error_propagate(MigrationState *s, Error *error)return ; } -migrate_set_state (&s->state, current, next); +if (next) { +migrate_set_state (&s->state, current, next); + } +migrate_error_propagate (s, error); }
@@ -4107,11 +4117,7 @@ void migration_connect(MigrationState *s, Error *error_in)return ; fail: -migrate_error_propagate (s,error_copy (local_err)); -if (s->state !=MIGRATION_STATUS_CANCELLING ) { -migrate_set_state (&s->state, s->state,MIGRATION_STATUS_FAILED ); - } -error_report_err (local_err); +migration_connect_error_propagate (s, local_err);migration_cleanup (s);if (s->error) {error_report_err (error_copy (s->error));
Signature · 1 line
2.51.0
Re: [RFC PATCH 10/25] migration: Expand migration_connect_error_propagate to cover cancelling
Quoted 57 lines · Fabiano Rosas
Cover the CANCELLING state in
migration_connect_error_propagate()and use it to funnel errors frommigrate_prepare()until the end ofmigration_connect().(add some line breaks for legibility)
Signed-off-by Fabiano Rosas <[email protected]>--- migration/migration.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)migration/migration.c +14
-4@@ -1575,18 +1575,25 @@ static void migrate_error_free(MigrationState *s)static void migration_connect_error_propagate (MigrationState *s,Error *error) {MigrationStatus current = s->state; -MigrationStatus next; - -assert (s->to_dst_file ==NULL ); +MigrationStatus next =MIGRATION_STATUS_NONE ;switch (current) {case MIGRATION_STATUS_SETUP : next =MIGRATION_STATUS_FAILED ;break ; +case MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP :/* Never fail a postcopy migration; switch back to PAUSED instead */ next =MIGRATION_STATUS_POSTCOPY_PAUSED ;break ; + +case MIGRATION_STATUS_CANCELLING : +/* +* Don't move out of CANCELLING, the only valid transition is to +* CANCELLED, at migration_cleanup(). +*/ +break ; +default :/* * This really shouldn't happen. Just be careful to not crash a VM @@ -1597,7 +1604,10 @@ static void migration_connect_error_propagate(MigrationState *s, Error *error)return ; } -migrate_set_state (&s->state, current, next); +if (next) { +migrate_set_state (&s->state, current, next); + } +migrate_error_propagate (s, error); }
migration/migration.c void migration_connect(MigrationState *s, Error *error_in) · line 4114
Quoted 8 lines
migration/migration.c +0
-5@@ -4107,11 +4117,7 @@ void migration_connect(MigrationState *s, Error *error_in)return ; fail: -migrate_error_propagate (s,error_copy (local_err)); -if (s->state !=MIGRATION_STATUS_CANCELLING ) { -migrate_set_state (&s->state, s->state,MIGRATION_STATUS_FAILED ); - } -error_report_err (local_err);
OK you removed this line here.. maybe it should belong to the previous patch?
If you agree, feel free to take:
Quoted 7 lines
migration/migration.c +1
-0+migration_connect_error_propagate (s, local_err);migration_cleanup (s);if (s->error) {error_report_err (error_copy (s->error));Signature · 1 line
2.51.0
Signature · 1 line
Peter Xu
RFC PATCH 11/25 migration: yank: Move register instance earlier
In reply to Fabiano RosasMove the register_instance call to migrate_prepare() so it can be paired with the unregister_instance at migration_cleanup(). Otherwise, the cleanup cannot be run when cpr_state_save() fails because the instance is registered only after it.
When resuming from a paused postcopy migration, migrate_prepare() returns early, but migration_cleanup() doesn't run, so the yank will remain paired.
--- migration/migration.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-)
migration/migration.c +8 -18
@@ -2181,11 +2181,12 @@ static bool migrate_prepare(MigrationState *s, bool resume, Error **errp)return false; } +yank_register_instance (MIGRATION_YANK_INSTANCE , &error_abort); +return true; } -static void qmp_migrate_finish (MigrationAddress *addr,bool resume_requested, -Error **errp); +static void qmp_migrate_finish (MigrationAddress *addr,Error **errp);static void migrate_hup_add (MigrationState *s,QIOChannel *ioc,GSourceFunc cb,void *opaque)
@@ -2210,7 +2211,7 @@ static gboolean qmp_migrate_finish_cb(QIOChannel *channel, {MigrationAddress *addr = opaque; -qmp_migrate_finish (addr, false,NULL ); +qmp_migrate_finish (addr,NULL );cpr_state_close ();migrate_hup_delete (migrate_get_current ());
@@ -2222,7 +2223,6 @@ void qmp_migrate(const char *uri, bool has_channels, MigrationChannelList *channels, bool has_detach, bool detach, bool has_resume, bool resume, Error **errp) { - bool resume_requested; Error *local_err = NULL;MigrationState *s =migrate_get_current ();g_autoptr (MigrationChannel) channel =NULL ;
@@ -2275,8 +2275,7 @@ void qmp_migrate(const char *uri, bool has_channels,return ; } - resume_requested = has_resume && resume; -if (!migrate_prepare (s, resume_requested, errp)) { +if (!migrate_prepare (s, has_resume && resume, errp)) {/* Error detected, put into errp */ return ; }
@@ -2300,28 +2299,22 @@ void qmp_migrate(const char *uri, bool has_channels, QAPI_CLONE(MigrationAddress, addr)); }else { -qmp_migrate_finish (addr, resume_requested, errp); +qmp_migrate_finish (addr, errp); } out:if (local_err) { +yank_unregister_instance (MIGRATION_YANK_INSTANCE );migration_connect_error_propagate (s,error_copy (local_err));error_propagate (errp, local_err); } } -static void qmp_migrate_finish (MigrationAddress *addr,bool resume_requested, -Error **errp) +static void qmp_migrate_finish (MigrationAddress *addr,Error **errp) {MigrationState *s =migrate_get_current ();Error *local_err =NULL ; -if (!resume_requested) { -if (!yank_register_instance (MIGRATION_YANK_INSTANCE , errp)) { -return ; - } - } -if (addr->transport ==MIGRATION_ADDRESS_TYPE_SOCKET ) {SocketAddress *saddr = &addr->u.socket; if (saddr->type == SOCKET_ADDRESS_TYPE_INET ||
@@ -2344,9 +2337,6 @@ static void qmp_migrate_finish(MigrationAddress *addr, bool resume_requested, }if (local_err) { -if (!resume_requested) { -yank_unregister_instance (MIGRATION_YANK_INSTANCE ); - }migration_connect_error_propagate (s,error_copy (local_err));error_propagate (errp, local_err);return ;
Signature · 1 line
2.51.0
Re: [RFC PATCH 11/25] migration: yank: Move register instance earlier
Quoted 10 lines · Fabiano Rosas
Move the
register_instancecall tomigrate_prepare()so it can be paired with theunregister_instanceatmigration_cleanup(). Otherwise, the cleanup cannot be run whencpr_state_save()fails because the instance is registered only after it.When resuming from a paused postcopy migration,
migrate_prepare()returns early, butmigration_cleanup()doesn't run, so the yank will remain paired.Signed-off-by Fabiano Rosas <[email protected]>
Signature · 1 line
Peter Xu
RFC PATCH 12/25 migration: Fold migration_cleanup() into migration_connect_error_propagate()
In reply to Fabiano RosasWhenever an error occurs between migrate_init() and the start of migration_thread, do cleanup immediately after.
This allows the special casing for resume to be removed from migration_connect(), that check is now done at migration_connect_error_propagate() which already had a case for resume.
--- migration/migration.c | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-)
migration/migration.c +27 -15
@@ -1576,15 +1576,21 @@ static void migration_connect_error_propagate(MigrationState *s, Error *error) {MigrationStatus current = s->state;MigrationStatus next =MIGRATION_STATUS_NONE ; +bool resume = false;switch (current) {case MIGRATION_STATUS_SETUP : next =MIGRATION_STATUS_FAILED ;break ; +case MIGRATION_STATUS_POSTCOPY_PAUSED : + resume = true; +break ; +case MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP :/* Never fail a postcopy migration; switch back to PAUSED instead */ next =MIGRATION_STATUS_POSTCOPY_PAUSED ; + resume = true;break ;case MIGRATION_STATUS_CANCELLING :
@@ -1609,6 +1615,10 @@ static void migration_connect_error_propagate(MigrationState *s, Error *error) }migrate_error_propagate (s, error); + +if (!resume) { +migration_cleanup (s); + } }void migration_cancel (void )
@@ -2209,12 +2219,19 @@ static gboolean qmp_migrate_finish_cb(QIOChannel *channel,GIOCondition cond, void *opaque) { + MigrationState *s = migrate_get_current();MigrationAddress *addr = opaque; +Error *local_err =NULL ; + +qmp_migrate_finish (addr, &local_err); + +if (local_err) { +migration_connect_error_propagate (s, local_err); + } -qmp_migrate_finish (addr,NULL );cpr_state_close (); -migrate_hup_delete (migrate_get_current ()); +migrate_hup_delete (s);qapi_free_MigrationAddress (addr);return G_SOURCE_REMOVE ; }
@@ -2223,7 +2240,6 @@ void qmp_migrate(const char *uri, bool has_channels, MigrationChannelList *channels, bool has_detach, bool detach, bool has_resume, bool resume, Error **errp) { - Error *local_err = NULL; MigrationState *s = migrate_get_current();g_autoptr (MigrationChannel) channel =NULL ;MigrationAddress *addr =NULL ;
@@ -2280,6 +2296,13 @@ void qmp_migrate(const char *uri, bool has_channels,return ; } +/* +* The migrate_prepare() above calls migrate_init(). From this +* point on, until the end of migration, make sure any failures +* eventually result in a call to migration_cleanup(). +*/ +Error *local_err =NULL ; +if (!cpr_state_save (cpr_channel, &local_err)) { goto out; }
@@ -2299,12 +2322,11 @@ void qmp_migrate(const char *uri, bool has_channels, QAPI_CLONE(MigrationAddress, addr)); }else { -qmp_migrate_finish (addr, errp); +qmp_migrate_finish (addr, &local_err); } out:if (local_err) { -yank_unregister_instance (MIGRATION_YANK_INSTANCE );migration_connect_error_propagate (s,error_copy (local_err));error_propagate (errp, local_err); }
@@ -2335,12 +2357,6 @@ static void qmp_migrate_finish(MigrationAddress *addr, Error **errp) }else {error_setg (&local_err,"uri is not a valid migration protocol" ); } - -if (local_err) { -migration_connect_error_propagate (s,error_copy (local_err)); -error_propagate (errp, local_err); -return ; - } }void qmp_migrate_cancel (Error **errp)
@@ -4027,9 +4043,6 @@ void migration_connect(MigrationState *s, Error *error_in) s->expected_downtime =migrate_downtime_limit ();if (error_in) {migration_connect_error_propagate (s, error_in); -if (!resume) { -migration_cleanup (s); - }if (s->error) {error_report_err (error_copy (s->error)); }
@@ -4108,7 +4121,6 @@ void migration_connect(MigrationState *s, Error *error_in) fail:migration_connect_error_propagate (s, local_err); -migration_cleanup (s);if (s->error) {error_report_err (error_copy (s->error)); }
Signature · 1 line
2.51.0
Re: [RFC PATCH 12/25] migration: Fold migration_cleanup() into migration_connect_error_propagate()
Quoted 9 lines · Fabiano Rosas
Whenever an error occurs between
migrate_init()and the start ofmigration_thread, do cleanup immediately after.This allows the special casing for resume to be removed from
migration_connect(), that check is now done atmigration_connect_error_propagate()which already had a case for resume.Signed-off-by Fabiano Rosas <[email protected]>
Didn't spot anything wrong,
One nitpick below,
Quoted 50 lines
--- migration/migration.c | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-)migration/migration.c +14
-0@@ -1576,15 +1576,21 @@ static void migration_connect_error_propagate(MigrationState *s, Error *error) {MigrationStatus current = s->state;MigrationStatus next =MIGRATION_STATUS_NONE ; +bool resume = false;switch (current) {case MIGRATION_STATUS_SETUP : next =MIGRATION_STATUS_FAILED ;break ; +case MIGRATION_STATUS_POSTCOPY_PAUSED : + resume = true; +break ; +case MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP :/* Never fail a postcopy migration; switch back to PAUSED instead */ next =MIGRATION_STATUS_POSTCOPY_PAUSED ; + resume = true;break ;case MIGRATION_STATUS_CANCELLING :@@ -1609,6 +1615,10 @@ static void migration_connect_error_propagate(MigrationState *s, Error *error) }migrate_error_propagate (s, error); + +if (!resume) { +migration_cleanup (s); + } }void migration_cancel (void )@@ -2209,12 +2219,19 @@ static gboolean qmp_migrate_finish_cb(QIOChannel *channel,GIOCondition cond, void *opaque) { + MigrationState *s = migrate_get_current();MigrationAddress *addr = opaque; +Error *local_err =NULL ; + +qmp_migrate_finish (addr, &local_err);
migration/migration.c static gboolean qmp_migrate_finish_cb(QIOChannel *channel, · line 2234
Quoted 10 lines
migration/migration.c +5
-2+ +if (local_err) { +migration_connect_error_propagate (s, local_err); + } -qmp_migrate_finish (addr,NULL );cpr_state_close (); -migrate_hup_delete (migrate_get_current ()); +migrate_hup_delete (s);
IMHO we should drop these two lines. For error cases, now they'll be done in migration_cleanup() above. Actually for success, it's the same, but in the cleanup BH.
Maybe there're other cases where we can clean the code a bit on cpr; there're codes that always does "if (xxx)" and calling them all over the places, so it's easy to write such code when drafting a feature, but hard to maintain, because it'll be obscure when it'll really trigger, like this one. We can leave the rest for later if there're applicable similar cleanups.
Quoted 73 lines
migration/migration.c +8
-13qapi_free_MigrationAddress (addr);return G_SOURCE_REMOVE ; }@@ -2223,7 +2240,6 @@ void qmp_migrate(const char *uri, bool has_channels, MigrationChannelList *channels, bool has_detach, bool detach, bool has_resume, bool resume, Error **errp) { - Error *local_err = NULL; MigrationState *s = migrate_get_current();g_autoptr (MigrationChannel) channel =NULL ;MigrationAddress *addr =NULL ;@@ -2280,6 +2296,13 @@ void qmp_migrate(const char *uri, bool has_channels,return ; } +/* +* The migrate_prepare() above calls migrate_init(). From this +* point on, until the end of migration, make sure any failures +* eventually result in a call to migration_cleanup(). +*/ +Error *local_err =NULL ; +if (!cpr_state_save (cpr_channel, &local_err)) { goto out; }@@ -2299,12 +2322,11 @@ void qmp_migrate(const char *uri, bool has_channels, QAPI_CLONE(MigrationAddress, addr)); }else { -qmp_migrate_finish (addr, errp); +qmp_migrate_finish (addr, &local_err); } out:if (local_err) { -yank_unregister_instance (MIGRATION_YANK_INSTANCE );migration_connect_error_propagate (s,error_copy (local_err));error_propagate (errp, local_err); }@@ -2335,12 +2357,6 @@ static void qmp_migrate_finish(MigrationAddress *addr, Error **errp) }else {error_setg (&local_err,"uri is not a valid migration protocol" ); } - -if (local_err) { -migration_connect_error_propagate (s,error_copy (local_err)); -error_propagate (errp, local_err); -return ; - } }void qmp_migrate_cancel (Error **errp)@@ -4027,9 +4043,6 @@ void migration_connect(MigrationState *s, Error *error_in) s->expected_downtime =migrate_downtime_limit ();if (error_in) {migration_connect_error_propagate (s, error_in); -if (!resume) { -migration_cleanup (s); - }if (s->error) {error_report_err (error_copy (s->error)); }@@ -4108,7 +4121,6 @@ void migration_connect(MigrationState *s, Error *error_in) fail:migration_connect_error_propagate (s, local_err); -migration_cleanup (s);if (s->error) {error_report_err (error_copy (s->error)); }Signature · 1 line
2.51.0
Signature · 1 line
Peter Xu
Re: [RFC PATCH 12/25] migration: Fold migration_cleanup() into migration_connect_error_propagate()
Quoted 74 lines · Peter Xu
Quoted 9 lines · Fabiano Rosas
Whenever an error occurs between
migrate_init()and the start ofmigration_thread, do cleanup immediately after.This allows the special casing for resume to be removed from
migration_connect(), that check is now done atmigration_connect_error_propagate()which already had a case for resume.Signed-off-by Fabiano Rosas <[email protected]>Didn't spot anything wrong,
Reviewed-by Peter Xu <[email protected]>One nitpick below,
Quoted 57 lines
--- migration/migration.c | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-)migration/migration.c +18
-1@@ -1576,15 +1576,21 @@ static void migration_connect_error_propagate(MigrationState *s, Error *error) {MigrationStatus current = s->state;MigrationStatus next =MIGRATION_STATUS_NONE ; +bool resume = false;switch (current) {case MIGRATION_STATUS_SETUP : next =MIGRATION_STATUS_FAILED ;break ; +case MIGRATION_STATUS_POSTCOPY_PAUSED : + resume = true; +break ; +case MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP :/* Never fail a postcopy migration; switch back to PAUSED instead */ next =MIGRATION_STATUS_POSTCOPY_PAUSED ; + resume = true;break ;case MIGRATION_STATUS_CANCELLING :@@ -1609,6 +1615,10 @@ static void migration_connect_error_propagate(MigrationState *s, Error *error) }migrate_error_propagate (s, error); + +if (!resume) { +migration_cleanup (s); + } }void migration_cancel (void )@@ -2209,12 +2219,19 @@ static gboolean qmp_migrate_finish_cb(QIOChannel *channel,GIOCondition cond, void *opaque) { + MigrationState *s = migrate_get_current();MigrationAddress *addr = opaque; +Error *local_err =NULL ; + +qmp_migrate_finish (addr, &local_err); + +if (local_err) { +migration_connect_error_propagate (s, local_err); + } -qmp_migrate_finish (addr,NULL );
Quoted 8 lines
migration/migration.c static gboolean qmp_migrate_finish_cb(QIOChannel *channel, · line 2234
Quoted 3 lines
migration/migration.c +1
-1cpr_state_close (); -migrate_hup_delete (migrate_get_current ()); +migrate_hup_delete (s);IMHO we should drop these two lines. For error cases, now they'll be done in
migration_cleanup()above. Actually for success, it's the same, but in the cleanup BH.
Hmm that would be good, I'll look into it.
Quoted 80 lines
Maybe there're other cases where we can clean the code a bit on cpr; there're codes that always does "if (xxx)" and calling them all over the places, so it's easy to write such code when drafting a feature, but hard to maintain, because it'll be obscure when it'll really trigger, like this one. We can leave the rest for later if there're applicable similar cleanups.
Quoted 73 lines
migration/migration.c +8
-13qapi_free_MigrationAddress (addr);return G_SOURCE_REMOVE ; }@@ -2223,7 +2240,6 @@ void qmp_migrate(const char *uri, bool has_channels, MigrationChannelList *channels, bool has_detach, bool detach, bool has_resume, bool resume, Error **errp) { - Error *local_err = NULL; MigrationState *s = migrate_get_current();g_autoptr (MigrationChannel) channel =NULL ;MigrationAddress *addr =NULL ;@@ -2280,6 +2296,13 @@ void qmp_migrate(const char *uri, bool has_channels,return ; } +/* +* The migrate_prepare() above calls migrate_init(). From this +* point on, until the end of migration, make sure any failures +* eventually result in a call to migration_cleanup(). +*/ +Error *local_err =NULL ; +if (!cpr_state_save (cpr_channel, &local_err)) { goto out; }@@ -2299,12 +2322,11 @@ void qmp_migrate(const char *uri, bool has_channels, QAPI_CLONE(MigrationAddress, addr)); }else { -qmp_migrate_finish (addr, errp); +qmp_migrate_finish (addr, &local_err); } out:if (local_err) { -yank_unregister_instance (MIGRATION_YANK_INSTANCE );migration_connect_error_propagate (s,error_copy (local_err));error_propagate (errp, local_err); }@@ -2335,12 +2357,6 @@ static void qmp_migrate_finish(MigrationAddress *addr, Error **errp) }else {error_setg (&local_err,"uri is not a valid migration protocol" ); } - -if (local_err) { -migration_connect_error_propagate (s,error_copy (local_err)); -error_propagate (errp, local_err); -return ; - } }void qmp_migrate_cancel (Error **errp)@@ -4027,9 +4043,6 @@ void migration_connect(MigrationState *s, Error *error_in) s->expected_downtime =migrate_downtime_limit ();if (error_in) {migration_connect_error_propagate (s, error_in); -if (!resume) { -migration_cleanup (s); - }if (s->error) {error_report_err (error_copy (s->error)); }@@ -4108,7 +4121,6 @@ void migration_connect(MigrationState *s, Error *error_in) fail:migration_connect_error_propagate (s, local_err); -migration_cleanup (s);if (s->error) {error_report_err (error_copy (s->error)); }Signature · 1 line
2.51.0
RFC PATCH 13/25 migration: Handle error in the early async paths
In reply to Fabiano RosasSimplify migration_channel_connect() and migration_connect() to not take an error as input. Move the error handling into the paths that generate the error.
To achive this, call migration_connect_error_propagate() from socket.c and tls.c, which are the async paths.
For the sync paths, the handling is done as normal by returning all the way to qmp_migrate_finish(), except that now the sync paths don't pass the error forward into migration_connect() anymore.
--- migration/channel.c | 46 +++++++++++++++++------------------------- migration/channel.h | 4 +--- migration/exec.c | 2 +- migration/fd.c | 2 +- migration/file.c | 2 +- migration/migration.c | 11 ++-------- migration/migration.h | 3 ++- migration/rdma.c | 2 +- migration/socket.c | 17 ++++++++-------- migration/tls.c | 19 ++++++++--------- migration/tls.h | 4 +--- migration/trace-events | 2 +- 12 files changed, 49 insertions(+), 65 deletions(-)
migration/channel.c +19 -27
@@ -60,38 +60,30 @@ void migration_channel_process_incoming(QIOChannel *ioc)* * @s: Current migration state * @ioc: Channel to which we are connecting -* @error: Error indicating failure to connect, free'd here */ -void migration_channel_connect (MigrationState *s, -QIOChannel *ioc, -Error *error) +void migration_channel_connect (MigrationState *s,QIOChannel *ioc) { -trace_migration_set_outgoing_channel ( - ioc,object_get_typename (OBJECT (ioc)), error); +trace_migration_set_outgoing_channel (ioc,object_get_typename (OBJECT (ioc))); -if (!error) { -if (migrate_channel_requires_tls_upgrade (ioc)) { -migration_tls_channel_connect (s, ioc, &error); +if (migrate_channel_requires_tls_upgrade (ioc)) { +migration_tls_channel_connect (s, ioc); -if (!error) { -/* tls_channel_connect will call back to this -* function after the TLS handshake, -* so we mustn't call migration_connect until then -*/ - -return ; - } - }else { -QEMUFile *f =qemu_file_new_output (ioc); - -migration_ioc_register_yank (ioc); - -qemu_mutex_lock (&s->qemu_file_lock); - s->to_dst_file = f; -qemu_mutex_unlock (&s->qemu_file_lock); - } +/* +* async: the above will call back to this function after +* the TLS handshake is successfully completed. +*/ +return ; } -migration_connect (s, error); + +QEMUFile *f =qemu_file_new_output (ioc); + +migration_ioc_register_yank (ioc); + +qemu_mutex_lock (&s->qemu_file_lock); + s->to_dst_file = f; +qemu_mutex_unlock (&s->qemu_file_lock); + +migration_connect (s); }
migration/channel.h +1 -3
@@ -20,9 +20,7 @@void migration_channel_process_incoming (QIOChannel *ioc); -void migration_channel_connect (MigrationState *s, -QIOChannel *ioc, -Error *error_in); +void migration_channel_connect (MigrationState *s,QIOChannel *ioc); int migration_channel_read_peek(QIOChannel *ioc, const char *buf,
migration/exec.c +1 -1
@@ -55,7 +55,7 @@ void exec_start_outgoing_migration(MigrationState *s, strList *command, }qio_channel_set_name (ioc,"migration-exec-outgoing" ); -migration_channel_connect (s, ioc,NULL ); +migration_channel_connect (s, ioc);object_unref (OBJECT (ioc)); }
migration/fd.c +1 -1
@@ -70,7 +70,7 @@ void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error ** }qio_channel_set_name (ioc,"migration-fd-outgoing" ); -migration_channel_connect (s, ioc,NULL ); +migration_channel_connect (s, ioc);object_unref (OBJECT (ioc)); }
migration/file.c +1 -1
@@ -122,7 +122,7 @@ void file_start_outgoing_migration(MigrationState *s,return ; }qio_channel_set_name (ioc,"migration-file-outgoing" ); -migration_channel_connect (s, ioc,NULL ); +migration_channel_connect (s, ioc); } static gboolean file_accept_incoming_migration(QIOChannel *ioc,
migration/migration.c +2 -9
@@ -1572,7 +1572,7 @@ static void migrate_error_free(MigrationState *s) } } -static void migration_connect_error_propagate (MigrationState *s,Error *error) +void migration_connect_error_propagate (MigrationState *s,Error *error) {MigrationStatus current = s->state;MigrationStatus next =MIGRATION_STATUS_NONE ;
@@ -4033,7 +4033,7 @@ fail_setup:return NULL ; } -void migration_connect (MigrationState *s,Error *error_in) +void migration_connect (MigrationState *s) {Error *local_err =NULL ;uint64_t rate_limit;
@@ -4041,13 +4041,6 @@ void migration_connect(MigrationState *s, Error *error_in)int ret; s->expected_downtime =migrate_downtime_limit (); -if (error_in) { -migration_connect_error_propagate (s, error_in); -if (s->error) { -error_report_err (error_copy (s->error)); - } -return ; - }if (resume) {/* This is a resumed migration */
migration/migration.h +2 -1
@@ -532,10 +532,11 @@ void migration_incoming_process(void);bool migration_has_all_channels (void ); +void migration_connect_error_propagate (MigrationState *s,Error *error);void migrate_error_propagate (MigrationState *s,Error *error);bool migrate_has_error (MigrationState *s); -void migration_connect (MigrationState *s,Error *error_in); +void migration_connect (MigrationState *s);int migration_call_notifiers (MigrationState *s,MigrationEventType type,Error **errp);
migration/rdma.c +1 -1
@@ -3997,7 +3997,7 @@ void rdma_start_outgoing_migration(void *opaque, s->to_dst_file =rdma_new_output (rdma); s->rdma_migration = true; -migration_connect (s,NULL ); +migration_connect (s);return ; return_path_err:qemu_rdma_cleanup (rdma);
migration/socket.c +9 -8
@@ -59,24 +59,25 @@ static void socket_outgoing_migration(QIOTask *task, gpointer opaque) {struct SocketConnectData *data = opaque; -QIOChannel *sioc =QIO_CHANNEL (qio_task_get_source (task)); +g_autoptr (QIOChannel) sioc =QIO_CHANNEL (qio_task_get_source (task));Error *err =NULL ;if (qio_task_propagate_error (task, &err)) { -trace_migration_socket_outgoing_error (error_get_pretty (err)); - goto out; + goto err; } -trace_migration_socket_outgoing_connected (); -if (migrate_zero_copy_send () && !qio_channel_has_feature (sioc,QIO_CHANNEL_FEATURE_WRITE_ZERO_COPY )) {error_setg (&err,"Zero copy send feature not detected in host kernel" ); + goto err; } -out: -migration_channel_connect (data->s, sioc, err); -object_unref (OBJECT (sioc)); +trace_migration_socket_outgoing_connected (); +migration_channel_connect (data->s, sioc); +return ; +err: +trace_migration_socket_outgoing_error (error_get_pretty (err)); +migration_connect_error_propagate (data->s, err); } void socket_start_outgoing_migration(MigrationState *s,
migration/tls.c +10 -9
@@ -104,16 +104,17 @@ static void migration_tls_outgoing_handshake(QIOTask *task, gpointer opaque) {MigrationState *s = opaque; -QIOChannel *ioc =QIO_CHANNEL (qio_task_get_source (task)); +g_autoptr (QIOChannel) ioc =QIO_CHANNEL (qio_task_get_source (task));Error *err =NULL ;if (qio_task_propagate_error (task, &err)) {trace_migration_tls_outgoing_handshake_error (error_get_pretty (err)); - }else { -trace_migration_tls_outgoing_handshake_complete (); +migration_connect_error_propagate (s, err); +return ; } -migration_channel_connect (s, ioc, err); -object_unref (OBJECT (ioc)); + +trace_migration_tls_outgoing_handshake_complete (); +migration_channel_connect (s, ioc); } QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc,
@@ -129,14 +130,14 @@ QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc,return qio_channel_tls_new_client (ioc, creds,migrate_tls_hostname (), errp); } -void migration_tls_channel_connect (MigrationState *s, -QIOChannel *ioc, -Error **errp) +void migration_tls_channel_connect (MigrationState *s,QIOChannel *ioc) {QIOChannelTLS *tioc; +Error *local_err =NULL ; - tioc =migration_tls_client_create (ioc, errp); + tioc =migration_tls_client_create (ioc, &local_err);if (!tioc) { +migration_connect_error_propagate (s, local_err);return ; }
migration/tls.h +1 -3
@@ -29,9 +29,7 @@ void migration_tls_channel_process_incoming(QIOChannel *ioc, Error **errp);QIOChannelTLS *migration_tls_client_create (QIOChannel *ioc,Error **errp); -void migration_tls_channel_connect (MigrationState *s, -QIOChannel *ioc, -Error **errp); +void migration_tls_channel_connect (MigrationState *s,QIOChannel *ioc);void migration_tls_channel_end (QIOChannel *ioc,Error **errp);/* Whether the QIO channel requires further TLS handshake? */ bool migrate_channel_requires_tls_upgrade (QIOChannel *ioc);
migration/trace-events +1 -1
@@ -204,7 +204,7 @@ migration_transferred_bytes(uint64_t qemu_file, uint64_t multifd, uint64_t rdma) # channel.c migration_set_incoming_channel(void *ioc, const char *ioctype) "ioc=%p ioctype=%s" -migration_set_outgoing_channel(void *ioc, const char *ioctype, void *err) "ioc=%p ioctype=%s err=%p" +migration_set_outgoing_channel(void *ioc, const char *ioctype) "ioc=%p ioctype=%s" # global_state.c migrate_state_too_big(void) ""
Signature · 1 line
2.51.0
Re: [RFC PATCH 13/25] migration: Handle error in the early async paths
Quoted 4 lines · Fabiano Rosas
Simplify
migration_channel_connect()andmigration_connect()to not take an error as input. Move the error handling into the paths that generate the error.
Quoted 8 lines
To achive this, call
migration_connect_error_propagate()fromsocket.candtls.c, which are the async paths.For the sync paths, the handling is done as normal by returning all the way to
qmp_migrate_finish(), except that now the sync paths don't pass the error forward intomigration_connect()anymore.Signed-off-by Fabiano Rosas <[email protected]>
Yeah this looks better in general, feel free to take:
One thing to mention:
Strictly speaking, migration_tls_channel_connect() doesn't fall into the "async op" category - it was invoked from migration core, so logically it can still keep its errp, then the migration core should also be able to process the error in migration_channel_connect(). It's not like the other two "async ops" where migration context was lost.
IOW, I can kind of see why we used to pass an Error into the current migration_channel_connect(), and it still makes some sense. OTOH, it doesn't really make sense to me to keep passing it to migration_connect()..
But since that's the only user of migration_tls_channel_connect(), I assume it's not a huge deal, anyway.
Quoted 312 lines
--- migration/channel.c | 46 +++++++++++++++++------------------------- migration/channel.h | 4 +--- migration/exec.c | 2 +- migration/fd.c | 2 +- migration/file.c | 2 +- migration/migration.c | 11 ++-------- migration/migration.h | 3 ++- migration/rdma.c | 2 +- migration/socket.c | 17 ++++++++-------- migration/tls.c | 19 ++++++++--------- migration/tls.h | 4 +--- migration/trace-events | 2 +- 12 files changed, 49 insertions(+), 65 deletions(-)migration/channel.c +19
-27@@ -60,38 +60,30 @@ void migration_channel_process_incoming(QIOChannel *ioc)* * @s: Current migration state * @ioc: Channel to which we are connecting -* @error: Error indicating failure to connect, free'd here */ -void migration_channel_connect (MigrationState *s, -QIOChannel *ioc, -Error *error) +void migration_channel_connect (MigrationState *s,QIOChannel *ioc) { -trace_migration_set_outgoing_channel ( - ioc,object_get_typename (OBJECT (ioc)), error); +trace_migration_set_outgoing_channel (ioc,object_get_typename (OBJECT (ioc))); -if (!error) { -if (migrate_channel_requires_tls_upgrade (ioc)) { -migration_tls_channel_connect (s, ioc, &error); +if (migrate_channel_requires_tls_upgrade (ioc)) { +migration_tls_channel_connect (s, ioc); -if (!error) { -/* tls_channel_connect will call back to this -* function after the TLS handshake, -* so we mustn't call migration_connect until then -*/ - -return ; - } - }else { -QEMUFile *f =qemu_file_new_output (ioc); - -migration_ioc_register_yank (ioc); - -qemu_mutex_lock (&s->qemu_file_lock); - s->to_dst_file = f; -qemu_mutex_unlock (&s->qemu_file_lock); - } +/* +* async: the above will call back to this function after +* the TLS handshake is successfully completed. +*/ +return ; } -migration_connect (s, error); + +QEMUFile *f =qemu_file_new_output (ioc); + +migration_ioc_register_yank (ioc); + +qemu_mutex_lock (&s->qemu_file_lock); + s->to_dst_file = f; +qemu_mutex_unlock (&s->qemu_file_lock); + +migration_connect (s); }migration/channel.h +1
-3@@ -20,9 +20,7 @@void migration_channel_process_incoming (QIOChannel *ioc); -void migration_channel_connect (MigrationState *s, -QIOChannel *ioc, -Error *error_in); +void migration_channel_connect (MigrationState *s,QIOChannel *ioc); int migration_channel_read_peek(QIOChannel *ioc, const char *buf,migration/exec.c +1
-1@@ -55,7 +55,7 @@ void exec_start_outgoing_migration(MigrationState *s, strList *command, }qio_channel_set_name (ioc,"migration-exec-outgoing" ); -migration_channel_connect (s, ioc,NULL ); +migration_channel_connect (s, ioc);object_unref (OBJECT (ioc)); }migration/fd.c +1
-1@@ -70,7 +70,7 @@ void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error ** }qio_channel_set_name (ioc,"migration-fd-outgoing" ); -migration_channel_connect (s, ioc,NULL ); +migration_channel_connect (s, ioc);object_unref (OBJECT (ioc)); }migration/file.c +1
-1@@ -122,7 +122,7 @@ void file_start_outgoing_migration(MigrationState *s,return ; }qio_channel_set_name (ioc,"migration-file-outgoing" ); -migration_channel_connect (s, ioc,NULL ); +migration_channel_connect (s, ioc); } static gboolean file_accept_incoming_migration(QIOChannel *ioc,migration/migration.c +2
-9@@ -1572,7 +1572,7 @@ static void migrate_error_free(MigrationState *s) } } -static void migration_connect_error_propagate (MigrationState *s,Error *error) +void migration_connect_error_propagate (MigrationState *s,Error *error) {MigrationStatus current = s->state;MigrationStatus next =MIGRATION_STATUS_NONE ;@@ -4033,7 +4033,7 @@ fail_setup:return NULL ; } -void migration_connect (MigrationState *s,Error *error_in) +void migration_connect (MigrationState *s) {Error *local_err =NULL ;uint64_t rate_limit;@@ -4041,13 +4041,6 @@ void migration_connect(MigrationState *s, Error *error_in)int ret; s->expected_downtime =migrate_downtime_limit (); -if (error_in) { -migration_connect_error_propagate (s, error_in); -if (s->error) { -error_report_err (error_copy (s->error)); - } -return ; - }if (resume) {/* This is a resumed migration */ migration/migration.h +2
-1@@ -532,10 +532,11 @@ void migration_incoming_process(void);bool migration_has_all_channels (void ); +void migration_connect_error_propagate (MigrationState *s,Error *error);void migrate_error_propagate (MigrationState *s,Error *error);bool migrate_has_error (MigrationState *s); -void migration_connect (MigrationState *s,Error *error_in); +void migration_connect (MigrationState *s);int migration_call_notifiers (MigrationState *s,MigrationEventType type,Error **errp);migration/rdma.c +1
-1@@ -3997,7 +3997,7 @@ void rdma_start_outgoing_migration(void *opaque, s->to_dst_file =rdma_new_output (rdma); s->rdma_migration = true; -migration_connect (s,NULL ); +migration_connect (s);return ; return_path_err:qemu_rdma_cleanup (rdma);migration/socket.c +9
-8@@ -59,24 +59,25 @@ static void socket_outgoing_migration(QIOTask *task, gpointer opaque) {struct SocketConnectData *data = opaque; -QIOChannel *sioc =QIO_CHANNEL (qio_task_get_source (task)); +g_autoptr (QIOChannel) sioc =QIO_CHANNEL (qio_task_get_source (task));Error *err =NULL ;if (qio_task_propagate_error (task, &err)) { -trace_migration_socket_outgoing_error (error_get_pretty (err)); - goto out; + goto err; } -trace_migration_socket_outgoing_connected (); -if (migrate_zero_copy_send () && !qio_channel_has_feature (sioc,QIO_CHANNEL_FEATURE_WRITE_ZERO_COPY )) {error_setg (&err,"Zero copy send feature not detected in host kernel" ); + goto err; } -out: -migration_channel_connect (data->s, sioc, err); -object_unref (OBJECT (sioc)); +trace_migration_socket_outgoing_connected (); +migration_channel_connect (data->s, sioc); +return ; +err: +trace_migration_socket_outgoing_error (error_get_pretty (err)); +migration_connect_error_propagate (data->s, err); } void socket_start_outgoing_migration(MigrationState *s,migration/tls.c +10
-9@@ -104,16 +104,17 @@ static void migration_tls_outgoing_handshake(QIOTask *task, gpointer opaque) {MigrationState *s = opaque; -QIOChannel *ioc =QIO_CHANNEL (qio_task_get_source (task)); +g_autoptr (QIOChannel) ioc =QIO_CHANNEL (qio_task_get_source (task));Error *err =NULL ;if (qio_task_propagate_error (task, &err)) {trace_migration_tls_outgoing_handshake_error (error_get_pretty (err)); - }else { -trace_migration_tls_outgoing_handshake_complete (); +migration_connect_error_propagate (s, err); +return ; } -migration_channel_connect (s, ioc, err); -object_unref (OBJECT (ioc)); + +trace_migration_tls_outgoing_handshake_complete (); +migration_channel_connect (s, ioc); } QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc,@@ -129,14 +130,14 @@ QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc,return qio_channel_tls_new_client (ioc, creds,migrate_tls_hostname (), errp); } -void migration_tls_channel_connect (MigrationState *s, -QIOChannel *ioc, -Error **errp) +void migration_tls_channel_connect (MigrationState *s,QIOChannel *ioc) {QIOChannelTLS *tioc; +Error *local_err =NULL ; - tioc =migration_tls_client_create (ioc, errp); + tioc =migration_tls_client_create (ioc, &local_err);if (!tioc) { +migration_connect_error_propagate (s, local_err);return ; }migration/tls.h +1
-3@@ -29,9 +29,7 @@ void migration_tls_channel_process_incoming(QIOChannel *ioc, Error **errp);QIOChannelTLS *migration_tls_client_create (QIOChannel *ioc,Error **errp); -void migration_tls_channel_connect (MigrationState *s, -QIOChannel *ioc, -Error **errp); +void migration_tls_channel_connect (MigrationState *s,QIOChannel *ioc);void migration_tls_channel_end (QIOChannel *ioc,Error **errp);/* Whether the QIO channel requires further TLS handshake? */ bool migrate_channel_requires_tls_upgrade (QIOChannel *ioc);migration/trace-events +1
-1@@ -204,7 +204,7 @@ migration_transferred_bytes(uint64_t qemu_file, uint64_t multifd, uint64_t rdma) # channel.c migration_set_incoming_channel(void *ioc, const char *ioctype) "ioc=%p ioctype=%s" -migration_set_outgoing_channel(void *ioc, const char *ioctype, void *err) "ioc=%p ioctype=%s err=%p" +migration_set_outgoing_channel(void *ioc, const char *ioctype) "ioc=%p ioctype=%s" # global_state.c migrate_state_too_big(void) ""Signature · 1 line
2.51.0
Signature · 1 line
Peter Xu
Re: [RFC PATCH 13/25] migration: Handle error in the early async paths
Quoted 18 lines · Peter Xu
Quoted 4 lines · Fabiano Rosas
Simplify
migration_channel_connect()andmigration_connect()to not take an error as input. Move the error handling into the paths that generate the error.Quoted 8 lines
To achive this, call
migration_connect_error_propagate()fromsocket.candtls.c, which are the async paths.For the sync paths, the handling is done as normal by returning all the way to
qmp_migrate_finish(), except that now the sync paths don't pass the error forward intomigration_connect()anymore.Signed-off-by Fabiano Rosas <[email protected]>Yeah this looks better in general, feel free to take:
Reviewed-by Peter Xu <[email protected]>
Quoted 8 lines
One thing to mention:
Strictly speaking,
migration_tls_channel_connect()doesn't fall into the "async op" category - it was invoked from migration core, so logically it can still keep its errp, then the migration core should also be able to process the error inmigration_channel_connect(). It's not like the other two "async ops" where migration context was lost.
I actually had it return the error in a previous version. Let me check if it still makes sense to do that.
Quoted 2 lines
IOW, I can kind of see why we used to pass an Error into the current
migration_channel_connect(), and it still makes some sense.
Yes, it was definitely not incorrect. I just think it's become a surprising thing to do given how the code has evolved.
Quoted 318 lines
OTOH, it doesn't really make sense to me to keep passing it to
migration_connect()..But since that's the only user of
migration_tls_channel_connect(), I assume it's not a huge deal, anyway.Quoted 312 lines
--- migration/channel.c | 46 +++++++++++++++++------------------------- migration/channel.h | 4 +--- migration/exec.c | 2 +- migration/fd.c | 2 +- migration/file.c | 2 +- migration/migration.c | 11 ++-------- migration/migration.h | 3 ++- migration/rdma.c | 2 +- migration/socket.c | 17 ++++++++-------- migration/tls.c | 19 ++++++++--------- migration/tls.h | 4 +--- migration/trace-events | 2 +- 12 files changed, 49 insertions(+), 65 deletions(-)migration/channel.c +19
-27@@ -60,38 +60,30 @@ void migration_channel_process_incoming(QIOChannel *ioc)* * @s: Current migration state * @ioc: Channel to which we are connecting -* @error: Error indicating failure to connect, free'd here */ -void migration_channel_connect (MigrationState *s, -QIOChannel *ioc, -Error *error) +void migration_channel_connect (MigrationState *s,QIOChannel *ioc) { -trace_migration_set_outgoing_channel ( - ioc,object_get_typename (OBJECT (ioc)), error); +trace_migration_set_outgoing_channel (ioc,object_get_typename (OBJECT (ioc))); -if (!error) { -if (migrate_channel_requires_tls_upgrade (ioc)) { -migration_tls_channel_connect (s, ioc, &error); +if (migrate_channel_requires_tls_upgrade (ioc)) { +migration_tls_channel_connect (s, ioc); -if (!error) { -/* tls_channel_connect will call back to this -* function after the TLS handshake, -* so we mustn't call migration_connect until then -*/ - -return ; - } - }else { -QEMUFile *f =qemu_file_new_output (ioc); - -migration_ioc_register_yank (ioc); - -qemu_mutex_lock (&s->qemu_file_lock); - s->to_dst_file = f; -qemu_mutex_unlock (&s->qemu_file_lock); - } +/* +* async: the above will call back to this function after +* the TLS handshake is successfully completed. +*/ +return ; } -migration_connect (s, error); + +QEMUFile *f =qemu_file_new_output (ioc); + +migration_ioc_register_yank (ioc); + +qemu_mutex_lock (&s->qemu_file_lock); + s->to_dst_file = f; +qemu_mutex_unlock (&s->qemu_file_lock); + +migration_connect (s); }migration/channel.h +1
-3@@ -20,9 +20,7 @@void migration_channel_process_incoming (QIOChannel *ioc); -void migration_channel_connect (MigrationState *s, -QIOChannel *ioc, -Error *error_in); +void migration_channel_connect (MigrationState *s,QIOChannel *ioc); int migration_channel_read_peek(QIOChannel *ioc, const char *buf,migration/exec.c +1
-1@@ -55,7 +55,7 @@ void exec_start_outgoing_migration(MigrationState *s, strList *command, }qio_channel_set_name (ioc,"migration-exec-outgoing" ); -migration_channel_connect (s, ioc,NULL ); +migration_channel_connect (s, ioc);object_unref (OBJECT (ioc)); }migration/fd.c +1
-1@@ -70,7 +70,7 @@ void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error ** }qio_channel_set_name (ioc,"migration-fd-outgoing" ); -migration_channel_connect (s, ioc,NULL ); +migration_channel_connect (s, ioc);object_unref (OBJECT (ioc)); }migration/file.c +1
-1@@ -122,7 +122,7 @@ void file_start_outgoing_migration(MigrationState *s,return ; }qio_channel_set_name (ioc,"migration-file-outgoing" ); -migration_channel_connect (s, ioc,NULL ); +migration_channel_connect (s, ioc); } static gboolean file_accept_incoming_migration(QIOChannel *ioc,migration/migration.c +2
-9@@ -1572,7 +1572,7 @@ static void migrate_error_free(MigrationState *s) } } -static void migration_connect_error_propagate (MigrationState *s,Error *error) +void migration_connect_error_propagate (MigrationState *s,Error *error) {MigrationStatus current = s->state;MigrationStatus next =MIGRATION_STATUS_NONE ;@@ -4033,7 +4033,7 @@ fail_setup:return NULL ; } -void migration_connect (MigrationState *s,Error *error_in) +void migration_connect (MigrationState *s) {Error *local_err =NULL ;uint64_t rate_limit;@@ -4041,13 +4041,6 @@ void migration_connect(MigrationState *s, Error *error_in)int ret; s->expected_downtime =migrate_downtime_limit (); -if (error_in) { -migration_connect_error_propagate (s, error_in); -if (s->error) { -error_report_err (error_copy (s->error)); - } -return ; - }if (resume) {/* This is a resumed migration */ migration/migration.h +2
-1@@ -532,10 +532,11 @@ void migration_incoming_process(void);bool migration_has_all_channels (void ); +void migration_connect_error_propagate (MigrationState *s,Error *error);void migrate_error_propagate (MigrationState *s,Error *error);bool migrate_has_error (MigrationState *s); -void migration_connect (MigrationState *s,Error *error_in); +void migration_connect (MigrationState *s);int migration_call_notifiers (MigrationState *s,MigrationEventType type,Error **errp);migration/rdma.c +1
-1@@ -3997,7 +3997,7 @@ void rdma_start_outgoing_migration(void *opaque, s->to_dst_file =rdma_new_output (rdma); s->rdma_migration = true; -migration_connect (s,NULL ); +migration_connect (s);return ; return_path_err:qemu_rdma_cleanup (rdma);migration/socket.c +9
-8@@ -59,24 +59,25 @@ static void socket_outgoing_migration(QIOTask *task, gpointer opaque) {struct SocketConnectData *data = opaque; -QIOChannel *sioc =QIO_CHANNEL (qio_task_get_source (task)); +g_autoptr (QIOChannel) sioc =QIO_CHANNEL (qio_task_get_source (task));Error *err =NULL ;if (qio_task_propagate_error (task, &err)) { -trace_migration_socket_outgoing_error (error_get_pretty (err)); - goto out; + goto err; } -trace_migration_socket_outgoing_connected (); -if (migrate_zero_copy_send () && !qio_channel_has_feature (sioc,QIO_CHANNEL_FEATURE_WRITE_ZERO_COPY )) {error_setg (&err,"Zero copy send feature not detected in host kernel" ); + goto err; } -out: -migration_channel_connect (data->s, sioc, err); -object_unref (OBJECT (sioc)); +trace_migration_socket_outgoing_connected (); +migration_channel_connect (data->s, sioc); +return ; +err: +trace_migration_socket_outgoing_error (error_get_pretty (err)); +migration_connect_error_propagate (data->s, err); } void socket_start_outgoing_migration(MigrationState *s,migration/tls.c +10
-9@@ -104,16 +104,17 @@ static void migration_tls_outgoing_handshake(QIOTask *task, gpointer opaque) {MigrationState *s = opaque; -QIOChannel *ioc =QIO_CHANNEL (qio_task_get_source (task)); +g_autoptr (QIOChannel) ioc =QIO_CHANNEL (qio_task_get_source (task));Error *err =NULL ;if (qio_task_propagate_error (task, &err)) {trace_migration_tls_outgoing_handshake_error (error_get_pretty (err)); - }else { -trace_migration_tls_outgoing_handshake_complete (); +migration_connect_error_propagate (s, err); +return ; } -migration_channel_connect (s, ioc, err); -object_unref (OBJECT (ioc)); + +trace_migration_tls_outgoing_handshake_complete (); +migration_channel_connect (s, ioc); } QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc,@@ -129,14 +130,14 @@ QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc,return qio_channel_tls_new_client (ioc, creds,migrate_tls_hostname (), errp); } -void migration_tls_channel_connect (MigrationState *s, -QIOChannel *ioc, -Error **errp) +void migration_tls_channel_connect (MigrationState *s,QIOChannel *ioc) {QIOChannelTLS *tioc; +Error *local_err =NULL ; - tioc =migration_tls_client_create (ioc, errp); + tioc =migration_tls_client_create (ioc, &local_err);if (!tioc) { +migration_connect_error_propagate (s, local_err);return ; }migration/tls.h +1
-3@@ -29,9 +29,7 @@ void migration_tls_channel_process_incoming(QIOChannel *ioc, Error **errp);QIOChannelTLS *migration_tls_client_create (QIOChannel *ioc,Error **errp); -void migration_tls_channel_connect (MigrationState *s, -QIOChannel *ioc, -Error **errp); +void migration_tls_channel_connect (MigrationState *s,QIOChannel *ioc);void migration_tls_channel_end (QIOChannel *ioc,Error **errp);/* Whether the QIO channel requires further TLS handshake? */ bool migrate_channel_requires_tls_upgrade (QIOChannel *ioc);migration/trace-events +1
-1@@ -204,7 +204,7 @@ migration_transferred_bytes(uint64_t qemu_file, uint64_t multifd, uint64_t rdma) # channel.c migration_set_incoming_channel(void *ioc, const char *ioctype) "ioc=%p ioctype=%s" -migration_set_outgoing_channel(void *ioc, const char *ioctype, void *err) "ioc=%p ioctype=%s err=%p" +migration_set_outgoing_channel(void *ioc, const char *ioctype) "ioc=%p ioctype=%s" # global_state.c migrate_state_too_big(void) ""Signature · 1 line
2.51.0
RFC PATCH 14/25 migration: Remove QEMUFile from channel.c
In reply to Fabiano RosasMake channel.c deal only with QIOChannel objects. Move any handling of QEMUFile into migration.c. To achieve this in a clean way:
1) Define a migration_outgoing_setup, analogous to migration_incoming_setup, responsible for creating the QEMUFile from the QIOChannel.
2) Increase the scope of migration_incoming_setup to create not only the main channel, but all the others as well. That is currently being done at migration_ioc_process, so move the code.
3) Adjust RDMA code to pass in the QIOChannel and remove some of the usage of QEMUFile.
--- migration/channel.c | 21 ++++++----- migration/migration.c | 88 ++++++++++++++++++++++--------------------- migration/migration.h | 6 ++- migration/multifd.c | 7 ++-- migration/multifd.h | 2 +- migration/rdma.c | 28 ++++---------- 6 files changed, 73 insertions(+), 79 deletions(-)
migration/channel.c +11 -10
@@ -14,7 +14,6 @@#include "channel.h" #include "tls.h" #include "migration.h" -#include "qemu-file.h" #include "trace.h" #include "qapi/error.h" #include "io/channel-tls.h"
@@ -34,6 +33,7 @@ void migration_channel_process_incoming(QIOChannel *ioc) {MigrationIncomingState *mis =migration_incoming_get_current ();Error *local_err =NULL ; +uint8_t ch;trace_migration_set_incoming_channel ( ioc,object_get_typename (OBJECT (ioc)));
@@ -42,9 +42,16 @@ void migration_channel_process_incoming(QIOChannel *ioc)migration_tls_channel_process_incoming (ioc, &local_err); }else {migration_ioc_register_yank (ioc); -migration_ioc_process_incoming (ioc, &local_err); - } + ch =migration_ioc_process_incoming (ioc, &local_err); +if (!ch) { + goto out; + } +if (migration_incoming_setup (ioc, ch, &local_err)) { +migration_incoming_process (); + } + } +out:if (local_err) {error_report_err (local_err);migrate_set_state (&mis->state, mis->state,MIGRATION_STATUS_FAILED );
@@ -75,14 +82,8 @@ void migration_channel_connect(MigrationState *s, QIOChannel *ioc)return ; } -QEMUFile *f =qemu_file_new_output (ioc); -migration_ioc_register_yank (ioc); - -qemu_mutex_lock (&s->qemu_file_lock); - s->to_dst_file = f; -qemu_mutex_unlock (&s->qemu_file_lock); - +migration_outgoing_setup (ioc);migration_connect (s); }
migration/migration.c +45 -43
140 lines not on this page · raw message
migration/migration.h +4 -2
@@ -526,8 +526,10 @@ struct MigrationState {void migrate_set_state (MigrationStatus *state,MigrationStatus old_state,MigrationStatus new_state); -void migration_fd_process_incoming (QEMUFile *f); -void migration_ioc_process_incoming (QIOChannel *ioc,Error **errp); +void migration_outgoing_setup (QIOChannel *ioc); +bool migration_incoming_setup (QIOChannel *ioc,uint8_t channel,Error **errp); + +uint8_t migration_ioc_process_incoming (QIOChannel *ioc,Error **errp);void migration_incoming_process (void );bool migration_has_all_channels (void );
migration/multifd.c +4 -3
@@ -1521,7 +1521,7 @@ bool multifd_recv_all_channels_created(void)* Try to receive all multifd channels to get ready for the migration. * Sets @errp when failing to receive the current channel. */ -void multifd_recv_new_channel (QIOChannel *ioc,Error **errp) +bool multifd_recv_new_channel (QIOChannel *ioc,Error **errp) {MultiFDRecvParams *p;Error *local_err =NULL ;
@@ -1536,7 +1536,7 @@ void multifd_recv_new_channel(QIOChannel *ioc, Error **errp)"failed to receive packet" " via multifd channel %d: " , qatomic_read(&multifd_recv_state->count)); -return ; +return false; }trace_multifd_recv_new_channel (id); }else {
@@ -1549,7 +1549,7 @@ void multifd_recv_new_channel(QIOChannel *ioc, Error **errp) id);multifd_recv_terminate_threads (error_copy (local_err));error_propagate (errp, local_err); -return ; +return false; } p->c = ioc;object_ref (OBJECT (ioc));
@@ -1558,4 +1558,5 @@ void multifd_recv_new_channel(QIOChannel *ioc, Error **errp)qemu_thread_create (&p->thread, p->name, multifd_recv_thread, p,QEMU_THREAD_JOINABLE );qatomic_inc (&multifd_recv_state->count); +return true; }
migration/multifd.h +1 -1
@@ -42,7 +42,7 @@ int multifd_recv_setup(Error **errp);void multifd_recv_cleanup (void );void multifd_recv_shutdown (void );bool multifd_recv_all_channels_created (void ); -void multifd_recv_new_channel (QIOChannel *ioc,Error **errp); +bool multifd_recv_new_channel (QIOChannel *ioc,Error **errp);void multifd_recv_sync_main (void );int multifd_send_sync_main (MultiFDSyncReq req);bool multifd_queue_page (RAMBlock *block,ram_addr_t offset);
migration/rdma.c +8 -20
@@ -384,7 +384,6 @@ struct QIOChannelRDMA {QIOChannel parent;RDMAContext *rdmain;RDMAContext *rdmaout; -QEMUFile *file;bool blocking;/* XXX we don't actually honour this yet */ };
@@ -3836,32 +3835,20 @@ static void qio_channel_rdma_register_types(void)type_init (qio_channel_rdma_register_types); -static QEMUFile *rdma_new_input (RDMAContext *rdma) +static QIOChannel *rdma_new_ioc (RDMAContext *rdma) {QIOChannelRDMA *rioc =QIO_CHANNEL_RDMA (object_new (TYPE_QIO_CHANNEL_RDMA )); - rioc->file =qemu_file_new_input (QIO_CHANNEL (rioc)); - rioc->rdmain = rdma; - rioc->rdmaout = rdma->return_path; - -return rioc->file; -} - -static QEMUFile *rdma_new_output (RDMAContext *rdma) -{ -QIOChannelRDMA *rioc =QIO_CHANNEL_RDMA (object_new (TYPE_QIO_CHANNEL_RDMA )); - - rioc->file =qemu_file_new_output (QIO_CHANNEL (rioc)); rioc->rdmaout = rdma; rioc->rdmain = rdma->return_path; -return rioc->file; +return QIO_CHANNEL (rioc); }static void rdma_accept_incoming_migration (void *opaque) {RDMAContext *rdma = opaque; -QEMUFile *f; +QIOChannel *ioc;trace_qemu_rdma_accept_incoming_migration ();if (qemu_rdma_accept (rdma) <0 ) {
@@ -3875,15 +3862,16 @@ static void rdma_accept_incoming_migration(void *opaque)return ; } - f =rdma_new_input (rdma); -if (f ==NULL ) { + ioc =rdma_new_ioc (rdma); +if (!ioc) {error_report ("RDMA ERROR: could not open RDMA for input" );qemu_rdma_cleanup (rdma);return ; } rdma->migration_started_on_destination =1 ; -migration_fd_process_incoming (f); +migration_incoming_setup (ioc,0 ,NULL ); +migration_incoming_process (); } void rdma_start_incoming_migration(InetSocketAddress *host_port,
@@ -3995,8 +3983,8 @@ void rdma_start_outgoing_migration(void *opaque,trace_rdma_start_outgoing_migration_after_rdma_connect (); - s->to_dst_file =rdma_new_output (rdma); s->rdma_migration = true; +migration_outgoing_setup (rdma_new_ioc (rdma));migration_connect (s);return ; return_path_err:
Signature · 1 line
2.51.0
Re: [RFC PATCH 14/25] migration: Remove QEMUFile from channel.c
Quoted 322 lines · Fabiano Rosas
Make
channel.cdeal only with QIOChannel objects. Move any handling of QEMUFile intomigration.c. To achieve this in a clean way:1) Define a
migration_outgoing_setup, analogous tomigration_incoming_setup, responsible for creating the QEMUFile from the QIOChannel.2) Increase the scope of
migration_incoming_setupto create not only the main channel, but all the others as well. That is currently being done atmigration_ioc_process, so move the code.3) Adjust RDMA code to pass in the QIOChannel and remove some of the usage of QEMUFile.
Signed-off-by Fabiano Rosas <[email protected]>--- migration/channel.c | 21 ++++++----- migration/migration.c | 88 ++++++++++++++++++++++--------------------- migration/migration.h | 6 ++- migration/multifd.c | 7 ++-- migration/multifd.h | 2 +- migration/rdma.c | 28 ++++---------- 6 files changed, 73 insertions(+), 79 deletions(-)migration/channel.c +11
-10@@ -14,7 +14,6 @@#include "channel.h" #include "tls.h" #include "migration.h" -#include "qemu-file.h" #include "trace.h" #include "qapi/error.h" #include "io/channel-tls.h" @@ -34,6 +33,7 @@ void migration_channel_process_incoming(QIOChannel *ioc) {MigrationIncomingState *mis =migration_incoming_get_current ();Error *local_err =NULL ; +uint8_t ch;trace_migration_set_incoming_channel ( ioc,object_get_typename (OBJECT (ioc)));@@ -42,9 +42,16 @@ void migration_channel_process_incoming(QIOChannel *ioc)migration_tls_channel_process_incoming (ioc, &local_err); }else {migration_ioc_register_yank (ioc); -migration_ioc_process_incoming (ioc, &local_err); - } + ch =migration_ioc_process_incoming (ioc, &local_err); +if (!ch) { + goto out; + } +if (migration_incoming_setup (ioc, ch, &local_err)) { +migration_incoming_process (); + } + } +out:if (local_err) {error_report_err (local_err);migrate_set_state (&mis->state, mis->state,MIGRATION_STATUS_FAILED );@@ -75,14 +82,8 @@ void migration_channel_connect(MigrationState *s, QIOChannel *ioc)return ; } -QEMUFile *f =qemu_file_new_output (ioc); -migration_ioc_register_yank (ioc); - -qemu_mutex_lock (&s->qemu_file_lock); - s->to_dst_file = f; -qemu_mutex_unlock (&s->qemu_file_lock); - +migration_outgoing_setup (ioc);migration_connect (s); }migration/migration.c +45
-43@@ -92,7 +92,7 @@ enum mig_rp_message_type { };/* Migration channel types */ -enum {CH_MAIN ,CH_MULTIFD ,CH_POSTCOPY }; +enum {CH_NONE ,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 @@ -934,17 +934,48 @@ out:migrate_incoming_unref_outgoing_state (); } -/** -* migration_incoming_setup: Setup incoming migration -* @f: file for main migration channel -*/ -static void migration_incoming_setup (QEMUFile *f) +static bool migration_has_main_and_multifd_channels (void ); + +bool migration_incoming_setup (QIOChannel *ioc,uint8_t channel,Error **errp) {MigrationIncomingState *mis =migration_incoming_get_current (); +QEMUFile *f; -assert (!mis->from_src_file); - mis->from_src_file = f; -qemu_file_set_blocking (f, false, &error_abort); +switch (channel) { +case CH_MAIN : + f =qemu_file_new_input (ioc); +assert (!mis->from_src_file); + mis->from_src_file = f; +qemu_file_set_blocking (f, false, &error_abort); +break ; + +case CH_MULTIFD : +if (!multifd_recv_new_channel (ioc, errp)) { +return false; + } +break ; + +case CH_POSTCOPY : +assert (!mis->postcopy_qemufile_dst); + f =qemu_file_new_input (ioc); +postcopy_preempt_new_channel (mis, f); +return false; + +default : +g_assert_not_reached (); + } + +return migration_has_main_and_multifd_channels (); +} + +void migration_outgoing_setup (QIOChannel *ioc) +{ +MigrationState *s =migrate_get_current (); +QEMUFile *f =qemu_file_new_output (ioc); + +qemu_mutex_lock (&s->qemu_file_lock); + s->to_dst_file = f; +qemu_mutex_unlock (&s->qemu_file_lock); }/* Returns true if recovered from a paused migration, otherwise false */ @@ -990,12 +1021,6 @@ void migration_incoming_process(void)qemu_coroutine_enter (co); } -void migration_fd_process_incoming (QEMUFile *f) -{ -migration_incoming_setup (f); -migration_incoming_process (); -} -static bool migration_has_main_and_multifd_channels (void ) {MigrationIncomingState *mis =migration_incoming_get_current ();@@ -1012,12 +1037,10 @@ static bool migration_has_main_and_multifd_channels(void)return true; } -void migration_ioc_process_incoming (QIOChannel *ioc,Error **errp) +uint8_t migration_ioc_process_incoming (QIOChannel *ioc,Error **errp) {MigrationIncomingState *mis =migration_incoming_get_current (); -Error *local_err =NULL ; -QEMUFile *f; -uint8_t channel; +uint8_t channel =CH_NONE ;uint32_t channel_magic =0 ;int ret =0 ;@@ -1036,7 +1059,7 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) ret =migration_channel_read_peek (ioc, (void *)&channel_magic,sizeof (channel_magic), errp);if (ret !=0 ) { -return ; + goto out; } channel_magic =be32_to_cpu (channel_magic);@@ -1051,7 +1074,6 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) channel =CH_MAIN ; }else {error_setg (errp,"unknown channel magic: %u" , channel_magic); -return ; } }else if (mis->from_src_file &&migrate_multifd ()) {/* @@ -1063,33 +1085,13 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) channel =CH_MAIN ; }else {error_setg (errp,"non-peekable channel used without multifd" ); -return ; } }else {assert (migrate_postcopy_preempt ()); channel =CH_POSTCOPY ; } - -if (channel ==CH_MAIN ) { - f =qemu_file_new_input (ioc); -migration_incoming_setup (f); - }else if (channel ==CH_MULTIFD ) { -/* Multiple connections */ -multifd_recv_new_channel (ioc, &local_err); -if (local_err) { -error_propagate (errp, local_err); -return ; - } - }else if (channel ==CH_POSTCOPY ) { -assert (!mis->postcopy_qemufile_dst); - f =qemu_file_new_input (ioc); -postcopy_preempt_new_channel (mis, f); -return ; - } - -if (migration_has_main_and_multifd_channels ()) { -migration_incoming_process (); - } +out: +return channel; }/** migration/migration.h +4
-2@@ -526,8 +526,10 @@ struct MigrationState {void migrate_set_state (MigrationStatus *state,MigrationStatus old_state,MigrationStatus new_state); -void migration_fd_process_incoming (QEMUFile *f); -void migration_ioc_process_incoming (QIOChannel *ioc,Error **errp); +void migration_outgoing_setup (QIOChannel *ioc); +bool migration_incoming_setup (QIOChannel *ioc,uint8_t channel,Error **errp); + +uint8_t migration_ioc_process_incoming (QIOChannel *ioc,Error **errp);void migration_incoming_process (void );bool migration_has_all_channels (void );migration/multifd.c +4
-3@@ -1521,7 +1521,7 @@ bool multifd_recv_all_channels_created(void)* Try to receive all multifd channels to get ready for the migration. * Sets @errp when failing to receive the current channel. */ -void multifd_recv_new_channel (QIOChannel *ioc,Error **errp) +bool multifd_recv_new_channel (QIOChannel *ioc,Error **errp) {MultiFDRecvParams *p;Error *local_err =NULL ;@@ -1536,7 +1536,7 @@ void multifd_recv_new_channel(QIOChannel *ioc, Error **errp)"failed to receive packet" " via multifd channel %d: " , qatomic_read(&multifd_recv_state->count)); -return ; +return false; }trace_multifd_recv_new_channel (id); }else {@@ -1549,7 +1549,7 @@ void multifd_recv_new_channel(QIOChannel *ioc, Error **errp) id);multifd_recv_terminate_threads (error_copy (local_err));error_propagate (errp, local_err); -return ; +return false; } p->c = ioc;object_ref (OBJECT (ioc));@@ -1558,4 +1558,5 @@ void multifd_recv_new_channel(QIOChannel *ioc, Error **errp)qemu_thread_create (&p->thread, p->name, multifd_recv_thread, p,QEMU_THREAD_JOINABLE );qatomic_inc (&multifd_recv_state->count); +return true; }migration/multifd.h +1
-1@@ -42,7 +42,7 @@ int multifd_recv_setup(Error **errp);void multifd_recv_cleanup (void );void multifd_recv_shutdown (void );bool multifd_recv_all_channels_created (void ); -void multifd_recv_new_channel (QIOChannel *ioc,Error **errp); +bool multifd_recv_new_channel (QIOChannel *ioc,Error **errp);void multifd_recv_sync_main (void );int multifd_send_sync_main (MultiFDSyncReq req);bool multifd_queue_page (RAMBlock *block,ram_addr_t offset);migration/rdma.c +1
-6@@ -384,7 +384,6 @@ struct QIOChannelRDMA {QIOChannel parent;RDMAContext *rdmain;RDMAContext *rdmaout; -QEMUFile *file;bool blocking;/* XXX we don't actually honour this yet */ };@@ -3836,32 +3835,20 @@ static void qio_channel_rdma_register_types(void)type_init (qio_channel_rdma_register_types); -static QEMUFile *rdma_new_input (RDMAContext *rdma) +static QIOChannel *rdma_new_ioc (RDMAContext *rdma) {QIOChannelRDMA *rioc =QIO_CHANNEL_RDMA (object_new (TYPE_QIO_CHANNEL_RDMA )); - rioc->file =qemu_file_new_input (QIO_CHANNEL (rioc)); - rioc->rdmain = rdma; - rioc->rdmaout = rdma->return_path; -
migration/rdma.c static void qio_channel_rdma_register_types(void) · line 3843
Quoted 10 lines
migration/rdma.c +0
-8-return rioc->file; -} - -static QEMUFile *rdma_new_output (RDMAContext *rdma) -{ -QIOChannelRDMA *rioc =QIO_CHANNEL_RDMA (object_new (TYPE_QIO_CHANNEL_RDMA )); - - rioc->file =qemu_file_new_output (QIO_CHANNEL (rioc)); rioc->rdmaout = rdma; rioc->rdmain = rdma->return_path;
Likely it was overlooked rdmaout/rdmain was set in reverse order in these two functions. I gave it a quick run on rdma and it was indeed broken starting from this patch.
The goal of the change looks reasonable in general otherwise, said that, maybe there's way to split the patch somehow?
Quoted 46 lines
migration/rdma.c +7
-6-return rioc->file; +return QIO_CHANNEL (rioc); }static void rdma_accept_incoming_migration (void *opaque) {RDMAContext *rdma = opaque; -QEMUFile *f; +QIOChannel *ioc;trace_qemu_rdma_accept_incoming_migration ();if (qemu_rdma_accept (rdma) <0 ) {@@ -3875,15 +3862,16 @@ static void rdma_accept_incoming_migration(void *opaque)return ; } - f =rdma_new_input (rdma); -if (f ==NULL ) { + ioc =rdma_new_ioc (rdma); +if (!ioc) {error_report ("RDMA ERROR: could not open RDMA for input" );qemu_rdma_cleanup (rdma);return ; } rdma->migration_started_on_destination =1 ; -migration_fd_process_incoming (f); +migration_incoming_setup (ioc,0 ,NULL ); +migration_incoming_process (); } void rdma_start_incoming_migration(InetSocketAddress *host_port,@@ -3995,8 +3983,8 @@ void rdma_start_outgoing_migration(void *opaque,trace_rdma_start_outgoing_migration_after_rdma_connect (); - s->to_dst_file =rdma_new_output (rdma); s->rdma_migration = true; +migration_outgoing_setup (rdma_new_ioc (rdma));migration_connect (s);return ; return_path_err:Signature · 1 line
2.51.0
Signature · 1 line
Peter Xu
Re: [RFC PATCH 14/25] migration: Remove QEMUFile from channel.c
Quoted 329 lines · Peter Xu
Quoted 328 lines · Fabiano Rosas
Make
channel.cdeal only with QIOChannel objects. Move any handling of QEMUFile intomigration.c. To achieve this in a clean way:1) Define a
migration_outgoing_setup, analogous tomigration_incoming_setup, responsible for creating the QEMUFile from the QIOChannel.2) Increase the scope of
migration_incoming_setupto create not only the main channel, but all the others as well. That is currently being done atmigration_ioc_process, so move the code.3) Adjust RDMA code to pass in the QIOChannel and remove some of the usage of QEMUFile.
Signed-off-by Fabiano Rosas <[email protected]>--- migration/channel.c | 21 ++++++----- migration/migration.c | 88 ++++++++++++++++++++++--------------------- migration/migration.h | 6 ++- migration/multifd.c | 7 ++-- migration/multifd.h | 2 +- migration/rdma.c | 28 ++++---------- 6 files changed, 73 insertions(+), 79 deletions(-)migration/channel.c +11
-10@@ -14,7 +14,6 @@#include "channel.h" #include "tls.h" #include "migration.h" -#include "qemu-file.h" #include "trace.h" #include "qapi/error.h" #include "io/channel-tls.h" @@ -34,6 +33,7 @@ void migration_channel_process_incoming(QIOChannel *ioc) {MigrationIncomingState *mis =migration_incoming_get_current ();Error *local_err =NULL ; +uint8_t ch;trace_migration_set_incoming_channel ( ioc,object_get_typename (OBJECT (ioc)));@@ -42,9 +42,16 @@ void migration_channel_process_incoming(QIOChannel *ioc)migration_tls_channel_process_incoming (ioc, &local_err); }else {migration_ioc_register_yank (ioc); -migration_ioc_process_incoming (ioc, &local_err); - } + ch =migration_ioc_process_incoming (ioc, &local_err); +if (!ch) { + goto out; + } +if (migration_incoming_setup (ioc, ch, &local_err)) { +migration_incoming_process (); + } + } +out:if (local_err) {error_report_err (local_err);migrate_set_state (&mis->state, mis->state,MIGRATION_STATUS_FAILED );@@ -75,14 +82,8 @@ void migration_channel_connect(MigrationState *s, QIOChannel *ioc)return ; } -QEMUFile *f =qemu_file_new_output (ioc); -migration_ioc_register_yank (ioc); - -qemu_mutex_lock (&s->qemu_file_lock); - s->to_dst_file = f; -qemu_mutex_unlock (&s->qemu_file_lock); - +migration_outgoing_setup (ioc);migration_connect (s); }migration/migration.c +45
-43@@ -92,7 +92,7 @@ enum mig_rp_message_type { };/* Migration channel types */ -enum {CH_MAIN ,CH_MULTIFD ,CH_POSTCOPY }; +enum {CH_NONE ,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 @@ -934,17 +934,48 @@ out:migrate_incoming_unref_outgoing_state (); } -/** -* migration_incoming_setup: Setup incoming migration -* @f: file for main migration channel -*/ -static void migration_incoming_setup (QEMUFile *f) +static bool migration_has_main_and_multifd_channels (void ); + +bool migration_incoming_setup (QIOChannel *ioc,uint8_t channel,Error **errp) {MigrationIncomingState *mis =migration_incoming_get_current (); +QEMUFile *f; -assert (!mis->from_src_file); - mis->from_src_file = f; -qemu_file_set_blocking (f, false, &error_abort); +switch (channel) { +case CH_MAIN : + f =qemu_file_new_input (ioc); +assert (!mis->from_src_file); + mis->from_src_file = f; +qemu_file_set_blocking (f, false, &error_abort); +break ; + +case CH_MULTIFD : +if (!multifd_recv_new_channel (ioc, errp)) { +return false; + } +break ; + +case CH_POSTCOPY : +assert (!mis->postcopy_qemufile_dst); + f =qemu_file_new_input (ioc); +postcopy_preempt_new_channel (mis, f); +return false; + +default : +g_assert_not_reached (); + } + +return migration_has_main_and_multifd_channels (); +} + +void migration_outgoing_setup (QIOChannel *ioc) +{ +MigrationState *s =migrate_get_current (); +QEMUFile *f =qemu_file_new_output (ioc); + +qemu_mutex_lock (&s->qemu_file_lock); + s->to_dst_file = f; +qemu_mutex_unlock (&s->qemu_file_lock); }/* Returns true if recovered from a paused migration, otherwise false */ @@ -990,12 +1021,6 @@ void migration_incoming_process(void)qemu_coroutine_enter (co); } -void migration_fd_process_incoming (QEMUFile *f) -{ -migration_incoming_setup (f); -migration_incoming_process (); -} -static bool migration_has_main_and_multifd_channels (void ) {MigrationIncomingState *mis =migration_incoming_get_current ();@@ -1012,12 +1037,10 @@ static bool migration_has_main_and_multifd_channels(void)return true; } -void migration_ioc_process_incoming (QIOChannel *ioc,Error **errp) +uint8_t migration_ioc_process_incoming (QIOChannel *ioc,Error **errp) {MigrationIncomingState *mis =migration_incoming_get_current (); -Error *local_err =NULL ; -QEMUFile *f; -uint8_t channel; +uint8_t channel =CH_NONE ;uint32_t channel_magic =0 ;int ret =0 ;@@ -1036,7 +1059,7 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) ret =migration_channel_read_peek (ioc, (void *)&channel_magic,sizeof (channel_magic), errp);if (ret !=0 ) { -return ; + goto out; } channel_magic =be32_to_cpu (channel_magic);@@ -1051,7 +1074,6 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) channel =CH_MAIN ; }else {error_setg (errp,"unknown channel magic: %u" , channel_magic); -return ; } }else if (mis->from_src_file &&migrate_multifd ()) {/* @@ -1063,33 +1085,13 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) channel =CH_MAIN ; }else {error_setg (errp,"non-peekable channel used without multifd" ); -return ; } }else {assert (migrate_postcopy_preempt ()); channel =CH_POSTCOPY ; } - -if (channel ==CH_MAIN ) { - f =qemu_file_new_input (ioc); -migration_incoming_setup (f); - }else if (channel ==CH_MULTIFD ) { -/* Multiple connections */ -multifd_recv_new_channel (ioc, &local_err); -if (local_err) { -error_propagate (errp, local_err); -return ; - } - }else if (channel ==CH_POSTCOPY ) { -assert (!mis->postcopy_qemufile_dst); - f =qemu_file_new_input (ioc); -postcopy_preempt_new_channel (mis, f); -return ; - } - -if (migration_has_main_and_multifd_channels ()) { -migration_incoming_process (); - } +out: +return channel; }/** migration/migration.h +4
-2@@ -526,8 +526,10 @@ struct MigrationState {void migrate_set_state (MigrationStatus *state,MigrationStatus old_state,MigrationStatus new_state); -void migration_fd_process_incoming (QEMUFile *f); -void migration_ioc_process_incoming (QIOChannel *ioc,Error **errp); +void migration_outgoing_setup (QIOChannel *ioc); +bool migration_incoming_setup (QIOChannel *ioc,uint8_t channel,Error **errp); + +uint8_t migration_ioc_process_incoming (QIOChannel *ioc,Error **errp);void migration_incoming_process (void );bool migration_has_all_channels (void );migration/multifd.c +4
-3@@ -1521,7 +1521,7 @@ bool multifd_recv_all_channels_created(void)* Try to receive all multifd channels to get ready for the migration. * Sets @errp when failing to receive the current channel. */ -void multifd_recv_new_channel (QIOChannel *ioc,Error **errp) +bool multifd_recv_new_channel (QIOChannel *ioc,Error **errp) {MultiFDRecvParams *p;Error *local_err =NULL ;@@ -1536,7 +1536,7 @@ void multifd_recv_new_channel(QIOChannel *ioc, Error **errp)"failed to receive packet" " via multifd channel %d: " , qatomic_read(&multifd_recv_state->count)); -return ; +return false; }trace_multifd_recv_new_channel (id); }else {@@ -1549,7 +1549,7 @@ void multifd_recv_new_channel(QIOChannel *ioc, Error **errp) id);multifd_recv_terminate_threads (error_copy (local_err));error_propagate (errp, local_err); -return ; +return false; } p->c = ioc;object_ref (OBJECT (ioc));@@ -1558,4 +1558,5 @@ void multifd_recv_new_channel(QIOChannel *ioc, Error **errp)qemu_thread_create (&p->thread, p->name, multifd_recv_thread, p,QEMU_THREAD_JOINABLE );qatomic_inc (&multifd_recv_state->count); +return true; }migration/multifd.h +1
-1@@ -42,7 +42,7 @@ int multifd_recv_setup(Error **errp);void multifd_recv_cleanup (void );void multifd_recv_shutdown (void );bool multifd_recv_all_channels_created (void ); -void multifd_recv_new_channel (QIOChannel *ioc,Error **errp); +bool multifd_recv_new_channel (QIOChannel *ioc,Error **errp);void multifd_recv_sync_main (void );int multifd_send_sync_main (MultiFDSyncReq req);bool multifd_queue_page (RAMBlock *block,ram_addr_t offset);migration/rdma.c +1
-12@@ -384,7 +384,6 @@ struct QIOChannelRDMA {QIOChannel parent;RDMAContext *rdmain;RDMAContext *rdmaout; -QEMUFile *file;bool blocking;/* XXX we don't actually honour this yet */ };@@ -3836,32 +3835,20 @@ static void qio_channel_rdma_register_types(void)type_init (qio_channel_rdma_register_types); -static QEMUFile *rdma_new_input (RDMAContext *rdma) +static QIOChannel *rdma_new_ioc (RDMAContext *rdma) {QIOChannelRDMA *rioc =QIO_CHANNEL_RDMA (object_new (TYPE_QIO_CHANNEL_RDMA )); - rioc->file =qemu_file_new_input (QIO_CHANNEL (rioc)); - rioc->rdmain = rdma; - rioc->rdmaout = rdma->return_path; - -return rioc->file; -} - -static QEMUFile *rdma_new_output (RDMAContext *rdma) -{ -QIOChannelRDMA *rioc =QIO_CHANNEL_RDMA (object_new (TYPE_QIO_CHANNEL_RDMA ));
Quoted 9 lines
migration/rdma.c static void qio_channel_rdma_register_types(void) · line 3843
Quoted 4 lines
migration/rdma.c +0
-2- - rioc->file =qemu_file_new_output (QIO_CHANNEL (rioc)); rioc->rdmaout = rdma; rioc->rdmain = rdma->return_path;Likely it was overlooked rdmaout/rdmain was set in reverse order in these two functions. I gave it a quick run on rdma and it was indeed broken starting from this patch.
I'll remember to test rdma next time, thanks for catching this.
Quoted 3 lines
The goal of the change looks reasonable in general otherwise, said that, maybe there's way to split the patch somehow?
Yes, no problem.
RFC PATCH 15/25 migration/channel: Rename migration_channel_connect
In reply to Fabiano RosasRename migration_channel_connect to indicate this is the source side. Future patches will do similar changes to the incoming side and this will avoid inconsistencies in naming.
--- migration/channel.c | 9 +-------- migration/channel.h | 2 +- migration/exec.c | 2 +- migration/fd.c | 2 +- migration/file.c | 2 +- migration/socket.c | 2 +- migration/tls.c | 2 +- 7 files changed, 7 insertions(+), 14 deletions(-)
migration/channel.c +1 -8
@@ -61,14 +61,7 @@ out: } } - -/** -* @migration_channel_connect - Create new outgoing migration channel -* -* @s: Current migration state -* @ioc: Channel to which we are connecting -*/ -void migration_channel_connect (MigrationState *s,QIOChannel *ioc) +void migration_channel_connect_outgoing (MigrationState *s,QIOChannel *ioc) {trace_migration_set_outgoing_channel (ioc,object_get_typename (OBJECT (ioc)));
migration/channel.h +1 -1
@@ -20,7 +20,7 @@void migration_channel_process_incoming (QIOChannel *ioc); -void migration_channel_connect (MigrationState *s,QIOChannel *ioc); +void migration_channel_connect_outgoing (MigrationState *s,QIOChannel *ioc); int migration_channel_read_peek(QIOChannel *ioc, const char *buf,
migration/exec.c +1 -1
@@ -55,7 +55,7 @@ void exec_start_outgoing_migration(MigrationState *s, strList *command, }qio_channel_set_name (ioc,"migration-exec-outgoing" ); -migration_channel_connect (s, ioc); +migration_channel_connect_outgoing (s, ioc);object_unref (OBJECT (ioc)); }
migration/fd.c +1 -1
@@ -70,7 +70,7 @@ void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error ** }qio_channel_set_name (ioc,"migration-fd-outgoing" ); -migration_channel_connect (s, ioc); +migration_channel_connect_outgoing (s, ioc);object_unref (OBJECT (ioc)); }
migration/file.c +1 -1
@@ -122,7 +122,7 @@ void file_start_outgoing_migration(MigrationState *s,return ; }qio_channel_set_name (ioc,"migration-file-outgoing" ); -migration_channel_connect (s, ioc); +migration_channel_connect_outgoing (s, ioc); } static gboolean file_accept_incoming_migration(QIOChannel *ioc,
migration/socket.c +1 -1
@@ -73,7 +73,7 @@ static void socket_outgoing_migration(QIOTask *task, }trace_migration_socket_outgoing_connected (); -migration_channel_connect (data->s, sioc); +migration_channel_connect_outgoing (data->s, sioc);return ; err:trace_migration_socket_outgoing_error (error_get_pretty (err));
migration/tls.c +1 -1
@@ -114,7 +114,7 @@ static void migration_tls_outgoing_handshake(QIOTask *task, }trace_migration_tls_outgoing_handshake_complete (); -migration_channel_connect (s, ioc); +migration_channel_connect_outgoing (s, ioc); } QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc,
Signature · 1 line
2.51.0
Re: [RFC PATCH 15/25] migration/channel: Rename migration_channel_connect
Quoted 5 lines · Fabiano Rosas
Rename
migration_channel_connectto indicate this is the source side. Future patches will do similar changes to the incoming side and this will avoid inconsistencies in naming.Signed-off-by Fabiano Rosas <[email protected]>
We have a lot of other helpers are using this pattern as names:
migration_incoming*
So I wonder if we want to unify it with
migration_outgoing*
?
Said that, I don't think it's always the case, so it's not a rule either. Adding "outgoing" anywhere should indeed be an improvement already.
Whichever you prefer:
Quoted 111 lines
--- migration/channel.c | 9 +-------- migration/channel.h | 2 +- migration/exec.c | 2 +- migration/fd.c | 2 +- migration/file.c | 2 +- migration/socket.c | 2 +- migration/tls.c | 2 +- 7 files changed, 7 insertions(+), 14 deletions(-)migration/channel.c +1
-8@@ -61,14 +61,7 @@ out: } } - -/** -* @migration_channel_connect - Create new outgoing migration channel -* -* @s: Current migration state -* @ioc: Channel to which we are connecting -*/ -void migration_channel_connect (MigrationState *s,QIOChannel *ioc) +void migration_channel_connect_outgoing (MigrationState *s,QIOChannel *ioc) {trace_migration_set_outgoing_channel (ioc,object_get_typename (OBJECT (ioc)));migration/channel.h +1
-1@@ -20,7 +20,7 @@void migration_channel_process_incoming (QIOChannel *ioc); -void migration_channel_connect (MigrationState *s,QIOChannel *ioc); +void migration_channel_connect_outgoing (MigrationState *s,QIOChannel *ioc); int migration_channel_read_peek(QIOChannel *ioc, const char *buf,migration/exec.c +1
-1@@ -55,7 +55,7 @@ void exec_start_outgoing_migration(MigrationState *s, strList *command, }qio_channel_set_name (ioc,"migration-exec-outgoing" ); -migration_channel_connect (s, ioc); +migration_channel_connect_outgoing (s, ioc);object_unref (OBJECT (ioc)); }migration/fd.c +1
-1@@ -70,7 +70,7 @@ void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error ** }qio_channel_set_name (ioc,"migration-fd-outgoing" ); -migration_channel_connect (s, ioc); +migration_channel_connect_outgoing (s, ioc);object_unref (OBJECT (ioc)); }migration/file.c +1
-1@@ -122,7 +122,7 @@ void file_start_outgoing_migration(MigrationState *s,return ; }qio_channel_set_name (ioc,"migration-file-outgoing" ); -migration_channel_connect (s, ioc); +migration_channel_connect_outgoing (s, ioc); } static gboolean file_accept_incoming_migration(QIOChannel *ioc,migration/socket.c +1
-1@@ -73,7 +73,7 @@ static void socket_outgoing_migration(QIOTask *task, }trace_migration_socket_outgoing_connected (); -migration_channel_connect (data->s, sioc); +migration_channel_connect_outgoing (data->s, sioc);return ; err:trace_migration_socket_outgoing_error (error_get_pretty (err));migration/tls.c +1
-1@@ -114,7 +114,7 @@ static void migration_tls_outgoing_handshake(QIOTask *task, }trace_migration_tls_outgoing_handshake_complete (); -migration_channel_connect (s, ioc); +migration_channel_connect_outgoing (s, ioc); } QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc,Signature · 1 line
2.51.0
Signature · 1 line
Peter Xu
RFC PATCH 16/25 migration: Rename instances of start
In reply to Fabiano RosasTo make it easier to follow the code, rename the functions that start the migration thread and migration coroutine to contain the word "start".
This will give new contributors the chance of seeing the word start and reaching the actual migration code, instead of twists and turns of qio_channel_add_watch and qio_task_run_in_thread.
Remove all other instances of "start" and use wording more suitable to what the current migration stage is. The transport code such as fd_start_migration_outgoing becomes fd_connect_outgoing, the early setup code such as qemu_start_incoming_migration becomes qemu_setup_incoming_migration and so on.
--- migration/channel.c | 4 ++-- migration/exec.c | 5 ++--- migration/exec.h | 5 ++--- migration/fd.c | 4 ++-- migration/fd.h | 6 +++--- migration/file.c | 6 +++--- migration/file.h | 6 +++--- migration/migration.c | 30 +++++++++++++++--------------- migration/migration.h | 5 +---- migration/rdma.c | 21 ++++++++++----------- migration/rdma.h | 6 +++--- migration/socket.c | 8 +++----- migration/socket.h | 6 +++--- migration/trace-events | 10 +++++----- 14 files changed, 57 insertions(+), 65 deletions(-)
migration/channel.c +2 -2
@@ -48,7 +48,7 @@ void migration_channel_process_incoming(QIOChannel *ioc) }if (migration_incoming_setup (ioc, ch, &local_err)) { -migration_incoming_process (); +migration_start_incoming (); } } out:
@@ -77,7 +77,7 @@ void migration_channel_connect_outgoing(MigrationState *s, QIOChannel *ioc)migration_ioc_register_yank (ioc);migration_outgoing_setup (ioc); -migration_connect (s); +migration_start_outgoing (s); }
migration/exec.c +2 -3
@@ -40,8 +40,7 @@ const char *exec_get_cmd_path(void) }#endif -void exec_start_outgoing_migration (MigrationState *s,strList *command, -Error **errp) +void exec_connect_outgoing (MigrationState *s,strList *command,Error **errp) {QIOChannel *ioc =NULL ;g_auto (GStrv) argv =strv_from_str_list (command);
@@ -68,7 +67,7 @@ static gboolean exec_accept_incoming_migration(QIOChannel *ioc,return G_SOURCE_REMOVE ; } -void exec_start_incoming_migration (strList *command,Error **errp) +void exec_connect_incoming (strList *command,Error **errp) {QIOChannel *ioc;g_auto (GStrv) argv =strv_from_str_list (command);
migration/exec.h +2 -3
@@ -23,8 +23,7 @@#ifdef WIN32 const char *exec_get_cmd_path (void );#endif -void exec_start_incoming_migration (strList *host_port,Error **errp); +void exec_connect_incoming (strList *host_port,Error **errp); -void exec_start_outgoing_migration (MigrationState *s,strList *host_port, -Error **errp); +void exec_connect_outgoing (MigrationState *s,strList *host_port,Error **errp);#endif
migration/fd.c +2 -2
@@ -49,7 +49,7 @@ static bool migration_fd_valid(int fd)return false; } -void fd_start_outgoing_migration (MigrationState *s,const char *fdname,Error **errp) +void fd_connect_outgoing (MigrationState *s,const char *fdname,Error **errp) {QIOChannel *ioc;int fd =monitor_get_fd (monitor_cur (), fdname, errp);
@@ -83,7 +83,7 @@ static gboolean fd_accept_incoming_migration(QIOChannel *ioc,return G_SOURCE_REMOVE ; } -void fd_start_incoming_migration (const char *fdname,Error **errp) +void fd_connect_incoming (const char *fdname,Error **errp) {QIOChannel *ioc;int fd =monitor_fd_param (monitor_cur (), fdname, errp);
migration/fd.h +3 -3
@@ -16,8 +16,8 @@#ifndef QEMU_MIGRATION_FD_H #define QEMU_MIGRATION_FD_H -void fd_start_incoming_migration (const char *fdname,Error **errp); +void fd_connect_incoming (const char *fdname,Error **errp); -void fd_start_outgoing_migration (MigrationState *s,const char *fdname, -Error **errp); +void fd_connect_outgoing (MigrationState *s,const char *fdname, +Error **errp);#endif
migration/file.c +3 -3
@@ -93,8 +93,8 @@ out:return ret; } -void file_start_outgoing_migration (MigrationState *s, -FileMigrationArgs *file_args,Error **errp) +void file_connect_outgoing (MigrationState *s, +FileMigrationArgs *file_args,Error **errp) {g_autoptr (QIOChannelFile) fioc =NULL ; g_autofree char *filename = g_strdup(file_args->filename);
@@ -173,7 +173,7 @@ static void file_create_incoming_channels(QIOChannel *ioc, char *filename, } } -void file_start_incoming_migration (FileMigrationArgs *file_args,Error **errp) +void file_connect_incoming (FileMigrationArgs *file_args,Error **errp) { g_autofree char *filename = g_strdup(file_args->filename);QIOChannelFile *fioc =NULL ;
migration/file.h +3 -3
@@ -13,10 +13,10 @@#include "channel.h" #include "multifd.h" -void file_start_incoming_migration (FileMigrationArgs *file_args,Error **errp); +void file_connect_incoming (FileMigrationArgs *file_args,Error **errp); -void file_start_outgoing_migration (MigrationState *s, -FileMigrationArgs *file_args,Error **errp); +void file_connect_outgoing (MigrationState *s, +FileMigrationArgs *file_args,Error **errp);int file_parse_offset (char *filespec,uint64_t *offsetp,Error **errp);void file_cleanup_outgoing_migration (void );bool file_send_channel_create (gpointer opaque,Error **errp);
migration/migration.c +15 -15
@@ -743,7 +743,7 @@ migration_incoming_state_setup(MigrationIncomingState *mis, Error **errp)return true; } -static void qemu_start_incoming_migration (const char *uri,bool has_channels, +static void qemu_setup_incoming_migration (const char *uri,bool has_channels,MigrationChannelList *channels,Error **errp) {
@@ -795,18 +795,18 @@ static void qemu_start_incoming_migration(const char *uri, bool has_channels,if (saddr->type ==SOCKET_ADDRESS_TYPE_INET || saddr->type ==SOCKET_ADDRESS_TYPE_UNIX || saddr->type ==SOCKET_ADDRESS_TYPE_VSOCK ) { -socket_start_incoming_migration (saddr, errp); +socket_connect_incoming (saddr, errp); }else if (saddr->type ==SOCKET_ADDRESS_TYPE_FD ) { -fd_start_incoming_migration (saddr->u.fd.str, errp); +fd_connect_incoming (saddr->u.fd.str, errp); } #ifdef CONFIG_RDMA }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_RDMA ) { -rdma_start_incoming_migration (&addr->u.rdma, errp); +rdma_connect_incoming (&addr->u.rdma, errp);#endif }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_EXEC ) { -exec_start_incoming_migration (addr->u.exec.args, errp); +exec_connect_incoming (addr->u.exec.args, errp); }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_FILE ) { -file_start_incoming_migration (&addr->u.file, errp); +file_connect_incoming (&addr->u.file, errp); }else {error_setg (errp,"unknown migration protocol: %s" , uri); }
@@ -1011,7 +1011,7 @@ static bool postcopy_try_recover(void)return false; } -void migration_incoming_process (void ) +void migration_start_incoming (void ) {if (postcopy_try_recover ()) {return ;
@@ -1970,7 +1970,7 @@ void qmp_migrate_incoming(const char *uri, bool has_channels, mis->exit_on_error = has_exit_on_error ? exit_on_error :INMIGRATE_DEFAULT_EXIT_ON_ERROR ; -qemu_start_incoming_migration (uri, has_channels, channels, &local_err); +qemu_setup_incoming_migration (uri, has_channels, channels, &local_err);if (local_err) {yank_unregister_instance (MIGRATION_YANK_INSTANCE );
@@ -2017,7 +2017,7 @@ void qmp_migrate_recover(const char *uri, Error **errp)* only re-setup the migration stream and poke existing migration * to continue using that newly established channel. */ -qemu_start_incoming_migration (uri, false,NULL , errp); +qemu_setup_incoming_migration (uri, false,NULL , errp); }void qmp_migrate_pause (Error **errp)
@@ -2344,18 +2344,18 @@ static void qmp_migrate_finish(MigrationAddress *addr, Error **errp)if (saddr->type ==SOCKET_ADDRESS_TYPE_INET || saddr->type ==SOCKET_ADDRESS_TYPE_UNIX || saddr->type ==SOCKET_ADDRESS_TYPE_VSOCK ) { -socket_start_outgoing_migration (s, saddr, &local_err); +socket_connect_outgoing (s, saddr, &local_err); }else if (saddr->type ==SOCKET_ADDRESS_TYPE_FD ) { -fd_start_outgoing_migration (s, saddr->u.fd.str, &local_err); +fd_connect_outgoing (s, saddr->u.fd.str, &local_err); } #ifdef CONFIG_RDMA }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_RDMA ) { -rdma_start_outgoing_migration (s, &addr->u.rdma, &local_err); +rdma_connect_outgoing (s, &addr->u.rdma, &local_err);#endif }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_EXEC ) { -exec_start_outgoing_migration (s, addr->u.exec.args, &local_err); +exec_connect_outgoing (s, addr->u.exec.args, &local_err); }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_FILE ) { -file_start_outgoing_migration (s, &addr->u.file, &local_err); +file_connect_outgoing (s, &addr->u.file, &local_err); }else {error_setg (&local_err,"uri is not a valid migration protocol" ); }
@@ -4035,7 +4035,7 @@ fail_setup:return NULL ; } -void migration_connect (MigrationState *s) +void migration_start_outgoing (MigrationState *s) {Error *local_err =NULL ;uint64_t rate_limit;
migration/migration.h +1 -4
@@ -529,16 +529,13 @@ void migrate_set_state(MigrationStatus *state, MigrationStatus old_state,void migration_outgoing_setup (QIOChannel *ioc);bool migration_incoming_setup (QIOChannel *ioc,uint8_t channel,Error **errp); -uint8_t migration_ioc_process_incoming (QIOChannel *ioc,Error **errp); -void migration_incoming_process (void ); -bool migration_has_all_channels (void );void migration_connect_error_propagate (MigrationState *s,Error *error);void migrate_error_propagate (MigrationState *s,Error *error);bool migrate_has_error (MigrationState *s); -void migration_connect (MigrationState *s); +void migration_start_outgoing (MigrationState *s,QEMUFile *file);int migration_call_notifiers (MigrationState *s,MigrationEventType type,Error **errp);
migration/rdma.c +10 -11
@@ -3871,17 +3871,16 @@ static void rdma_accept_incoming_migration(void *opaque) rdma->migration_started_on_destination =1 ;migration_incoming_setup (ioc,0 ,NULL ); -migration_incoming_process (); +migration_start_incoming (); } -void rdma_start_incoming_migration (InetSocketAddress *host_port, -Error **errp) +void rdma_connect_incoming (InetSocketAddress *host_port,Error **errp) {MigrationState *s =migrate_get_current ();int ret;RDMAContext *rdma; -trace_rdma_start_incoming_migration (); +trace_rdma_connect_incoming ();/* Avoid ram_block_discard_disable(), cannot change during migration. */ if (ram_block_discard_is_required ()) {
@@ -3899,7 +3898,7 @@ void rdma_start_incoming_migration(InetSocketAddress *host_port, goto err; } -trace_rdma_start_incoming_migration_after_dest_init (); +trace_rdma_connect_incoming_after_dest_init (); ret =rdma_listen (rdma->listen_id,5 );
@@ -3908,7 +3907,7 @@ void rdma_start_incoming_migration(InetSocketAddress *host_port, goto cleanup_rdma; } -trace_rdma_start_incoming_migration_after_rdma_listen (); +trace_rdma_connect_incoming_after_rdma_listen (); s->rdma_migration = true;qemu_set_fd_handler (rdma->channel->fd, rdma_accept_incoming_migration,NULL , (void *)(intptr_t )rdma);
@@ -3923,8 +3922,8 @@ err:g_free (rdma); } -void rdma_start_outgoing_migration (void *opaque, -InetSocketAddress *host_port,Error **errp) +void rdma_connect_outgoing (void *opaque, +InetSocketAddress *host_port,Error **errp) {MigrationState *s = opaque;RDMAContext *rdma_return_path =NULL ;
@@ -3948,7 +3947,7 @@ void rdma_start_outgoing_migration(void *opaque, goto err; } -trace_rdma_start_outgoing_migration_after_rdma_source_init (); +trace_rdma_connect_outgoing_after_rdma_source_init (); ret =qemu_rdma_connect (rdma, false, errp);if (ret <0 ) {
@@ -3981,11 +3980,11 @@ void rdma_start_outgoing_migration(void *opaque, rdma_return_path->is_return_path = true; } -trace_rdma_start_outgoing_migration_after_rdma_connect (); +trace_rdma_connect_outgoing_after_rdma_connect (); s->rdma_migration = true;migration_outgoing_setup (rdma_new_ioc (rdma)); -migration_connect (s); +migration_start_outgoing (s);return ; return_path_err:qemu_rdma_cleanup (rdma);
migration/rdma.h +3 -3
@@ -21,10 +21,10 @@#include "system/memory.h" -void rdma_start_outgoing_migration (void *opaque,InetSocketAddress *host_port, -Error **errp); +void rdma_connect_outgoing (void *opaque,InetSocketAddress *host_port, +Error **errp); -void rdma_start_incoming_migration (InetSocketAddress *host_port,Error **errp); +void rdma_connect_incoming (InetSocketAddress *host_port,Error **errp);/* * Constants used by rdma return codes
migration/socket.c +3 -5
@@ -80,9 +80,8 @@ err:migration_connect_error_propagate (data->s, err); } -void socket_start_outgoing_migration (MigrationState *s, -SocketAddress *saddr, -Error **errp) +void socket_connect_outgoing (MigrationState *s,SocketAddress *saddr, +Error **errp) {QIOChannelSocket *sioc =qio_channel_socket_new (); struct SocketConnectData *data = g_new0(struct SocketConnectData, 1);
@@ -140,8 +139,7 @@ socket_incoming_migration_end(void *opaque)object_unref (OBJECT (listener)); } -void socket_start_incoming_migration (SocketAddress *saddr, -Error **errp) +void socket_connect_incoming (SocketAddress *saddr,Error **errp) {QIONetListener *listener =qio_net_listener_new ();MigrationIncomingState *mis =migration_incoming_get_current ();
migration/socket.h +3 -3
@@ -23,10 +23,10 @@void socket_send_channel_create (QIOTaskFunc f,void *data); -void socket_start_incoming_migration (SocketAddress *saddr,Error **errp); +void socket_connect_incoming (SocketAddress *saddr,Error **errp); -void socket_start_outgoing_migration (MigrationState *s, -SocketAddress *saddr,Error **errp); +void socket_connect_outgoing (MigrationState *s, +SocketAddress *saddr,Error **errp);void socket_cleanup_outgoing_migration (void );#endif
migration/trace-events +5 -5
@@ -271,11 +271,11 @@ rdma_registration_handle_wait(void) "" rdma_registration_start(uint64_t flags) "%" PRIu64 rdma_registration_stop(uint64_t flags) "%" PRIu64 rdma_registration_stop_ram(void) "" -rdma_start_incoming_migration(void) "" -rdma_start_incoming_migration_after_dest_init(void) "" -rdma_start_incoming_migration_after_rdma_listen(void) "" -rdma_start_outgoing_migration_after_rdma_connect(void) "" -rdma_start_outgoing_migration_after_rdma_source_init(void) "" +rdma_connect_incoming(void) "" +rdma_connect_incoming_after_dest_init(void) "" +rdma_connect_incoming_after_rdma_listen(void) "" +rdma_connect_outgoing_after_rdma_connect(void) "" +rdma_connect_outgoing_after_rdma_source_init(void) "" # postcopy-ram.c postcopy_discard_send_finish(const char *ramblock, int nwords, int ncmds) "%s mask words sent=%d in %d commands"
Signature · 1 line
2.51.0
RFC PATCH 17/25 migration: Move channel code to channel.c
In reply to Fabiano RosasMove the code responsible for the various channels connection into channel.c. This is all executed before the migration_thread and process_incoming_migration_co are running, so it helps the reasoning to have them out of migration.c.
migration_ioc_process_incoming becomes migration_channel_identify which is more in line with what the function does.
--- migration/channel.c | 99 ++++++++++++++++++++++++++++++++++++++++++- migration/channel.h | 12 ++++++ migration/migration.c | 98 ------------------------------------------ migration/migration.h | 5 +-- migration/rdma.c | 1 + 5 files changed, 113 insertions(+), 102 deletions(-)
migration/channel.c +98 -1
@@ -14,13 +14,110 @@#include "channel.h" #include "tls.h" #include "migration.h" +#include "multifd.h" +#include "savevm.h" #include "trace.h" +#include "options.h" #include "qapi/error.h" #include "io/channel-tls.h" #include "io/channel-socket.h" #include "qemu/yank.h" #include "yank_functions.h" +bool migration_has_main_and_multifd_channels (void ) +{ +MigrationIncomingState *mis =migration_incoming_get_current (); +if (!mis->from_src_file) { +/* main channel not established */ +return false; + } + +if (migrate_multifd () && !multifd_recv_all_channels_created ()) { +return false; + } + +/* main and all multifd channels are established */ +return true; +} + +/** +* @migration_has_all_channels: We have received all channels that we need +* +* Returns true when we have got connections to all the channels that +* we need for migration. +*/ +bool migration_has_all_channels (void ) +{ +if (!migration_has_main_and_multifd_channels ()) { +return false; + } + +MigrationIncomingState *mis =migration_incoming_get_current (); +if (migrate_postcopy_preempt () && !mis->postcopy_qemufile_dst) { +return false; + } + +return true; +} + +static int migration_channel_identify (MigrationIncomingState *mis, +QIOChannel *ioc,Error **errp) +{ +int channel =CH_NONE ; +uint32_t channel_magic =0 ; +int ret =0 ; + +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 +* source channels on destination side. Check channel MAGIC to +* decide type of channel. Please note this is best effort, +* postcopy preempt channel does not send any magic number so +* avoid it for postcopy live migration. Also tls live migration +* already does 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); +if (ret !=0 ) { + goto out; + } + + channel_magic =be32_to_cpu (channel_magic); +if (channel_magic ==QEMU_VM_FILE_MAGIC ) { + channel =CH_MAIN ; + }else if (channel_magic ==MULTIFD_MAGIC ) { +assert (migrate_multifd ()); + channel =CH_MULTIFD ; + }else if (!mis->from_src_file && + mis->state ==MIGRATION_STATUS_POSTCOPY_PAUSED ) { +/* reconnect main channel for postcopy recovery */ + channel =CH_MAIN ; + }else { +error_setg (errp,"unknown channel magic: %u" , channel_magic); + } + }else if (mis->from_src_file &&migrate_multifd ()) { +/* +* Non-peekable channels like tls/file are processed as +* multifd channels when multifd is enabled. +*/ + channel =CH_MULTIFD ; + }else if (!mis->from_src_file) { + channel =CH_MAIN ; + }else { +error_setg (errp,"non-peekable channel used without multifd" ); + } + }else { +assert (migrate_postcopy_preempt ()); + channel =CH_POSTCOPY ; + } + +out: +return channel; +} +/** * @migration_channel_process_incoming - Create new incoming migration channel *
@@ -42,7 +139,7 @@ void migration_channel_process_incoming(QIOChannel *ioc)migration_tls_channel_process_incoming (ioc, &local_err); }else {migration_ioc_register_yank (ioc); - ch =migration_ioc_process_incoming (ioc, &local_err); + ch =migration_channel_identify (mis, ioc, &local_err);if (!ch) { goto out; }
migration/channel.h +12 -0
@@ -18,6 +18,14 @@#include "io/channel.h" +/* Migration channel types */ +enum { +CH_NONE , +CH_MAIN , +CH_MULTIFD , +CH_POSTCOPY +}; +void migration_channel_process_incoming (QIOChannel *ioc);void migration_channel_connect_outgoing (MigrationState *s,QIOChannel *ioc);
@@ -26,4 +34,8 @@ int migration_channel_read_peek(QIOChannel *ioc,const char *buf, const size_t buflen, Error **errp); + +bool migration_has_main_and_multifd_channels (void ); +bool migration_has_all_channels (void ); +#endif
migration/migration.c +0 -98
116 lines not on this page · raw message
migration/migration.h +2 -3
@@ -529,13 +529,12 @@ void migrate_set_state(MigrationStatus *state, MigrationStatus old_state,void migration_outgoing_setup (QIOChannel *ioc);bool migration_incoming_setup (QIOChannel *ioc,uint8_t channel,Error **errp); -bool migration_has_all_channels (void ); -void migration_connect_error_propagate (MigrationState *s,Error *error);void migrate_error_propagate (MigrationState *s,Error *error);bool migrate_has_error (MigrationState *s); -void migration_start_outgoing (MigrationState *s,QEMUFile *file); +void migration_start_outgoing (MigrationState *s); +void migration_start_incoming (void );int migration_call_notifiers (MigrationState *s,MigrationEventType type,Error **errp);
migration/rdma.c +1 -0
@@ -17,6 +17,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/cutils.h" +#include "channel.h" #include "exec/target_page.h" #include "rdma.h" #include "migration.h"
Signature · 1 line
2.51.0
RFC PATCH 18/25 migration: Move transport connection code into channel.c
In reply to Fabiano RosasMove the <transport>_connect_incoming|outgoing functions to channel.c. It leaves migration.c to deal with the established connection only.
(I sorted the includes)
--- migration/channel.c | 66 +++++++++++++++++++++++++++++++++++++++---- migration/channel.h | 4 +++ migration/migration.c | 45 ++--------------------------- 3 files changed, 67 insertions(+), 48 deletions(-)
migration/channel.c +61 -5
@@ -12,18 +12,74 @@#include "qemu/osdep.h" #include "channel.h" -#include "tls.h" +#include "exec.h" +#include "fd.h" +#include "file.h" +#include "io/channel-socket.h" +#include "io/channel-tls.h" #include "migration.h" #include "multifd.h" -#include "savevm.h" -#include "trace.h" #include "options.h" +#include "qapi/qapi-types-migration.h" #include "qapi/error.h" -#include "io/channel-tls.h" -#include "io/channel-socket.h" +#include "qemu-file.h" #include "qemu/yank.h" +#include "rdma.h" +#include "savevm.h" +#include "socket.h" +#include "tls.h" +#include "trace.h" #include "yank_functions.h" +void migration_connect_outgoing (MigrationState *s,MigrationAddress *addr, +Error **errp) +{ +if (addr->transport ==MIGRATION_ADDRESS_TYPE_SOCKET ) { +SocketAddress *saddr = &addr->u.socket; +if (saddr->type ==SOCKET_ADDRESS_TYPE_INET || + saddr->type ==SOCKET_ADDRESS_TYPE_UNIX || + saddr->type ==SOCKET_ADDRESS_TYPE_VSOCK ) { +socket_connect_outgoing (s, saddr, errp); + }else if (saddr->type ==SOCKET_ADDRESS_TYPE_FD ) { +fd_connect_outgoing (s, saddr->u.fd.str, errp); + } +#ifdef CONFIG_RDMA + }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_RDMA ) { +rdma_connect_outgoing (s, &addr->u.rdma, errp); +#endif + }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_EXEC ) { +exec_connect_outgoing (s, addr->u.exec.args, errp); + }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_FILE ) { +file_connect_outgoing (s, &addr->u.file, errp); + }else { +error_setg (errp,"uri is not a valid migration protocol" ); + } +} + +void migration_connect_incoming (MigrationAddress *addr,Error **errp) +{ +if (addr->transport ==MIGRATION_ADDRESS_TYPE_SOCKET ) { +SocketAddress *saddr = &addr->u.socket; +if (saddr->type ==SOCKET_ADDRESS_TYPE_INET || + saddr->type ==SOCKET_ADDRESS_TYPE_UNIX || + saddr->type ==SOCKET_ADDRESS_TYPE_VSOCK ) { +socket_connect_incoming (saddr, errp); + }else if (saddr->type ==SOCKET_ADDRESS_TYPE_FD ) { +fd_connect_incoming (saddr->u.fd.str, errp); + } +#ifdef CONFIG_RDMA + }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_RDMA ) { +rdma_connect_incoming (&addr->u.rdma, errp); +#endif + }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_EXEC ) { +exec_connect_incoming (addr->u.exec.args, errp); + }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_FILE ) { +file_connect_incoming (&addr->u.file, errp); + }else { +error_setg (errp,"unknown migration protocol" ); + } +} +bool migration_has_main_and_multifd_channels (void ) {MigrationIncomingState *mis =migration_incoming_get_current ();
migration/channel.h +4 -0
@@ -17,6 +17,7 @@#define QEMU_MIGRATION_CHANNEL_H #include "io/channel.h" +#include "qapi/qapi-types-migration.h" /* Migration channel types */ enum {
@@ -38,4 +39,7 @@ int migration_channel_read_peek(QIOChannel *ioc,bool migration_has_main_and_multifd_channels (void );bool migration_has_all_channels (void ); +void migration_connect_outgoing (MigrationState *s,MigrationAddress *addr, +Error **errp); +void migration_connect_incoming (MigrationAddress *addr,Error **errp);#endif
migration/migration.c +2 -43
67 lines not on this page · raw message
Signature · 1 line
2.51.0
RFC PATCH 19/25 migration/channel: Make synchronous calls evident
In reply to Fabiano RosasMake the synchronous calls evident by not hiding the call to migration_channel_connect_outgoing in the transport code. Have those functions return and call the migration_connect_outgoing() at the upper level.
This helps with navigation: the transport code returns the ioc, there's no need to look into them when browsing the code.
It also allows RDMA in the source side to use the same path as the rest of the transports.
While here, document the async calls which are the exception.
--- migration/channel.c | 30 +++++++++++++++++++++++++----- migration/channel.h | 2 +- migration/exec.c | 8 ++++---- migration/exec.h | 5 ++++- migration/fd.c | 13 +++++++------ migration/fd.h | 7 +++++-- migration/file.c | 18 ++++++++++-------- migration/file.h | 5 +++-- migration/migration.c | 3 +-- migration/rdma.c | 11 +++++------ migration/rdma.h | 4 ++-- 11 files changed, 67 insertions(+), 39 deletions(-)
migration/channel.c +25 -5
@@ -31,29 +31,43 @@#include "trace.h" #include "yank_functions.h" -void migration_connect_outgoing (MigrationState *s,MigrationAddress *addr, +bool migration_connect_outgoing (MigrationState *s,MigrationAddress *addr,Error **errp) { +g_autoptr (QIOChannel) ioc =NULL ; +if (addr->transport ==MIGRATION_ADDRESS_TYPE_SOCKET ) {SocketAddress *saddr = &addr->u.socket;if (saddr->type ==SOCKET_ADDRESS_TYPE_INET || saddr->type ==SOCKET_ADDRESS_TYPE_UNIX || saddr->type ==SOCKET_ADDRESS_TYPE_VSOCK ) {socket_connect_outgoing (s, saddr, errp); +/* +* async: after the socket is connected, calls +* migration_channel_connect_outgoing() directly. +*/ +return true; }else if (saddr->type ==SOCKET_ADDRESS_TYPE_FD ) { -fd_connect_outgoing (s, saddr->u.fd.str, errp); + ioc =fd_connect_outgoing (s, saddr->u.fd.str, errp); } #ifdef CONFIG_RDMA }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_RDMA ) { -rdma_connect_outgoing (s, &addr->u.rdma, errp); + ioc =rdma_connect_outgoing (s, &addr->u.rdma, errp);#endif }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_EXEC ) { -exec_connect_outgoing (s, addr->u.exec.args, errp); + ioc =exec_connect_outgoing (s, addr->u.exec.args, errp); }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_FILE ) { -file_connect_outgoing (s, &addr->u.file, errp); + ioc =file_connect_outgoing (s, &addr->u.file, errp); }else {error_setg (errp,"uri is not a valid migration protocol" ); } + +if (!ioc) { +return false; + } + +migration_channel_connect_outgoing (s, ioc); +return true; }void migration_connect_incoming (MigrationAddress *addr,Error **errp)
@@ -78,6 +92,12 @@ void migration_connect_incoming(MigrationAddress *addr, Error **errp) }else {error_setg (errp,"unknown migration protocol" ); } + +/* +* async: the above routines all wait for the incoming connection +* and call back to migration_channel_process_incoming() to start +* the migration. +*/ }bool migration_has_main_and_multifd_channels (void )
migration/channel.h +1 -1
@@ -39,7 +39,7 @@ int migration_channel_read_peek(QIOChannel *ioc,bool migration_has_main_and_multifd_channels (void );bool migration_has_all_channels (void ); -void migration_connect_outgoing (MigrationState *s,MigrationAddress *addr, +bool migration_connect_outgoing (MigrationState *s,MigrationAddress *addr,Error **errp);void migration_connect_incoming (MigrationAddress *addr,Error **errp);#endif
migration/exec.c +4 -4
@@ -40,7 +40,8 @@ const char *exec_get_cmd_path(void) }#endif -void exec_connect_outgoing (MigrationState *s,strList *command,Error **errp) +QIOChannel *exec_connect_outgoing (MigrationState *s,strList *command, +Error **errp) {QIOChannel *ioc =NULL ;g_auto (GStrv) argv =strv_from_str_list (command);
@@ -50,12 +51,11 @@ void exec_connect_outgoing(MigrationState *s, strList *command, Error **errp)trace_migration_exec_outgoing (new_command); ioc =QIO_CHANNEL (qio_channel_command_new_spawn (args,O_RDWR , errp));if (!ioc) { -return ; +return NULL ; }qio_channel_set_name (ioc,"migration-exec-outgoing" ); -migration_channel_connect_outgoing (s, ioc); -object_unref (OBJECT (ioc)); +return ioc; } static gboolean exec_accept_incoming_migration(QIOChannel *ioc,
migration/exec.h +4 -1
@@ -20,10 +20,13 @@#ifndef QEMU_MIGRATION_EXEC_H #define QEMU_MIGRATION_EXEC_H +#include "io/channel.h" +#ifdef WIN32 const char *exec_get_cmd_path (void );#endif void exec_connect_incoming (strList *host_port,Error **errp); -void exec_connect_outgoing (MigrationState *s,strList *host_port,Error **errp); +QIOChannel *exec_connect_outgoing (MigrationState *s,strList *host_port, +Error **errp);#endif
migration/fd.c +7 -6
@@ -49,12 +49,13 @@ static bool migration_fd_valid(int fd)return false; } -void fd_connect_outgoing (MigrationState *s,const char *fdname,Error **errp) +QIOChannel *fd_connect_outgoing (MigrationState *s,const char *fdname, +Error **errp) { -QIOChannel *ioc; +QIOChannel *ioc =NULL ;int fd =monitor_get_fd (monitor_cur (), fdname, errp);if (fd ==-1 ) { -return ; + goto out; }if (!migration_fd_valid (fd)) {
@@ -66,12 +67,12 @@ void fd_connect_outgoing(MigrationState *s, const char *fdname, Error **errp) ioc =qio_channel_new_fd (fd, errp);if (!ioc) {close (fd); -return ; + goto out; }qio_channel_set_name (ioc,"migration-fd-outgoing" ); -migration_channel_connect_outgoing (s, ioc); -object_unref (OBJECT (ioc)); +out: +return ioc; } static gboolean fd_accept_incoming_migration(QIOChannel *ioc,
migration/fd.h +5 -2
@@ -16,8 +16,11 @@#ifndef QEMU_MIGRATION_FD_H #define QEMU_MIGRATION_FD_H + +#include "io/channel.h" +void fd_connect_incoming (const char *fdname,Error **errp); -void fd_connect_outgoing (MigrationState *s,const char *fdname, -Error **errp); +QIOChannel *fd_connect_outgoing (MigrationState *s,const char *fdname, +Error **errp);#endif
migration/file.c +10 -8
@@ -93,36 +93,38 @@ out:return ret; } -void file_connect_outgoing (MigrationState *s, -FileMigrationArgs *file_args,Error **errp) +QIOChannel *file_connect_outgoing (MigrationState *s, +FileMigrationArgs *file_args,Error **errp) { -g_autoptr (QIOChannelFile) fioc =NULL ; +QIOChannelFile *fioc =NULL ; g_autofree char *filename = g_strdup(file_args->filename);uint64_t offset = file_args->offset; -QIOChannel *ioc; +QIOChannel *ioc =NULL ;trace_migration_file_outgoing (filename); fioc =qio_channel_file_new_path (filename,O_CREAT |O_WRONLY ,0600 , errp);if (!fioc) { -return ; + goto out; }if (ftruncate (fioc->fd, offset)) {error_setg_errno (errp, errno,"failed to truncate migration file to offset %" PRIx64, offset); -return ; + goto out; } outgoing_args.fname =g_strdup (filename); ioc =QIO_CHANNEL (fioc);if (offset &&qio_channel_io_seek (ioc, offset,SEEK_SET , errp) <0 ) { -return ; + ioc =NULL ; + goto out; }qio_channel_set_name (ioc,"migration-file-outgoing" ); -migration_channel_connect_outgoing (s, ioc); +out: +return ioc; } static gboolean file_accept_incoming_migration(QIOChannel *ioc,
migration/file.h +3 -2
@@ -9,14 +9,15 @@#define QEMU_MIGRATION_FILE_H #include "qapi/qapi-types-migration.h" +#include "io/channel.h" #include "io/task.h" #include "channel.h" #include "multifd.h" void file_connect_incoming (FileMigrationArgs *file_args,Error **errp); -void file_connect_outgoing (MigrationState *s, -FileMigrationArgs *file_args,Error **errp); +QIOChannel *file_connect_outgoing (MigrationState *s, +FileMigrationArgs *file_args,Error **errp);int file_parse_offset (char *filespec,uint64_t *offsetp,Error **errp);void file_cleanup_outgoing_migration (void );bool file_send_channel_create (gpointer opaque,Error **errp);
migration/migration.c +1 -2
@@ -2217,9 +2217,8 @@ out:static void qmp_migrate_finish (MigrationAddress *addr,Error **errp) {MigrationState *s =migrate_get_current (); -Error *local_err =NULL ; -migration_connect_outgoing (s, addr, &local_err); +migration_connect_outgoing (s, addr, errp); }void qmp_migrate_cancel (Error **errp)
migration/rdma.c +5 -6
@@ -3923,8 +3923,8 @@ err:g_free (rdma); } -void rdma_connect_outgoing (void *opaque, -InetSocketAddress *host_port,Error **errp) +QIOChannel *rdma_connect_outgoing (void *opaque, +InetSocketAddress *host_port,Error **errp) {MigrationState *s = opaque;RDMAContext *rdma_return_path =NULL ;
@@ -3934,7 +3934,7 @@ void rdma_connect_outgoing(void *opaque,/* Avoid ram_block_discard_disable(), cannot change during migration. */ if (ram_block_discard_is_required ()) {error_setg (errp,"RDMA: cannot disable RAM discard" ); -return ; +return NULL ; } rdma =qemu_rdma_data_init (host_port, errp);
@@ -3984,12 +3984,11 @@ void rdma_connect_outgoing(void *opaque,trace_rdma_connect_outgoing_after_rdma_connect (); s->rdma_migration = true; -migration_outgoing_setup (rdma_new_ioc (rdma)); -migration_start_outgoing (s); -return ; +return rdma_new_ioc (rdma); return_path_err:qemu_rdma_cleanup (rdma); err:g_free (rdma);g_free (rdma_return_path); +return NULL ; }
migration/rdma.h +2 -2
@@ -21,8 +21,8 @@#include "system/memory.h" -void rdma_connect_outgoing (void *opaque,InetSocketAddress *host_port, -Error **errp); +QIOChannel *rdma_connect_outgoing (void *opaque,InetSocketAddress *host_port, +Error **errp);void rdma_connect_incoming (InetSocketAddress *host_port,Error **errp);
Signature · 1 line
2.51.0
RFC PATCH 20/25 migration/channel: Use switch statements in outgoing code
In reply to Fabiano RosasMake this code easier on the eyes and remove all the visual clutter. There will be more lines added here in next patches.
--- migration/channel.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-)
migration/channel.c +28 -10
@@ -35,31 +35,49 @@ bool migration_connect_outgoing(MigrationState *s, MigrationAddress *addr, Error **errp) {g_autoptr (QIOChannel) ioc =NULL ; +SocketAddress *saddr; -if (addr->transport ==MIGRATION_ADDRESS_TYPE_SOCKET ) { -SocketAddress *saddr = &addr->u.socket; -if (saddr->type ==SOCKET_ADDRESS_TYPE_INET || - saddr->type ==SOCKET_ADDRESS_TYPE_UNIX || - saddr->type ==SOCKET_ADDRESS_TYPE_VSOCK ) { +switch (addr->transport) { +case MIGRATION_ADDRESS_TYPE_SOCKET : + saddr = &addr->u.socket; + +switch (saddr->type) { +case SOCKET_ADDRESS_TYPE_INET : +case SOCKET_ADDRESS_TYPE_UNIX : +case SOCKET_ADDRESS_TYPE_VSOCK :socket_connect_outgoing (s, saddr, errp);/* * async: after the socket is connected, calls * migration_channel_connect_outgoing() directly. */ return true; - }else if (saddr->type ==SOCKET_ADDRESS_TYPE_FD ) { +break ; +case SOCKET_ADDRESS_TYPE_FD : ioc =fd_connect_outgoing (s, saddr->u.fd.str, errp); +break ; +default : +g_assert_not_reached (); } + +break ; +#ifdef CONFIG_RDMA - }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_RDMA ) { +case MIGRATION_ADDRESS_TYPE_RDMA : ioc =rdma_connect_outgoing (s, &addr->u.rdma, errp); +break ;#endif - }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_EXEC ) { + +case MIGRATION_ADDRESS_TYPE_EXEC : ioc =exec_connect_outgoing (s, addr->u.exec.args, errp); - }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_FILE ) { +break ; + +case MIGRATION_ADDRESS_TYPE_FILE : ioc =file_connect_outgoing (s, &addr->u.file, errp); - }else { +break ; + +default :error_setg (errp,"uri is not a valid migration protocol" ); +break ; }if (!ioc) {
Signature · 1 line
2.51.0
RFC PATCH 21/25 migration/channel: Cleanup early passing of MigrationState
In reply to Fabiano RosasMigrationState is being passed around quite a lot, but there are not many actual users. Reduce the passing around by converting some key functions to use migrate_get_current(). Although this goes against the general direction of not using migrate_get_current(), doing this helps to isolate the places that actually need MigrationState and could facilitate future cleanups.
In the early connection code, qmp_migrate() needs MigrationState only to make sure it reaches:
migrate_prepare()
migrate_hup_add()
migration_start_outgoing()
migration_connect_error_propagate()
The first two are at the top level, so are trivial to change. The last two actually require passing 's' around between several functions, making the code way more complex than it needs to be.
--- migration/channel.c | 21 +++++++++---------- migration/channel.h | 5 ++--- migration/exec.c | 3 +-- migration/exec.h | 3 +-- migration/fd.c | 3 +-- migration/fd.h | 3 +-- migration/file.c | 3 +-- migration/file.h | 3 +-- migration/migration.c | 49 +++++++++++++++++++++++-------------------- migration/migration.h | 4 ++-- migration/rdma.c | 5 ++--- migration/rdma.h | 3 +-- migration/socket.c | 32 +++++++--------------------- migration/socket.h | 3 +-- migration/tls.c | 11 +++++----- migration/tls.h | 2 +- 16 files changed, 63 insertions(+), 90 deletions(-)
migration/channel.c +10 -11
@@ -31,8 +31,7 @@#include "trace.h" #include "yank_functions.h" -bool migration_connect_outgoing (MigrationState *s,MigrationAddress *addr, -Error **errp) +bool migration_connect_outgoing (MigrationAddress *addr,Error **errp) {g_autoptr (QIOChannel) ioc =NULL ;SocketAddress *saddr;
@@ -45,7 +44,7 @@ bool migration_connect_outgoing(MigrationState *s, MigrationAddress *addr,case SOCKET_ADDRESS_TYPE_INET :case SOCKET_ADDRESS_TYPE_UNIX :case SOCKET_ADDRESS_TYPE_VSOCK : -socket_connect_outgoing (s, saddr, errp); +socket_connect_outgoing (saddr, errp);/* * async: after the socket is connected, calls * migration_channel_connect_outgoing() directly.
@@ -53,7 +52,7 @@ bool migration_connect_outgoing(MigrationState *s, MigrationAddress *addr,return true;break ;case SOCKET_ADDRESS_TYPE_FD : - ioc =fd_connect_outgoing (s, saddr->u.fd.str, errp); + ioc =fd_connect_outgoing (saddr->u.fd.str, errp);break ;default :g_assert_not_reached ();
@@ -63,16 +62,16 @@ bool migration_connect_outgoing(MigrationState *s, MigrationAddress *addr,#ifdef CONFIG_RDMA case MIGRATION_ADDRESS_TYPE_RDMA : - ioc =rdma_connect_outgoing (s, &addr->u.rdma, errp); + ioc =rdma_connect_outgoing (&addr->u.rdma, errp);break ;#endif case MIGRATION_ADDRESS_TYPE_EXEC : - ioc =exec_connect_outgoing (s, addr->u.exec.args, errp); + ioc =exec_connect_outgoing (addr->u.exec.args, errp);break ;case MIGRATION_ADDRESS_TYPE_FILE : - ioc =file_connect_outgoing (s, &addr->u.file, errp); + ioc =file_connect_outgoing (&addr->u.file, errp);break ;default :
@@ -84,7 +83,7 @@ bool migration_connect_outgoing(MigrationState *s, MigrationAddress *addr,return false; } -migration_channel_connect_outgoing (s, ioc); +migration_channel_connect_outgoing (ioc);return true; }
@@ -252,12 +251,12 @@ out: } } -void migration_channel_connect_outgoing (MigrationState *s,QIOChannel *ioc) +void migration_channel_connect_outgoing (QIOChannel *ioc) {trace_migration_set_outgoing_channel (ioc,object_get_typename (OBJECT (ioc)));if (migrate_channel_requires_tls_upgrade (ioc)) { -migration_tls_channel_connect (s, ioc); +migration_tls_channel_connect (ioc);/* * async: the above will call back to this function after
@@ -268,7 +267,7 @@ void migration_channel_connect_outgoing(MigrationState *s, QIOChannel *ioc)migration_ioc_register_yank (ioc);migration_outgoing_setup (ioc); -migration_start_outgoing (s); +migration_start_outgoing (); }
migration/channel.h +2 -3
@@ -29,7 +29,7 @@ enum {void migration_channel_process_incoming (QIOChannel *ioc); -void migration_channel_connect_outgoing (MigrationState *s,QIOChannel *ioc); +void migration_channel_connect_outgoing (QIOChannel *ioc); int migration_channel_read_peek(QIOChannel *ioc, const char *buf,
@@ -39,7 +39,6 @@ int migration_channel_read_peek(QIOChannel *ioc,bool migration_has_main_and_multifd_channels (void );bool migration_has_all_channels (void ); -bool migration_connect_outgoing (MigrationState *s,MigrationAddress *addr, -Error **errp); +bool migration_connect_outgoing (MigrationAddress *addr,Error **errp);void migration_connect_incoming (MigrationAddress *addr,Error **errp);#endif
migration/exec.c +1 -2
@@ -40,8 +40,7 @@ const char *exec_get_cmd_path(void) }#endif -QIOChannel *exec_connect_outgoing (MigrationState *s,strList *command, -Error **errp) +QIOChannel *exec_connect_outgoing (strList *command,Error **errp) {QIOChannel *ioc =NULL ;g_auto (GStrv) argv =strv_from_str_list (command);
migration/exec.h +1 -2
@@ -27,6 +27,5 @@ const char *exec_get_cmd_path(void);#endif void exec_connect_incoming (strList *host_port,Error **errp); -QIOChannel *exec_connect_outgoing (MigrationState *s,strList *host_port, -Error **errp); +QIOChannel *exec_connect_outgoing (strList *host_port,Error **errp);#endif
migration/fd.c +1 -2
@@ -49,8 +49,7 @@ static bool migration_fd_valid(int fd)return false; } -QIOChannel *fd_connect_outgoing (MigrationState *s,const char *fdname, -Error **errp) +QIOChannel *fd_connect_outgoing (const char *fdname,Error **errp) {QIOChannel *ioc =NULL ;int fd =monitor_get_fd (monitor_cur (), fdname, errp);
migration/fd.h +1 -2
@@ -21,6 +21,5 @@void fd_connect_incoming (const char *fdname,Error **errp); -QIOChannel *fd_connect_outgoing (MigrationState *s,const char *fdname, -Error **errp); +QIOChannel *fd_connect_outgoing (const char *fdname,Error **errp);#endif
migration/file.c +1 -2
@@ -93,8 +93,7 @@ out:return ret; } -QIOChannel *file_connect_outgoing (MigrationState *s, -FileMigrationArgs *file_args,Error **errp) +QIOChannel *file_connect_outgoing (FileMigrationArgs *file_args,Error **errp) {QIOChannelFile *fioc =NULL ; g_autofree char *filename = g_strdup(file_args->filename);
migration/file.h +1 -2
@@ -16,8 +16,7 @@void file_connect_incoming (FileMigrationArgs *file_args,Error **errp); -QIOChannel *file_connect_outgoing (MigrationState *s, -FileMigrationArgs *file_args,Error **errp); +QIOChannel *file_connect_outgoing (FileMigrationArgs *file_args,Error **errp);int file_parse_offset (char *filespec,uint64_t *offsetp,Error **errp);void file_cleanup_outgoing_migration (void );bool file_send_channel_create (gpointer opaque,Error **errp);
migration/migration.c +26 -23
150 lines not on this page · raw message
migration/migration.h +2 -2
@@ -529,11 +529,11 @@ void migrate_set_state(MigrationStatus *state, MigrationStatus old_state,void migration_outgoing_setup (QIOChannel *ioc);bool migration_incoming_setup (QIOChannel *ioc,uint8_t channel,Error **errp); -void migration_connect_error_propagate (MigrationState *s,Error *error); +void migration_connect_error_propagate (Error *error);void migrate_error_propagate (MigrationState *s,Error *error);bool migrate_has_error (MigrationState *s); -void migration_start_outgoing (MigrationState *s); +void migration_start_outgoing (void );void migration_start_incoming (void ); int migration_call_notifiers(MigrationState *s, MigrationEventType type,
migration/rdma.c +2 -3
@@ -3923,10 +3923,9 @@ err:g_free (rdma); } -QIOChannel *rdma_connect_outgoing (void *opaque, -InetSocketAddress *host_port,Error **errp) +QIOChannel *rdma_connect_outgoing (InetSocketAddress *host_port,Error **errp) { -MigrationState *s = opaque; +MigrationState *s =migrate_get_current ();RDMAContext *rdma_return_path =NULL ;RDMAContext *rdma;int ret;
migration/rdma.h +1 -2
@@ -21,8 +21,7 @@#include "system/memory.h" -QIOChannel *rdma_connect_outgoing (void *opaque,InetSocketAddress *host_port, -Error **errp); +QIOChannel *rdma_connect_outgoing (InetSocketAddress *host_port,Error **errp);void rdma_connect_incoming (InetSocketAddress *host_port,Error **errp);
migration/socket.c +7 -25
@@ -42,23 +42,8 @@ void socket_send_channel_create(QIOTaskFunc f, void *data) f, data, NULL, NULL); } -struct SocketConnectData { -MigrationState *s; -}; - -static void socket_connect_data_free (void *opaque) +static void socket_outgoing_migration (QIOTask *task,gpointer opaque) { -struct SocketConnectData *data = opaque; -if (!data) { -return ; - } -g_free (data); -} - -static void socket_outgoing_migration (QIOTask *task, -gpointer opaque) -{ -struct SocketConnectData *data = opaque;g_autoptr (QIOChannel) sioc =QIO_CHANNEL (qio_task_get_source (task));Error *err =NULL ;
@@ -73,22 +58,19 @@ static void socket_outgoing_migration(QIOTask *task, }trace_migration_socket_outgoing_connected (); -migration_channel_connect_outgoing (data->s, sioc); +migration_channel_connect_outgoing (sioc);return ; err:trace_migration_socket_outgoing_error (error_get_pretty (err)); -migration_connect_error_propagate (data->s, err); +migration_connect_error_propagate (err); } -void socket_connect_outgoing (MigrationState *s,SocketAddress *saddr, -Error **errp) +void socket_connect_outgoing (SocketAddress *saddr,Error **errp) { +MigrationState *s =migrate_get_current ();QIOChannelSocket *sioc =qio_channel_socket_new (); - struct SocketConnectData *data = g_new0(struct SocketConnectData, 1);SocketAddress *addr =QAPI_CLONE (SocketAddress, saddr); - data->s = s; -/* in case previous migration leaked it */ qapi_free_SocketAddress (outgoing_args.saddr); outgoing_args.saddr = addr;
@@ -101,8 +83,8 @@ void socket_connect_outgoing(MigrationState *s, SocketAddress *saddr,qio_channel_socket_connect_async (sioc, saddr, socket_outgoing_migration, - data, - socket_connect_data_free, +NULL , +NULL ,NULL ); }
migration/socket.h +1 -2
@@ -25,8 +25,7 @@ void socket_send_channel_create(QIOTaskFunc f, void *data);void socket_connect_incoming (SocketAddress *saddr,Error **errp); -void socket_connect_outgoing (MigrationState *s, -SocketAddress *saddr,Error **errp); +void socket_connect_outgoing (SocketAddress *saddr,Error **errp);void socket_cleanup_outgoing_migration (void );#endif
migration/tls.c +5 -6
@@ -103,18 +103,17 @@ void migration_tls_channel_process_incoming(QIOChannel *ioc, Error **errp)static void migration_tls_outgoing_handshake (QIOTask *task,gpointer opaque) { -MigrationState *s = opaque;g_autoptr (QIOChannel) ioc =QIO_CHANNEL (qio_task_get_source (task));Error *err =NULL ;if (qio_task_propagate_error (task, &err)) {trace_migration_tls_outgoing_handshake_error (error_get_pretty (err)); -migration_connect_error_propagate (s, err); +migration_connect_error_propagate (err);return ; }trace_migration_tls_outgoing_handshake_complete (); -migration_channel_connect_outgoing (s, ioc); +migration_channel_connect_outgoing (ioc); } QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc,
@@ -130,14 +129,14 @@ QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc,return qio_channel_tls_new_client (ioc, creds,migrate_tls_hostname (), errp); } -void migration_tls_channel_connect (MigrationState *s,QIOChannel *ioc) +void migration_tls_channel_connect (QIOChannel *ioc) {QIOChannelTLS *tioc;Error *local_err =NULL ; tioc =migration_tls_client_create (ioc, &local_err);if (!tioc) { -migration_connect_error_propagate (s, local_err); +migration_connect_error_propagate (local_err);return ; }
@@ -150,7 +149,7 @@ void migration_tls_channel_connect(MigrationState *s, QIOChannel *ioc) }qio_channel_tls_handshake (tioc, migration_tls_outgoing_handshake, - s, +NULL ,NULL ,NULL ); }
migration/tls.h +1 -1
@@ -29,7 +29,7 @@ void migration_tls_channel_process_incoming(QIOChannel *ioc, Error **errp);QIOChannelTLS *migration_tls_client_create (QIOChannel *ioc,Error **errp); -void migration_tls_channel_connect (MigrationState *s,QIOChannel *ioc); +void migration_tls_channel_connect (QIOChannel *ioc);void migration_tls_channel_end (QIOChannel *ioc,Error **errp);/* Whether the QIO channel requires further TLS handshake? */ bool migrate_channel_requires_tls_upgrade (QIOChannel *ioc);
Signature · 1 line
2.51.0
RFC PATCH 22/25 migration/channel: Merge both sides of the connection initiation code
In reply to Fabiano RosasNow that everything is in channel.c, it's easier to browse this code if it's all in the same place. It's also easier to grasp what the connection flow is if both sides of the connection are close together.
--- migration/channel.c | 86 +++++++++++++++++++++++---------------------- migration/channel.h | 14 ++++++-- 2 files changed, 56 insertions(+), 44 deletions(-)
migration/channel.c +44 -42
@@ -31,10 +31,11 @@#include "trace.h" #include "yank_functions.h" -bool migration_connect_outgoing (MigrationAddress *addr,Error **errp) +bool migration_connect (MigrationAddress *addr,bool out,Error **errp) {g_autoptr (QIOChannel) ioc =NULL ;SocketAddress *saddr; +ERRP_GUARD ();switch (addr->transport) {case MIGRATION_ADDRESS_TYPE_SOCKET :
@@ -44,15 +45,24 @@ bool migration_connect_outgoing(MigrationAddress *addr, Error **errp)case SOCKET_ADDRESS_TYPE_INET :case SOCKET_ADDRESS_TYPE_UNIX :case SOCKET_ADDRESS_TYPE_VSOCK : -socket_connect_outgoing (saddr, errp); -/* -* async: after the socket is connected, calls -* migration_channel_connect_outgoing() directly. -*/ -return true; +if (out) { +socket_connect_outgoing (saddr, errp); +/* +* async: after the socket is connected, calls +* migration_channel_connect_outgoing() directly. +*/ +return true; + }else { +socket_connect_incoming (saddr, errp); + } +break ;case SOCKET_ADDRESS_TYPE_FD : - ioc =fd_connect_outgoing (saddr->u.fd.str, errp); +if (out) { + ioc =fd_connect_outgoing (saddr->u.fd.str, errp); + }else { +fd_connect_incoming (saddr->u.fd.str, errp); + }break ;default :g_assert_not_reached ();
@@ -62,16 +72,28 @@ bool migration_connect_outgoing(MigrationAddress *addr, Error **errp)#ifdef CONFIG_RDMA case MIGRATION_ADDRESS_TYPE_RDMA : - ioc =rdma_connect_outgoing (&addr->u.rdma, errp); +if (out) { + ioc =rdma_connect_outgoing (&addr->u.rdma, errp); + }else { +rdma_connect_incoming (&addr->u.rdma, errp); + }break ;#endif case MIGRATION_ADDRESS_TYPE_EXEC : - ioc =exec_connect_outgoing (addr->u.exec.args, errp); +if (out) { + ioc =exec_connect_outgoing (addr->u.exec.args, errp); + }else { +exec_connect_incoming (addr->u.exec.args, errp); + }break ;case MIGRATION_ADDRESS_TYPE_FILE : - ioc =file_connect_outgoing (&addr->u.file, errp); +if (out) { + ioc =file_connect_outgoing (&addr->u.file, errp); + }else { +file_connect_incoming (&addr->u.file, errp); + }break ;default :
@@ -79,42 +101,22 @@ bool migration_connect_outgoing(MigrationAddress *addr, Error **errp)break ; } -if (!ioc) { -return false; - } - -migration_channel_connect_outgoing (ioc); -return true; -} - -void migration_connect_incoming (MigrationAddress *addr,Error **errp) -{ -if (addr->transport ==MIGRATION_ADDRESS_TYPE_SOCKET ) { -SocketAddress *saddr = &addr->u.socket; -if (saddr->type ==SOCKET_ADDRESS_TYPE_INET || - saddr->type ==SOCKET_ADDRESS_TYPE_UNIX || - saddr->type ==SOCKET_ADDRESS_TYPE_VSOCK ) { -socket_connect_incoming (saddr, errp); - }else if (saddr->type ==SOCKET_ADDRESS_TYPE_FD ) { -fd_connect_incoming (saddr->u.fd.str, errp); +if (out) { +if (!ioc) { +return false; } -#ifdef CONFIG_RDMA - }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_RDMA ) { -rdma_connect_incoming (&addr->u.rdma, errp); -#endif - }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_EXEC ) { -exec_connect_incoming (addr->u.exec.args, errp); - }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_FILE ) { -file_connect_incoming (&addr->u.file, errp); - }else { -error_setg (errp,"unknown migration protocol" ); + +migration_channel_connect_outgoing (ioc); +return true; }/* -* async: the above routines all wait for the incoming connection -* and call back to migration_channel_process_incoming() to start -* the migration. +* async: on the incoming side all of the transport routines above +* wait for the incoming connection and call back to +* migration_channel_process_incoming() to start the migration. */ + +return !*errp; }bool migration_has_main_and_multifd_channels (void )
migration/channel.h +12 -2
@@ -39,6 +39,16 @@ int migration_channel_read_peek(QIOChannel *ioc,bool migration_has_main_and_multifd_channels (void );bool migration_has_all_channels (void ); -bool migration_connect_outgoing (MigrationAddress *addr,Error **errp); -void migration_connect_incoming (MigrationAddress *addr,Error **errp); +bool migration_connect (MigrationAddress *addr,bool out,Error **errp); +static inline bool migration_connect_outgoing (MigrationAddress *addr, +Error **errp) +{ +return migration_connect (addr, true, errp); +} + +static inline bool migration_connect_incoming (MigrationAddress *addr, +Error **errp) +{ +return migration_connect (addr, false, errp); +}#endif
Signature · 1 line
2.51.0
Re: [RFC PATCH 22/25] migration/channel: Merge both sides of the connection initiation code
Quoted 28 lines · Fabiano Rosas
Now that everything is in
channel.c, it's easier to browse this code if it's all in the same place. It's also easier to grasp what the connection flow is if both sides of the connection are close together.Signed-off-by Fabiano Rosas <[email protected]>--- migration/channel.c | 86 +++++++++++++++++++++++---------------------- migration/channel.h | 14 ++++++-- 2 files changed, 56 insertions(+), 44 deletions(-)migration/channel.c +2
-1@@ -31,10 +31,11 @@#include "trace.h" #include "yank_functions.h" -bool migration_connect_outgoing (MigrationAddress *addr,Error **errp) +bool migration_connect (MigrationAddress *addr,bool out,Error **errp) {g_autoptr (QIOChannel) ioc =NULL ;SocketAddress *saddr; +ERRP_GUARD ();switch (addr->transport) {case MIGRATION_ADDRESS_TYPE_SOCKET :
migration/channel.c bool migration_connect_outgoing(MigrationAddress *addr, Error **errp) · line 48
Quoted 10 lines
migration/channel.c +1
-6@@ -44,15 +45,24 @@ bool migration_connect_outgoing(MigrationAddress *addr, Error **errp)case SOCKET_ADDRESS_TYPE_INET :case SOCKET_ADDRESS_TYPE_UNIX :case SOCKET_ADDRESS_TYPE_VSOCK : -socket_connect_outgoing (saddr, errp); -/* -* async: after the socket is connected, calls -* migration_channel_connect_outgoing() directly. -*/ -return true; +if (out) {
Personally I wouldn't suggest we merge the outgoing / incoming with migration_connect() then split paths once more in this exact function.
I got this conclusion when I started to count how many "if (out)" are there.. When there're too much, it may imply we need to think more..
This also answers part of my confusion when reading the previous patch - if that was only paving way for this one, IMHO it may not be as worthwhile, and I would tend to avoid both.
Thoughts?
Quoted 133 lines
migration/channel.c +41
-35+socket_connect_outgoing (saddr, errp); +/* +* async: after the socket is connected, calls +* migration_channel_connect_outgoing() directly. +*/ +return true; + }else { +socket_connect_incoming (saddr, errp); + } +break ;case SOCKET_ADDRESS_TYPE_FD : - ioc =fd_connect_outgoing (saddr->u.fd.str, errp); +if (out) { + ioc =fd_connect_outgoing (saddr->u.fd.str, errp); + }else { +fd_connect_incoming (saddr->u.fd.str, errp); + }break ;default :g_assert_not_reached ();@@ -62,16 +72,28 @@ bool migration_connect_outgoing(MigrationAddress *addr, Error **errp)#ifdef CONFIG_RDMA case MIGRATION_ADDRESS_TYPE_RDMA : - ioc =rdma_connect_outgoing (&addr->u.rdma, errp); +if (out) { + ioc =rdma_connect_outgoing (&addr->u.rdma, errp); + }else { +rdma_connect_incoming (&addr->u.rdma, errp); + }break ;#endif case MIGRATION_ADDRESS_TYPE_EXEC : - ioc =exec_connect_outgoing (addr->u.exec.args, errp); +if (out) { + ioc =exec_connect_outgoing (addr->u.exec.args, errp); + }else { +exec_connect_incoming (addr->u.exec.args, errp); + }break ;case MIGRATION_ADDRESS_TYPE_FILE : - ioc =file_connect_outgoing (&addr->u.file, errp); +if (out) { + ioc =file_connect_outgoing (&addr->u.file, errp); + }else { +file_connect_incoming (&addr->u.file, errp); + }break ;default :@@ -79,42 +101,22 @@ bool migration_connect_outgoing(MigrationAddress *addr, Error **errp)break ; } -if (!ioc) { -return false; - } - -migration_channel_connect_outgoing (ioc); -return true; -} - -void migration_connect_incoming (MigrationAddress *addr,Error **errp) -{ -if (addr->transport ==MIGRATION_ADDRESS_TYPE_SOCKET ) { -SocketAddress *saddr = &addr->u.socket; -if (saddr->type ==SOCKET_ADDRESS_TYPE_INET || - saddr->type ==SOCKET_ADDRESS_TYPE_UNIX || - saddr->type ==SOCKET_ADDRESS_TYPE_VSOCK ) { -socket_connect_incoming (saddr, errp); - }else if (saddr->type ==SOCKET_ADDRESS_TYPE_FD ) { -fd_connect_incoming (saddr->u.fd.str, errp); +if (out) { +if (!ioc) { +return false; } -#ifdef CONFIG_RDMA - }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_RDMA ) { -rdma_connect_incoming (&addr->u.rdma, errp); -#endif - }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_EXEC ) { -exec_connect_incoming (addr->u.exec.args, errp); - }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_FILE ) { -file_connect_incoming (&addr->u.file, errp); - }else { -error_setg (errp,"unknown migration protocol" ); + +migration_channel_connect_outgoing (ioc); +return true; }/* -* async: the above routines all wait for the incoming connection -* and call back to migration_channel_process_incoming() to start -* the migration. +* async: on the incoming side all of the transport routines above +* wait for the incoming connection and call back to +* migration_channel_process_incoming() to start the migration. */ + +return !*errp; }bool migration_has_main_and_multifd_channels (void )migration/channel.h +12
-2@@ -39,6 +39,16 @@ int migration_channel_read_peek(QIOChannel *ioc,bool migration_has_main_and_multifd_channels (void );bool migration_has_all_channels (void ); -bool migration_connect_outgoing (MigrationAddress *addr,Error **errp); -void migration_connect_incoming (MigrationAddress *addr,Error **errp); +bool migration_connect (MigrationAddress *addr,bool out,Error **errp); +static inline bool migration_connect_outgoing (MigrationAddress *addr, +Error **errp) +{ +return migration_connect (addr, true, errp); +} + +static inline bool migration_connect_incoming (MigrationAddress *addr, +Error **errp) +{ +return migration_connect (addr, false, errp); +}#endif Signature · 1 line
2.51.0
Signature · 1 line
Peter Xu
Re: [RFC PATCH 22/25] migration/channel: Merge both sides of the connection initiation code
Quoted 43 lines · Peter Xu
Quoted 28 lines · Fabiano Rosas
Now that everything is in
channel.c, it's easier to browse this code if it's all in the same place. It's also easier to grasp what the connection flow is if both sides of the connection are close together.Signed-off-by Fabiano Rosas <[email protected]>--- migration/channel.c | 86 +++++++++++++++++++++++---------------------- migration/channel.h | 14 ++++++-- 2 files changed, 56 insertions(+), 44 deletions(-)migration/channel.c +2
-1@@ -31,10 +31,11 @@#include "trace.h" #include "yank_functions.h" -bool migration_connect_outgoing (MigrationAddress *addr,Error **errp) +bool migration_connect (MigrationAddress *addr,bool out,Error **errp) {g_autoptr (QIOChannel) ioc =NULL ;SocketAddress *saddr; +ERRP_GUARD ();switch (addr->transport) {case MIGRATION_ADDRESS_TYPE_SOCKET :migration/channel.c bool migration_connect_outgoing(MigrationAddress *addr, Error **errp) · line 48
Quoted 10 lines
migration/channel.c +1
-6@@ -44,15 +45,24 @@ bool migration_connect_outgoing(MigrationAddress *addr, Error **errp)case SOCKET_ADDRESS_TYPE_INET :case SOCKET_ADDRESS_TYPE_UNIX :case SOCKET_ADDRESS_TYPE_VSOCK : -socket_connect_outgoing (saddr, errp); -/* -* async: after the socket is connected, calls -* migration_channel_connect_outgoing() directly. -*/ -return true; +if (out) {Personally I wouldn't suggest we merge the outgoing / incoming with
migration_connect()then split paths once more in this exact function.
Quoted 3 lines
I got this conclusion when I started to count how many "if (out)" are there.. When there're too much, it may imply we need to think more..
Well, compared to before, there 50% less "if (addr->transport == ...)", this is top level programming! =D
This part of the series is highly subjective, if there's a patch you don't like it we can drop it, let's not dwell on it.. Just read my words below on the previous patch, which I think you may be mistaken about.
Quoted 4 lines
This also answers part of my confusion when reading the previous patch - if that was only paving way for this one, IMHO it may not be as worthwhile, and I would tend to avoid both.
Patch 21 is just a cleanup after patch 19 moves the call to migration_channel_connect_outgoing from being inside the transport routines to this top level here at migration_connect(), which moves the places where MigrationState is used as well. So it removes unused passing of MigrationState along with the SocketConnectionData.
Quoted 135 lines
Thoughts?
Quoted 133 lines
migration/channel.c +41
-35+socket_connect_outgoing (saddr, errp); +/* +* async: after the socket is connected, calls +* migration_channel_connect_outgoing() directly. +*/ +return true; + }else { +socket_connect_incoming (saddr, errp); + } +break ;case SOCKET_ADDRESS_TYPE_FD : - ioc =fd_connect_outgoing (saddr->u.fd.str, errp); +if (out) { + ioc =fd_connect_outgoing (saddr->u.fd.str, errp); + }else { +fd_connect_incoming (saddr->u.fd.str, errp); + }break ;default :g_assert_not_reached ();@@ -62,16 +72,28 @@ bool migration_connect_outgoing(MigrationAddress *addr, Error **errp)#ifdef CONFIG_RDMA case MIGRATION_ADDRESS_TYPE_RDMA : - ioc =rdma_connect_outgoing (&addr->u.rdma, errp); +if (out) { + ioc =rdma_connect_outgoing (&addr->u.rdma, errp); + }else { +rdma_connect_incoming (&addr->u.rdma, errp); + }break ;#endif case MIGRATION_ADDRESS_TYPE_EXEC : - ioc =exec_connect_outgoing (addr->u.exec.args, errp); +if (out) { + ioc =exec_connect_outgoing (addr->u.exec.args, errp); + }else { +exec_connect_incoming (addr->u.exec.args, errp); + }break ;case MIGRATION_ADDRESS_TYPE_FILE : - ioc =file_connect_outgoing (&addr->u.file, errp); +if (out) { + ioc =file_connect_outgoing (&addr->u.file, errp); + }else { +file_connect_incoming (&addr->u.file, errp); + }break ;default :@@ -79,42 +101,22 @@ bool migration_connect_outgoing(MigrationAddress *addr, Error **errp)break ; } -if (!ioc) { -return false; - } - -migration_channel_connect_outgoing (ioc); -return true; -} - -void migration_connect_incoming (MigrationAddress *addr,Error **errp) -{ -if (addr->transport ==MIGRATION_ADDRESS_TYPE_SOCKET ) { -SocketAddress *saddr = &addr->u.socket; -if (saddr->type ==SOCKET_ADDRESS_TYPE_INET || - saddr->type ==SOCKET_ADDRESS_TYPE_UNIX || - saddr->type ==SOCKET_ADDRESS_TYPE_VSOCK ) { -socket_connect_incoming (saddr, errp); - }else if (saddr->type ==SOCKET_ADDRESS_TYPE_FD ) { -fd_connect_incoming (saddr->u.fd.str, errp); +if (out) { +if (!ioc) { +return false; } -#ifdef CONFIG_RDMA - }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_RDMA ) { -rdma_connect_incoming (&addr->u.rdma, errp); -#endif - }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_EXEC ) { -exec_connect_incoming (addr->u.exec.args, errp); - }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_FILE ) { -file_connect_incoming (&addr->u.file, errp); - }else { -error_setg (errp,"unknown migration protocol" ); + +migration_channel_connect_outgoing (ioc); +return true; }/* -* async: the above routines all wait for the incoming connection -* and call back to migration_channel_process_incoming() to start -* the migration. +* async: on the incoming side all of the transport routines above +* wait for the incoming connection and call back to +* migration_channel_process_incoming() to start the migration. */ + +return !*errp; }bool migration_has_main_and_multifd_channels (void )migration/channel.h +12
-2@@ -39,6 +39,16 @@ int migration_channel_read_peek(QIOChannel *ioc,bool migration_has_main_and_multifd_channels (void );bool migration_has_all_channels (void ); -bool migration_connect_outgoing (MigrationAddress *addr,Error **errp); -void migration_connect_incoming (MigrationAddress *addr,Error **errp); +bool migration_connect (MigrationAddress *addr,bool out,Error **errp); +static inline bool migration_connect_outgoing (MigrationAddress *addr, +Error **errp) +{ +return migration_connect (addr, true, errp); +} + +static inline bool migration_connect_incoming (MigrationAddress *addr, +Error **errp) +{ +return migration_connect (addr, false, errp); +}#endif Signature · 1 line
2.51.0
Re: [RFC PATCH 22/25] migration/channel: Merge both sides of the connection initiation code
Quoted 45 lines · Fabiano Rosas
Quoted 43 lines · Peter Xu
Quoted 28 lines · Fabiano Rosas
Now that everything is in
channel.c, it's easier to browse this code if it's all in the same place. It's also easier to grasp what the connection flow is if both sides of the connection are close together.Signed-off-by Fabiano Rosas <[email protected]>--- migration/channel.c | 86 +++++++++++++++++++++++---------------------- migration/channel.h | 14 ++++++-- 2 files changed, 56 insertions(+), 44 deletions(-)migration/channel.c +2
-1@@ -31,10 +31,11 @@#include "trace.h" #include "yank_functions.h" -bool migration_connect_outgoing (MigrationAddress *addr,Error **errp) +bool migration_connect (MigrationAddress *addr,bool out,Error **errp) {g_autoptr (QIOChannel) ioc =NULL ;SocketAddress *saddr; +ERRP_GUARD ();switch (addr->transport) {case MIGRATION_ADDRESS_TYPE_SOCKET :migration/channel.c bool migration_connect_outgoing(MigrationAddress *addr, Error **errp) · line 48
Quoted 10 lines
migration/channel.c +1
-6@@ -44,15 +45,24 @@ bool migration_connect_outgoing(MigrationAddress *addr, Error **errp)case SOCKET_ADDRESS_TYPE_INET :case SOCKET_ADDRESS_TYPE_UNIX :case SOCKET_ADDRESS_TYPE_VSOCK : -socket_connect_outgoing (saddr, errp); -/* -* async: after the socket is connected, calls -* migration_channel_connect_outgoing() directly. -*/ -return true; +if (out) {Personally I wouldn't suggest we merge the outgoing / incoming with
migration_connect()then split paths once more in this exact function.
Quoted 6 lines
Quoted 3 lines
I got this conclusion when I started to count how many "if (out)" are there.. When there're too much, it may imply we need to think more..
Well, compared to before, there 50% less "if (
addr->transport== ...)", this is top level programming! =D
Yep, though that'll be the only part got deduplicated.
Reading migration_connect() will definitely break my flow of thoughts when hitting so many "if (out)", and I'll be a bit puzzled on how the code runs.
I'm not sure if I'm the only one, though.
If we really want, we can introduce a MigrationAddressOps, providing one ops for each type of MigrationAddress, differently on both sides:
/* Return true if success; when false errp will be set */
bool (*MigrationAddressOp)(MigrationAddress *addr, QIOChannel **channel, Error **errp)
Then define:
MigrationAddressOps[MIGRATION_ADDRESS_TYPE__MAX] addr_ops_outgoing = { ... }; MigrationAddressOps[MIGRATION_ADDRESS_TYPE__MAX] addr_ops_incoming = { ... };
And use them.. but it may also be an overkill when we only have incoming / outgoing anyway.. So IMHO the existing code (after you refactored many of the rest!) looks still pretty decent to me.
Quoted 4 lines
This part of the series is highly subjective, if there's a patch you don't like it we can drop it, let's not dwell on it.. Just read my words below on the previous patch, which I think you may be mistaken about.
Thanks, yes I was indeed mistaken and overlooked something. :)
Quoted 11 lines
Quoted 5 lines
This also answers part of my confusion when reading the previous patch - if that was only paving way for this one, IMHO it may not be as worthwhile, and I would tend to avoid both.
Patch 21 is just a cleanup after patch 19 moves the call to
migration_channel_connect_outgoingfrom being inside the transport routines to this top level here atmigration_connect(), which moves the places where MigrationState is used as well. So it removes unused passing of MigrationState along with the SocketConnectionData.
Now after I read it again, I agree with those removal of *s where they're not used, like for:
fd_connect_outgoing()
exec_connect_outgoing()
file_connect_outgoing()
I think socket_connect_outgoing() should also be fine, but maybe better to have a pre-requisite patch removing SocketConnectData?
For most of the rest, IMHO we don't get much benefit from removing *s from the parameters, especially inside qmp_migrate()..
So IMHO you were right in the commit log there, that we should justify every use of migrate_get_current() to deserve fetching from a global, and we should avoid using it in new code whenever possible. IMHO we should stick with that.
Imagine the old days we debug when *s can become null, and the more we reference the global, the harder we fight those things (taking one refcount from the very top caller would work for all the sub-callers OTOH, when we justify one place thread-safe and justify all the rest). More referencing globals normally will just make things harder for us. This rule applies to all the globals.. not only *s.
Quoted 137 lines
Quoted 136 lines
Thoughts?
Quoted 133 lines
migration/channel.c +41
-35+socket_connect_outgoing (saddr, errp); +/* +* async: after the socket is connected, calls +* migration_channel_connect_outgoing() directly. +*/ +return true; + }else { +socket_connect_incoming (saddr, errp); + } +break ;case SOCKET_ADDRESS_TYPE_FD : - ioc =fd_connect_outgoing (saddr->u.fd.str, errp); +if (out) { + ioc =fd_connect_outgoing (saddr->u.fd.str, errp); + }else { +fd_connect_incoming (saddr->u.fd.str, errp); + }break ;default :g_assert_not_reached ();@@ -62,16 +72,28 @@ bool migration_connect_outgoing(MigrationAddress *addr, Error **errp)#ifdef CONFIG_RDMA case MIGRATION_ADDRESS_TYPE_RDMA : - ioc =rdma_connect_outgoing (&addr->u.rdma, errp); +if (out) { + ioc =rdma_connect_outgoing (&addr->u.rdma, errp); + }else { +rdma_connect_incoming (&addr->u.rdma, errp); + }break ;#endif case MIGRATION_ADDRESS_TYPE_EXEC : - ioc =exec_connect_outgoing (addr->u.exec.args, errp); +if (out) { + ioc =exec_connect_outgoing (addr->u.exec.args, errp); + }else { +exec_connect_incoming (addr->u.exec.args, errp); + }break ;case MIGRATION_ADDRESS_TYPE_FILE : - ioc =file_connect_outgoing (&addr->u.file, errp); +if (out) { + ioc =file_connect_outgoing (&addr->u.file, errp); + }else { +file_connect_incoming (&addr->u.file, errp); + }break ;default :@@ -79,42 +101,22 @@ bool migration_connect_outgoing(MigrationAddress *addr, Error **errp)break ; } -if (!ioc) { -return false; - } - -migration_channel_connect_outgoing (ioc); -return true; -} - -void migration_connect_incoming (MigrationAddress *addr,Error **errp) -{ -if (addr->transport ==MIGRATION_ADDRESS_TYPE_SOCKET ) { -SocketAddress *saddr = &addr->u.socket; -if (saddr->type ==SOCKET_ADDRESS_TYPE_INET || - saddr->type ==SOCKET_ADDRESS_TYPE_UNIX || - saddr->type ==SOCKET_ADDRESS_TYPE_VSOCK ) { -socket_connect_incoming (saddr, errp); - }else if (saddr->type ==SOCKET_ADDRESS_TYPE_FD ) { -fd_connect_incoming (saddr->u.fd.str, errp); +if (out) { +if (!ioc) { +return false; } -#ifdef CONFIG_RDMA - }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_RDMA ) { -rdma_connect_incoming (&addr->u.rdma, errp); -#endif - }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_EXEC ) { -exec_connect_incoming (addr->u.exec.args, errp); - }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_FILE ) { -file_connect_incoming (&addr->u.file, errp); - }else { -error_setg (errp,"unknown migration protocol" ); + +migration_channel_connect_outgoing (ioc); +return true; }/* -* async: the above routines all wait for the incoming connection -* and call back to migration_channel_process_incoming() to start -* the migration. +* async: on the incoming side all of the transport routines above +* wait for the incoming connection and call back to +* migration_channel_process_incoming() to start the migration. */ + +return !*errp; }bool migration_has_main_and_multifd_channels (void )migration/channel.h +12
-2@@ -39,6 +39,16 @@ int migration_channel_read_peek(QIOChannel *ioc,bool migration_has_main_and_multifd_channels (void );bool migration_has_all_channels (void ); -bool migration_connect_outgoing (MigrationAddress *addr,Error **errp); -void migration_connect_incoming (MigrationAddress *addr,Error **errp); +bool migration_connect (MigrationAddress *addr,bool out,Error **errp); +static inline bool migration_connect_outgoing (MigrationAddress *addr, +Error **errp) +{ +return migration_connect (addr, true, errp); +} + +static inline bool migration_connect_incoming (MigrationAddress *addr, +Error **errp) +{ +return migration_connect (addr, false, errp); +}#endif Signature · 1 line
2.51.0
Signature · 1 line
Peter Xu
RFC PATCH 23/25 migration: Move channel parsing to channel.c
In reply to Fabiano RosasEncapsulate the MigrationChannelList parsing in a new migrate_channels_parse() located at channel.c.
--- migration/channel.c | 54 +++++++++++++++++++++++++++++++++++++++++++ migration/channel.h | 5 ++++ migration/migration.c | 50 +++++++++++---------------------------- 3 files changed, 73 insertions(+), 36 deletions(-)
migration/channel.c +54 -0
@@ -11,6 +11,7 @@*/ #include "qemu/osdep.h" +#include "qemu/cutils.h" #include "channel.h" #include "exec.h" #include "fd.h"
@@ -20,7 +21,9 @@#include "migration.h" #include "multifd.h" #include "options.h" +#include "qapi/clone-visitor.h" #include "qapi/qapi-types-migration.h" +#include "qapi/qapi-visit-migration.h" #include "qapi/error.h" #include "qemu-file.h" #include "qemu/yank.h"
@@ -314,3 +317,54 @@ int migration_channel_read_peek(QIOChannel *ioc,return 0 ; } + +bool migrate_channels_parse (MigrationChannelList *channels, +MigrationChannel **main_channelp, +MigrationChannel **cpr_channelp, +Error **errp) +{ +MigrationChannel *channelv[MIGRATION_CHANNEL_TYPE__MAX ] = {NULL }; +bool single_channel; + +if (cpr_channelp) { + single_channel = false; + }else { + single_channel = true; + } + +for ( ; channels; channels = channels->next) { +MigrationChannelType type; + + type = channels->value->channel_type; +if (channelv[type]) { +error_setg (errp,"Channel list has more than one %s entry" , +MigrationChannelType_str (type)); +return false; + } + channelv[type] = channels->value; + +if (single_channel) { +if (channels->next) { +error_setg (errp,"Channel list must have only one entry, " +"for type 'main'" ); +return false; + } +break ; + } + } + +if (cpr_channelp) { + *cpr_channelp =QAPI_CLONE (MigrationChannel, + channelv[MIGRATION_CHANNEL_TYPE_CPR ]); + } + + *main_channelp =QAPI_CLONE (MigrationChannel, + channelv[MIGRATION_CHANNEL_TYPE_MAIN ]); + +if (!(*main_channelp)->addr) { +error_setg (errp,"Channel list has no main entry" ); +return false; + } + +return true; +}
migration/channel.h +5 -0
@@ -51,4 +51,9 @@ static inline bool migration_connect_incoming(MigrationAddress *addr, {return migration_connect (addr, false, errp); } + +bool migrate_channels_parse (MigrationChannelList *channels, +MigrationChannel **main_channelp, +MigrationChannel **cpr_channelp, +Error **errp);#endif
migration/migration.c +14 -36
119 lines not on this page · raw message
Signature · 1 line
2.51.0
Re: [RFC PATCH 23/25] migration: Move channel parsing to channel.c
Quoted 4 lines · Fabiano Rosas
Encapsulate the MigrationChannelList parsing in a new
migrate_channels_parse()located atchannel.c.Signed-off-by Fabiano Rosas <[email protected]>
Signature · 1 line
Peter Xu
RFC PATCH 24/25 migration: Move URI parsing to channel.c
In reply to Fabiano RosasThe migrate_uri_parse function is responsible for converting the URI string into a MigrationChannel for consumption by the rest of the code. Move it to channel.c and add a wrapper that calls both URI and channels parsing.
While here, add some words about the memory management of the MigrationChannel object, which is slightly different from migrate_uri_parse() and migrate_channels_parse(). The former takes a string and has to allocate a MigrationChannel, the latter takes a QAPI object that is managed by the QAPI code.
--- migration/channel.c | 97 +++++++++++++++++++++++++++++++++++++++++-- migration/channel.h | 9 ++-- migration/migration.c | 95 ++---------------------------------------- 3 files changed, 101 insertions(+), 100 deletions(-)
migration/channel.c +93 -4
@@ -40,6 +40,12 @@ bool migration_connect(MigrationAddress *addr, bool out, Error **errp)SocketAddress *saddr;ERRP_GUARD (); +/* +* This is reached from a QMP command, the transport code below +* must copy the relevant parts of 'addr' before this function +* returns because the QAPI code will free it. +*/ +switch (addr->transport) {case MIGRATION_ADDRESS_TYPE_SOCKET : saddr = &addr->u.socket;
@@ -318,10 +324,10 @@ int migration_channel_read_peek(QIOChannel *ioc,return 0 ; } -bool migrate_channels_parse (MigrationChannelList *channels, -MigrationChannel **main_channelp, -MigrationChannel **cpr_channelp, -Error **errp) +static bool migrate_channels_parse (MigrationChannelList *channels, +MigrationChannel **main_channelp, +MigrationChannel **cpr_channelp, +Error **errp) {MigrationChannel *channelv[MIGRATION_CHANNEL_TYPE__MAX ] = {NULL };bool single_channel;
@@ -353,6 +359,15 @@ bool migrate_channels_parse(MigrationChannelList *channels, } } +/* +* These don't technically need to be cloned because they come +* from a QAPI object ('channels'). The top-level caller +* (qmp_migrate) needs to copy the necessary information before +* returning from the QMP command. Cloning here is just to keep +* the interface consistent with migrate_uri_parse() that _does +* not_ take a QAPI object and instead allocates and transfers +* ownership of a MigrationChannel to qmp_migrate. +*/ if (cpr_channelp) { *cpr_channelp =QAPI_CLONE (MigrationChannel, channelv[MIGRATION_CHANNEL_TYPE_CPR ]);
@@ -368,3 +383,77 @@ bool migrate_channels_parse(MigrationChannelList *channels,return true; } + +bool migrate_uri_parse (const char *uri,MigrationChannel **channel, +Error **errp) +{ +g_autoptr (MigrationChannel) val =g_new0 (MigrationChannel,1 ); +g_autoptr (MigrationAddress) addr =g_new0 (MigrationAddress,1 ); +InetSocketAddress *isock = &addr->u.rdma; +strList **tail = &addr->u.exec.args; + +if (strstart (uri,"exec:" ,NULL )) { + addr->transport =MIGRATION_ADDRESS_TYPE_EXEC ; +#ifdef WIN32 +QAPI_LIST_APPEND (tail,g_strdup (exec_get_cmd_path ())); +QAPI_LIST_APPEND (tail,g_strdup ("/c" )); +#else +QAPI_LIST_APPEND (tail,g_strdup ("/bin/sh" )); +QAPI_LIST_APPEND (tail,g_strdup ("-c" )); +#endif +QAPI_LIST_APPEND (tail,g_strdup (uri +strlen ("exec:" ))); + }else if (strstart (uri,"rdma:" ,NULL )) { +if (inet_parse (isock, uri +strlen ("rdma:" ), errp)) { +qapi_free_InetSocketAddress (isock); +return false; + } + addr->transport =MIGRATION_ADDRESS_TYPE_RDMA ; + }else if (strstart (uri,"tcp:" ,NULL ) || +strstart (uri,"unix:" ,NULL ) || +strstart (uri,"vsock:" ,NULL ) || +strstart (uri,"fd:" ,NULL )) { + addr->transport =MIGRATION_ADDRESS_TYPE_SOCKET ; +SocketAddress *saddr =socket_parse (uri, errp); +if (!saddr) { +return false; + } + addr->u.socket.type = saddr->type; + addr->u.socket.u = saddr->u; +/* Don't free the objects inside; their ownership moved to "addr" */ +g_free (saddr); + }else if (strstart (uri,"file:" ,NULL )) { + addr->transport =MIGRATION_ADDRESS_TYPE_FILE ; + addr->u.file.filename =g_strdup (uri +strlen ("file:" )); +if (file_parse_offset (addr->u.file.filename, &addr->u.file.offset, + errp)) { +return false; + } + }else { +error_setg (errp,"unknown migration protocol: %s" , uri); +return false; + } + + val->channel_type =MIGRATION_CHANNEL_TYPE_MAIN ; + val->addr =g_steal_pointer (&addr); + *channel =g_steal_pointer (&val); +return true; +} + +bool migration_channel_parse_input (const char *uri, +MigrationChannelList *channels, +MigrationChannel **main_channelp, +MigrationChannel **cpr_channelp, +Error **errp) +{ +if (!uri == !channels) { +error_setg (errp,"need either 'uri' or 'channels' argument" ); +return false; + } + +if (channels) { +return migrate_channels_parse (channels, main_channelp, cpr_channelp, + errp); + }else { +return migrate_uri_parse (uri, main_channelp, errp); + } +}
migration/channel.h +5 -4
@@ -52,8 +52,9 @@ static inline bool migration_connect_incoming(MigrationAddress *addr, return migration_connect(addr, false, errp); } -bool migrate_channels_parse (MigrationChannelList *channels, -MigrationChannel **main_channelp, -MigrationChannel **cpr_channelp, -Error **errp); +bool migration_channel_parse_input (const char *uri, +MigrationChannelList *channels, +MigrationChannel **main_channelp, +MigrationChannel **cpr_channelp, +Error **errp);#endif
migration/migration.c +3 -92
125 lines not on this page · raw message
Signature · 1 line
2.51.0
Re: [RFC PATCH 24/25] migration: Move URI parsing to channel.c
Quoted 5 lines · Fabiano Rosas
The
migrate_uri_parsefunction is responsible for converting the URI string into a MigrationChannel for consumption by the rest of the code. Move it tochannel.cand add a wrapper that calls both URI and channels parsing.
Quoted 7 lines
While here, add some words about the memory management of the MigrationChannel object, which is slightly different from
migrate_uri_parse()andmigrate_channels_parse(). The former takes a string and has to allocate a MigrationChannel, the latter takes a QAPI object that is managed by the QAPI code.Signed-off-by Fabiano Rosas <[email protected]>
There're some comments added into migration_connect(), that I still don't think I fully agree upon.. but the rest looks all good to me.
That's probably to be discussed separately anyway, I think you can take mine here:
Quoted 286 lines
--- migration/channel.c | 97 +++++++++++++++++++++++++++++++++++++++++-- migration/channel.h | 9 ++-- migration/migration.c | 95 ++---------------------------------------- 3 files changed, 101 insertions(+), 100 deletions(-)migration/channel.c +93
-4@@ -40,6 +40,12 @@ bool migration_connect(MigrationAddress *addr, bool out, Error **errp)SocketAddress *saddr;ERRP_GUARD (); +/* +* This is reached from a QMP command, the transport code below +* must copy the relevant parts of 'addr' before this function +* returns because the QAPI code will free it. +*/ +switch (addr->transport) {case MIGRATION_ADDRESS_TYPE_SOCKET : saddr = &addr->u.socket;@@ -318,10 +324,10 @@ int migration_channel_read_peek(QIOChannel *ioc,return 0 ; } -bool migrate_channels_parse (MigrationChannelList *channels, -MigrationChannel **main_channelp, -MigrationChannel **cpr_channelp, -Error **errp) +static bool migrate_channels_parse (MigrationChannelList *channels, +MigrationChannel **main_channelp, +MigrationChannel **cpr_channelp, +Error **errp) {MigrationChannel *channelv[MIGRATION_CHANNEL_TYPE__MAX ] = {NULL };bool single_channel;@@ -353,6 +359,15 @@ bool migrate_channels_parse(MigrationChannelList *channels, } } +/* +* These don't technically need to be cloned because they come +* from a QAPI object ('channels'). The top-level caller +* (qmp_migrate) needs to copy the necessary information before +* returning from the QMP command. Cloning here is just to keep +* the interface consistent with migrate_uri_parse() that _does +* not_ take a QAPI object and instead allocates and transfers +* ownership of a MigrationChannel to qmp_migrate. +*/ if (cpr_channelp) { *cpr_channelp =QAPI_CLONE (MigrationChannel, channelv[MIGRATION_CHANNEL_TYPE_CPR ]);@@ -368,3 +383,77 @@ bool migrate_channels_parse(MigrationChannelList *channels,return true; } + +bool migrate_uri_parse (const char *uri,MigrationChannel **channel, +Error **errp) +{ +g_autoptr (MigrationChannel) val =g_new0 (MigrationChannel,1 ); +g_autoptr (MigrationAddress) addr =g_new0 (MigrationAddress,1 ); +InetSocketAddress *isock = &addr->u.rdma; +strList **tail = &addr->u.exec.args; + +if (strstart (uri,"exec:" ,NULL )) { + addr->transport =MIGRATION_ADDRESS_TYPE_EXEC ; +#ifdef WIN32 +QAPI_LIST_APPEND (tail,g_strdup (exec_get_cmd_path ())); +QAPI_LIST_APPEND (tail,g_strdup ("/c" )); +#else +QAPI_LIST_APPEND (tail,g_strdup ("/bin/sh" )); +QAPI_LIST_APPEND (tail,g_strdup ("-c" )); +#endif +QAPI_LIST_APPEND (tail,g_strdup (uri +strlen ("exec:" ))); + }else if (strstart (uri,"rdma:" ,NULL )) { +if (inet_parse (isock, uri +strlen ("rdma:" ), errp)) { +qapi_free_InetSocketAddress (isock); +return false; + } + addr->transport =MIGRATION_ADDRESS_TYPE_RDMA ; + }else if (strstart (uri,"tcp:" ,NULL ) || +strstart (uri,"unix:" ,NULL ) || +strstart (uri,"vsock:" ,NULL ) || +strstart (uri,"fd:" ,NULL )) { + addr->transport =MIGRATION_ADDRESS_TYPE_SOCKET ; +SocketAddress *saddr =socket_parse (uri, errp); +if (!saddr) { +return false; + } + addr->u.socket.type = saddr->type; + addr->u.socket.u = saddr->u; +/* Don't free the objects inside; their ownership moved to "addr" */ +g_free (saddr); + }else if (strstart (uri,"file:" ,NULL )) { + addr->transport =MIGRATION_ADDRESS_TYPE_FILE ; + addr->u.file.filename =g_strdup (uri +strlen ("file:" )); +if (file_parse_offset (addr->u.file.filename, &addr->u.file.offset, + errp)) { +return false; + } + }else { +error_setg (errp,"unknown migration protocol: %s" , uri); +return false; + } + + val->channel_type =MIGRATION_CHANNEL_TYPE_MAIN ; + val->addr =g_steal_pointer (&addr); + *channel =g_steal_pointer (&val); +return true; +} + +bool migration_channel_parse_input (const char *uri, +MigrationChannelList *channels, +MigrationChannel **main_channelp, +MigrationChannel **cpr_channelp, +Error **errp) +{ +if (!uri == !channels) { +error_setg (errp,"need either 'uri' or 'channels' argument" ); +return false; + } + +if (channels) { +return migrate_channels_parse (channels, main_channelp, cpr_channelp, + errp); + }else { +return migrate_uri_parse (uri, main_channelp, errp); + } +}migration/channel.h +5
-4@@ -52,8 +52,9 @@ static inline bool migration_connect_incoming(MigrationAddress *addr, return migration_connect(addr, false, errp); } -bool migrate_channels_parse (MigrationChannelList *channels, -MigrationChannel **main_channelp, -MigrationChannel **cpr_channelp, -Error **errp); +bool migration_channel_parse_input (const char *uri, +MigrationChannelList *channels, +MigrationChannel **main_channelp, +MigrationChannel **cpr_channelp, +Error **errp);#endif migration/migration.c +3
-92@@ -15,7 +15,6 @@#include "qemu/osdep.h" #include "qemu/ctype.h" -#include "qemu/cutils.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "migration/blocker.h" @@ -659,61 +658,6 @@ bool migrate_is_uri(const char *uri)return *uri ==':' ; } -bool migrate_uri_parse (const char *uri,MigrationChannel **channel, -Error **errp) -{ -g_autoptr (MigrationChannel) val =g_new0 (MigrationChannel,1 ); -g_autoptr (MigrationAddress) addr =g_new0 (MigrationAddress,1 ); -InetSocketAddress *isock = &addr->u.rdma; -strList **tail = &addr->u.exec.args; - -if (strstart (uri,"exec:" ,NULL )) { - addr->transport =MIGRATION_ADDRESS_TYPE_EXEC ; -#ifdef WIN32 -QAPI_LIST_APPEND (tail,g_strdup (exec_get_cmd_path ())); -QAPI_LIST_APPEND (tail,g_strdup ("/c" )); -#else -QAPI_LIST_APPEND (tail,g_strdup ("/bin/sh" )); -QAPI_LIST_APPEND (tail,g_strdup ("-c" )); -#endif -QAPI_LIST_APPEND (tail,g_strdup (uri +strlen ("exec:" ))); - }else if (strstart (uri,"rdma:" ,NULL )) { -if (inet_parse (isock, uri +strlen ("rdma:" ), errp)) { -qapi_free_InetSocketAddress (isock); -return false; - } - addr->transport =MIGRATION_ADDRESS_TYPE_RDMA ; - }else if (strstart (uri,"tcp:" ,NULL ) || -strstart (uri,"unix:" ,NULL ) || -strstart (uri,"vsock:" ,NULL ) || -strstart (uri,"fd:" ,NULL )) { - addr->transport =MIGRATION_ADDRESS_TYPE_SOCKET ; -SocketAddress *saddr =socket_parse (uri, errp); -if (!saddr) { -return false; - } - addr->u.socket.type = saddr->type; - addr->u.socket.u = saddr->u; -/* Don't free the objects inside; their ownership moved to "addr" */ -g_free (saddr); - }else if (strstart (uri,"file:" ,NULL )) { - addr->transport =MIGRATION_ADDRESS_TYPE_FILE ; - addr->u.file.filename =g_strdup (uri +strlen ("file:" )); -if (file_parse_offset (addr->u.file.filename, &addr->u.file.offset, - errp)) { -return false; - } - }else { -error_setg (errp,"unknown migration protocol: %s" , uri); -return false; - } - - val->channel_type =MIGRATION_CHANNEL_TYPE_MAIN ; - val->addr =g_steal_pointer (&addr); - *channel =g_steal_pointer (&val); -return true; -} -static bool migration_incoming_state_setup (MigrationIncomingState *mis,Error **errp) {@@ -744,27 +688,10 @@ static void qemu_setup_incoming_migration(const char *uri, bool has_channels,g_autoptr (MigrationChannel) main_ch =NULL ;MigrationIncomingState *mis =migration_incoming_get_current (); -/* -* Having preliminary checks for uri and channel -*/ -if (!uri == !channels) { -error_setg (errp,"need either 'uri' or 'channels' argument" ); +if (!migration_channel_parse_input (uri, channels, &main_ch,NULL , errp)) {return ; } -if (channels) { -if (!migrate_channels_parse (channels, &main_ch,NULL , errp)) { -return ; - } - } - -if (uri) { -/* caller uses the old URI syntax */ -if (!migrate_uri_parse (uri, &main_ch, errp)) { -return ; - } - } -/* transport mechanism not suitable for migration? */ if (!migration_transport_compatible (main_ch->addr, errp)) {return ;@@ -2124,27 +2051,11 @@ void qmp_migrate(const char *uri, bool has_channels,g_autoptr (MigrationChannel) main_ch =NULL ;g_autoptr (MigrationChannel) cpr_ch =NULL ; -/* -* Having preliminary checks for uri and channel -*/ -if (!uri == !channels) { -error_setg (errp,"need either 'uri' or 'channels' argument" ); +if (!migration_channel_parse_input (uri, channels, &main_ch, &cpr_ch, + errp)) {return ; } -if (channels) { -if (!migrate_channels_parse (channels, &main_ch, &cpr_ch, errp)) { -return ; - } - } - -if (uri) { -/* caller uses the old URI syntax */ -if (!migrate_uri_parse (uri, &main_ch, errp)) { -return ; - } - } -/* transport mechanism not suitable for migration? */ if (!migration_transport_compatible (main_ch->addr, errp)) {return ;Signature · 1 line
2.51.0
Signature · 1 line
Peter Xu
Re: [RFC PATCH 24/25] migration: Move URI parsing to channel.c
Quoted 12 lines · Peter Xu
Quoted 11 lines · Fabiano Rosas
The
migrate_uri_parsefunction is responsible for converting the URI string into a MigrationChannel for consumption by the rest of the code. Move it tochannel.cand add a wrapper that calls both URI and channels parsing.While here, add some words about the memory management of the MigrationChannel object, which is slightly different from
migrate_uri_parse()andmigrate_channels_parse(). The former takes a string and has to allocate a MigrationChannel, the latter takes a QAPI object that is managed by the QAPI code.
Quoted 5 lines
Quoted 1 line
Signed-off-by Fabiano Rosas <[email protected]>There're some comments added into
migration_connect(), that I still don't think I fully agree upon.. but the rest looks all good to me.
You're talking about the comments not being at the right place? I can duplicate them in migration_connect_outgoing|incoming.
Quoted 291 lines
That's probably to be discussed separately anyway, I think you can take mine here:
Reviewed-by Peter Xu <[email protected]>Quoted 286 lines
--- migration/channel.c | 97 +++++++++++++++++++++++++++++++++++++++++-- migration/channel.h | 9 ++-- migration/migration.c | 95 ++---------------------------------------- 3 files changed, 101 insertions(+), 100 deletions(-)migration/channel.c +93
-4@@ -40,6 +40,12 @@ bool migration_connect(MigrationAddress *addr, bool out, Error **errp)SocketAddress *saddr;ERRP_GUARD (); +/* +* This is reached from a QMP command, the transport code below +* must copy the relevant parts of 'addr' before this function +* returns because the QAPI code will free it. +*/ +switch (addr->transport) {case MIGRATION_ADDRESS_TYPE_SOCKET : saddr = &addr->u.socket;@@ -318,10 +324,10 @@ int migration_channel_read_peek(QIOChannel *ioc,return 0 ; } -bool migrate_channels_parse (MigrationChannelList *channels, -MigrationChannel **main_channelp, -MigrationChannel **cpr_channelp, -Error **errp) +static bool migrate_channels_parse (MigrationChannelList *channels, +MigrationChannel **main_channelp, +MigrationChannel **cpr_channelp, +Error **errp) {MigrationChannel *channelv[MIGRATION_CHANNEL_TYPE__MAX ] = {NULL };bool single_channel;@@ -353,6 +359,15 @@ bool migrate_channels_parse(MigrationChannelList *channels, } } +/* +* These don't technically need to be cloned because they come +* from a QAPI object ('channels'). The top-level caller +* (qmp_migrate) needs to copy the necessary information before +* returning from the QMP command. Cloning here is just to keep +* the interface consistent with migrate_uri_parse() that _does +* not_ take a QAPI object and instead allocates and transfers +* ownership of a MigrationChannel to qmp_migrate. +*/ if (cpr_channelp) { *cpr_channelp =QAPI_CLONE (MigrationChannel, channelv[MIGRATION_CHANNEL_TYPE_CPR ]);@@ -368,3 +383,77 @@ bool migrate_channels_parse(MigrationChannelList *channels,return true; } + +bool migrate_uri_parse (const char *uri,MigrationChannel **channel, +Error **errp) +{ +g_autoptr (MigrationChannel) val =g_new0 (MigrationChannel,1 ); +g_autoptr (MigrationAddress) addr =g_new0 (MigrationAddress,1 ); +InetSocketAddress *isock = &addr->u.rdma; +strList **tail = &addr->u.exec.args; + +if (strstart (uri,"exec:" ,NULL )) { + addr->transport =MIGRATION_ADDRESS_TYPE_EXEC ; +#ifdef WIN32 +QAPI_LIST_APPEND (tail,g_strdup (exec_get_cmd_path ())); +QAPI_LIST_APPEND (tail,g_strdup ("/c" )); +#else +QAPI_LIST_APPEND (tail,g_strdup ("/bin/sh" )); +QAPI_LIST_APPEND (tail,g_strdup ("-c" )); +#endif +QAPI_LIST_APPEND (tail,g_strdup (uri +strlen ("exec:" ))); + }else if (strstart (uri,"rdma:" ,NULL )) { +if (inet_parse (isock, uri +strlen ("rdma:" ), errp)) { +qapi_free_InetSocketAddress (isock); +return false; + } + addr->transport =MIGRATION_ADDRESS_TYPE_RDMA ; + }else if (strstart (uri,"tcp:" ,NULL ) || +strstart (uri,"unix:" ,NULL ) || +strstart (uri,"vsock:" ,NULL ) || +strstart (uri,"fd:" ,NULL )) { + addr->transport =MIGRATION_ADDRESS_TYPE_SOCKET ; +SocketAddress *saddr =socket_parse (uri, errp); +if (!saddr) { +return false; + } + addr->u.socket.type = saddr->type; + addr->u.socket.u = saddr->u; +/* Don't free the objects inside; their ownership moved to "addr" */ +g_free (saddr); + }else if (strstart (uri,"file:" ,NULL )) { + addr->transport =MIGRATION_ADDRESS_TYPE_FILE ; + addr->u.file.filename =g_strdup (uri +strlen ("file:" )); +if (file_parse_offset (addr->u.file.filename, &addr->u.file.offset, + errp)) { +return false; + } + }else { +error_setg (errp,"unknown migration protocol: %s" , uri); +return false; + } + + val->channel_type =MIGRATION_CHANNEL_TYPE_MAIN ; + val->addr =g_steal_pointer (&addr); + *channel =g_steal_pointer (&val); +return true; +} + +bool migration_channel_parse_input (const char *uri, +MigrationChannelList *channels, +MigrationChannel **main_channelp, +MigrationChannel **cpr_channelp, +Error **errp) +{ +if (!uri == !channels) { +error_setg (errp,"need either 'uri' or 'channels' argument" ); +return false; + } + +if (channels) { +return migrate_channels_parse (channels, main_channelp, cpr_channelp, + errp); + }else { +return migrate_uri_parse (uri, main_channelp, errp); + } +}migration/channel.h +5
-4@@ -52,8 +52,9 @@ static inline bool migration_connect_incoming(MigrationAddress *addr, return migration_connect(addr, false, errp); } -bool migrate_channels_parse (MigrationChannelList *channels, -MigrationChannel **main_channelp, -MigrationChannel **cpr_channelp, -Error **errp); +bool migration_channel_parse_input (const char *uri, +MigrationChannelList *channels, +MigrationChannel **main_channelp, +MigrationChannel **cpr_channelp, +Error **errp);#endif migration/migration.c +3
-92@@ -15,7 +15,6 @@#include "qemu/osdep.h" #include "qemu/ctype.h" -#include "qemu/cutils.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "migration/blocker.h" @@ -659,61 +658,6 @@ bool migrate_is_uri(const char *uri)return *uri ==':' ; } -bool migrate_uri_parse (const char *uri,MigrationChannel **channel, -Error **errp) -{ -g_autoptr (MigrationChannel) val =g_new0 (MigrationChannel,1 ); -g_autoptr (MigrationAddress) addr =g_new0 (MigrationAddress,1 ); -InetSocketAddress *isock = &addr->u.rdma; -strList **tail = &addr->u.exec.args; - -if (strstart (uri,"exec:" ,NULL )) { - addr->transport =MIGRATION_ADDRESS_TYPE_EXEC ; -#ifdef WIN32 -QAPI_LIST_APPEND (tail,g_strdup (exec_get_cmd_path ())); -QAPI_LIST_APPEND (tail,g_strdup ("/c" )); -#else -QAPI_LIST_APPEND (tail,g_strdup ("/bin/sh" )); -QAPI_LIST_APPEND (tail,g_strdup ("-c" )); -#endif -QAPI_LIST_APPEND (tail,g_strdup (uri +strlen ("exec:" ))); - }else if (strstart (uri,"rdma:" ,NULL )) { -if (inet_parse (isock, uri +strlen ("rdma:" ), errp)) { -qapi_free_InetSocketAddress (isock); -return false; - } - addr->transport =MIGRATION_ADDRESS_TYPE_RDMA ; - }else if (strstart (uri,"tcp:" ,NULL ) || -strstart (uri,"unix:" ,NULL ) || -strstart (uri,"vsock:" ,NULL ) || -strstart (uri,"fd:" ,NULL )) { - addr->transport =MIGRATION_ADDRESS_TYPE_SOCKET ; -SocketAddress *saddr =socket_parse (uri, errp); -if (!saddr) { -return false; - } - addr->u.socket.type = saddr->type; - addr->u.socket.u = saddr->u; -/* Don't free the objects inside; their ownership moved to "addr" */ -g_free (saddr); - }else if (strstart (uri,"file:" ,NULL )) { - addr->transport =MIGRATION_ADDRESS_TYPE_FILE ; - addr->u.file.filename =g_strdup (uri +strlen ("file:" )); -if (file_parse_offset (addr->u.file.filename, &addr->u.file.offset, - errp)) { -return false; - } - }else { -error_setg (errp,"unknown migration protocol: %s" , uri); -return false; - } - - val->channel_type =MIGRATION_CHANNEL_TYPE_MAIN ; - val->addr =g_steal_pointer (&addr); - *channel =g_steal_pointer (&val); -return true; -} -static bool migration_incoming_state_setup (MigrationIncomingState *mis,Error **errp) {@@ -744,27 +688,10 @@ static void qemu_setup_incoming_migration(const char *uri, bool has_channels,g_autoptr (MigrationChannel) main_ch =NULL ;MigrationIncomingState *mis =migration_incoming_get_current (); -/* -* Having preliminary checks for uri and channel -*/ -if (!uri == !channels) { -error_setg (errp,"need either 'uri' or 'channels' argument" ); +if (!migration_channel_parse_input (uri, channels, &main_ch,NULL , errp)) {return ; } -if (channels) { -if (!migrate_channels_parse (channels, &main_ch,NULL , errp)) { -return ; - } - } - -if (uri) { -/* caller uses the old URI syntax */ -if (!migrate_uri_parse (uri, &main_ch, errp)) { -return ; - } - } -/* transport mechanism not suitable for migration? */ if (!migration_transport_compatible (main_ch->addr, errp)) {return ;@@ -2124,27 +2051,11 @@ void qmp_migrate(const char *uri, bool has_channels,g_autoptr (MigrationChannel) main_ch =NULL ;g_autoptr (MigrationChannel) cpr_ch =NULL ; -/* -* Having preliminary checks for uri and channel -*/ -if (!uri == !channels) { -error_setg (errp,"need either 'uri' or 'channels' argument" ); +if (!migration_channel_parse_input (uri, channels, &main_ch, &cpr_ch, + errp)) {return ; } -if (channels) { -if (!migrate_channels_parse (channels, &main_ch, &cpr_ch, errp)) { -return ; - } - } - -if (uri) { -/* caller uses the old URI syntax */ -if (!migrate_uri_parse (uri, &main_ch, errp)) { -return ; - } - } -/* transport mechanism not suitable for migration? */ if (!migration_transport_compatible (main_ch->addr, errp)) {return ;Signature · 1 line
2.51.0
Re: [RFC PATCH 24/25] migration: Move URI parsing to channel.c
Quoted 2 lines · Fabiano Rosas
You're talking about the comments not being at the right place? I can duplicate them in migration_connect_outgoing|incoming.
Yep, dup it is fine, or just drop them?
Normally we should assume all parameters to be freed anytime by default for a function. AFAIU that's the common case.
OTOH, IMHO we may better need comments where the function can transit ownership of the memory of the parameters... while this is not the case.
Signature · 1 line
Peter Xu
RFC PATCH 25/25 migration: Remove qmp_migrate_finish
In reply to Fabiano RosasWith recent cleanups, the qmp_migrate_finish() function has now become just a call to migration_connect_outgoing(), which makes sense because that's what the "second part of qmp_migrate" does. The qmp_migrate_finish is (in retrospect) too confusing because it never had a matching qmp_migrate_start. I think it's best to just remove this function and call migration_connect_outgoing() directly.
--- migration/migration.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
migration/migration.c +7 -13
@@ -1470,8 +1470,8 @@ void migration_cancel(void) }/* -* If qmp_migrate_finish has not been called, then there is no path that -* will complete the cancellation. Do it now. +* If migration_connect_outgoing has not been called, then there +* is no path that will complete the cancellation. Do it now. */ if (setup && !s->to_dst_file) { migrate_set_state(&s->state, MIGRATION_STATUS_CANCELLING,
@@ -2002,8 +2002,6 @@ static bool migrate_prepare(bool resume, Error **errp)return true; } -static void qmp_migrate_finish (MigrationAddress *addr,Error **errp); -static void migrate_hup_add (QIOChannel *ioc,GSourceFunc cb,void *opaque) {MigrationState *s =migrate_get_current ();
@@ -2031,7 +2029,7 @@ static gboolean qmp_migrate_finish_cb(QIOChannel *channel,MigrationAddress *addr = opaque;Error *local_err =NULL ; -qmp_migrate_finish (addr, &local_err); +migration_connect_outgoing (addr, &local_err);if (local_err) {migration_connect_error_propagate (local_err);
@@ -2086,18 +2084,19 @@ void qmp_migrate(const char *uri, bool has_channels,* For cpr-transfer, the target may not be listening yet on the migration * channel, because first it must finish cpr_load_state. The target tells * us it is listening by closing the cpr-state socket. Wait for that HUP -* event before connecting in qmp_migrate_finish. +* event before connecting in migration_connect_outgoing. * * The HUP could occur because the target fails while reading CPR state, * in which case the target will not listen for the incoming migration -* connection, so qmp_migrate_finish will fail to connect, and then recover. +* connection, so migration_connect_outgoing fail to connect, and +* then recover. */ if (migrate_mode () ==MIG_MODE_CPR_TRANSFER ) {migrate_hup_add (cpr_state_ioc (), (GSourceFunc )qmp_migrate_finish_cb,QAPI_CLONE (MigrationAddress, main_ch->addr)); }else { -qmp_migrate_finish (main_ch->addr, &local_err); +migration_connect_outgoing (main_ch->addr, &local_err); } out:
@@ -2107,11 +2106,6 @@ out: } } -static void qmp_migrate_finish (MigrationAddress *addr,Error **errp) -{ -migration_connect_outgoing (addr, errp); -} -void qmp_migrate_cancel (Error **errp) {/*
Signature · 1 line
2.51.0