From patchwork Tue Apr 9 03:04:35 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: 234939 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 7CFAF2C00C0 for ; Tue, 9 Apr 2013 13:06:13 +1000 (EST) Received: from localhost ([::1]:45356 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPOst-0000Sg-If for incoming@patchwork.ozlabs.org; Mon, 08 Apr 2013 23:06:11 -0400 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 d03dlp02.boulder.ibm.com (9.17.202.178) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 8 Apr 2013 21:05:21 -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 Received: from mrhinesdev.klabtestbed.com (klinux.watson.ibm.com [9.2.208.21]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r3937w28012821; Mon, 8 Apr 2013 21:08:03 -0600 From: mrhines@linux.vnet.ibm.com To: qemu-devel@nongnu.org Date: Mon, 8 Apr 2013 23:04:35 -0400 Message-Id: <1365476681-31593-7-git-send-email-mrhines@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.10.4 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> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13040903-4834-0000-0000-000005977705 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, mst@redhat.com, owasserm@redhat.com, abali@us.ibm.com, mrhines@us.ibm.com, gokul@us.ibm.com, pbonzini@redhat.com Subject: [Qemu-devel] [RFC PATCH RDMA support v5: 06/12] connection-establishment for RDMA 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-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); +}