]>
Commit | Line | Data |
---|---|---|
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" | |
1a92d6d5 LS |
11 | #include "io/channel.h" |
12 | #include "yank_functions.h" | |
18711405 | 13 | #include "qemu/yank.h" |
39675fff | 14 | #include "qemu-file.h" |
1a92d6d5 LS |
15 | |
16 | void migration_yank_iochannel(void *opaque) | |
17 | { | |
18 | QIOChannel *ioc = QIO_CHANNEL(opaque); | |
19 | ||
20 | qio_channel_shutdown(ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL); | |
21 | } | |
18711405 PX |
22 | |
23 | /* Return whether yank is supported on this ioc */ | |
24 | static bool migration_ioc_yank_supported(QIOChannel *ioc) | |
25 | { | |
0a5d1108 | 26 | return qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN); |
18711405 PX |
27 | } |
28 | ||
29 | void migration_ioc_register_yank(QIOChannel *ioc) | |
30 | { | |
31 | if (migration_ioc_yank_supported(ioc)) { | |
32 | yank_register_function(MIGRATION_YANK_INSTANCE, | |
33 | migration_yank_iochannel, | |
7d5b0d68 | 34 | ioc); |
18711405 PX |
35 | } |
36 | } | |
37 | ||
38 | void migration_ioc_unregister_yank(QIOChannel *ioc) | |
39 | { | |
40 | if (migration_ioc_yank_supported(ioc)) { | |
41 | yank_unregister_function(MIGRATION_YANK_INSTANCE, | |
42 | migration_yank_iochannel, | |
7d5b0d68 | 43 | ioc); |
18711405 PX |
44 | } |
45 | } | |
39675fff PX |
46 | |
47 | void migration_ioc_unregister_yank_from_file(QEMUFile *file) | |
48 | { | |
49 | QIOChannel *ioc = qemu_file_get_ioc(file); | |
50 | ||
51 | if (ioc) { | |
52 | /* | |
53 | * For migration qemufiles, we'll always reach here. Though we'll skip | |
54 | * calls from e.g. savevm/loadvm as they don't use yank. | |
55 | */ | |
56 | migration_ioc_unregister_yank(ioc); | |
57 | } | |
58 | } |