[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 6/6] multifd: Add colo support
|
From: |
Lukas Straub |
|
Subject: |
[PATCH v2 6/6] multifd: Add colo support |
|
Date: |
Mon, 8 May 2023 21:11:10 +0200 |
Like in the normal ram_load() path, put the received pages into the
colo cache and mark the pages in the bitmap so that they will be
flushed to the guest later.
Signed-off-by: Lukas Straub <lukasstraub2@web.de>
---
migration/multifd-colo.c | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/migration/multifd-colo.c b/migration/multifd-colo.c
index c035d15e87..305a1b7000 100644
--- a/migration/multifd-colo.c
+++ b/migration/multifd-colo.c
@@ -15,13 +15,41 @@
#include "ram.h"
#include "multifd.h"
#include "io/channel-socket.h"
+#include "migration/colo.h"
#define MULTIFD_INTERNAL
#include "multifd-internal.h"
static int multifd_colo_recv_pages(MultiFDRecvParams *p, Error **errp)
{
- return multifd_recv_state->ops->recv_pages(p, errp);
+ int ret = 0;
+
+ /*
+ * While we're still in precopy mode, we copy received pages to both guest
+ * and cache. No need to set dirty bits, since guest and cache memory are
+ * in sync.
+ */
+ if (migration_incoming_in_colo_state()) {
+ colo_record_bitmap(p->block, p->normal, p->normal_num);
+ }
+
+ p->host = p->block->colo_cache;
+ ret = multifd_recv_state->ops->recv_pages(p, errp);
+ if (ret != 0) {
+ p->host = p->block->host;
+ return ret;
+ }
+
+ if (!migration_incoming_in_colo_state()) {
+ for (int i = 0; i < p->normal_num; i++) {
+ void *guest = p->block->host + p->normal[i];
+ void *cache = p->host + p->normal[i];
+ memcpy(guest, cache, p->page_size);
+ }
+ }
+
+ p->host = p->block->host;
+ return ret;
}
int multifd_colo_load_setup(Error **errp)
--
2.39.2
pgpGrjy8TxCtb.pgp
Description: OpenPGP digital signature
- [PATCH v2 0/6] multifd: Add colo support, Lukas Straub, 2023/05/08
- [PATCH v2 1/6] ram: Add public helper to set colo bitmap, Lukas Straub, 2023/05/08
- [PATCH v2 2/6] ram: Let colo_flush_ram_cache take the bitmap_mutex, Lukas Straub, 2023/05/08
- [PATCH v2 3/6] multifd: Introduce multifd-internal.h, Lukas Straub, 2023/05/08
- [PATCH v2 4/6] multifd: Introduce a overridable revc_pages method, Lukas Straub, 2023/05/08
- [PATCH v2 5/6] multifd: Add the ramblock to MultiFDRecvParams, Lukas Straub, 2023/05/08
- [PATCH v2 6/6] multifd: Add colo support,
Lukas Straub <=