mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
migration: Move the yank unregister of channel_close out
It's efficient, but hackish to call yank unregister calls in channel_close(), especially it'll be hard to debug when qemu crashed with some yank function leaked. Remove that hack, but instead explicitly unregister yank functions at the places where needed, they are: (on src) - migrate_fd_cleanup - postcopy_pause (on dst) - migration_incoming_state_destroy - postcopy_pause_incoming Signed-off-by: Peter Xu <peterx@redhat.com> Message-Id: <20210722175841.938739-6-peterx@redhat.com> Reviewed-by: Lukas Straub <lukasstraub2@web.de> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
This commit is contained in:
parent
c6ad5be7ae
commit
39675ffffb
5 changed files with 35 additions and 4 deletions
|
@ -59,6 +59,7 @@
|
|||
#include "multifd.h"
|
||||
#include "qemu/yank.h"
|
||||
#include "sysemu/cpus.h"
|
||||
#include "yank_functions.h"
|
||||
|
||||
#define MAX_THROTTLE (128 << 20) /* Migration transfer speed throttling */
|
||||
|
||||
|
@ -273,6 +274,7 @@ void migration_incoming_state_destroy(void)
|
|||
}
|
||||
|
||||
if (mis->from_src_file) {
|
||||
migration_ioc_unregister_yank_from_file(mis->from_src_file);
|
||||
qemu_fclose(mis->from_src_file);
|
||||
mis->from_src_file = NULL;
|
||||
}
|
||||
|
@ -1811,6 +1813,7 @@ static void migrate_fd_cleanup(MigrationState *s)
|
|||
* Close the file handle without the lock to make sure the
|
||||
* critical section won't block for long.
|
||||
*/
|
||||
migration_ioc_unregister_yank_from_file(tmp);
|
||||
qemu_fclose(tmp);
|
||||
}
|
||||
|
||||
|
@ -3351,8 +3354,17 @@ static MigThrError postcopy_pause(MigrationState *s)
|
|||
while (true) {
|
||||
QEMUFile *file;
|
||||
|
||||
/* Current channel is possibly broken. Release it. */
|
||||
/*
|
||||
* Current channel is possibly broken. Release it. Note that this is
|
||||
* guaranteed even without lock because to_dst_file should only be
|
||||
* modified by the migration thread. That also guarantees that the
|
||||
* unregister of yank is safe too without the lock. It should be safe
|
||||
* even to be within the qemu_file_lock, but we didn't do that to avoid
|
||||
* taking more mutex (yank_lock) within qemu_file_lock. TL;DR: we make
|
||||
* the qemu_file_lock critical section as small as possible.
|
||||
*/
|
||||
assert(s->to_dst_file);
|
||||
migration_ioc_unregister_yank_from_file(s->to_dst_file);
|
||||
qemu_mutex_lock(&s->qemu_file_lock);
|
||||
file = s->to_dst_file;
|
||||
s->to_dst_file = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue