|
|
9119d9 |
From 298d5857152494dfd31f182ecc16f4aa16c5617f Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <298d5857152494dfd31f182ecc16f4aa16c5617f@dist-git>
|
|
|
9119d9 |
From: "Michael R. Hines" <mrhines@us.ibm.com>
|
|
|
9119d9 |
Date: Tue, 23 Sep 2014 15:47:57 +0200
|
|
|
9119d9 |
Subject: [PATCH] qemu: RDMA migration support
|
|
|
9119d9 |
|
|
|
9119d9 |
This patch adds support for RDMA protocol in migration URIs.
|
|
|
9119d9 |
|
|
|
9119d9 |
USAGE: $ virsh migrate --live --migrateuri rdma://hostname domain qemu+ssh://hostname/system
|
|
|
9119d9 |
|
|
|
9119d9 |
Since libvirt runs QEMU in a pretty restricted environment, several
|
|
|
9119d9 |
files needs to be added to cgroup_device_acl (in qemu.conf) for QEMU to
|
|
|
9119d9 |
be able to access the host's infiniband hardware. Full documenation of
|
|
|
9119d9 |
the feature can be found on QEMU wiki:
|
|
|
9119d9 |
http://wiki.qemu.org/Features/RDMALiveMigration
|
|
|
9119d9 |
|
|
|
9119d9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1013055
|
|
|
9119d9 |
|
|
|
9119d9 |
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
(cherry picked from commit ed22a4743437b6f646eb33659a212dd252a5b65d)
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
src/qemu/qemu.conf | 8 ++++++++
|
|
|
9119d9 |
src/qemu/qemu_command.c | 8 ++++++++
|
|
|
9119d9 |
src/qemu/qemu_migration.c | 39 +++++++++++++++++++++++++++++++++++++--
|
|
|
9119d9 |
3 files changed, 53 insertions(+), 2 deletions(-)
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
|
|
|
9119d9 |
index 79bba36..92ca715 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu.conf
|
|
|
9119d9 |
+++ b/src/qemu/qemu.conf
|
|
|
9119d9 |
@@ -274,6 +274,14 @@
|
|
|
9119d9 |
# "/dev/ptmx", "/dev/kvm", "/dev/kqemu",
|
|
|
9119d9 |
# "/dev/rtc","/dev/hpet", "/dev/vfio/vfio"
|
|
|
9119d9 |
#]
|
|
|
9119d9 |
+#
|
|
|
9119d9 |
+# RDMA migration requires the following extra files to be added to the list:
|
|
|
9119d9 |
+# "/dev/infiniband/rdma_cm",
|
|
|
9119d9 |
+# "/dev/infiniband/issm0",
|
|
|
9119d9 |
+# "/dev/infiniband/issm1",
|
|
|
9119d9 |
+# "/dev/infiniband/umad0",
|
|
|
9119d9 |
+# "/dev/infiniband/umad1",
|
|
|
9119d9 |
+# "/dev/infiniband/uverbs0"
|
|
|
9119d9 |
|
|
|
9119d9 |
|
|
|
9119d9 |
# The default format for Qemu/KVM guest save images is raw; that is, the
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
|
|
9119d9 |
index 05f328a..7d4f3cc 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_command.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_command.c
|
|
|
9119d9 |
@@ -9475,6 +9475,14 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|
|
9119d9 |
goto error;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
virCommandAddArg(cmd, migrateFrom);
|
|
|
9119d9 |
+ } else if (STRPREFIX(migrateFrom, "rdma")) {
|
|
|
9119d9 |
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_RDMA)) {
|
|
|
9119d9 |
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
|
|
9119d9 |
+ _("incoming RDMA migration is not supported "
|
|
|
9119d9 |
+ "with this QEMU binary"));
|
|
|
9119d9 |
+ goto error;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
+ virCommandAddArg(cmd, migrateFrom);
|
|
|
9119d9 |
} else if (STREQ(migrateFrom, "stdio")) {
|
|
|
9119d9 |
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD)) {
|
|
|
9119d9 |
virCommandAddArgFormat(cmd, "fd:%d", migrateFd);
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
|
|
|
9119d9 |
index 6b690b8..3433ec9 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_migration.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_migration.c
|
|
|
9119d9 |
@@ -56,6 +56,7 @@
|
|
|
9119d9 |
#include "virhook.h"
|
|
|
9119d9 |
#include "virstring.h"
|
|
|
9119d9 |
#include "virtypedparam.h"
|
|
|
9119d9 |
+#include "virprocess.h"
|
|
|
9119d9 |
|
|
|
9119d9 |
#define VIR_FROM_THIS VIR_FROM_QEMU
|
|
|
9119d9 |
|
|
|
9119d9 |
@@ -2653,6 +2654,13 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
|
|
|
9119d9 |
QEMU_MIGRATION_COOKIE_NBD)))
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
|
|
|
9119d9 |
+ if (STREQ(protocol, "rdma") && !vm->def->mem.hard_limit) {
|
|
|
9119d9 |
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
|
9119d9 |
+ _("cannot start RDMA migration with no memory hard "
|
|
|
9119d9 |
+ "limit set"));
|
|
|
9119d9 |
+ goto cleanup;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
+
|
|
|
9119d9 |
if (qemuMigrationJobStart(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
qemuMigrationJobSetPhase(driver, vm, QEMU_MIGRATION_PHASE_PREPARE);
|
|
|
9119d9 |
@@ -2696,6 +2704,11 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
|
|
|
9119d9 |
QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
|
|
|
9119d9 |
goto stop;
|
|
|
9119d9 |
|
|
|
9119d9 |
+ if (STREQ(protocol, "rdma") &&
|
|
|
9119d9 |
+ virProcessSetMaxMemLock(vm->pid, vm->def->mem.hard_limit << 10) < 0) {
|
|
|
9119d9 |
+ goto stop;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
+
|
|
|
9119d9 |
if (mig->lockState) {
|
|
|
9119d9 |
VIR_DEBUG("Received lockstate %s", mig->lockState);
|
|
|
9119d9 |
VIR_FREE(priv->lockState);
|
|
|
9119d9 |
@@ -2926,7 +2939,8 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
|
|
|
9119d9 |
if (!(uri = qemuMigrationParseURI(uri_in, &well_formed_uri)))
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
|
|
|
9119d9 |
- if (STRNEQ(uri->scheme, "tcp")) {
|
|
|
9119d9 |
+ if (STRNEQ(uri->scheme, "tcp") &&
|
|
|
9119d9 |
+ STRNEQ(uri->scheme, "rdma")) {
|
|
|
9119d9 |
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,
|
|
|
9119d9 |
_("unsupported scheme %s in migration URI %s"),
|
|
|
9119d9 |
uri->scheme, uri_in);
|
|
|
9119d9 |
@@ -3547,6 +3561,11 @@ qemuMigrationRun(virQEMUDriverPtr driver,
|
|
|
9119d9 |
|
|
|
9119d9 |
switch (spec->destType) {
|
|
|
9119d9 |
case MIGRATION_DEST_HOST:
|
|
|
9119d9 |
+ if (STREQ(spec->dest.host.protocol, "rdma") &&
|
|
|
9119d9 |
+ virProcessSetMaxMemLock(vm->pid, vm->def->mem.hard_limit << 10) < 0) {
|
|
|
9119d9 |
+ qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
+ goto cleanup;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
ret = qemuMonitorMigrateToHost(priv->mon, migrate_flags,
|
|
|
9119d9 |
spec->dest.host.protocol,
|
|
|
9119d9 |
spec->dest.host.name,
|
|
|
9119d9 |
@@ -3719,7 +3738,23 @@ static int doNativeMigrate(virQEMUDriverPtr driver,
|
|
|
9119d9 |
if (!(uribits = qemuMigrationParseURI(uri, NULL)))
|
|
|
9119d9 |
return -1;
|
|
|
9119d9 |
|
|
|
9119d9 |
- if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD))
|
|
|
9119d9 |
+ if (STREQ(uribits->scheme, "rdma")) {
|
|
|
9119d9 |
+ if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_RDMA)) {
|
|
|
9119d9 |
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
|
|
9119d9 |
+ _("outgoing RDMA migration is not supported "
|
|
|
9119d9 |
+ "with this QEMU binary"));
|
|
|
9119d9 |
+ return -1;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
+ if (!vm->def->mem.hard_limit) {
|
|
|
9119d9 |
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
|
9119d9 |
+ _("cannot start RDMA migration with no memory hard "
|
|
|
9119d9 |
+ "limit set"));
|
|
|
9119d9 |
+ return -1;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
|
|
|
9119d9 |
+ STRNEQ(uribits->scheme, "rdma"))
|
|
|
9119d9 |
spec.destType = MIGRATION_DEST_CONNECT_HOST;
|
|
|
9119d9 |
else
|
|
|
9119d9 |
spec.destType = MIGRATION_DEST_HOST;
|
|
|
9119d9 |
--
|
|
|
9119d9 |
2.1.1
|
|
|
9119d9 |
|