|
|
4372d3 |
From 35f06623b82d99dd380340eef465394975dd1c80 Mon Sep 17 00:00:00 2001
|
|
|
4372d3 |
Message-Id: <35f06623b82d99dd380340eef465394975dd1c80@dist-git>
|
|
|
11fcb6 |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
11fcb6 |
Date: Wed, 22 Jun 2022 16:37:31 +0200
|
|
|
11fcb6 |
Subject: [PATCH] qemu_migration: Implement VIR_MIGRATE_ZEROCOPY flag
|
|
|
11fcb6 |
MIME-Version: 1.0
|
|
|
11fcb6 |
Content-Type: text/plain; charset=UTF-8
|
|
|
11fcb6 |
Content-Transfer-Encoding: 8bit
|
|
|
11fcb6 |
|
|
|
11fcb6 |
Resolves: https://gitlab.com/libvirt/libvirt/-/issues/306
|
|
|
11fcb6 |
|
|
|
11fcb6 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
11fcb6 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
11fcb6 |
(cherry picked from commit d375993ab314a41bca7ef6c846e07afc18c37774)
|
|
|
11fcb6 |
|
|
|
4372d3 |
https://bugzilla.redhat.com/show_bug.cgi?id=2089433
|
|
|
11fcb6 |
|
|
|
11fcb6 |
Conflicts:
|
|
|
11fcb6 |
src/qemu/qemu_migration.c
|
|
|
11fcb6 |
src/qemu/qemu_migration.h
|
|
|
11fcb6 |
- post-copy recovery not bacported
|
|
|
11fcb6 |
|
|
|
11fcb6 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
11fcb6 |
---
|
|
|
11fcb6 |
src/qemu/qemu_migration.c | 21 +++++++++++++++++++++
|
|
|
11fcb6 |
src/qemu/qemu_migration.h | 1 +
|
|
|
11fcb6 |
src/qemu/qemu_migration_params.c | 6 ++++++
|
|
|
11fcb6 |
src/qemu/qemu_migration_params.h | 1 +
|
|
|
11fcb6 |
4 files changed, 29 insertions(+)
|
|
|
11fcb6 |
|
|
|
11fcb6 |
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
|
|
|
4372d3 |
index 35ad201580..db5163e993 100644
|
|
|
11fcb6 |
--- a/src/qemu/qemu_migration.c
|
|
|
11fcb6 |
+++ b/src/qemu/qemu_migration.c
|
|
|
11fcb6 |
@@ -2366,6 +2366,12 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver,
|
|
|
11fcb6 |
return NULL;
|
|
|
11fcb6 |
}
|
|
|
11fcb6 |
|
|
|
11fcb6 |
+ if (flags & VIR_MIGRATE_ZEROCOPY && !(flags & VIR_MIGRATE_PARALLEL)) {
|
|
|
11fcb6 |
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
|
11fcb6 |
+ _("zero-copy is only available for parallel migration"));
|
|
|
11fcb6 |
+ return NULL;
|
|
|
11fcb6 |
+ }
|
|
|
11fcb6 |
+
|
|
|
11fcb6 |
if (flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC)) {
|
|
|
11fcb6 |
if (flags & VIR_MIGRATE_NON_SHARED_SYNCHRONOUS_WRITES &&
|
|
|
11fcb6 |
!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) {
|
|
|
11fcb6 |
@@ -4137,6 +4143,21 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
|
|
|
11fcb6 |
migParams) < 0)
|
|
|
11fcb6 |
goto error;
|
|
|
11fcb6 |
|
|
|
11fcb6 |
+ if (flags & VIR_MIGRATE_ZEROCOPY) {
|
|
|
11fcb6 |
+ /* Zero-copy requires pages in transfer to be locked in host memory.
|
|
|
11fcb6 |
+ * Unfortunately, we have no reliable way of computing how many pages
|
|
|
11fcb6 |
+ * will need to be locked at the same time. Thus we set the limit to
|
|
|
11fcb6 |
+ * the whole guest memory and reset it back once migration is done. */
|
|
|
11fcb6 |
+ unsigned long long limit;
|
|
|
11fcb6 |
+
|
|
|
11fcb6 |
+ if (virMemoryLimitIsSet(vm->def->mem.hard_limit))
|
|
|
11fcb6 |
+ limit = vm->def->mem.hard_limit;
|
|
|
11fcb6 |
+ else
|
|
|
11fcb6 |
+ limit = virDomainDefGetMemoryTotal(vm->def);
|
|
|
11fcb6 |
+
|
|
|
11fcb6 |
+ if (qemuDomainSetMaxMemLock(vm, limit << 10, &priv->preMigrationMemlock) < 0)
|
|
|
11fcb6 |
+ goto error;
|
|
|
11fcb6 |
+ }
|
|
|
11fcb6 |
|
|
|
11fcb6 |
if (storageMigration) {
|
|
|
11fcb6 |
if (mig->nbd) {
|
|
|
11fcb6 |
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
|
|
|
11fcb6 |
index b233358a51..6f737f7b4c 100644
|
|
|
11fcb6 |
--- a/src/qemu/qemu_migration.h
|
|
|
11fcb6 |
+++ b/src/qemu/qemu_migration.h
|
|
|
11fcb6 |
@@ -60,6 +60,7 @@
|
|
|
11fcb6 |
VIR_MIGRATE_TLS | \
|
|
|
11fcb6 |
VIR_MIGRATE_PARALLEL | \
|
|
|
11fcb6 |
VIR_MIGRATE_NON_SHARED_SYNCHRONOUS_WRITES | \
|
|
|
11fcb6 |
+ VIR_MIGRATE_ZEROCOPY | \
|
|
|
11fcb6 |
0)
|
|
|
11fcb6 |
|
|
|
11fcb6 |
/* All supported migration parameters and their types. */
|
|
|
11fcb6 |
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
|
|
|
11fcb6 |
index 7b225fdf4b..c985583861 100644
|
|
|
11fcb6 |
--- a/src/qemu/qemu_migration_params.c
|
|
|
11fcb6 |
+++ b/src/qemu/qemu_migration_params.c
|
|
|
11fcb6 |
@@ -96,6 +96,7 @@ VIR_ENUM_IMPL(qemuMigrationCapability,
|
|
|
11fcb6 |
"multifd",
|
|
|
11fcb6 |
"dirty-bitmaps",
|
|
|
11fcb6 |
"return-path",
|
|
|
11fcb6 |
+ "zero-copy-send",
|
|
|
11fcb6 |
);
|
|
|
11fcb6 |
|
|
|
11fcb6 |
|
|
|
11fcb6 |
@@ -177,6 +178,11 @@ static const qemuMigrationParamsFlagMapItem qemuMigrationParamsFlagMap[] = {
|
|
|
11fcb6 |
VIR_MIGRATE_TUNNELLED,
|
|
|
11fcb6 |
QEMU_MIGRATION_CAP_RETURN_PATH,
|
|
|
11fcb6 |
QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION},
|
|
|
11fcb6 |
+
|
|
|
11fcb6 |
+ {QEMU_MIGRATION_FLAG_REQUIRED,
|
|
|
11fcb6 |
+ VIR_MIGRATE_ZEROCOPY,
|
|
|
11fcb6 |
+ QEMU_MIGRATION_CAP_ZERO_COPY_SEND,
|
|
|
11fcb6 |
+ QEMU_MIGRATION_SOURCE},
|
|
|
11fcb6 |
};
|
|
|
11fcb6 |
|
|
|
11fcb6 |
/* Translation from VIR_MIGRATE_PARAM_* typed parameters to
|
|
|
11fcb6 |
diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h
|
|
|
11fcb6 |
index b4de8dda7b..caa5e47f0f 100644
|
|
|
11fcb6 |
--- a/src/qemu/qemu_migration_params.h
|
|
|
11fcb6 |
+++ b/src/qemu/qemu_migration_params.h
|
|
|
11fcb6 |
@@ -41,6 +41,7 @@ typedef enum {
|
|
|
11fcb6 |
QEMU_MIGRATION_CAP_MULTIFD,
|
|
|
11fcb6 |
QEMU_MIGRATION_CAP_BLOCK_DIRTY_BITMAPS,
|
|
|
11fcb6 |
QEMU_MIGRATION_CAP_RETURN_PATH,
|
|
|
11fcb6 |
+ QEMU_MIGRATION_CAP_ZERO_COPY_SEND,
|
|
|
11fcb6 |
|
|
|
11fcb6 |
QEMU_MIGRATION_CAP_LAST
|
|
|
11fcb6 |
} qemuMigrationCapability;
|
|
|
11fcb6 |
--
|
|
|
11fcb6 |
2.35.1
|
|
|
11fcb6 |
|