mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
39675ffffb
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>
62 lines
1.7 KiB
C
62 lines
1.7 KiB
C
/*
|
|
* migration yank functions
|
|
*
|
|
* Copyright (c) Lukas Straub <lukasstraub2@web.de>
|
|
*
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
* See the COPYING file in the top-level directory.
|
|
*/
|
|
|
|
#include "qemu/osdep.h"
|
|
#include "qapi/error.h"
|
|
#include "io/channel.h"
|
|
#include "yank_functions.h"
|
|
#include "qemu/yank.h"
|
|
#include "io/channel-socket.h"
|
|
#include "io/channel-tls.h"
|
|
#include "qemu-file.h"
|
|
|
|
void migration_yank_iochannel(void *opaque)
|
|
{
|
|
QIOChannel *ioc = QIO_CHANNEL(opaque);
|
|
|
|
qio_channel_shutdown(ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL);
|
|
}
|
|
|
|
/* Return whether yank is supported on this ioc */
|
|
static bool migration_ioc_yank_supported(QIOChannel *ioc)
|
|
{
|
|
return object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET) ||
|
|
object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_TLS);
|
|
}
|
|
|
|
void migration_ioc_register_yank(QIOChannel *ioc)
|
|
{
|
|
if (migration_ioc_yank_supported(ioc)) {
|
|
yank_register_function(MIGRATION_YANK_INSTANCE,
|
|
migration_yank_iochannel,
|
|
QIO_CHANNEL(ioc));
|
|
}
|
|
}
|
|
|
|
void migration_ioc_unregister_yank(QIOChannel *ioc)
|
|
{
|
|
if (migration_ioc_yank_supported(ioc)) {
|
|
yank_unregister_function(MIGRATION_YANK_INSTANCE,
|
|
migration_yank_iochannel,
|
|
QIO_CHANNEL(ioc));
|
|
}
|
|
}
|
|
|
|
void migration_ioc_unregister_yank_from_file(QEMUFile *file)
|
|
{
|
|
QIOChannel *ioc = qemu_file_get_ioc(file);
|
|
|
|
if (ioc) {
|
|
/*
|
|
* For migration qemufiles, we'll always reach here. Though we'll skip
|
|
* calls from e.g. savevm/loadvm as they don't use yank.
|
|
*/
|
|
migration_ioc_unregister_yank(ioc);
|
|
}
|
|
}
|