Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Multifd zlib compression implementation |
| 3 | * |
| 4 | * Copyright (c) 2020 Red Hat Inc |
| 5 | * |
| 6 | * Authors: |
| 7 | * Juan Quintela <quintela@redhat.com> |
| 8 | * |
| 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. |
| 11 | */ |
| 12 | |
| 13 | #include "qemu/osdep.h" |
| 14 | #include <zlib.h> |
| 15 | #include "qemu/rcu.h" |
Juan Quintela | a5ed229 | 2021-11-19 14:14:11 +0100 | [diff] [blame] | 16 | #include "exec/ramblock.h" |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 17 | #include "exec/target_page.h" |
| 18 | #include "qapi/error.h" |
| 19 | #include "migration.h" |
| 20 | #include "trace.h" |
Juan Quintela | 1dfc4b9 | 2023-03-02 00:39:03 +0100 | [diff] [blame] | 21 | #include "options.h" |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 22 | #include "multifd.h" |
| 23 | |
| 24 | struct zlib_data { |
| 25 | /* stream for compression */ |
| 26 | z_stream zs; |
| 27 | /* compressed buffer */ |
| 28 | uint8_t *zbuff; |
| 29 | /* size of compressed buffer */ |
| 30 | uint32_t zbuff_len; |
Ilya Leoshkevich | 007e179 | 2022-07-05 22:35:59 +0200 | [diff] [blame] | 31 | /* uncompressed buffer of size qemu_target_page_size() */ |
| 32 | uint8_t *buf; |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | /* Multifd zlib compression */ |
| 36 | |
| 37 | /** |
| 38 | * zlib_send_setup: setup send side |
| 39 | * |
| 40 | * Setup each channel with zlib compression. |
| 41 | * |
| 42 | * Returns 0 for success or -1 for error |
| 43 | * |
| 44 | * @p: Params for the channel that we are using |
| 45 | * @errp: pointer to an error |
| 46 | */ |
| 47 | static int zlib_send_setup(MultiFDSendParams *p, Error **errp) |
| 48 | { |
Markus Armbruster | b21e238 | 2022-03-15 15:41:56 +0100 | [diff] [blame] | 49 | struct zlib_data *z = g_new0(struct zlib_data, 1); |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 50 | z_stream *zs = &z->zs; |
Ilya Leoshkevich | 007e179 | 2022-07-05 22:35:59 +0200 | [diff] [blame] | 51 | const char *err_msg; |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 52 | |
| 53 | zs->zalloc = Z_NULL; |
| 54 | zs->zfree = Z_NULL; |
| 55 | zs->opaque = Z_NULL; |
| 56 | if (deflateInit(zs, migrate_multifd_zlib_level()) != Z_OK) { |
Ilya Leoshkevich | 007e179 | 2022-07-05 22:35:59 +0200 | [diff] [blame] | 57 | err_msg = "deflate init failed"; |
| 58 | goto err_free_z; |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 59 | } |
Michael Tokarev | d8b71d9 | 2023-07-14 14:32:41 +0300 | [diff] [blame] | 60 | /* This is the maximum size of the compressed buffer */ |
Juan Quintela | fc67052 | 2021-11-26 10:30:32 +0100 | [diff] [blame] | 61 | z->zbuff_len = compressBound(MULTIFD_PACKET_SIZE); |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 62 | z->zbuff = g_try_malloc(z->zbuff_len); |
| 63 | if (!z->zbuff) { |
Ilya Leoshkevich | 007e179 | 2022-07-05 22:35:59 +0200 | [diff] [blame] | 64 | err_msg = "out of memory for zbuff"; |
| 65 | goto err_deflate_end; |
| 66 | } |
| 67 | z->buf = g_try_malloc(qemu_target_page_size()); |
| 68 | if (!z->buf) { |
| 69 | err_msg = "out of memory for buf"; |
| 70 | goto err_free_zbuff; |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 71 | } |
Fabiano Rosas | 402dd7a | 2024-02-29 12:30:06 -0300 | [diff] [blame] | 72 | p->compress_data = z; |
Yuan Liu | d9d3e4f | 2024-06-10 18:21:05 +0800 | [diff] [blame] | 73 | |
| 74 | /* Needs 2 IOVs, one for packet header and one for compressed data */ |
| 75 | p->iov = g_new0(struct iovec, 2); |
| 76 | |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 77 | return 0; |
Ilya Leoshkevich | 007e179 | 2022-07-05 22:35:59 +0200 | [diff] [blame] | 78 | |
| 79 | err_free_zbuff: |
| 80 | g_free(z->zbuff); |
| 81 | err_deflate_end: |
Philippe Mathieu-Daudé | ee1004b | 2024-01-29 17:44:43 +0100 | [diff] [blame] | 82 | deflateEnd(zs); |
Ilya Leoshkevich | 007e179 | 2022-07-05 22:35:59 +0200 | [diff] [blame] | 83 | err_free_z: |
| 84 | g_free(z); |
| 85 | error_setg(errp, "multifd %u: %s", p->id, err_msg); |
| 86 | return -1; |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | /** |
| 90 | * zlib_send_cleanup: cleanup send side |
| 91 | * |
| 92 | * Close the channel and return memory. |
| 93 | * |
| 94 | * @p: Params for the channel that we are using |
Juan Quintela | 18ede63 | 2021-11-22 11:58:41 +0100 | [diff] [blame] | 95 | * @errp: pointer to an error |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 96 | */ |
| 97 | static void zlib_send_cleanup(MultiFDSendParams *p, Error **errp) |
| 98 | { |
Fabiano Rosas | 402dd7a | 2024-02-29 12:30:06 -0300 | [diff] [blame] | 99 | struct zlib_data *z = p->compress_data; |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 100 | |
| 101 | deflateEnd(&z->zs); |
| 102 | g_free(z->zbuff); |
| 103 | z->zbuff = NULL; |
Ilya Leoshkevich | 007e179 | 2022-07-05 22:35:59 +0200 | [diff] [blame] | 104 | g_free(z->buf); |
| 105 | z->buf = NULL; |
Fabiano Rosas | 402dd7a | 2024-02-29 12:30:06 -0300 | [diff] [blame] | 106 | g_free(p->compress_data); |
| 107 | p->compress_data = NULL; |
Yuan Liu | d9d3e4f | 2024-06-10 18:21:05 +0800 | [diff] [blame] | 108 | |
| 109 | g_free(p->iov); |
| 110 | p->iov = NULL; |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | /** |
| 114 | * zlib_send_prepare: prepare date to be able to send |
| 115 | * |
| 116 | * Create a compressed buffer with all the pages that we are going to |
| 117 | * send. |
| 118 | * |
| 119 | * Returns 0 for success or -1 for error |
| 120 | * |
| 121 | * @p: Params for the channel that we are using |
Juan Quintela | 18ede63 | 2021-11-22 11:58:41 +0100 | [diff] [blame] | 122 | * @errp: pointer to an error |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 123 | */ |
Juan Quintela | 02fb810 | 2021-11-22 12:08:08 +0100 | [diff] [blame] | 124 | static int zlib_send_prepare(MultiFDSendParams *p, Error **errp) |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 125 | { |
Peter Xu | efd8c54 | 2024-02-02 18:28:39 +0800 | [diff] [blame] | 126 | MultiFDPages_t *pages = p->pages; |
Fabiano Rosas | 402dd7a | 2024-02-29 12:30:06 -0300 | [diff] [blame] | 127 | struct zlib_data *z = p->compress_data; |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 128 | z_stream *zs = &z->zs; |
| 129 | uint32_t out_size = 0; |
| 130 | int ret; |
| 131 | uint32_t i; |
| 132 | |
Hao Xiang | 303e6f5 | 2024-03-11 18:00:12 +0000 | [diff] [blame] | 133 | if (!multifd_send_prepare_common(p)) { |
| 134 | goto out; |
| 135 | } |
Peter Xu | 25a1f87 | 2024-02-02 18:28:47 +0800 | [diff] [blame] | 136 | |
Hao Xiang | 303e6f5 | 2024-03-11 18:00:12 +0000 | [diff] [blame] | 137 | for (i = 0; i < pages->normal_num; i++) { |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 138 | uint32_t available = z->zbuff_len - out_size; |
| 139 | int flush = Z_NO_FLUSH; |
| 140 | |
Hao Xiang | 303e6f5 | 2024-03-11 18:00:12 +0000 | [diff] [blame] | 141 | if (i == pages->normal_num - 1) { |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 142 | flush = Z_SYNC_FLUSH; |
| 143 | } |
| 144 | |
Ilya Leoshkevich | 007e179 | 2022-07-05 22:35:59 +0200 | [diff] [blame] | 145 | /* |
| 146 | * Since the VM might be running, the page may be changing concurrently |
| 147 | * with compression. zlib does not guarantee that this is safe, |
| 148 | * therefore copy the page before calling deflate(). |
| 149 | */ |
Peter Xu | efd8c54 | 2024-02-02 18:28:39 +0800 | [diff] [blame] | 150 | memcpy(z->buf, p->pages->block->host + pages->offset[i], p->page_size); |
Juan Quintela | ddec20f | 2022-05-02 16:45:35 +0200 | [diff] [blame] | 151 | zs->avail_in = p->page_size; |
Ilya Leoshkevich | 007e179 | 2022-07-05 22:35:59 +0200 | [diff] [blame] | 152 | zs->next_in = z->buf; |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 153 | |
| 154 | zs->avail_out = available; |
| 155 | zs->next_out = z->zbuff + out_size; |
| 156 | |
| 157 | /* |
| 158 | * Welcome to deflate semantics |
| 159 | * |
| 160 | * We need to loop while: |
| 161 | * - return is Z_OK |
| 162 | * - there are stuff to be compressed |
| 163 | * - there are output space free |
| 164 | */ |
| 165 | do { |
| 166 | ret = deflate(zs, flush); |
| 167 | } while (ret == Z_OK && zs->avail_in && zs->avail_out); |
| 168 | if (ret == Z_OK && zs->avail_in) { |
Juan Quintela | 04e1140 | 2021-12-15 14:20:48 +0100 | [diff] [blame] | 169 | error_setg(errp, "multifd %u: deflate failed to compress all input", |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 170 | p->id); |
| 171 | return -1; |
| 172 | } |
| 173 | if (ret != Z_OK) { |
Juan Quintela | 04e1140 | 2021-12-15 14:20:48 +0100 | [diff] [blame] | 174 | error_setg(errp, "multifd %u: deflate returned %d instead of Z_OK", |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 175 | p->id, ret); |
| 176 | return -1; |
| 177 | } |
| 178 | out_size += available - zs->avail_out; |
| 179 | } |
Juan Quintela | 48a4a44 | 2021-11-19 15:03:02 +0100 | [diff] [blame] | 180 | p->iov[p->iovs_num].iov_base = z->zbuff; |
| 181 | p->iov[p->iovs_num].iov_len = out_size; |
| 182 | p->iovs_num++; |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 183 | p->next_packet_size = out_size; |
Hao Xiang | 303e6f5 | 2024-03-11 18:00:12 +0000 | [diff] [blame] | 184 | |
| 185 | out: |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 186 | p->flags |= MULTIFD_FLAG_ZLIB; |
Peter Xu | 25a1f87 | 2024-02-02 18:28:47 +0800 | [diff] [blame] | 187 | multifd_send_fill_packet(p); |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 188 | return 0; |
| 189 | } |
| 190 | |
| 191 | /** |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 192 | * zlib_recv_setup: setup receive side |
| 193 | * |
| 194 | * Create the compressed channel and buffer. |
| 195 | * |
| 196 | * Returns 0 for success or -1 for error |
| 197 | * |
| 198 | * @p: Params for the channel that we are using |
| 199 | * @errp: pointer to an error |
| 200 | */ |
| 201 | static int zlib_recv_setup(MultiFDRecvParams *p, Error **errp) |
| 202 | { |
Markus Armbruster | b21e238 | 2022-03-15 15:41:56 +0100 | [diff] [blame] | 203 | struct zlib_data *z = g_new0(struct zlib_data, 1); |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 204 | z_stream *zs = &z->zs; |
| 205 | |
Fabiano Rosas | 402dd7a | 2024-02-29 12:30:06 -0300 | [diff] [blame] | 206 | p->compress_data = z; |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 207 | zs->zalloc = Z_NULL; |
| 208 | zs->zfree = Z_NULL; |
| 209 | zs->opaque = Z_NULL; |
| 210 | zs->avail_in = 0; |
| 211 | zs->next_in = Z_NULL; |
| 212 | if (inflateInit(zs) != Z_OK) { |
Juan Quintela | 04e1140 | 2021-12-15 14:20:48 +0100 | [diff] [blame] | 213 | error_setg(errp, "multifd %u: inflate init failed", p->id); |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 214 | return -1; |
| 215 | } |
Juan Quintela | 47a1782 | 2021-11-22 20:18:28 +0100 | [diff] [blame] | 216 | /* To be safe, we reserve twice the size of the packet */ |
| 217 | z->zbuff_len = MULTIFD_PACKET_SIZE * 2; |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 218 | z->zbuff = g_try_malloc(z->zbuff_len); |
| 219 | if (!z->zbuff) { |
| 220 | inflateEnd(zs); |
Juan Quintela | 04e1140 | 2021-12-15 14:20:48 +0100 | [diff] [blame] | 221 | error_setg(errp, "multifd %u: out of memory for zbuff", p->id); |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 222 | return -1; |
| 223 | } |
| 224 | return 0; |
| 225 | } |
| 226 | |
| 227 | /** |
| 228 | * zlib_recv_cleanup: setup receive side |
| 229 | * |
| 230 | * For no compression this function does nothing. |
| 231 | * |
| 232 | * @p: Params for the channel that we are using |
| 233 | */ |
| 234 | static void zlib_recv_cleanup(MultiFDRecvParams *p) |
| 235 | { |
Fabiano Rosas | 402dd7a | 2024-02-29 12:30:06 -0300 | [diff] [blame] | 236 | struct zlib_data *z = p->compress_data; |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 237 | |
| 238 | inflateEnd(&z->zs); |
| 239 | g_free(z->zbuff); |
| 240 | z->zbuff = NULL; |
Fabiano Rosas | 402dd7a | 2024-02-29 12:30:06 -0300 | [diff] [blame] | 241 | g_free(p->compress_data); |
| 242 | p->compress_data = NULL; |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | /** |
Fabiano Rosas | 9db1912 | 2024-02-29 12:30:07 -0300 | [diff] [blame] | 246 | * zlib_recv: read the data from the channel into actual pages |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 247 | * |
| 248 | * Read the compressed buffer, and uncompress it into the actual |
| 249 | * pages. |
| 250 | * |
| 251 | * Returns 0 for success or -1 for error |
| 252 | * |
| 253 | * @p: Params for the channel that we are using |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 254 | * @errp: pointer to an error |
| 255 | */ |
Fabiano Rosas | 9db1912 | 2024-02-29 12:30:07 -0300 | [diff] [blame] | 256 | static int zlib_recv(MultiFDRecvParams *p, Error **errp) |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 257 | { |
Fabiano Rosas | 402dd7a | 2024-02-29 12:30:06 -0300 | [diff] [blame] | 258 | struct zlib_data *z = p->compress_data; |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 259 | z_stream *zs = &z->zs; |
| 260 | uint32_t in_size = p->next_packet_size; |
| 261 | /* we measure the change of total_out */ |
| 262 | uint32_t out_size = zs->total_out; |
Juan Quintela | ddec20f | 2022-05-02 16:45:35 +0200 | [diff] [blame] | 263 | uint32_t expected_size = p->normal_num * p->page_size; |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 264 | uint32_t flags = p->flags & MULTIFD_FLAG_COMPRESSION_MASK; |
| 265 | int ret; |
| 266 | int i; |
| 267 | |
| 268 | if (flags != MULTIFD_FLAG_ZLIB) { |
Juan Quintela | 04e1140 | 2021-12-15 14:20:48 +0100 | [diff] [blame] | 269 | error_setg(errp, "multifd %u: flags received %x flags expected %x", |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 270 | p->id, flags, MULTIFD_FLAG_ZLIB); |
| 271 | return -1; |
| 272 | } |
Hao Xiang | 303e6f5 | 2024-03-11 18:00:12 +0000 | [diff] [blame] | 273 | |
| 274 | multifd_recv_zero_page_process(p); |
| 275 | |
| 276 | if (!p->normal_num) { |
| 277 | assert(in_size == 0); |
| 278 | return 0; |
| 279 | } |
| 280 | |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 281 | ret = qio_channel_read_all(p->c, (void *)z->zbuff, in_size, errp); |
| 282 | |
| 283 | if (ret != 0) { |
| 284 | return ret; |
| 285 | } |
| 286 | |
| 287 | zs->avail_in = in_size; |
| 288 | zs->next_in = z->zbuff; |
| 289 | |
Juan Quintela | cf2d4aa | 2021-11-22 13:41:06 +0100 | [diff] [blame] | 290 | for (i = 0; i < p->normal_num; i++) { |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 291 | int flush = Z_NO_FLUSH; |
| 292 | unsigned long start = zs->total_out; |
| 293 | |
Yuan Liu | 5ef7e26 | 2024-04-01 23:41:10 +0800 | [diff] [blame] | 294 | ramblock_recv_bitmap_set_offset(p->block, p->normal[i]); |
Juan Quintela | cf2d4aa | 2021-11-22 13:41:06 +0100 | [diff] [blame] | 295 | if (i == p->normal_num - 1) { |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 296 | flush = Z_SYNC_FLUSH; |
| 297 | } |
| 298 | |
Juan Quintela | ddec20f | 2022-05-02 16:45:35 +0200 | [diff] [blame] | 299 | zs->avail_out = p->page_size; |
Juan Quintela | faf6093 | 2021-11-22 14:10:57 +0100 | [diff] [blame] | 300 | zs->next_out = p->host + p->normal[i]; |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 301 | |
| 302 | /* |
| 303 | * Welcome to inflate semantics |
| 304 | * |
| 305 | * We need to loop while: |
| 306 | * - return is Z_OK |
| 307 | * - there are input available |
| 308 | * - we haven't completed a full page |
| 309 | */ |
| 310 | do { |
| 311 | ret = inflate(zs, flush); |
| 312 | } while (ret == Z_OK && zs->avail_in |
Juan Quintela | ddec20f | 2022-05-02 16:45:35 +0200 | [diff] [blame] | 313 | && (zs->total_out - start) < p->page_size); |
| 314 | if (ret == Z_OK && (zs->total_out - start) < p->page_size) { |
Juan Quintela | 04e1140 | 2021-12-15 14:20:48 +0100 | [diff] [blame] | 315 | error_setg(errp, "multifd %u: inflate generated too few output", |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 316 | p->id); |
| 317 | return -1; |
| 318 | } |
| 319 | if (ret != Z_OK) { |
Juan Quintela | 04e1140 | 2021-12-15 14:20:48 +0100 | [diff] [blame] | 320 | error_setg(errp, "multifd %u: inflate returned %d instead of Z_OK", |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 321 | p->id, ret); |
| 322 | return -1; |
| 323 | } |
| 324 | } |
| 325 | out_size = zs->total_out - out_size; |
| 326 | if (out_size != expected_size) { |
Juan Quintela | 04e1140 | 2021-12-15 14:20:48 +0100 | [diff] [blame] | 327 | error_setg(errp, "multifd %u: packet size received %u size expected %u", |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 328 | p->id, out_size, expected_size); |
| 329 | return -1; |
| 330 | } |
Hao Xiang | 303e6f5 | 2024-03-11 18:00:12 +0000 | [diff] [blame] | 331 | |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 332 | return 0; |
| 333 | } |
| 334 | |
| 335 | static MultiFDMethods multifd_zlib_ops = { |
| 336 | .send_setup = zlib_send_setup, |
| 337 | .send_cleanup = zlib_send_cleanup, |
| 338 | .send_prepare = zlib_send_prepare, |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 339 | .recv_setup = zlib_recv_setup, |
| 340 | .recv_cleanup = zlib_recv_cleanup, |
Fabiano Rosas | 9db1912 | 2024-02-29 12:30:07 -0300 | [diff] [blame] | 341 | .recv = zlib_recv |
Juan Quintela | 7ec2c2b | 2019-01-04 15:30:06 +0100 | [diff] [blame] | 342 | }; |
| 343 | |
| 344 | static void multifd_zlib_register(void) |
| 345 | { |
| 346 | multifd_register_ops(MULTIFD_COMPRESSION_ZLIB, &multifd_zlib_ops); |
| 347 | } |
| 348 | |
| 349 | migration_init(multifd_zlib_register); |