From patchwork Sat Apr 7 08:26:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: 858585 jemmy X-Patchwork-Id: 10327771 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 D24BD600CB for ; Sat, 7 Apr 2018 08:30:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B221A295A1 for ; Sat, 7 Apr 2018 08:30:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3C202961E; Sat, 7 Apr 2018 08:30:13 +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 EBF5E295A1 for ; Sat, 7 Apr 2018 08:30:12 +0000 (UTC) Received: from localhost ([::1]:40968 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f4jEi-0007pF-3v for patchwork-qemu-devel@patchwork.kernel.org; Sat, 07 Apr 2018 04:30:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47448) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f4jBW-0004uh-5G for qemu-devel@nongnu.org; Sat, 07 Apr 2018 04:26:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f4jBV-00027L-57 for qemu-devel@nongnu.org; Sat, 07 Apr 2018 04:26:54 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:40640) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f4jBU-00026u-UK for qemu-devel@nongnu.org; Sat, 07 Apr 2018 04:26:53 -0400 Received: by mail-pl0-x242.google.com with SMTP id x4-v6so2040160pln.7 for ; Sat, 07 Apr 2018 01:26:52 -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=B5U0faMyZEUEcNNcwNhUXcCQmVCig7eD4qDHmGmnx5o=; b=rmF/Amm58ZLNrVw0jlnBs+yN07iZhfze3qMLytg0JFL2TINrjZTvnl3mmDgi4BQd0o Ate4OecMduriSRuY+MR8Sd/HWxQokfMXL1Glu9/kOGrQ4FfJcaeDTA9FB+Iog2HZ2OiE MRB1oQVkcAyRSETIURsE1z1IIqWpiABhmZdp0O6syLCJHs1RNC/FVGtter2w9SxzkP0w AoAjZ53Uljm7so8Sa4gLbnFvL7N29uOZWLFhVvemDfmLJWrgjt8IMOnajcbAPfnP8jjg ed1vzGBILfE1VdtP7LKufy1+J/mfS7EHw0MEX0xEz5lpEefdTV828ylx3GpuV7JgOLgj zy9A== 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=B5U0faMyZEUEcNNcwNhUXcCQmVCig7eD4qDHmGmnx5o=; b=cpIOIQDlxNk2wXLa71PtBcyDB6nZi2KSrg8OZq4I+1/R/T6rxCigjLXfVBNjeBcqty B2esaf50LDFGx1KiMHoPIyizKuKheFjU93d3yIdwNf/gYNlelzjsp5gTxCMZlf22gNYf JA4qlvn2xQo5uW037AhBOrsLeKyLqOen7Vbi0bwR5pnuEDtyJxU3QU5zZF4eoSpDL9vv SmFvzsw0TrA7d/b/+JGQwK7w0A7s1OBl386+KcAPoUEV7uFEX9DBPOZVBYlN2r29gfMf Cd4WAeDcVKeryFGXxXRfncr9zkk/TEpSw3teXa3qEr7r/jl8JVom3NrYPnosLjI0geSV Vquw== X-Gm-Message-State: AElRT7GhenWravTxHqA02+BdW0EWGaasuL53j+1vWA9rZX2BMVSHNdnR +q+yHuabJZ+lFEGZmfQzYUc= X-Google-Smtp-Source: AIpwx48U5/lP3BLK2eUqty++twC6U8fJP9YergQOSyWgrOg8kP9Asvz3uQhQHr0MzTOz09uwVHpckQ== X-Received: by 2002:a17:902:102:: with SMTP id 2-v6mr30521433plb.48.1523089612222; Sat, 07 Apr 2018 01:26:52 -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.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Apr 2018 01:26:51 -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:31 +0800 Message-Id: <1523089594-1422-3-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:c01::242 Subject: [Qemu-devel] [PATCH 2/5] migration: add the interface to set get_return_path 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 of iochannel does not work for RDMA live migration. So add the interface to set get_return_path. Signed-off-by: Lidong Chen --- migration/qemu-file-channel.c | 12 ++++++++---- migration/qemu-file.c | 10 ++++++++-- migration/qemu-file.h | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c index e202d73..d4dd8c4 100644 --- a/migration/qemu-file-channel.c +++ b/migration/qemu-file-channel.c @@ -156,7 +156,6 @@ static const QEMUFileOps channel_input_ops = { .close = channel_close, .shut_down = channel_shutdown, .set_blocking = channel_set_blocking, - .get_return_path = channel_get_input_return_path, }; @@ -165,18 +164,23 @@ static const QEMUFileOps channel_output_ops = { .close = channel_close, .shut_down = channel_shutdown, .set_blocking = channel_set_blocking, - .get_return_path = channel_get_output_return_path, }; QEMUFile *qemu_fopen_channel_input(QIOChannel *ioc) { + QEMUFile *f; object_ref(OBJECT(ioc)); - return qemu_fopen_ops(ioc, &channel_input_ops); + f = qemu_fopen_ops(ioc, &channel_input_ops); + qemu_file_set_return_path(f, channel_get_input_return_path); + return f; } QEMUFile *qemu_fopen_channel_output(QIOChannel *ioc) { + QEMUFile *f; object_ref(OBJECT(ioc)); - return qemu_fopen_ops(ioc, &channel_output_ops); + f = qemu_fopen_ops(ioc, &channel_output_ops); + qemu_file_set_return_path(f, channel_get_output_return_path); + return f; } diff --git a/migration/qemu-file.c b/migration/qemu-file.c index bb63c77..8acb574 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -36,6 +36,7 @@ struct QEMUFile { const QEMUFileOps *ops; const QEMUFileHooks *hooks; + QEMURetPathFunc *get_return_path; void *opaque; int64_t bytes_xfer; @@ -72,10 +73,15 @@ int qemu_file_shutdown(QEMUFile *f) */ QEMUFile *qemu_file_get_return_path(QEMUFile *f) { - if (!f->ops->get_return_path) { + if (!f->get_return_path) { return NULL; } - return f->ops->get_return_path(f->opaque); + return f->get_return_path(f->opaque); +} + +void qemu_file_set_return_path(QEMUFile *f, QEMURetPathFunc *get_return_path) +{ + f->get_return_path = get_return_path; } bool qemu_file_mode_is_not_valid(const char *mode) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index f4f356a..74210b7 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -102,7 +102,6 @@ typedef struct QEMUFileOps { QEMUFileCloseFunc *close; QEMUFileSetBlocking *set_blocking; QEMUFileWritevBufferFunc *writev_buffer; - QEMURetPathFunc *get_return_path; QEMUFileShutdownFunc *shut_down; } QEMUFileOps; @@ -114,6 +113,7 @@ typedef struct QEMUFileHooks { } QEMUFileHooks; QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops); +void qemu_file_set_return_path(QEMUFile *f, QEMURetPathFunc *get_return_path); void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks); int qemu_get_fd(QEMUFile *f); int qemu_fclose(QEMUFile *f);