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