render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
9119d9
From 088baea86780021290cc9dbb3e313723d7040cbd Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <088baea86780021290cc9dbb3e313723d7040cbd@dist-git>
9119d9
From: "Michael R. Hines" <mrhines@us.ibm.com>
9119d9
Date: Tue, 23 Sep 2014 15:47:58 +0200
9119d9
Subject: [PATCH] qemu: Memory pre-pinning support for RDMA migration
9119d9
9119d9
RDMA Live migration requires registering memory with the hardware, and
9119d9
thus QEMU offers a new 'capability' to pre-register / mlock() the guest
9119d9
memory in advance for higher RDMA performance before the migration
9119d9
begins. This capability is disabled by default, which means QEMU will
9119d9
register the memory with the hardware in an on-demand basis.
9119d9
9119d9
This patch exposes this capability with the following example usage:
9119d9
9119d9
virsh migrate --live --rdma-pin-all --migrateuri rdma://hostname domain qemu+ssh://hostname/system
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 9cc1586d2b5b6d4d396ebfa0479ae441e0b917ea)
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 include/libvirt/libvirt.h.in |  1 +
9119d9
 src/qemu/qemu_migration.c    | 49 ++++++++++++++++++++++++++++++++++++++++++++
9119d9
 src/qemu/qemu_migration.h    |  3 ++-
9119d9
 tools/virsh-domain.c         |  7 +++++++
9119d9
 4 files changed, 59 insertions(+), 1 deletion(-)
9119d9
9119d9
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
9119d9
index b07797e..0b40727 100644
9119d9
--- a/include/libvirt/libvirt.h.in
9119d9
+++ b/include/libvirt/libvirt.h.in
9119d9
@@ -1224,6 +1224,7 @@ typedef enum {
9119d9
     VIR_MIGRATE_COMPRESSED        = (1 << 11), /* compress data during migration */
9119d9
     VIR_MIGRATE_ABORT_ON_ERROR    = (1 << 12), /* abort migration on I/O errors happened during migration */
9119d9
     VIR_MIGRATE_AUTO_CONVERGE     = (1 << 13), /* force convergence */
9119d9
+    VIR_MIGRATE_RDMA_PIN_ALL      = (1 << 14), /* RDMA memory pinning */
9119d9
 } virDomainMigrateFlags;
9119d9
 
9119d9
 
9119d9
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
9119d9
index 3433ec9..fda7cda 100644
9119d9
--- a/src/qemu/qemu_migration.c
9119d9
+++ b/src/qemu/qemu_migration.c
9119d9
@@ -1874,6 +1874,46 @@ qemuMigrationSetAutoConverge(virQEMUDriverPtr driver,
9119d9
 
9119d9
 
9119d9
 static int
9119d9
+qemuMigrationSetPinAll(virQEMUDriverPtr driver,
9119d9
+                       virDomainObjPtr vm,
9119d9
+                       qemuDomainAsyncJob job)
9119d9
+{
9119d9
+    qemuDomainObjPrivatePtr priv = vm->privateData;
9119d9
+    int ret;
9119d9
+
9119d9
+    if (qemuDomainObjEnterMonitorAsync(driver, vm, job) < 0)
9119d9
+        return -1;
9119d9
+
9119d9
+    ret = qemuMonitorGetMigrationCapability(
9119d9
+                priv->mon,
9119d9
+                QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL);
9119d9
+
9119d9
+    if (ret < 0) {
9119d9
+        goto cleanup;
9119d9
+    } else if (ret == 0) {
9119d9
+        if (job == QEMU_ASYNC_JOB_MIGRATION_IN) {
9119d9
+            virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
9119d9
+                           _("rdma pinning migration is not supported by "
9119d9
+                             "target QEMU binary"));
9119d9
+        } else {
9119d9
+            virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
9119d9
+                           _("rdma pinning migration is not supported by "
9119d9
+                             "source QEMU binary"));
9119d9
+        }
9119d9
+        ret = -1;
9119d9
+        goto cleanup;
9119d9
+    }
9119d9
+
9119d9
+    ret = qemuMonitorSetMigrationCapability(
9119d9
+                priv->mon,
9119d9
+                QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL);
9119d9
+
9119d9
+ cleanup:
9119d9
+    qemuDomainObjExitMonitor(driver, vm);
9119d9
+    return ret;
9119d9
+}
9119d9
+
9119d9
+static int
9119d9
 qemuMigrationWaitForSpice(virQEMUDriverPtr driver,
9119d9
                           virDomainObjPtr vm)
