blob: 23697173ae55703e3e9656bef9a2283b8ea85a7e [file] [log] [blame]
Lukas Straub1a92d6d2021-03-23 18:52:42 +01001/*
2 * migration yank functions
3 *
4 * Copyright (c) Lukas Straub <lukasstraub2@web.de>
5 *
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 */
9
10#include "qemu/osdep.h"
11#include "qapi/error.h"
12#include "io/channel.h"
13#include "yank_functions.h"
Peter Xu18711402021-07-22 13:58:39 -040014#include "qemu/yank.h"
15#include "io/channel-socket.h"
16#include "io/channel-tls.h"
Lukas Straub1a92d6d2021-03-23 18:52:42 +010017
18void migration_yank_iochannel(void *opaque)
19{
20 QIOChannel *ioc = QIO_CHANNEL(opaque);
21
22 qio_channel_shutdown(ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL);
23}
Peter Xu18711402021-07-22 13:58:39 -040024
25/* Return whether yank is supported on this ioc */
26static bool migration_ioc_yank_supported(QIOChannel *ioc)
27{
28 return object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET) ||
29 object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_TLS);
30}
31
32void migration_ioc_register_yank(QIOChannel *ioc)
33{
34 if (migration_ioc_yank_supported(ioc)) {
35 yank_register_function(MIGRATION_YANK_INSTANCE,
36 migration_yank_iochannel,
37 QIO_CHANNEL(ioc));
38 }
39}
40
41void migration_ioc_unregister_yank(QIOChannel *ioc)
42{
43 if (migration_ioc_yank_supported(ioc)) {
44 yank_unregister_function(MIGRATION_YANK_INSTANCE,
45 migration_yank_iochannel,
46 QIO_CHANNEL(ioc));
47 }
48}