From patchwork Mon Feb 11 22:49:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mrhines@linux.vnet.ibm.com X-Patchwork-Id: 219689 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DCA332C02C1 for ; Tue, 12 Feb 2013 09:50:55 +1100 (EST) Received: from localhost ([::1]:36497 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U52D7-0006DB-Kw for incoming@patchwork.ozlabs.org; Mon, 11 Feb 2013 17:50:53 -0500 Received: from eggs.gnu.org ([208.118.235.92]:40284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U52Cv-0006Cn-Gr for qemu-devel@nongnu.org; Mon, 11 Feb 2013 17:50:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U52Cr-0007m8-Kn for qemu-devel@nongnu.org; Mon, 11 Feb 2013 17:50:41 -0500 Received: from e35.co.us.ibm.com ([32.97.110.153]:48814) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U52Cr-0007lT-EA for qemu-devel@nongnu.org; Mon, 11 Feb 2013 17:50:37 -0500 Received: from /spool/local by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 11 Feb 2013 15:50:35 -0700 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 11 Feb 2013 15:50:35 -0700 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id E507319D803E for ; Mon, 11 Feb 2013 15:50:32 -0700 (MST) Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r1BMoXqM324372 for ; Mon, 11 Feb 2013 15:50:33 -0700 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r1BMoWPn010196 for ; Mon, 11 Feb 2013 15:50:32 -0700 Received: from mrhinesdev.klabtestbed.com (klinux.watson.ibm.com [9.2.208.21]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r1BMoUWK010052; Mon, 11 Feb 2013 15:50:32 -0700 From: "Michael R. Hines" To: qemu-devel@nongnu.org Date: Mon, 11 Feb 2013 17:49:55 -0500 Message-Id: <1360622997-26904-4-git-send-email-mrhines@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1360622997-26904-1-git-send-email-mrhines@linux.vnet.ibm.com> References: <1360622997-26904-1-git-send-email-mrhines@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13021122-4834-0000-0000-0000038BF5C0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 32.97.110.153 Cc: aliguori@us.ibm.com, abali@us.ibm.com, "Michael R. Hines" , gokul@us.ibm.com Subject: [Qemu-devel] [RFC PATCH RDMA support v2: 4/6] initialize RDMA options when QEMU first runs on command-line X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Michael R. Hines" Signed-off-by: Michael R. Hines --- exec.c | 27 +++++++++++++++++++++++++++ vl.c | 13 +++++++++++++ 2 files changed, 40 insertions(+) diff --git a/exec.c b/exec.c index b85508b..b7ac6fa 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 rdma_init_ram_blocks(struct 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 >= RDMA_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..170d209 100644 --- a/vl.c +++ b/vl.c @@ -29,6 +29,7 @@ #include #include #include "qemu/bitmap.h" +#include "qemu/rdma.h" /* Needed early for CONFIG_BSD etc. */ #include "config-host.h" @@ -233,6 +234,9 @@ int boot_menu; uint8_t *boot_splash_filedata; size_t boot_splash_filedata_size; uint8_t qemu_extra_params_fw[2]; +int rdmaport = -1; +char rdmahost[64] = ""; +struct rdma_data rdma_mdata; typedef struct FWBootEntry FWBootEntry; @@ -3622,6 +3626,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); @@ -3725,6 +3736,8 @@ int main(int argc, char **argv, char **envp) } loc_set_none(); + rdma_data_init(&rdma_mdata); + if (qemu_init_main_loop()) { fprintf(stderr, "qemu_init_main_loop failed\n"); exit(1);