Patchwork [RFC,RDMA,support,v1:,3/5] initialize RDMA options when QEMU first runs on command-line

login
register
mail settings
Submitter mrhines@linux.vnet.ibm.com
Date Jan. 28, 2013, 10:01 p.m.
Message ID <1359410505-4715-3-git-send-email-mrhines@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/216380/
State New
Headers show

Comments

mrhines@linux.vnet.ibm.com - Jan. 28, 2013, 10:01 p.m.
From: "Michael R. Hines" <mrhines@us.ibm.com>


Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
---
 exec.c |   27 +++++++++++++++++++++++++++
 vl.c   |   10 ++++++++++
 2 files changed, 37 insertions(+)

Patch

diff --git a/exec.c b/exec.c
index b85508b..4fc56d1 100644
--- a/exec.c
+++ b/exec.c
@@ -25,6 +25,8 @@ 
 #endif
 
 #include "qemu-common.h"
+#include "qemu/rdma.h"
+#include "monitor/monitor.h"
 #include "cpu.h"
 #include "tcg.h"
 #include "hw/hw.h"
@@ -104,6 +106,31 @@  static MemoryRegion io_mem_watch;
 
 #if !defined(CONFIG_USER_ONLY)
 
+/*
+ * Memory regions need to be registered with the device and queue pairs setup
+ * in advanced before the migration starts. This tells us where the RAM blocks
+ * are so that we can register them individually.
+ */
+int qemu_rdma_init_ram_blocks(struct qemu_rdma_ram_blocks *rdma_ram_blocks)
+{
+    RAMBlock *block;
+    int num_blocks = 0;
+
+    memset(rdma_ram_blocks, 0, sizeof *rdma_ram_blocks);
+    QTAILQ_FOREACH(block, &ram_list.blocks, next) {
+        if (num_blocks >= QEMU_MAX_RAM_BLOCKS) {
+                return -1;
+        }
+        rdma_ram_blocks->block[num_blocks].local_host_addr = block->host;
+        rdma_ram_blocks->block[num_blocks].offset = (uint64_t)block->offset;
+        rdma_ram_blocks->block[num_blocks].length = (uint64_t)block->length;
+        num_blocks++;
+    }
+    rdma_ram_blocks->num_blocks = num_blocks;
+
+    return 0;
+}
+
 static void phys_map_node_reserve(unsigned nodes)
 {
     if (phys_map_nodes_nb + nodes > phys_map_nodes_nb_alloc) {
diff --git a/vl.c b/vl.c
index 7aab73b..195a56e 100644
--- a/vl.c
+++ b/vl.c
@@ -29,6 +29,7 @@ 
 #include <sys/time.h>
 #include <zlib.h>
 #include "qemu/bitmap.h"
+#include "qemu/rdma.h"
 
 /* Needed early for CONFIG_BSD etc. */
 #include "config-host.h"
@@ -3622,6 +3623,13 @@  int main(int argc, char **argv, char **envp)
                 default_sdcard = 0;
                 default_vga = 0;
                 break;
+            case QEMU_OPTION_rdmaport:
+                rdmaport = atoi(optarg);
+                break;
+            case QEMU_OPTION_rdmahost:
+                strncpy(rdmahost, optarg, 64);
+                rdmahost[63] = '\0';
+                break;
             case QEMU_OPTION_xen_domid:
                 if (!(xen_available())) {
                     printf("Option %s not supported for this target\n", popt->name);
@@ -4007,6 +4015,8 @@  int main(int argc, char **argv, char **envp)
 
     register_savevm_live(NULL, "ram", 0, 4, &savevm_ram_handlers, NULL);
 
+    qemu_rdma_migration_data_init(&rdma_mdata);
+
     if (nb_numa_nodes > 0) {
         int i;