master
c 41 lines 1.19 KB
Raw
1 /*
2 * SPDX-License-Identifier: GPL-2.0-or-later
3 *
4 * multifd colo implementation
5 *
6 * Copyright (c) Lukas Straub <lukasstraub2@web.de>
7 */
8
9 #include "qemu/osdep.h"
10 #include "multifd.h"
11 #include "multifd-colo.h"
12 #include "migration/colo.h"
13 #include "system/ramblock.h"
14
15 void multifd_colo_prepare_recv(MultiFDRecvParams *p)
16 {
17 /*
18 * While we're still in precopy state (not yet in colo state), we copy
19 * received pages to both guest and cache. No need to set dirty bits,
20 * since guest and cache memory are in sync.
21 */
22 if (migration_incoming_in_colo_state()) {
23 colo_record_bitmap(p->block, p->normal, p->normal_num);
24 colo_record_bitmap(p->block, p->zero, p->zero_num);
25 }
26 }
27
28 void multifd_colo_process_recv(MultiFDRecvParams *p)
29 {
30 if (!migration_incoming_in_colo_state()) {
31 for (int i = 0; i < p->normal_num; i++) {
32 void *guest = p->block->host + p->normal[i];
33 void *cache = p->host + p->normal[i];
34 memcpy(guest, cache, multifd_ram_page_size());
35 }
36 for (int i = 0; i < p->zero_num; i++) {
37 void *guest = p->block->host + p->zero[i];
38 memset(guest, 0, multifd_ram_page_size());
39 }
40 }
41 }