]> git.proxmox.com Git - mirror_qemu.git/blame - migration/yank_functions.c
linux-user: Allow gdbstub to ignore page protection
[mirror_qemu.git] / migration / yank_functions.c
CommitLineData
1a92d6d5
LS
1/*
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"
18711405
PX
14#include "qemu/yank.h"
15#include "io/channel-socket.h"
16#include "io/channel-tls.h"
39675fff 17#include "qemu-file.h"
1a92d6d5
LS
18
19void migration_yank_iochannel(void *opaque)
20{
21 QIOChannel *ioc = QIO_CHANNEL(opaque);
22
23 qio_channel_shutdown(ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL);
24}
18711405
PX
25
26/* Return whether yank is supported on this ioc */
27static bool migration_ioc_yank_supported(QIOChannel *ioc)
28{
29 return object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET) ||
30 object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_TLS);
31}
32
33void migration_ioc_register_yank(QIOChannel *ioc)
34{
35 if (migration_ioc_yank_supported(ioc)) {
36 yank_register_function(MIGRATION_YANK_INSTANCE,
37 migration_yank_iochannel,
7d5b0d68 38 ioc);
18711405
PX
39 }
40}
41
42void migration_ioc_unregister_yank(QIOChannel *ioc)
43{
44 if (migration_ioc_yank_supported(ioc)) {
45 yank_unregister_function(MIGRATION_YANK_INSTANCE,
46 migration_yank_iochannel,
7d5b0d68 47 ioc);
18711405
PX
48 }
49}
39675fff
PX
50
51void migration_ioc_unregister_yank_from_file(QEMUFile *file)
52{
53 QIOChannel *ioc = qemu_file_get_ioc(file);
54
55 if (ioc) {
56 /*
57 * For migration qemufiles, we'll always reach here. Though we'll skip
58 * calls from e.g. savevm/loadvm as they don't use yank.
59 */
60 migration_ioc_unregister_yank(ioc);
61 }
62}