From patchwork Mon May 27 09:33:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Kotov X-Patchwork-Id: 10962443 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1C86A1390 for ; Mon, 27 May 2019 09:35:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BFDA28AA5 for ; Mon, 27 May 2019 09:35:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3ADE28B1F; Mon, 27 May 2019 09:35:40 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9D53528AA5 for ; Mon, 27 May 2019 09:35:40 +0000 (UTC) Received: from localhost ([127.0.0.1]:42652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVC2d-0006Tg-Uf for patchwork-qemu-devel@patchwork.kernel.org; Mon, 27 May 2019 05:35:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVC1G-0005IE-CA for qemu-devel@nongnu.org; Mon, 27 May 2019 05:34:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVC1F-0004JI-5z for qemu-devel@nongnu.org; Mon, 27 May 2019 05:34:14 -0400 Received: from forwardcorp1j.mail.yandex.net ([2a02:6b8:0:1619::183]:43838) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hVC1E-0004Ds-Rr for qemu-devel@nongnu.org; Mon, 27 May 2019 05:34:13 -0400 Received: from mxbackcorp1o.mail.yandex.net (mxbackcorp1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::301]) by forwardcorp1j.mail.yandex.net (Yandex) with ESMTP id A60682E0D77; Mon, 27 May 2019 12:34:07 +0300 (MSK) Received: from smtpcorp1o.mail.yandex.net (smtpcorp1o.mail.yandex.net [2a02:6b8:0:1a2d::30]) by mxbackcorp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id MTcYoHEohe-Y7T4R1kD; Mon, 27 May 2019 12:34:07 +0300 Precedence: bulk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1558949647; bh=KoT/42fTCftwmyxvkchXYJktCH0HvQrO/0ta05NwHe8=; h=In-Reply-To:Message-Id:References:Date:Subject:To:From:Cc; b=Rg2McVI4MXBCedCZ++mR5Yyt1WMPyhspxpPlZdjevkcd5K7Vyc4bovmp8WUSEMyHZ 9AeMPNBtiPPk2pGqw3WTkVbRtLQwsWVoLp5f1M6H+eQUD5e9scy2GApeQgLcVJxJ4C CbJtSUv2wmL4rMsL3no5gGr9VHCPVZIGwxAMUdzE= Authentication-Results: mxbackcorp1o.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:c428:a8c1:9de0:d2bf]) by smtpcorp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZkWW82ke0f-Y7lmKsvP; Mon, 27 May 2019 12:34:07 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Yury Kotov To: Juan Quintela , "Dr. David Alan Gilbert" , Thomas Huth , Laurent Vivier , Paolo Bonzini Date: Mon, 27 May 2019 12:33:49 +0300 Message-Id: <20190527093350.28567-2-yury-kotov@yandex-team.ru> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190527093350.28567-1-yury-kotov@yandex-team.ru> References: <20190527093350.28567-1-yury-kotov@yandex-team.ru> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a02:6b8:0:1619::183 Subject: [Qemu-devel] [PATCH 1/2] migration: Fix fd protocol for incoming defer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, yc-core@yandex-team.ru Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently, incoming migration through fd supports only command-line case: E.g. fork(); fd = open(); exec("qemu ... -incoming fd:%d", fd); It's possible to use add-fd commands to pass fd for migration, but it's invalid case. add-fd works with fdset but not with particular fds. To work with getfd in incoming defer it's enough to use monitor_fd_param instead of strtol. monitor_fd_param supports both cases: * fd:123 * fd:fd_name (added by getfd). Signed-off-by: Yury Kotov Reviewed-by: Juan Quintela --- migration/fd.c | 8 +++++--- migration/fd.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/migration/fd.c b/migration/fd.c index a7c13df4ad..0a29ecdebf 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -52,12 +52,14 @@ static gboolean fd_accept_incoming_migration(QIOChannel *ioc, return G_SOURCE_REMOVE; } -void fd_start_incoming_migration(const char *infd, Error **errp) +void fd_start_incoming_migration(const char *fdname, Error **errp) { QIOChannel *ioc; - int fd; + int fd = monitor_fd_param(cur_mon, fdname, errp); + if (fd == -1) { + return; + } - fd = strtol(infd, NULL, 0); trace_migration_fd_incoming(fd); ioc = qio_channel_new_fd(fd, errp); diff --git a/migration/fd.h b/migration/fd.h index a14a63ce2e..b901bc014e 100644 --- a/migration/fd.h +++ b/migration/fd.h @@ -16,7 +16,7 @@ #ifndef QEMU_MIGRATION_FD_H #define QEMU_MIGRATION_FD_H -void fd_start_incoming_migration(const char *path, Error **errp); +void fd_start_incoming_migration(const char *fdname, Error **errp); void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp);