migration/multifd: Drop MultiFDSendParams.quit, cleanup error paths
commit15f3f21d598148895c33b6fc41e29777cf6ad992
authorPeter Xu <peterx@redhat.com>
Fri, 2 Feb 2024 10:28:37 +0000 (2 18:28 +0800)
committerPeter Xu <peterx@redhat.com>
Mon, 5 Feb 2024 06:42:10 +0000 (5 14:42 +0800)
tree78e5c840c99b1c600841781089826558139cbe4e
parent48c0f5d56fd2ff0a0cda23301637b742c690f59a
migration/multifd: Drop MultiFDSendParams.quit, cleanup error paths

Multifd send side has two fields to indicate error quits:

  - MultiFDSendParams.quit
  - &multifd_send_state->exiting

Merge them into the global one.  The replacement is done by changing all
p->quit checks into the global var check.  The global check doesn't need
any lock.

A few more things done on top of this altogether:

  - multifd_send_terminate_threads()

    Moving the xchg() of &multifd_send_state->exiting upper, so as to cover
    the tracepoint, migrate_set_error() and migrate_set_state().

  - multifd_send_sync_main()

    In the 2nd loop, add one more check over the global var to make sure we
    don't keep the looping if QEMU already decided to quit.

  - multifd_tls_outgoing_handshake()

    Use multifd_send_terminate_threads() to set the error state.  That has
    a benefit of updating MigrationState.error to that error too, so we can
    persist that 1st error we hit in that specific channel.

  - multifd_new_send_channel_async()

    Take similar approach like above, drop the migrate_set_error() because
    multifd_send_terminate_threads() already covers that.  Unwrap the helper
    multifd_new_send_channel_cleanup() along the way; not really needed.

Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20240202102857.110210-4-peterx@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
migration/multifd.c
migration/multifd.h