From patchwork Mon Jan 28 22:01:44 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: 216381 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 535B12C009A for ; Tue, 29 Jan 2013 09:04:00 +1100 (EST) Received: from localhost ([::1]:59307 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tzwo2-0002BZ-FO for incoming@patchwork.ozlabs.org; Mon, 28 Jan 2013 17:03:58 -0500 Received: from eggs.gnu.org ([208.118.235.92]:34851) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tzwmw-0007yC-QD for qemu-devel@nongnu.org; Mon, 28 Jan 2013 17:02:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tzwmo-0007xc-JS for qemu-devel@nongnu.org; Mon, 28 Jan 2013 17:02:50 -0500 Received: from e7.ny.us.ibm.com ([32.97.182.137]:35336) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tzwmo-0007xV-E0 for qemu-devel@nongnu.org; Mon, 28 Jan 2013 17:02:42 -0500 Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Jan 2013 17:02:42 -0500 Received: from d01dlp03.pok.ibm.com (9.56.250.168) by e7.ny.us.ibm.com (192.168.1.107) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Jan 2013 17:02:14 -0500 Received: from d01relay03.pok.ibm.com (d01relay03.pok.ibm.com [9.56.227.235]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id 397EEC90044 for ; Mon, 28 Jan 2013 17:02:14 -0500 (EST) Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r0SM2DTW303656 for ; Mon, 28 Jan 2013 17:02:14 -0500 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r0SM2D5I001589 for ; Mon, 28 Jan 2013 20:02:13 -0200 Received: from mrhinesdev.klabtestbed.com (klinux.watson.ibm.com [9.2.208.21]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r0SM1qhJ030965; Mon, 28 Jan 2013 20:02:13 -0200 From: mrhines@linux.vnet.ibm.com To: qemu-devel@nongnu.org Date: Mon, 28 Jan 2013 17:01:44 -0500 Message-Id: <1359410505-4715-4-git-send-email-mrhines@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1359410505-4715-1-git-send-email-mrhines@linux.vnet.ibm.com> References: <1359410505-4715-1-git-send-email-mrhines@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13012822-5806-0000-0000-00001EDD0D9F X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 32.97.182.137 Cc: aliguori@us.ibm.com, abali@us.ibm.com, "Michael R. Hines" , gokul@us.ibm.com Subject: [Qemu-devel] [RFC PATCH RDMA support v1: 4/5] connection-setup code between client/server 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 --- migration-tcp.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ migration.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/migration-tcp.c b/migration-tcp.c index e78a296..b6c53ba 100644 --- a/migration-tcp.c +++ b/migration-tcp.c @@ -14,10 +14,12 @@ */ #include "qemu-common.h" +#include "qemu/rdma.h" #include "qemu/sockets.h" #include "migration/migration.h" #include "migration/qemu-file.h" #include "block/block.h" +#include //#define DEBUG_MIGRATION_TCP @@ -55,6 +57,9 @@ static void tcp_wait_for_connect(int fd, void *opaque) if (fd < 0) { DPRINTF("migrate connect error\n"); + if (qemu_use_rdma_migration()) { + qemu_rdma_migration_cleanup(&rdma_mdata); + } s->fd = -1; migrate_fd_error(s); } else { @@ -62,6 +67,25 @@ static void tcp_wait_for_connect(int fd, void *opaque) s->fd = fd; socket_set_block(s->fd); migrate_fd_connect(s); + + /* RDMA initailization */ + if (qemu_use_rdma_migration()) { + if (qemu_rdma_migration_client_init(&rdma_mdata)) { + migrate_fd_error(s); + return; + } + + fprintf(stderr, "qemu_rdma_migration_client_init success\n"); + + if (qemu_rdma_migration_client_connect(&rdma_mdata)) { + migrate_fd_error(s); + close(s->fd); + return; + } + + fprintf(stderr, "qemu_rdma_migration_client_connect success\n"); + } + } } @@ -101,6 +125,16 @@ static void tcp_accept_incoming_migration(void *opaque) goto out; } + if (qemu_use_rdma_migration()) { + printf("listen on port started: %d\n", rdma_mdata.port); + + if (qemu_rdma_migration_server_wait_for_client(&rdma_mdata)) { + fprintf(stderr, "rdma migration: error waiting for client!\n"); + close(s); + return; + } + } + process_incoming_migration(f); return; @@ -117,6 +151,25 @@ void tcp_start_incoming_migration(const char *host_port, Error **errp) return; } + if (qemu_use_rdma_migration()) { + int ret; + + ret = qemu_rdma_migration_server_init(&rdma_mdata); + if (ret) { + fprintf(stderr, "rdma migration: error init server!\n"); + close(s); + return; + } + + ret = qemu_rdma_migration_server_prepare(&rdma_mdata); + if (ret) { + fprintf(stderr, "rdma migration: error preparing server!\n"); + close(s); + return; + } + + } + qemu_set_fd_handler2(s, NULL, tcp_accept_incoming_migration, NULL, (void *)(intptr_t)s); } diff --git a/migration.c b/migration.c index 77c1971..cffe16f 100644 --- a/migration.c +++ b/migration.c @@ -22,6 +22,7 @@ #include "qemu/sockets.h" #include "migration/block.h" #include "qemu/thread.h" +#include "qemu/rdma.h" #include "qmp-commands.h" //#define DEBUG_MIGRATION @@ -279,6 +280,11 @@ static int migrate_fd_cleanup(MigrationState *s) } assert(s->fd == -1); + + if (qemu_rdma_migration_enabled()) { + qemu_rdma_migration_cleanup(&rdma_mdata); + } + return ret; } @@ -481,6 +487,41 @@ int64_t qmp_query_migrate_cache_size(Error **errp) return migrate_xbzrle_cache_size(); } +void qmp_migrate_set_rdma_port(int64_t port, Error **errp) +{ + MigrationState *s = migrate_get_current(); + if (s && (s->state == MIG_STATE_ACTIVE)) { + return; + } + printf("rdma migration port: %" PRId64 "\n", port); + rdma_mdata.port = port; +} + +void qmp_migrate_set_rdma_host(const char *host, Error **errp) +{ + MigrationState *s = migrate_get_current(); + if (s && (s->state == MIG_STATE_ACTIVE)) { + return; + } + printf("rdma migration host name: %s\n", host); + strncpy(rdma_mdata.host, host, 64); + rdma_mdata.host[63] = '\0'; +} + +void qmp_migrate_rdma_prepare(Error **errp) +{ + MigrationState *s = migrate_get_current(); + if (s && (s->state == MIG_STATE_ACTIVE)) { + return; + } + qemu_rdma_migration_client_init(&rdma_mdata); +} + +void qmp_migrate_rdma_release(Error **errp) +{ + qemu_rdma_migration_cleanup(&rdma_mdata); +} + void qmp_migrate_set_speed(int64_t value, Error **errp) { MigrationState *s;