From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Laurent Vivier <lvivier@redhat.com>
Cc: "Michael S . Tsirkin" <mst@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Amit Shah <amit@kernel.org>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 1/2] migration: don't close a file descriptor while it can be in use
Date: Thu, 20 Apr 2017 19:48:43 +0100 [thread overview]
Message-ID: <20170420184843.GJ2094@work-vm> (raw)
In-Reply-To: <20170412135312.1686-2-lvivier@redhat.com>
* Laurent Vivier (lvivier@redhat.com) wrote:
> If we close the QEMUFile descriptor in process_incoming_migration_co()
> while it has been stopped by an error, the postcopy_ram_listen_thread()
> can try to continue to use it. And as the memory has been freed
> it is working with an invalid pointer and crashes.
>
> Fix this by releasing the memory after having managed the error
> case (which, in fact, calls exit())
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Yes, this took me some thinking about why it got there.
(I only managed to reproduce this case once, even with 'tc')
'LISTEN' message via loadvm_postcopy_handle_listen,
postcopy state is set to LISTENING
sets mis->have_listen_thread
starts 'listen' thread
Errors while 'loading state of instance...' so fails
qemu_loadvm_state_main in loadvm_handle_cmd_packaged
fails loadvm_process_command
fails qemu_loadvm_state_main
fails in qemu_loadvm_state
has mis->have_listen_thread
process_incoming_migration_co
since ret < 0 fails now rather than leaving it to the
'listening thread' - which is probably still alive
Dave
> ---
> migration/migration.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/migration/migration.c b/migration/migration.c
> index ad4036f..e024e0a 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -436,9 +436,6 @@ static void process_incoming_migration_co(void *opaque)
> qemu_thread_join(&mis->colo_incoming_thread);
> }
>
> - qemu_fclose(f);
> - free_xbzrle_decoded_buf();
> -
> if (ret < 0) {
> migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,
> MIGRATION_STATUS_FAILED);
> @@ -447,6 +444,9 @@ static void process_incoming_migration_co(void *opaque)
> exit(EXIT_FAILURE);
> }
>
> + qemu_fclose(f);
> + free_xbzrle_decoded_buf();
> +
> mis->bh = qemu_bh_new(process_incoming_migration_bh, mis);
> qemu_bh_schedule(mis->bh);
> }
> --
> 2.9.3
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2017-04-20 18:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-12 13:53 [Qemu-devel] [PATCH v2 0/2] migration: fix virtio-rng Laurent Vivier
2017-04-12 13:53 ` [Qemu-devel] [PATCH v2 1/2] migration: don't close a file descriptor while it can be in use Laurent Vivier
2017-04-20 18:48 ` Dr. David Alan Gilbert [this message]
2017-04-21 9:19 ` Juan Quintela
2017-04-12 13:53 ` [Qemu-devel] [PATCH v2 2/2] virtio-rng: stop virtqueue while the CPU is stopped Laurent Vivier
2017-04-21 9:20 ` Juan Quintela
2017-04-13 14:51 ` [Qemu-devel] [PATCH v2 0/2] migration: fix virtio-rng Stefan Hajnoczi
2017-04-17 19:33 ` Amit Shah
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=20170420184843.GJ2094@work-vm \
--to=dgilbert@redhat.com \
--cc=amit@kernel.org \
--cc=lvivier@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.