2021-03-23 18:52:42 +01:00
|
|
|
/*
|
|
|
|
* 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 "io/channel.h"
|
|
|
|
#include "yank_functions.h"
|
2021-07-22 19:58:39 +02:00
|
|
|
#include "qemu/yank.h"
|
2021-07-22 19:58:41 +02:00
|
|
|
#include "qemu-file.h"
|
2021-03-23 18:52:42 +01:00
|
|
|
|
|
|
|
void migration_yank_iochannel(void *opaque)
|
|
|
|
{
|
|
|
|
QIOChannel *ioc = QIO_CHANNEL(opaque);
|
|
|
|
|
|
|
|
qio_channel_shutdown(ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL);
|
|
|
|
}
|
2021-07-22 19:58:39 +02:00
|
|
|
|
|
|
|
/* Return whether yank is supported on this ioc */
|
|
|
|
static bool migration_ioc_yank_supported(QIOChannel *ioc)
|
|
|
|
{
|
2023-09-11 19:13:18 +02:00
|
|
|
return qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN);
|
2021-07-22 19:58:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void migration_ioc_register_yank(QIOChannel *ioc)
|
|
|
|
{
|
|
|
|
if (migration_ioc_yank_supported(ioc)) {
|
|
|
|
yank_register_function(MIGRATION_YANK_INSTANCE,
|
|
|
|
migration_yank_iochannel,
|
2023-06-01 11:34:52 +02:00
|
|
|
ioc);
|
2021-07-22 19:58:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void migration_ioc_unregister_yank(QIOChannel *ioc)
|
|
|
|
{
|
|
|
|
if (migration_ioc_yank_supported(ioc)) {
|
|
|
|
yank_unregister_function(MIGRATION_YANK_INSTANCE,
|
|
|
|
migration_yank_iochannel,
|
2023-06-01 11:34:52 +02:00
|
|
|
ioc);
|
2021-07-22 19:58:39 +02:00
|
|
|
}
|
|
|
|
}
|
2021-07-22 19:58:41 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|