2 * Multifd common functions
4 * Copyright (c) 2019-2020 Red Hat Inc
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #ifndef QEMU_MIGRATION_MULTIFD_H
14 #define QEMU_MIGRATION_MULTIFD_H
16 int multifd_save_setup(Error **errp);
17 void multifd_save_cleanup(void);
18 int multifd_load_setup(Error **errp);
19 int multifd_load_cleanup(Error **errp);
20 bool multifd_recv_all_channels_created(void);
21 bool multifd_recv_new_channel(QIOChannel *ioc, Error **errp);
22 void multifd_recv_sync_main(void);
23 void multifd_send_sync_main(QEMUFile *f);
24 int multifd_queue_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset);
26 #define MULTIFD_FLAG_SYNC (1 << 0)
28 /* This value needs to be a multiple of qemu_target_page_size() */
29 #define MULTIFD_PACKET_SIZE (512 * 1024)
35 /* maximum number of allocated pages */
38 /* size of the next packet that contains pages */
39 uint32_t next_packet_size;
41 uint64_t unused[4]; /* Reserved for future use */
44 } __attribute__((packed)) MultiFDPacket_t;
47 /* number of used pages */
49 /* number of allocated pages */
51 /* global number of generated multifd packets */
53 /* offset of each page */
55 /* pointer to each page */
61 /* this fields are not changed once the thread is created */
64 /* channel thread name */
66 /* channel thread id */
68 /* communication channel */
70 /* sem where to wait for more work */
72 /* this mutex protects the following parameters */
74 /* is this channel thread running */
76 /* should this thread finish */
78 /* thread has work to do */
80 /* array of pages to sent */
81 MultiFDPages_t *pages;
82 /* packet allocated len */
84 /* pointer to the packet */
85 MultiFDPacket_t *packet;
86 /* multifd flags for each packet */
88 /* size of the next packet that contains pages */
89 uint32_t next_packet_size;
90 /* global number of generated multifd packets */
92 /* thread local variables */
93 /* packets sent through this channel */
95 /* pages sent through this channel */
97 /* syncs main thread and channels */
98 QemuSemaphore sem_sync;
102 /* this fields are not changed once the thread is created */
105 /* channel thread name */
107 /* channel thread id */
109 /* communication channel */
111 /* this mutex protects the following parameters */
113 /* is this channel thread running */
115 /* should this thread finish */
117 /* array of pages to receive */
118 MultiFDPages_t *pages;
119 /* packet allocated len */
121 /* pointer to the packet */
122 MultiFDPacket_t *packet;
123 /* multifd flags for each packet */
125 /* global number of generated multifd packets */
127 /* thread local variables */
128 /* size of the next packet that contains pages */
129 uint32_t next_packet_size;
130 /* packets sent through this channel */
131 uint64_t num_packets;
132 /* pages sent through this channel */
134 /* syncs main thread and channels */
135 QemuSemaphore sem_sync;