migration: Refactor error handling in source return path
commit7aa6070d09c5a6c83490599a3c564c64d7e2520a
authorPeter Xu <peterx@redhat.com>
Tue, 17 Oct 2023 20:26:29 +0000 (17 16:26 -0400)
committerJuan Quintela <quintela@redhat.com>
Thu, 2 Nov 2023 10:35:03 +0000 (2 11:35 +0100)
treeb9173cb1f3f58a8fc624cb9605494311f7d055db
parente7b428d6bc06a0dfffa7e47fb3b3ee47f1c93499
migration: Refactor error handling in source return path

rp_state.error was a boolean used to show error happened in return path
thread.  That's not only duplicating error reporting (migrate_set_error),
but also not good enough in that we only do error_report() and set it to
true, we never can keep a history of the exact error and show it in
query-migrate.

To make this better, a few things done:

  - Use error_setg() rather than error_report() across the whole lifecycle
    of return path thread, keeping the error in an Error*.

  - With above, no need to have mark_source_rp_bad(), remove it, alongside
    with rp_state.error itself.

  - Use migrate_set_error() to apply that captured error to the global
    migration object when error occured in this thread.

  - Do the same when detected qemufile error in source return path

We need to re-export qemu_file_get_error_obj() to do the last one.

Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20231017202633.296756-2-peterx@redhat.com>
migration/migration.c
migration/migration.h
migration/qemu-file.c
migration/qemu-file.h
migration/ram.c
migration/ram.h
migration/trace-events