From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPOsD-0000Ia-0c for qemu-devel@nongnu.org; Mon, 08 Apr 2013 23:05:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPOs7-0004li-KR for qemu-devel@nongnu.org; Mon, 08 Apr 2013 23:05:28 -0400 Received: from e35.co.us.ibm.com ([32.97.110.153]:37016) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPOs7-0004lU-Cx for qemu-devel@nongnu.org; Mon, 08 Apr 2013 23:05:23 -0400 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, 8 Apr 2013 21:05:23 -0600 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 4C4853E4003E for ; Mon, 8 Apr 2013 21:05:08 -0600 (MDT) Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r3935HDr090282 for ; Mon, 8 Apr 2013 21:05:17 -0600 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r39383iL013255 for ; Mon, 8 Apr 2013 21:08:03 -0600 From: mrhines@linux.vnet.ibm.com Date: Mon, 8 Apr 2013 23:04:35 -0400 Message-Id: <1365476681-31593-7-git-send-email-mrhines@linux.vnet.ibm.com> In-Reply-To: <1365476681-31593-1-git-send-email-mrhines@linux.vnet.ibm.com> References: <1365476681-31593-1-git-send-email-mrhines@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC PATCH RDMA support v5: 06/12] connection-establishment for RDMA List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, mst@redhat.com, owasserm@redhat.com, abali@us.ibm.com, mrhines@us.ibm.com, gokul@us.ibm.com, pbonzini@redhat.com From: "Michael R. Hines" Signed-off-by: Michael R. Hines --- migration-rdma.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 migration-rdma.c diff --git a/migration-rdma.c b/migration-rdma.c new file mode 100644 index 0000000..2a0becd --- /dev/null +++ b/migration-rdma.c @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2013 Michael R. Hines + * Copyright (C) 2010 Jiuxing Liu + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; under version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +#include "migration/rdma.h" +#include "qemu-common.h" +#include "migration/migration.h" +#include "migration/qemu-file.h" +#include +#include +#include +#include +#include +#include + +//#define DEBUG_MIGRATION_RDMA + +#ifdef DEBUG_MIGRATION_RDMA +#define DPRINTF(fmt, ...) \ + do { printf("migration-rdma: " fmt, ## __VA_ARGS__); } while (0) +#else +#define DPRINTF(fmt, ...) \ + do { } while (0) +#endif + +static void rdma_accept_incoming_migration(void *opaque) +{ + int ret; + QEMUFile *f; + + DPRINTF("Accepting rdma connection...\n"); + + if ((ret = qemu_rdma_accept(opaque))) { + fprintf(stderr, "RDMA Migration initialization failed!\n"); + goto err; + } + + DPRINTF("Accepted migration\n"); + + f = qemu_fopen_rdma(opaque, "rb"); + if (f == NULL) { + fprintf(stderr, "could not qemu_fopen_rdma!\n"); + goto err; + } + + process_incoming_migration(f); + return; + +err: + qemu_rdma_cleanup(opaque); +} + +void rdma_start_incoming_migration(const char * host_port, Error **errp) +{ + int ret; + void *opaque; + + DPRINTF("Starting RDMA-based incoming migration\n"); + + if ((opaque = qemu_rdma_data_init(host_port, errp)) == NULL) { + return; + } + + ret = qemu_rdma_server_init(opaque, NULL); + + if (!ret) { + DPRINTF("qemu_rdma_server_init success\n"); + ret = qemu_rdma_server_prepare(opaque, NULL); + + if (!ret) { + DPRINTF("qemu_rdma_server_prepare success\n"); + + qemu_set_fd_handler2(qemu_rdma_get_fd(opaque), NULL, + rdma_accept_incoming_migration, NULL, + (void *)(intptr_t) opaque); + return; + } + } + + g_free(opaque); +} + +void rdma_start_outgoing_migration(void *opaque, const char *host_port, Error **errp) +{ + MigrationState *s = opaque; + void *rdma_opaque = NULL; + int ret; + + if ((rdma_opaque = qemu_rdma_data_init(host_port, errp)) == NULL) + return; + + ret = qemu_rdma_client_init(rdma_opaque, NULL, + s->enabled_capabilities[MIGRATION_CAPABILITY_CHUNK_REGISTER_DESTINATION]); + + if(!ret) { + DPRINTF("qemu_rdma_client_init success\n"); + ret = qemu_rdma_connect(rdma_opaque, NULL); + + if(!ret) { + s->file = qemu_fopen_rdma(rdma_opaque, "wb"); + DPRINTF("qemu_rdma_client_connect success\n"); + migrate_fd_connect(s); + return; + } + } + + g_free(rdma_opaque); + migrate_fd_error(s); +} -- 1.7.10.4