From: "Cédric Le Goater" <clg@redhat.com>
To: Fabiano Rosas <farosas@suse.de>, qemu-devel@nongnu.org
Cc: Peter Xu <peterx@redhat.com>
Subject: Re: [PATCH 2/2] migration: Fix return-path thread exit
Date: Fri, 2 Feb 2024 15:51:02 +0100 [thread overview]
Message-ID: <d2d0314a-494f-4ace-ba73-e14019fb4fd3@redhat.com> (raw)
In-Reply-To: <8734ubhqr9.fsf@suse.de>
On 2/2/24 15:42, Fabiano Rosas wrote:
> Cédric Le Goater <clg@redhat.com> writes:
>
>> In case of error, close_return_path_on_source() can perform a shutdown
>> to exit the return-path thread. However, in migrate_fd_cleanup(),
>> 'to_dst_file' is closed before calling close_return_path_on_source()
>> and the shutdown fails, leaving the source and destination waiting for
>> an event to occur.
>
> At close_return_path_on_source, qemu_file_shutdown() and checking
> ms->to_dst_file are done under the qemu_file_lock, so how could
> migrate_fd_cleanup() have cleared the pointer but the ms->to_dst_file
> check have passed?
This is not a locking issue, it's much simpler. migrate_fd_cleanup()
clears the ms->to_dst_file pointer and closes the QEMUFile and then
calls close_return_path_on_source() which then tries to use resources
which are not available anymore.
Thanks,
C.
>
>>
>> Close the file after calling close_return_path_on_source() so that the
>> shutdown succeeds and the return-path thread exits.
>>
>> Signed-off-by: Cédric Le Goater <clg@redhat.com>
>> ---
>> migration/migration.c | 12 +++++-------
>> 1 file changed, 5 insertions(+), 7 deletions(-)
>>
>> diff --git a/migration/migration.c b/migration/migration.c
>> index 2c3362235c7651c11d581f3c3639571f1f9636ef..1e0b6acaedc272e8ce26ad40be2c42177f5fd14e 100644
>> --- a/migration/migration.c
>> +++ b/migration/migration.c
>> @@ -1314,6 +1314,7 @@ void migrate_set_state(int *state, int old_state, int new_state)
>> static void migrate_fd_cleanup(MigrationState *s)
>> {
>> int file_error = 0;
>> + QEMUFile *tmp = NULL;
>>
>> g_free(s->hostname);
>> s->hostname = NULL;
>> @@ -1323,8 +1324,6 @@ static void migrate_fd_cleanup(MigrationState *s)
>> qemu_savevm_state_cleanup();
>>
>> if (s->to_dst_file) {
>> - QEMUFile *tmp;
>> -
>> trace_migrate_fd_cleanup();
>> bql_unlock();
>> if (s->migration_thread_running) {
>> @@ -1344,15 +1343,14 @@ static void migrate_fd_cleanup(MigrationState *s)
>> * critical section won't block for long.
>> */
>> migration_ioc_unregister_yank_from_file(tmp);
>> - qemu_fclose(tmp);
>> }
>>
>> - /*
>> - * We already cleaned up to_dst_file, so errors from the return
>> - * path might be due to that, ignore them.
>> - */
>> close_return_path_on_source(s, file_error);
>>
>> + if (tmp) {
>> + qemu_fclose(tmp);
>> + }
>> +
>> assert(!migration_is_active(s));
>>
>> if (s->state == MIGRATION_STATUS_CANCELLING) {
>
next prev parent reply other threads:[~2024-02-02 14:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 18:48 [PATCH 0/2] migration: Fix return-path thread exit Cédric Le Goater
2024-02-01 18:48 ` [PATCH 1/2] migration: Add a file_error argument to close_return_path_on_source() Cédric Le Goater
2024-02-02 14:30 ` Fabiano Rosas
2024-02-02 14:45 ` Cédric Le Goater
2024-02-01 18:48 ` [PATCH 2/2] migration: Fix return-path thread exit Cédric Le Goater
2024-02-02 14:42 ` Fabiano Rosas
2024-02-02 14:51 ` Cédric Le Goater [this message]
2024-02-02 15:11 ` Fabiano Rosas
2024-02-05 3:37 ` Peter Xu
2024-02-05 10:17 ` Cédric Le Goater
2024-02-02 9:53 ` [PATCH 0/2] " Peter Xu
2024-02-02 13:04 ` Cédric Le Goater
2024-02-05 10:32 ` Daniel P. Berrangé
2024-02-06 2:42 ` Peter Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d2d0314a-494f-4ace-ba73-e14019fb4fd3@redhat.com \
--to=clg@redhat.com \
--cc=farosas@suse.de \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).