9119d9
 {
9119d9
@@ -2709,6 +2749,10 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
9119d9
         goto stop;
9119d9
     }
9119d9
 
9119d9
+    if (flags & VIR_MIGRATE_RDMA_PIN_ALL &&
9119d9
+        qemuMigrationSetPinAll(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
9119d9
+        goto stop;
9119d9
+
9119d9
     if (mig->lockState) {
9119d9
         VIR_DEBUG("Received lockstate %s", mig->lockState);
9119d9
         VIR_FREE(priv->lockState);
9119d9
@@ -3532,6 +3576,11 @@ qemuMigrationRun(virQEMUDriverPtr driver,
9119d9
                                      QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
9119d9
         goto cleanup;
9119d9
 
9119d9
+    if (flags & VIR_MIGRATE_RDMA_PIN_ALL &&
9119d9
+        qemuMigrationSetPinAll(driver, vm,
9119d9
+                               QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
9119d9
+        goto cleanup;
9119d9
+
9119d9
     if (qemuDomainObjEnterMonitorAsync(driver, vm,
9119d9
                                        QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
9119d9
         goto cleanup;
9119d9
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
9119d9
index 3fa68dc..e7a90c3 100644
9119d9
--- a/src/qemu/qemu_migration.h
9119d9
+++ b/src/qemu/qemu_migration.h
9119d9
@@ -40,7 +40,8 @@
9119d9
      VIR_MIGRATE_OFFLINE |                      \
9119d9
      VIR_MIGRATE_COMPRESSED |                   \
9119d9
      VIR_MIGRATE_ABORT_ON_ERROR |               \
9119d9
-     VIR_MIGRATE_AUTO_CONVERGE)
9119d9
+     VIR_MIGRATE_AUTO_CONVERGE |                \
9119d9
+     VIR_MIGRATE_RDMA_PIN_ALL)
9119d9
 
9119d9
 /* All supported migration parameters and their types. */
9119d9
 # define QEMU_MIGRATION_PARAMETERS                              \
9119d9
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
9119d9
index 683d92e..23395e5 100644
9119d9
--- a/tools/virsh-domain.c
9119d9
+++ b/tools/virsh-domain.c
9119d9
@@ -8999,6 +8999,10 @@ static const vshCmdOptDef opts_migrate[] = {
9119d9
      .type = VSH_OT_BOOL,
9119d9
      .help = N_("force convergence during live migration")
9119d9
     },
9119d9
+    {.name = "rdma-pin-all",
9119d9
+     .type = VSH_OT_BOOL,
9119d9
+     .help = N_("support memory pinning during RDMA live migration")
9119d9
+    },
9119d9
     {.name = "abort-on-error",
9119d9
      .type = VSH_OT_BOOL,
9119d9
      .help = N_("abort on soft errors during migration")
9119d9
@@ -9147,6 +9151,9 @@ doMigrate(void *opaque)
9119d9
     if (vshCommandOptBool(cmd, "auto-converge"))
9119d9
         flags |= VIR_MIGRATE_AUTO_CONVERGE;
9119d9
 
9119d9
+    if (vshCommandOptBool(cmd, "rdma-pin-all"))
9119d9
+        flags |= VIR_MIGRATE_RDMA_PIN_ALL;
9119d9
+
9119d9
     if (vshCommandOptBool(cmd, "offline")) {
9119d9
         flags |= VIR_MIGRATE_OFFLINE;
9119d9
     }
9119d9
-- 
9119d9
2.1.1
9119d9