From patchwork Sat Apr 7 08:26:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: 858585 jemmy X-Patchwork-Id: 10327769 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1EA8B60541 for ; Sat, 7 Apr 2018 08:28:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12AD82923D for ; Sat, 7 Apr 2018 08:28:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 073082931A; Sat, 7 Apr 2018 08:28:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 801592923D for ; Sat, 7 Apr 2018 08:28:08 +0000 (UTC) Received: from localhost ([::1]:40866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f4jCh-0005uu-Mg for patchwork-qemu-devel@patchwork.kernel.org; Sat, 07 Apr 2018 04:28:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f4jBY-0004vd-4c for qemu-devel@nongnu.org; Sat, 07 Apr 2018 04:26:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f4jBX-000287-3f for qemu-devel@nongnu.org; Sat, 07 Apr 2018 04:26:56 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:35826) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f4jBW-00027x-TU for qemu-devel@nongnu.org; Sat, 07 Apr 2018 04:26:55 -0400 Received: by mail-pf0-x241.google.com with SMTP id u86so2381298pfd.2 for ; Sat, 07 Apr 2018 01:26:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=F/LhuOuEAG96WLQdVIFLedAXwZVIGT9cZmBjjZ6NZlA=; b=hhrteowCjCI8MNQa4e8/ShpO/QgKlo28hXiKdkFfBu6XjefrHVwbiM6RmXVOuHCvX8 cESjPNRVZ25mxNICcHVPEsbqJo+dRJYNM5/q1tlmVZ8u6dQICrBQwsqYM5b8+Lf2m9YQ 4ATGkkzqM9j4xC9gKVjiHTgj3G5cvSkNaaKwUNIRADDZWxpMY9NZlmQqOZTIJAMr1f6V wzfz4BDY3cAjeABugFFW/20aUJesWYlyJJzBjtVyqLEkdJyZxgHnEwMSLIzJJcoe38ka XEF9+mCbtruGtfhiK0uQ6yR1uX/5PFV9tlrAlCV2+feYq54hhDkaLEfJfuN1RvZ59Ipn 4GSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=F/LhuOuEAG96WLQdVIFLedAXwZVIGT9cZmBjjZ6NZlA=; b=dB1d6ZRmVAG6bkO36mQxqv/Xr0Q7kOeCz6O1PBLHqzGdsr8+7fuRAle49hvYeWzcUv /Pgn/MxhlTTgqZofeEJjwFhz4o6Zd2kLPpiY5ATbtim9wZwleZlwl5nn+GX1CHJ6SMEx JVbJzzxjZ7/z53wFiFEd/R7dzhqfG13Q9EfAQLMR19qUqdfiH2+ur9QDtH9/KV8IjKrl XpMpqDDOOVERJY+QNaOYU1p5YpE9YdDawC6HZGnYzZC35a2ySO0Ur7pwWeubxsMhrUnf Nbi5M3hsZf0xnolGcFMzMLeBOa9LIbHDBd/B0ujEd+GvKDko9dJlmp4lf4Xu1DL3t0d6 fqag== X-Gm-Message-State: AElRT7GBiejeXGMBzv5AIA2pGFqD7Ze1XVlzqrDnjHDsTEyDfDsVx8oa DVFhX8MZl5RlELo1+yBOqUI= X-Google-Smtp-Source: AIpwx4++P92O3Roolu4Y4PZ/W3cWyCcRQ+0fFRFIaQdNDNx4X5frP7jO8XIhDw9lD0MVC+Ka1UzxlQ== X-Received: by 10.99.95.144 with SMTP id t138mr19247849pgb.94.1523089614000; Sat, 07 Apr 2018 01:26:54 -0700 (PDT) Received: from VM_127_91_centos.localdomain ([119.28.195.137]) by smtp.gmail.com with ESMTPSA id y129sm18478558pgb.64.2018.04.07.01.26.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Apr 2018 01:26:53 -0700 (PDT) From: Lidong Chen X-Google-Original-From: Lidong Chen To: quintela@redhat.com, dgilbert@redhat.com Date: Sat, 7 Apr 2018 16:26:32 +0800 Message-Id: <1523089594-1422-4-git-send-email-lidongchen@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1523089594-1422-1-git-send-email-lidongchen@tencent.com> References: <1523089594-1422-1-git-send-email-lidongchen@tencent.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH 3/5] migration: implement the get_return_path for RDMA iochannel X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lidong Chen , adido@mellanox.com, qemu-devel@nongnu.org, licq@mellanox.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP the default get_return_path function does not work for RDMA live migration, the patch implement the get_return_path for RDMA iochannel. Signed-off-by: Lidong Chen --- migration/rdma.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/migration/rdma.c b/migration/rdma.c index 230bd97..53773c7 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3638,6 +3638,40 @@ err: return ret; } +static QEMUFile *qio_channel_rdma_get_return_path(void *opaque, int input) +{ + QIOChannel *ioc = opaque; + QIOChannelRDMA *rioc = QIO_CHANNEL_RDMA(ioc); + RDMAContext *rdma = rioc->rdma; + + QIOChannelRDMA *rioc_return_path; + RDMAContext *rdma_return_path = rdma->return_path; + + if (!rdma_return_path) { + return NULL; + } + + rioc_return_path = QIO_CHANNEL_RDMA(object_new(TYPE_QIO_CHANNEL_RDMA)); + rioc_return_path->rdma = rdma_return_path; + if (input) { + rioc_return_path->file = qemu_fopen_channel_output( + QIO_CHANNEL(rioc_return_path)); + } else { + rioc_return_path->file = qemu_fopen_channel_input( + QIO_CHANNEL(rioc_return_path)); + } + return rioc_return_path->file; +} + +static QEMUFile *qio_channel_rdma_get_output_return_path(void *opaque) +{ + return qio_channel_rdma_get_return_path(opaque, 0); +} + +static QEMUFile *qio_channel_rdma_get_input_return_path(void *opaque) +{ + return qio_channel_rdma_get_return_path(opaque, 1); +} static const QEMUFileHooks rdma_read_hooks = { .hook_ram_load = rdma_load_hook, }; @@ -3700,9 +3734,13 @@ static QEMUFile *qemu_fopen_rdma(RDMAContext *rdma, const char *mode) if (mode[0] == 'w') { rioc->file = qemu_fopen_channel_output(QIO_CHANNEL(rioc)); qemu_file_set_hooks(rioc->file, &rdma_write_hooks); + qemu_file_set_return_path(rioc->file, + qio_channel_rdma_get_output_return_path); } else { rioc->file = qemu_fopen_channel_input(QIO_CHANNEL(rioc)); qemu_file_set_hooks(rioc->file, &rdma_read_hooks); + qemu_file_set_return_path(rioc->file, + qio_channel_rdma_get_input_return_path); } return rioc->file;