Lukas Straub | 1a92d6d | 2021-03-23 18:52:42 +0100 | [diff] [blame] | 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" |
Peter Xu | 1871140 | 2021-07-22 13:58:39 -0400 | [diff] [blame] | 14 | #include "qemu/yank.h" |
| 15 | #include "io/channel-socket.h" |
| 16 | #include "io/channel-tls.h" |
Lukas Straub | 1a92d6d | 2021-03-23 18:52:42 +0100 | [diff] [blame] | 17 | |
| 18 | void 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 Xu | 1871140 | 2021-07-22 13:58:39 -0400 | [diff] [blame] | 24 | |
| 25 | /* Return whether yank is supported on this ioc */ |
| 26 | static 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 | |
| 32 | void 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 | |
| 41 | void 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 | } |