From patchwork Thu Jan 25 16:25:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13531224 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 18C95C47258 for ; Thu, 25 Jan 2024 16:26:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT2YA-0002Hu-15; Thu, 25 Jan 2024 11:25:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2Y0-0002Gv-NT for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:25:50 -0500 Received: from mail-dm6nam10on2062a.outbound.protection.outlook.com ([2a01:111:f400:7e88::62a] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2Xy-0000Qg-LO for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:25:48 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gGyWw7qivkxc6JYrMuAzC6yoiC+beQToCLijsJDxGVoLsKv3dwTqf8fTuQUxX9dTqdh5/bEiW6WseQAVZ+Outi/8TFpxwd/UqAHeo9eqa1n+wHyIJG/6G0g4hK9aENEjJVs5twxeDvo60T9Nct2lKAz3se5KdqQtp7SDLOf3P4mnf2HPqrJJ+VVeKcT1uxzCUcL8+Y8Payi/eJZ4M/7o3chVl3kGiKZ7xgy/hXzUw/xlp4O+gtM0IzZsQEJuIUKK0FTF/ucemc45MdTTTHw5miDHmF2WaqWVe6VxW21SgqMOsZ7E0VaB1Q1GTYhkqQNP/HKmNWM9kCH76WBrZytCEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=crbYLni9S89KWLQnHn85X3Qv2aaylUqb4MnpLmw+pR4=; b=LhJwhQCYqrg++Bs6DJwvOEEUUOD1SfitfHZh8Yji0Ec9TOt79OEjIDYB5T7PYlSnb9R2vXF+SRNnCUF30/pu2lIATYfpbe8OFuQTYfkY5FDymoxWLxbnhDvqVfwwW7LwIZaABLX5QCeBDakIOac+YiMT9VpH/eUI0r3shyDneNS7xQEU92wR7JHsef0qPhfMUpAW91xJF+6gT1i6M4ve9IH2o6Voq0gavlZBsqiTwWqay18YRxx2fukaDyaRYDJpM2mmeTXs/uel6K8UsQoKKHbbffqdpz43lruvqEj0zXnKoH9iWElAgnYpTHwM17ULkfJ3VKEJr2eF0boJXjzO8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=crbYLni9S89KWLQnHn85X3Qv2aaylUqb4MnpLmw+pR4=; b=XBIv9agsd/0B4guaWB5RmuZ6ISXaw4H383UGxktw8mc2Qd1jrn4RgG33cjpw2PEeNEUmZgMBlizn4h4Jq/07Dt2oCHIcTSzSvPT5mbOLMoWYTIEyX6JNMAnj4AUmAoOb6mXH1ZopIJ+e8QhX3J8fml/msKMFaeLLsRdwjE6b0NoEMYryZ79URei+yL3jn1PIcghuquveqy5KBOzZqEnlAMFW1lorYmG8lJH2x+qT3MGTdgfNsd77BQZn9Jkxv2j6a14eNtxWsW4rriV5FEyO6spDJbqipTtmn8rTcpxbsFWKJXY38RCevEweL91bkNta+YHCLj6XLAgnyi6x/3qe6A== Received: from DM6PR17CA0014.namprd17.prod.outlook.com (2603:10b6:5:1b3::27) by LV3PR12MB9354.namprd12.prod.outlook.com (2603:10b6:408:211::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.26; Thu, 25 Jan 2024 16:25:40 +0000 Received: from CY4PEPF0000E9DB.namprd05.prod.outlook.com (2603:10b6:5:1b3:cafe::b4) by DM6PR17CA0014.outlook.office365.com (2603:10b6:5:1b3::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22 via Frontend Transport; Thu, 25 Jan 2024 16:25:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by CY4PEPF0000E9DB.mail.protection.outlook.com (10.167.241.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.16 via Frontend Transport; Thu, 25 Jan 2024 16:25:40 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:32 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:32 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 25 Jan 2024 08:25:30 -0800 From: Avihai Horon To: CC: Peter Xu , Fabiano Rosas , "Avihai Horon" Subject: [PATCH 01/17] migration: Fix logic of channels and transport compatibility check Date: Thu, 25 Jan 2024 18:25:12 +0200 Message-ID: <20240125162528.7552-2-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240125162528.7552-1-avihaih@nvidia.com> References: <20240125162528.7552-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9DB:EE_|LV3PR12MB9354:EE_ X-MS-Office365-Filtering-Correlation-Id: 8db83e9b-9bce-419d-25c0-08dc1dc24557 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FCkw7mG6aTeyp5A9tHQ7qHIvEIx/AzY5+6+lMZIHlqHyYUJ5OKySos53u9Dn56n99UNJjqr91yKpfbf/rJJFPL7g4VPtyYlsPWz0kvnr2+AzMpVxo7tZjfoJTjNdHQZK4Azk4Xh/K/A/vqZ4fOylhhTDi2Pn5FDMcjHNOTMaQ93JMIKChdOG+XRd5adVu/Yv2Tr5qyluJnov9s1qZ1Z+V+2xR9Xs2dLoc0utKyGgDWpxlE2srLb87R4xHFu1XCEtTZPquA8rUwFpciGnBiQ+6uwsOnHoVyDuGWFQWeKrQPssAEmqu8kZKMLRHs7D5AdxCpsuFnGFHiFv1J3bdf/57JZQ8IJTJZjtTQeu6KmST94hDB6seyJvt0bzT+6oFGRSGJtXcO+7vqhsN17PtWDaHLvg0ePkchbqquQsIRez7+3dmOodzQfZfmYFSb+GMJASGuIDvIpzDmqgRBzYNiF0Y7ghi9DoLWl3qF3RnDM44qzk30D+zZKnpNhBDMAZhAQp8Tc7659N4+1czCl+ECzaDoEIie6C36tD+jb57NxtJCIdaiTMngOATPtfbTjdgeEOoPaqbT1nuS1hFaWYTZS/VXhrE3eC/joe6oXScWDvCyYN4sYw48YtP0nF2seqlcmSR6MekC9Uo1uxNgSA5EhPSCM7IB7d2XgIvGE2AxEMQuSxz2W74zB8e+F4kGiVlwDyZr9zemkMEXYSslNotD8db6iHriomc20zD5X+OaeozEX+w+AJMNmX7slv3ub3P2qI X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(346002)(396003)(376002)(136003)(39860400002)(230922051799003)(64100799003)(82310400011)(451199024)(1800799012)(186009)(40470700004)(46966006)(36840700001)(36860700001)(47076005)(36756003)(2906002)(41300700001)(86362001)(7636003)(82740400003)(356005)(54906003)(7696005)(6916009)(316002)(70586007)(478600001)(70206006)(6666004)(83380400001)(336012)(426003)(8676002)(5660300002)(2616005)(8936002)(26005)(107886003)(1076003)(4326008)(40480700001)(40460700003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 16:25:40.3030 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8db83e9b-9bce-419d-25c0-08dc1dc24557 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9DB.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9354 Received-SPF: softfail client-ip=2a01:111:f400:7e88::62a; envelope-from=avihaih@nvidia.com; helo=NAM10-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The commit in the fixes line mistakenly modified the channels and transport compatibility check logic so it now checks multi-channel support only for socket transport type. Thus, running multifd migration using a transport other than socket that is incompatible with multi-channels (such as "exec") would lead to a segmentation fault instead of an error message. For example: (qemu) migrate_set_capability multifd on (qemu) migrate -d "exec:cat > /tmp/vm_state" Segmentation fault (core dumped) Fix it by checking multi-channel compatibility for all transport types. Fixes: d95533e1cdcc ("migration: modify migration_channels_and_uri_compatible() for new QAPI syntax") Signed-off-by: Avihai Horon Reviewed-by: Peter Xu --- migration/migration.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 219447dea1..6fc544711a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -128,11 +128,17 @@ static bool migration_needs_multiple_sockets(void) return migrate_multifd() || migrate_postcopy_preempt(); } -static bool transport_supports_multi_channels(SocketAddress *saddr) +static bool transport_supports_multi_channels(MigrationAddress *addr) { - return saddr->type == SOCKET_ADDRESS_TYPE_INET || - saddr->type == SOCKET_ADDRESS_TYPE_UNIX || - saddr->type == SOCKET_ADDRESS_TYPE_VSOCK; + if (addr->transport == MIGRATION_ADDRESS_TYPE_SOCKET) { + SocketAddress *saddr = &addr->u.socket; + + return saddr->type == SOCKET_ADDRESS_TYPE_INET || + saddr->type == SOCKET_ADDRESS_TYPE_UNIX || + saddr->type == SOCKET_ADDRESS_TYPE_VSOCK; + } + + return false; } static bool @@ -140,8 +146,7 @@ migration_channels_and_transport_compatible(MigrationAddress *addr, Error **errp) { if (migration_needs_multiple_sockets() && - (addr->transport == MIGRATION_ADDRESS_TYPE_SOCKET) && - !transport_supports_multi_channels(&addr->u.socket)) { + !transport_supports_multi_channels(addr)) { error_setg(errp, "Migration requires multi-channel URIs (e.g. tcp)"); return false; } From patchwork Thu Jan 25 16:25:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13531228 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A54D8C47258 for ; Thu, 25 Jan 2024 16:27:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT2YG-0002Je-TG; Thu, 25 Jan 2024 11:26:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2Y6-0002Ha-3h for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:25:55 -0500 Received: from mail-dm6nam12on20600.outbound.protection.outlook.com ([2a01:111:f403:2417::600] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2Y4-0000RN-FA for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:25:53 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ka1TFKI6VtIsh7k9/dalk6MkxiEsrzeoXKt1zXAEwucd2x8qcOKLuuUEk6LAlRF2IMMKNXtBc3nX3bdW7Hr9wyPxgwwcSVZMo9Gr1HfY3qk5T9Tzf/gXgebhQniQutssbdti6vxe0yZDbmYGw5ylKsiUCFdoaDdScrD5OFaOt6pc45ATU7oonSRuoOouax0hhXKeDNrRIaI69SGof5ehKG2U73dBKP63IO765O3593Al/Wa32F09cdYWX8fCzxCPhp04FAxekejmmcekE2RBoSME19JUlIZY9L4Oii2lyLC9Tw5R0WztBrBxc8G9t1LK25zH37DRofryEuwSywznwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wlPwzH63ATMiNUtDCCHHjny0M27LHnPipZqgvXnQbMg=; b=XLF6BTQUR4IPRpGzOF4w7pO9EqwS6TulCS1eOnMp78JX3Lr4AHaVDqrJTNbVSAQFDbV6LQAgbvXAkjyjzCfqB/DRlRs/fAtdyiqQNR0Gw2BxXPA8YldK64GUvNDTvt1lw2FAR6o41sLihKuCJq3es2cPMXtmwpPVhTRiC5xah+691FwwiGtp6u9jMANzuI9Vatdg2l0s1s/gYG81r2XK1Blpxw4jV4NxEwrmcF7kPvPiyDdqAxvFglE8sq5LS7eNhUreQjXNuv1FcT+DM5Adwi7ucpBMTQa0kmV1fcMbUJvZRX8f2y7D2Qkj5K/JIBnKRk1K3Q5ImcztEhyXvoALpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wlPwzH63ATMiNUtDCCHHjny0M27LHnPipZqgvXnQbMg=; b=SrQrMy1IX1ax7AiangcWA0+84dkqz1TXS2OG1JWz+R2w7phW34ebVRvs2kWiEyFZboZLU37UTCnf+enns2H/0907XyV39Rojm99IPjtrobvct4vpunSTGJhwy7r6VfoYebC77rou4MrDtWiRtKp40jwl0OVjLhvLmsozpIcXIbIUq+pv2Uu7W+K2+mJLFcgDqwz3uq6PSv9u8LdkLFtZ3xf8pt98HUiKbyqIn8eUN4nlxUfmfuTYy3cB34L7fwoiCfYitaGBEIs1V2UOCI9OktB+77Gh8nGpo+wHqBbyBihy1JJ+eBNW+BK5nR+FiSrHbcjn63kHHMJ18unZvpv90A== Received: from CYZPR12CA0018.namprd12.prod.outlook.com (2603:10b6:930:8b::10) by LV2PR12MB5824.namprd12.prod.outlook.com (2603:10b6:408:176::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Thu, 25 Jan 2024 16:25:44 +0000 Received: from CY4PEPF0000E9DC.namprd05.prod.outlook.com (2603:10b6:930:8b:cafe::d5) by CYZPR12CA0018.outlook.office365.com (2603:10b6:930:8b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27 via Frontend Transport; Thu, 25 Jan 2024 16:25:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by CY4PEPF0000E9DC.mail.protection.outlook.com (10.167.241.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.16 via Frontend Transport; Thu, 25 Jan 2024 16:25:44 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:34 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:33 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 25 Jan 2024 08:25:32 -0800 From: Avihai Horon To: CC: Peter Xu , Fabiano Rosas , "Avihai Horon" Subject: [PATCH 02/17] migration: Move local_err check in migration_ioc_process_incoming() Date: Thu, 25 Jan 2024 18:25:13 +0200 Message-ID: <20240125162528.7552-3-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240125162528.7552-1-avihaih@nvidia.com> References: <20240125162528.7552-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9DC:EE_|LV2PR12MB5824:EE_ X-MS-Office365-Filtering-Correlation-Id: b986b661-a071-4c53-ce88-08dc1dc247b0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OUIxz0txPN7n/kqED4mkudVzZnYuo2RusVlW99AZKQhBjFCf7g2xgOZOeGxnmPt8ZwvMEpzlMJ9/eiQ73/j5kJpPOUCXCBWG4uDm3oH0El+tj7GjSCJ5uqc3r35vODIyKlWzFLMsCwa0fw1egtqYY4FlL5mCQiEqB1QcMG2j82bEjaGQSvYeB02giytFm6tg1qr6SKk5bt3dp4ox5AsHCNodw0Rj8oLju5tzh7owKyIKA1ogcQ1FiXGFH7tpL5/B2NHX3QhEfeQXNvUrrPPz8usIooPxYP2NeWL0Uhj2Mo562dFrskIC+sPI7uACoWo6P36vHD60aL/3JapZ9F9nL2XFdTlXP2UMU1B2BWxg8m16fzWQuaa1EMmYD60/umathHht8so0mQkmy66b9g/lj2oRJoHHFIRCkCcXeWvsT0lXD0y31fHCL5+qSzSKiDxi9+73oOZ1II4OOc5DfHQ1Kmt98kd8MrUOeV81xfFgh9HtL8zILaK3lFBQ6a7qOHEBsl3G2Wi+fjUfWz0vi1e83u2M2UQ2wmQmG1XrpGrAXmd0/GEX3yk87Gkou7VAA4Ss/RMrEnsJ96pS4Pdl5BF18LPHf8xXeqwGRni2efy6oeFvb/NC9erRsbSXYm1qYnGJNioCkFfIUdM3idJX2p7s3/w0xuroWVzGXN1Ry7QZEgidomypH72NUbphSLZyKsc2+e8ynzgjWp0Zp7bT6FNXVMCOXFQvenOcZm/21UTjj9XyR7cBuvDDRHPwU4RpKU59 X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(396003)(39860400002)(346002)(376002)(136003)(230922051799003)(186009)(64100799003)(1800799012)(82310400011)(451199024)(46966006)(36840700001)(40470700004)(107886003)(2616005)(70586007)(54906003)(1076003)(316002)(26005)(336012)(426003)(70206006)(6916009)(8676002)(4326008)(8936002)(83380400001)(47076005)(2906002)(36860700001)(4744005)(82740400003)(6666004)(7636003)(356005)(41300700001)(86362001)(40460700003)(40480700001)(7696005)(478600001)(5660300002)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 16:25:44.2460 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b986b661-a071-4c53-ce88-08dc1dc247b0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9DC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5824 Received-SPF: softfail client-ip=2a01:111:f403:2417::600; envelope-from=avihaih@nvidia.com; helo=NAM12-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org local_err in migration_ioc_process_incoming() is used only in the multifd if branch. Move the local_err check under the multifd branch, where it is actually used. Signed-off-by: Avihai Horon Reviewed-by: Peter Xu --- migration/migration.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 6fc544711a..ccd497ca21 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -863,15 +863,15 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) assert(migration_needs_multiple_sockets()); if (migrate_multifd()) { multifd_recv_new_channel(ioc, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } } else { assert(migrate_postcopy_preempt()); f = qemu_file_new_input(ioc); postcopy_preempt_new_channel(mis, f); } - if (local_err) { - error_propagate(errp, local_err); - return; - } } if (migration_should_start_incoming(default_channel)) { From patchwork Thu Jan 25 16:25:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13531232 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D6B7C47258 for ; Thu, 25 Jan 2024 16:27:24 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT2YH-0002Jf-4Q; Thu, 25 Jan 2024 11:26:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2Y4-0002H4-4b for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:25:52 -0500 Received: from mail-bn7nam10on20601.outbound.protection.outlook.com ([2a01:111:f403:2009::601] helo=NAM10-BN7-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2Y2-0000R9-D0 for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:25:51 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h5atxKd5NicLOaUyiMNTDHOwKt7se7V085xmExuaNyhQVH7RXBdOjPHE3RU8wVeqfoSqEvT4LuqtJXt6dDH6aOUDYPsVrhuvt2kbg/UgxNnX5qNRXDr2ehrHQepKkrGabXmtiPAykK2h/IcRIpf3EyySwwGK+7Df4bYyv9J+onFSeV3RI8mnlVMzvBdXOhTIkYiMnXv2qT64HBDKAZsIY9ymOHquddTndll4nPL7/EQa3u4pBUVSYqai67+z3stD/5nSBUdkLvVbePg7YQIicKXBXuCY4fC2QrDoQzcC2g2wK5xPpRZ1Bs1XnuPb3qA6yfCFYF9j5bRsAgE6D0OH3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=H5e8kRabni7h6uSmKIfcUNkTJ7spjOv2ouVVhTzHaA4=; b=ATHOTt3OItQ91GMYMKrO9xe29gzrwO0lQtM8GfoUhT06H4Ruts5sy/2GVXsKm9Nqdmxxbmp5tgTTm4Cai9Ww4ZEwZM5qubfi5CHihwuhgPEsyOz2nWco+esPhnZR88k8kfHmGxTnwjpunWNdY9ldWa1ORanZW+lzOmXXNyNFz/pXb3DyO3lnpj7sLfHuFOgHrbhksIwmemJ51BbZQJdSh3rVU5KADBjGqiczw/EAvmOZ6B7fd6HdrREIv8ggjLgRcKQY1b3DFz0zYIhhm54P7BEz+Xbi854ZmMpDDKCrnn7D+eoe2iNf/Bg2tfwwnfH/L3mKQ+YfMXOjChNmI9lxeQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H5e8kRabni7h6uSmKIfcUNkTJ7spjOv2ouVVhTzHaA4=; b=ciqt33uZGgS0GQJakNghAFwqoOS9vSPnT0VlhlUi+1q2Vx7o43ukxkkPWt1lOayLZYD4+MhnQf9Ugr6IrZjeUkh8BdM6hjGECAXXNx+kWnWw3/9yGoVb5AIz2rdS/S3ojs45ZDB8L7L7OcSiwqlJSX1tH9PuVjKQdg8wuyBfb/M/TJAcJH5fkE0OI405rEdFZrLqbd4mAb0sWW7rl6sKJUe1jrZwOgkJgzY4MMN3wyN7Q6R1zYnCMFwIMBcXYH4qO5JZzDEDnnrDAIKLpaInN6h3Ys7k/3kcVpNSwciraS/oLHnwiVQ5wigyD+caCFoqaz2dBi0nTvpVhgHVnJCEZw== Received: from CH0PR03CA0391.namprd03.prod.outlook.com (2603:10b6:610:11b::10) by CYYPR12MB8990.namprd12.prod.outlook.com (2603:10b6:930:ba::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.24; Thu, 25 Jan 2024 16:25:42 +0000 Received: from DS3PEPF000099DE.namprd04.prod.outlook.com (2603:10b6:610:11b:cafe::26) by CH0PR03CA0391.outlook.office365.com (2603:10b6:610:11b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.32 via Frontend Transport; Thu, 25 Jan 2024 16:25:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DS3PEPF000099DE.mail.protection.outlook.com (10.167.17.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.16 via Frontend Transport; Thu, 25 Jan 2024 16:25:41 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:35 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:35 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 25 Jan 2024 08:25:34 -0800 From: Avihai Horon To: CC: Peter Xu , Fabiano Rosas , "Avihai Horon" Subject: [PATCH 03/17] migration: Rename default_channel to main_channel Date: Thu, 25 Jan 2024 18:25:14 +0200 Message-ID: <20240125162528.7552-4-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240125162528.7552-1-avihaih@nvidia.com> References: <20240125162528.7552-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DE:EE_|CYYPR12MB8990:EE_ X-MS-Office365-Filtering-Correlation-Id: 48b5ff43-2b1f-4e0c-eacd-08dc1dc24636 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Jl9KSN5sxY7X1iwHzOcckyDxeHh5ZgIuEzlJ9gNy4t3AnyMsB3yto/5sHblIx1JcooG3gjV5vSVI8CzYvNKVgHhe9009wKOkkrC8Vo9Rz8fQDHkmkvquM1NxO2C6LGzbkmubO3ofmBF9SbNKrxv4TlkN0vT+WCQ6PsGXvjKVGejnUQUE3hCrLUDElOi54o7JMcZ8z6mjUdChA5yMr1/VdWCBj9LSJLk5FUQB+TzeOCP9RsRYWs8eoR+IgLoRmqHT+yUQ6JTkulK/3Pueh8TVfOsWjiBjDpjzHTRtYAb9JWJPVqN2cE0h+N8mptPCWyZdC+lofAhsprB7S0ayQUYT/sRQ8mKHC6N7aYjeQuQkgtp+svvTIbBUKiC6paECJY1bgDzaw/TBhMARv0HZiljGJE+SUDMYvuKMX/qMZMwuKUJGHIiSFdq+sqYmRLAdsrkJXWvsCmCMkMeaHQMVguQdc596h/jCIPLSo80dm1HxnHIeQ434zi3ED5ykziwdumjpQSrPvbvZcueFr7nLLHx8RrMgs0yP+qrcYjKLeB5dxFrwnW3GT2/8BukHOL9bGG+3ykH7ZmoQLsBtA+SZVEWF7AGILiyQlu9ziLPZ0ygZh8M45P9kapJOrKv1Crsbd3BvUWWug/uf5oroP36G1g7xvLD9iQ4VrvnCFzkguBtWwFRPI7Dt7VZa9HlGEArWOYs+mbYGRVXPbUlo8Xi3IvAgx78pNhuEKs7xBSf+2qvaaes= X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(396003)(346002)(136003)(39860400002)(376002)(230922051799003)(1800799012)(186009)(64100799003)(82310400011)(451199024)(46966006)(40470700004)(36840700001)(36756003)(82740400003)(2906002)(5660300002)(7636003)(36860700001)(86362001)(41300700001)(356005)(4326008)(336012)(478600001)(26005)(426003)(1076003)(47076005)(2616005)(7696005)(107886003)(6666004)(70586007)(54906003)(70206006)(8676002)(8936002)(83380400001)(6916009)(316002)(40480700001)(40460700003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 16:25:41.7226 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48b5ff43-2b1f-4e0c-eacd-08dc1dc24636 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DE.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8990 Received-SPF: softfail client-ip=2a01:111:f403:2009::601; envelope-from=avihaih@nvidia.com; helo=NAM10-BN7-obe.outbound.protection.outlook.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org migration_ioc_process_incoming() uses the term "default_channel" to describe the main migration channel. Rename it to the more commonly used and informative term "main_channel". Signed-off-by: Avihai Horon Reviewed-by: Peter Xu --- migration/migration.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index ccd497ca21..9c769a1ecd 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -823,7 +823,7 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) MigrationIncomingState *mis = migration_incoming_get_current(); Error *local_err = NULL; QEMUFile *f; - bool default_channel = true; + bool main_channel = true; uint32_t channel_magic = 0; int ret = 0; @@ -846,16 +846,16 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) return; } - default_channel = (channel_magic == cpu_to_be32(QEMU_VM_FILE_MAGIC)); + main_channel = (channel_magic == cpu_to_be32(QEMU_VM_FILE_MAGIC)); } else { - default_channel = !mis->from_src_file; + main_channel = !mis->from_src_file; } if (multifd_load_setup(errp) != 0) { return; } - if (default_channel) { + if (main_channel) { f = qemu_file_new_input(ioc); migration_incoming_setup(f); } else { @@ -874,7 +874,7 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) } } - if (migration_should_start_incoming(default_channel)) { + if (migration_should_start_incoming(main_channel)) { /* If it's a recovery, we're done */ if (postcopy_try_recover()) { return; From patchwork Thu Jan 25 16:25:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13531231 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BACB3C47258 for ; Thu, 25 Jan 2024 16:27:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT2YG-0002Jc-AI; Thu, 25 Jan 2024 11:26:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2Y7-0002Hg-Ob for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:25:55 -0500 Received: from mail-mw2nam12on20601.outbound.protection.outlook.com ([2a01:111:f403:200a::601] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2Y5-0000RS-9W for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:25:55 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ahNsbUenSOnjVO8fmgtKYu3Y6nrekoKFapxGVOpr40fjoEXwyMm438jKYH9zhaWwkb8J8WOiUR0RBImb+aQLrbrBLLdq/xkq078chjy+Jj+xdB+OV0CXYQnr19oL4muDzHBYtw3Ply5SzN2CT1dSXPDQ5yj+6b88SrzAw1C6oJG40MnNyl4K2Y8dlSryfTxjy9J5BXrVKzL5FEu0+n1aUnznZKnbqRl5YuM+SYZMEuOKMxtiRwGXH562miTxcueSmmNA1skWq8VjIbVTZoklpHDt56HS33ECXXBg5HyvoU7CgXW/SrboRbTHeGzjc5i9gE/w1CLU6AwC6RByUdTCCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HbWKboD99E3jpvqxT8LmzTS86iLG2aPdwE9Aek8Rvo4=; b=I2PCdb9HGzFMFqCJ7T/Q+T2lQ+0G5I93dGZzUfeO1LmNV16ijpMxwIzqHzVuTLaNXsx4PpVIMXdsVDc970LcAzyCaX2dhA1bC9nms9S8ZPYIBZGl5Q8fxVOJDFShVy1hcf1dh4zqiqr8afqQPu9mH5aFd2jRjpI0VuiuN3Fx7GfQrAHkj5c7EiTyKv8NS49PdnkyVKoQIvUREurSIokDBxPtHoia+xoIelA34h+fhykc59GfIoBE5C96hUwsHNGFksYgcp5PoQqYlz3mAGr1jq/nXJae0f9AqjRLyFFrQVz/U+TyZglK4/vdRHwZxutzQu27IThxH9q18d//jdwYUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HbWKboD99E3jpvqxT8LmzTS86iLG2aPdwE9Aek8Rvo4=; b=HIYtYQTmKUpscTO4VdMADVnP5H07sz969ssuAQtXko8aDiuAHop9PU9bQZPrG6DgZz0LaYQGO29ydpGbQq5rzJH98oNDO7XnM+RFNr5MLf6ZgBvse88XyaRsBD5hvxbdbRguop4MxdQ336PfdsyNEWuDKdxE44QtMdq1oF9exXX2pE1GKNyywNZUULSyM2JiAwR/ffFyadY7zQHqRGiZnt8IxYPAb9LNfax7sSkMKEN7EMtY3HQrqskAU97TSRR6igp3UNLZvi6sdBCEmp92SZKFJzPV7eW3M0bX7y9NNcghqsQhD8z3Ln6+7tKbaMobEwwGrKRBE5KEgUqfo8hrEw== Received: from DM6PR17CA0020.namprd17.prod.outlook.com (2603:10b6:5:1b3::33) by SJ0PR12MB6709.namprd12.prod.outlook.com (2603:10b6:a03:44a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.24; Thu, 25 Jan 2024 16:25:49 +0000 Received: from CY4PEPF0000E9DB.namprd05.prod.outlook.com (2603:10b6:5:1b3:cafe::fa) by DM6PR17CA0020.outlook.office365.com (2603:10b6:5:1b3::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22 via Frontend Transport; Thu, 25 Jan 2024 16:25:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by CY4PEPF0000E9DB.mail.protection.outlook.com (10.167.241.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.16 via Frontend Transport; Thu, 25 Jan 2024 16:25:48 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:37 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:37 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 25 Jan 2024 08:25:36 -0800 From: Avihai Horon To: CC: Peter Xu , Fabiano Rosas , "Avihai Horon" Subject: [PATCH 04/17] migration/multifd: Set p->running = true in the right place Date: Thu, 25 Jan 2024 18:25:15 +0200 Message-ID: <20240125162528.7552-5-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240125162528.7552-1-avihaih@nvidia.com> References: <20240125162528.7552-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9DB:EE_|SJ0PR12MB6709:EE_ X-MS-Office365-Filtering-Correlation-Id: aa8c39c9-0ef6-4d04-d70b-08dc1dc24a59 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q+CaRrq/W6KTig7KdgPE5JT3byGMyZXWNrsAel5RD/OV2w7QK7Kkv8A67S1qm4bPomuKL5o3A4VwFySwmj8ihL8j0YCqDfVklvG6PrZZ728rJjLqWUAiWlH0njq9Td6Of/E9SR7aLr1c+l11//d3FWzVjbX4N7vYymD4JJjOUejNn3ZN5aVYGLKr8pfIAwQD7xb+pFZMN/3XCQhFOTiY12Hepo2BwILiRAFhz7btVOEyQ2UveBftqpqUEEOYT3kJTzNWx6VoCVnrss7mnlf7Jj2GIyxlQxjNYqfFuytQh2xbT3sk+LmS5prBSjwpyOj69vwAsTRKh7PlW8QGkfHzxV4fH9fGF4q1KPnh3bKi5a2FtReGwR3Il+Wy1F0O03DDmVvHR7MVFnL2Q7eM+Pv7AB6NOTJBPjuy38qU/Ybg9oO2TY9L0WyTlccn/EFfljgs2VkohaIcWtGCkcu6KEj1VpJM5GmYCLuEewvxIT4fhxPWUfU/mR/gzl573HlOARTTBNtM7J4r+I8OTGSrzf1PQSV2pj9wR9gDEsGaEfPjK6HivE+P9657/zpdLSABk6lpNbMwu7JwvCoviR6zzynDc+kzreNiIlFyHB4gvfBItzsDBa0fIq+HwdPWsBha4euuDNDlcg9uljen5ASTs9Ht1OmPqhpODnToTPNWoTrEeOXImQzCZm2XoMui2R3I9nU9P9d2qRMpDRN16MhZ1axmRNFLJMkGnchSTQH+RrClmYB54514oTGm8QiOhRg3BiQW X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(376002)(396003)(136003)(346002)(39860400002)(230922051799003)(451199024)(1800799012)(82310400011)(64100799003)(186009)(36840700001)(40470700004)(46966006)(41300700001)(40460700003)(83380400001)(2616005)(26005)(47076005)(107886003)(1076003)(426003)(336012)(82740400003)(36860700001)(7636003)(2906002)(4326008)(6916009)(5660300002)(8936002)(8676002)(70206006)(7696005)(6666004)(478600001)(54906003)(316002)(70586007)(36756003)(356005)(86362001)(40480700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 16:25:48.6936 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aa8c39c9-0ef6-4d04-d70b-08dc1dc24a59 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9DB.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6709 Received-SPF: softfail client-ip=2a01:111:f403:200a::601; envelope-from=avihaih@nvidia.com; helo=NAM12-MW2-obe.outbound.protection.outlook.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The commit in the fixes line moved multifd thread creation to a different location, but forgot to move the p->running = true assignment as well. Thus, p->running is set to true before multifd thread is actually created. p->running is used in multifd_save_cleanup() to decide whether to join the multifd thread or not. With TLS, an error in multifd_tls_channel_connect() can lead to a segmentation fault because p->running is true but p->thread is never initialized, so multifd_save_cleanup() tries to join an uninitialized thread. Fix it by moving p->running = true assignment right after multifd thread creation. Also move qio_channel_set_delay() to there, as this is where it used to be originally. Fixes: 29647140157a ("migration/tls: add support for multifd tls-handshake") Signed-off-by: Avihai Horon --- migration/multifd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index 25cbc6dc6b..564e911b6c 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -850,11 +850,13 @@ static bool multifd_channel_connect(MultiFDSendParams *p, return multifd_tls_channel_connect(p, ioc, errp); } + qio_channel_set_delay(ioc, false); migration_ioc_register_yank(ioc); p->registered_yank = true; p->c = ioc; qemu_thread_create(&p->thread, p->name, multifd_send_thread, p, QEMU_THREAD_JOINABLE); + p->running = true; return true; } @@ -883,8 +885,6 @@ static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque) trace_multifd_new_send_channel_async(p->id); if (!qio_task_propagate_error(task, &local_err)) { - qio_channel_set_delay(ioc, false); - p->running = true; if (multifd_channel_connect(p, ioc, &local_err)) { return; } From patchwork Thu Jan 25 16:25:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13531238 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CBC3CC47258 for ; Thu, 25 Jan 2024 16:28:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT2YH-0002Jx-JD; Thu, 25 Jan 2024 11:26:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YB-0002IJ-CN for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:01 -0500 Received: from mail-dm6nam11on2061e.outbound.protection.outlook.com ([2a01:111:f400:7eaa::61e] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2Y9-0000Rw-6h for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:25:59 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Eio2ZXITtbx8suhXsUoCR5GUcMbedodoXZ2vdJTxxWT4GLPn9oP0uH6JLakKCGq8y0tn9dLT/7EdcNyK/5Proj3OjNS6/Vd5vYeVVPnBstZxqYWPywXsCjp/3ke0BgUHEd0A31NKcP8yp9DBx1/1f/D/6Klw7p4k9LN6ZfF74h3vK3dg4kOT8Y5YrBpXJgg+ekzQeRm/4SCMo2pizQ3YnzBGTsDyF+fQ0KXvOn1p/qdiyqWdtt06+ts5JTCsXyZPuWUYSLI9VMbtFM20CLoCo+vrUqAo8Znudk6TUD7S9QdnXIWiynV65EoSG8ZzXYzPp6OUlkF5/L9ZZ+r8Ix0QjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5FbyVZXOlSh2wPsFIAvxzddoG5UlCNVdaCnEc9QjGcM=; b=FQqVPOcR8xO21E2ydDb5pdtlVehydxKDOtSP08BCSv0ORsluKtwrD2HSFCAY1UKJjQs/MkIB273k038OOTZCLqgAnIEQI+ulKmanJDWDmQdoIX40NxtNKTgt5sqwlQUwblWmnRBA2JHEi3lxuFJFdpPwLAa33U8EArQ9qQMKxC1xgNfjSQlCZb2YB20tC0mqAw0bSud/Bkp3pbh9OU7z+W1QfHPOuIYR/UAWHIlEFkUeVMQB7/USfFhHGdZYNwpps2ZZK2u09fi28Jgk0Rz4QTlS+PZa+cGibJa1rH6zSkcJZEODC5lKl2xPYWlKMUxuUlP9m0gW+Yfvj1YXQ53NBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5FbyVZXOlSh2wPsFIAvxzddoG5UlCNVdaCnEc9QjGcM=; b=pRsDqIwnKxm9M+ZG2snLcJrMZBzR9HH0Lk2EQOb63rfUcHQHwuTih60ClqGsBBu2GOoWiQl9iLaZ7/lOjT1IjB2lEoxNz7dje+4jO2Xd6Cgun5VlZVNn47GwWtvadObNIFVxut9eXyD0knpDV1EaD6EwfF1K3M/cikRlr1sOECDH6uEsGGnEe5fKXC2gsDy5ZIFdh6WJqYGNk4to+etyVHIIGxlDJcYKXJASC04j3vhYIaJwrKCAn/qzoFs3eNeq+qkxiY5BZZiIwhv9rocM/3LFzd43/XWaChau6uvVcRNtz3qY/+zpGyyLpSEZfgqOtv01KbAUUpldPEgRFG7YFA== Received: from DM6PR07CA0090.namprd07.prod.outlook.com (2603:10b6:5:337::23) by MW4PR12MB7191.namprd12.prod.outlook.com (2603:10b6:303:22d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.30; Thu, 25 Jan 2024 16:25:51 +0000 Received: from CY4PEPF0000E9DA.namprd05.prod.outlook.com (2603:10b6:5:337:cafe::99) by DM6PR07CA0090.outlook.office365.com (2603:10b6:5:337::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.24 via Frontend Transport; Thu, 25 Jan 2024 16:25:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by CY4PEPF0000E9DA.mail.protection.outlook.com (10.167.241.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.16 via Frontend Transport; Thu, 25 Jan 2024 16:25:51 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:39 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:38 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 25 Jan 2024 08:25:37 -0800 From: Avihai Horon To: CC: Peter Xu , Fabiano Rosas , "Avihai Horon" Subject: [PATCH 05/17] migration/multifd: Wait for multifd channels creation before proceeding Date: Thu, 25 Jan 2024 18:25:16 +0200 Message-ID: <20240125162528.7552-6-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240125162528.7552-1-avihaih@nvidia.com> References: <20240125162528.7552-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9DA:EE_|MW4PR12MB7191:EE_ X-MS-Office365-Filtering-Correlation-Id: 6fc7fb83-1169-467c-f189-08dc1dc24be0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ii3pTLuQYsXLOf9yH3SyDcbBDxXEdWDsmEbMURZgIl28mKtG5lIPun0heFX3yjNg856Nexl/vohhz7SQFkfogVxIZJdUzGrwf4eXI/hPAT8btNbXbWXQZNw3NoV1QYuN5nOG3T8ibCKcM9BdpvrrONBHj7DWApcKN86tDAK1vfGFw4dDWvFZFQvzATuweS+RrESxhMwRlFPvCfryDSH2bAmMNUaVhEG0hwNMt/hIaLOc9nzxlxY8VjqBTzA7p0AcCx0eaxE7g8zm14H0902CwB1C2f5WkDh3WhCSwgu8qLlEBqyTOSdyB8/gnkLfby3tUx18rwBBlOiFiL+WYqAjaP06LE30MmKte/XPikyHHzOVgkwwr/mfQ/8KD5Wk8eja6AAje6iW7GMyt6IdZqrCl0BVbRVdfvpD1CJtBKZRk2Jyv/eExeMt0bXBWd0zFYi0q8oouf++eE+k0Co1w6Ouc4jO2B05yyAIKrAREoRyim5cgAsuTbkkrly8mP1EOyovvPMIZYGQYGBcdEpCP+PmfLy/p71hi+IAWrdHiAml4xZyaFBHJ9qNxMC71qZiOmNrbCMToCrBEArqQBh/O6601qBOmO14USPCZYtD/yjtqgJOV9qBWfIBFIpFekNf8ezT1TAcUuZnPx69Ld1fc6pH3uOcGCp7K4lDc9MydvhYYrxSQZU7wWUjHQn4Q5O6kOC/i/x3vQsQ3PtpfJftbiJdP7Kfw2UfR654Ba5SxMP1kU+PFe3YhJmSkroh7qzuP/OH X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(396003)(136003)(376002)(39860400002)(346002)(230922051799003)(64100799003)(82310400011)(451199024)(186009)(1800799012)(46966006)(40470700004)(36840700001)(2906002)(6916009)(70586007)(36756003)(36860700001)(41300700001)(47076005)(86362001)(7636003)(83380400001)(356005)(82740400003)(6666004)(4326008)(7696005)(316002)(8676002)(478600001)(5660300002)(54906003)(26005)(70206006)(426003)(336012)(1076003)(8936002)(2616005)(107886003)(40480700001)(40460700003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 16:25:51.2568 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6fc7fb83-1169-467c-f189-08dc1dc24be0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9DA.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7191 Received-SPF: softfail client-ip=2a01:111:f400:7eaa::61e; envelope-from=avihaih@nvidia.com; helo=NAM11-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Currently, multifd channels are created asynchronously without waiting for their creation -- migration simply proceeds and may wait in multifd_send_sync_main(), which is called by ram_save_setup(). This hides in it some race conditions which can cause an unexpected behavior if some channels creation fail. For example, the following scenario of multifd migration with two channels, where the first channel creation fails, will end in a segmentation fault (time advances from top to bottom): Thread | Code execution ------------------------------------------------------------------------ Multifd 1 | | multifd_new_send_channel_async (errors and quits) | multifd_new_send_channel_cleanup | Migration thread | | qemu_savevm_state_setup | ram_save_setup | multifd_send_sync_main | (detects Multifd 1 error and quits) | [...] | migration_iteration_finish | migrate_fd_cleanup_schedule | Main thread | | migrate_fd_cleanup | multifd_save_cleanup (destroys Multifd 2 resources) | Multifd 2 | | multifd_new_send_channel_async | (accesses destroyed resources, segfault) In another scenario, migration can hang indefinitely: 1. Main migration thread reaches multifd_send_sync_main() and waits on the semaphores. 2. Then, all multifd channels creation fails, so they post the semaphores and quit. 3. Main migration channel will not identify the error, proceed to send pages and will hang. Fix it by waiting for all multifd channels to be created before proceeding with migration. Signed-off-by: Avihai Horon --- migration/multifd.h | 3 +++ migration/migration.c | 1 + migration/multifd.c | 34 +++++++++++++++++++++++++++++++--- migration/ram.c | 7 +++++++ 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/migration/multifd.h b/migration/multifd.h index 35d11f103c..87a64e0a87 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -23,6 +23,7 @@ void multifd_recv_new_channel(QIOChannel *ioc, Error **errp); void multifd_recv_sync_main(void); int multifd_send_sync_main(void); int multifd_queue_page(RAMBlock *block, ram_addr_t offset); +int multifd_send_channels_created(void); /* Multifd Compression flags */ #define MULTIFD_FLAG_SYNC (1 << 0) @@ -86,6 +87,8 @@ typedef struct { /* multifd flags for sending ram */ int write_flags; + /* Syncs channel creation and migration thread */ + QemuSemaphore create_sem; /* sem where to wait for more work */ QemuSemaphore sem; /* syncs main thread and channels */ diff --git a/migration/migration.c b/migration/migration.c index 9c769a1ecd..d81d96eaa5 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3621,6 +3621,7 @@ void migrate_fd_connect(MigrationState *s, Error *error_in) error_report_err(local_err); migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_FAILED); + multifd_send_channels_created(); migrate_fd_cleanup(s); return; } diff --git a/migration/multifd.c b/migration/multifd.c index 564e911b6c..f0c216f4f9 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -538,6 +538,7 @@ void multifd_save_cleanup(void) multifd_send_channel_destroy(p->c); p->c = NULL; qemu_mutex_destroy(&p->mutex); + qemu_sem_destroy(&p->create_sem); qemu_sem_destroy(&p->sem); qemu_sem_destroy(&p->sem_sync); g_free(p->name); @@ -766,6 +767,29 @@ out: return NULL; } +int multifd_send_channels_created(void) +{ + int ret = 0; + + if (!migrate_multifd()) { + return 0; + } + + for (int i = 0; i < migrate_multifd_channels(); i++) { + MultiFDSendParams *p = &multifd_send_state->params[i]; + + qemu_sem_wait(&p->create_sem); + WITH_QEMU_LOCK_GUARD(&p->mutex) { + if (p->quit) { + error_report("%s: channel %d has already quit", __func__, i); + ret = -1; + } + } + } + + return ret; +} + static bool multifd_channel_connect(MultiFDSendParams *p, QIOChannel *ioc, Error **errp); @@ -794,6 +818,7 @@ static void multifd_tls_outgoing_handshake(QIOTask *task, p->quit = true; qemu_sem_post(&multifd_send_state->channels_ready); qemu_sem_post(&p->sem_sync); + qemu_sem_post(&p->create_sem); error_free(err); } @@ -857,6 +882,7 @@ static bool multifd_channel_connect(MultiFDSendParams *p, qemu_thread_create(&p->thread, p->name, multifd_send_thread, p, QEMU_THREAD_JOINABLE); p->running = true; + qemu_sem_post(&p->create_sem); return true; } @@ -864,15 +890,16 @@ static void multifd_new_send_channel_cleanup(MultiFDSendParams *p, QIOChannel *ioc, Error *err) { migrate_set_error(migrate_get_current(), err); - /* Error happen, we need to tell who pay attention to me */ - qemu_sem_post(&multifd_send_state->channels_ready); - qemu_sem_post(&p->sem_sync); /* + * Error happen, we need to tell who pay attention to me. * Although multifd_send_thread is not created, but main migration * thread need to judge whether it is running, so we need to mark * its status. */ p->quit = true; + qemu_sem_post(&multifd_send_state->channels_ready); + qemu_sem_post(&p->sem_sync); + qemu_sem_post(&p->create_sem); object_unref(OBJECT(ioc)); error_free(err); } @@ -921,6 +948,7 @@ int multifd_save_setup(Error **errp) MultiFDSendParams *p = &multifd_send_state->params[i]; qemu_mutex_init(&p->mutex); + qemu_sem_init(&p->create_sem, 0); qemu_sem_init(&p->sem, 0); qemu_sem_init(&p->sem_sync, 0); p->quit = false; diff --git a/migration/ram.c b/migration/ram.c index c0cdcccb75..b3e864a22b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2937,6 +2937,13 @@ static int ram_save_setup(QEMUFile *f, void *opaque) RAMBlock *block; int ret; + bql_unlock(); + ret = multifd_send_channels_created(); + bql_lock(); + if (ret < 0) { + return ret; + } + if (compress_threads_save_setup()) { return -1; } From patchwork Thu Jan 25 16:25:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13531234 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4C764C47258 for ; Thu, 25 Jan 2024 16:27:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT2YJ-0002KI-18; Thu, 25 Jan 2024 11:26:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YC-0002IP-Ug for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:01 -0500 Received: from mail-dm6nam11on20601.outbound.protection.outlook.com ([2a01:111:f400:7eaa::601] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2Y9-0000SA-K5 for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:00 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OXBtKGLoifx/KlNSqm/UZlfvU125aO9fFXIMOJVc6kbNgfeTaDYFZJVw1GYeYWgm1uby6nLM+4XqyWjfMhKkl6X1oB8LLfCcESzx7JEWVY9C800e31gJCbWqJnsYG2MU7Vi7vTCa2GC1rqb9nlWLcTdZz9lx/aNksEFwuwbPgooBZq2BgDX7HbwQ27+/tIqE0seZ04w1f8rYdc9zS3rTBacpULRZTFX9TIYzfOQR6sbbveQ9RhnEAIdo4s+z+wxqIKyGgW//BnTa3QDBBObo8Z7bLovTsl3WOj/bifPLIcu8LAIP6xro+ZFCngdhSntdqt1VAbC6pEKet9vYH3reOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=N2luifolw7a6U9Ml2qGEzAIwBi2Yfqe7F7+I3RhSzko=; b=JCUyVlRSfmX7AQBNY5cAqJuYl6ruIFO3xi8SJ8ISj+y7oa0+YtMvC4zijqxLSM6aIyHlvHewbKEo5zpiLQALg40tbZePaENN6xCT7jPhVBc/ADmRvx2jODR9j8B1pXYSl250R1DPlgYHmVZRLRHT/AuNTqA4wwZ+QUzY8/+eHm++UIJb9S41OlkvDY1mJ4S9QZMSnDu/kH+gMxgZ5zTlgIDmuaV6OoNqCClbC7Tj4lX95WhPXqn5yBPBrCllLyTGzqUQij51FRKFo5IBLeHVId/ig6mqs57rLrMuXltMCYWYbklNVHIFojLlLjfKaRYr8sAqLJs6hHVVJ2wKdnWaPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N2luifolw7a6U9Ml2qGEzAIwBi2Yfqe7F7+I3RhSzko=; b=kxDLBAJfd1fTw7R11Tlkh6pJ7RiYK58MUwSXHbWf0hAB3IKI0q3c68Ow1QcLEDceX/waNxlwWO9bcYds6NwNgHRxqEmXD/slCEX5kTfJbGgzvR017vVXGwBx9huRILqhckogvpEN0ND4rzJz6rHmPFmyeQOh0wXmJKB5tgws+QRrAQJmvHEoYovIgavRnaBlhKKp5NMKsMCE5ufGIGD8DAHHeG0shMLDPC8Ms5GIiROohPQCxUM2vxsxsHtRidetWYyFYNlhN1exl8Ocdr8i6ghhptLLzeSqCPmdEH6x0OTzxLs5N0qD3cGLP+n7Dzxp+8AQpAhuPLKKdNbnDh+kTw== Received: from DM5PR07CA0066.namprd07.prod.outlook.com (2603:10b6:4:ad::31) by SJ2PR12MB8782.namprd12.prod.outlook.com (2603:10b6:a03:4d0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.24; Thu, 25 Jan 2024 16:25:52 +0000 Received: from DS3PEPF000099DC.namprd04.prod.outlook.com (2603:10b6:4:ad:cafe::71) by DM5PR07CA0066.outlook.office365.com (2603:10b6:4:ad::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22 via Frontend Transport; Thu, 25 Jan 2024 16:25:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DS3PEPF000099DC.mail.protection.outlook.com (10.167.17.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.16 via Frontend Transport; Thu, 25 Jan 2024 16:25:51 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:41 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:40 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 25 Jan 2024 08:25:39 -0800 From: Avihai Horon To: CC: Peter Xu , Fabiano Rosas , "Avihai Horon" Subject: [PATCH 06/17] migration/tls: Rename main migration channel TLS functions Date: Thu, 25 Jan 2024 18:25:17 +0200 Message-ID: <20240125162528.7552-7-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240125162528.7552-1-avihaih@nvidia.com> References: <20240125162528.7552-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DC:EE_|SJ2PR12MB8782:EE_ X-MS-Office365-Filtering-Correlation-Id: a2908811-10df-48c2-45e4-08dc1dc24bf0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dzjuDFLZX3AGyyz1A0Oa8g2TDEgNXIGteClSBTDlb10BvJ3+b+o7ld3ED9Kv4uBeown9XtKUvO7uc2jiyWJPwFCkHVL/DDDc8X7WYc/8Moynp+iL9zxcdqfv5oic9e0KzRDXa/AAUoeMWLSybWasO0av7gvxYacondIhFURYBihRwSnSY+4VPoa2sqGMlS8JrmOKyhQL/mTvtRF3MF/4i1fs0WaOm2oE4Z1uvChANUcXsufxnHNUoKiZ4tByCfNK20E2evJSKTNzOIEJ0p5QsxKE2XmKF15+6SQBGp+75O7hP0MX4+Lb5OO/Yns+OV5rl69MTo/hC1lSEH4cUH/3bADSPjzm5NPFuMeWsxN2lr33GrTXII9x2b0pC6zJZk00PhNIxnfSSCCWS6NEfO/xp0okueDWPHIT4i2OfJ5iNb087yihojmhfQxonLH+aGeG5dzyCuolUNKwI3+ueqb/lc/O6LS4AxZab42iypGBKCg8FLiKzLndVitK8oUTAYQIxQHMPXH37ecpDAHA3Fy6n7aqBzdvtoe4eHwTTs2QG+PbbPxkuU0tWKUbY8LO3lB6PXHgA5XZhGzFDlz6XEoJN+ibeBR65XTKXhskX6o/GJjP6AULBrsRubxBz6cGAo7fWR4L1byecPU3MlRQeiZ64SCItLmzML+x5GPFIDQIhfKawWljwyHopiTFAcB51co26SexxPJ7gy/Xh+TGTddLmkdI0s6CcRKBt5NmtQKwLuHwpNfAoAzI6AS5BL1P8W8I X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(396003)(346002)(376002)(136003)(230922051799003)(186009)(451199024)(82310400011)(64100799003)(1800799012)(46966006)(40470700004)(36840700001)(41300700001)(36756003)(478600001)(6666004)(47076005)(4326008)(316002)(7696005)(70206006)(70586007)(107886003)(2616005)(6916009)(1076003)(54906003)(26005)(8676002)(5660300002)(83380400001)(336012)(40480700001)(40460700003)(426003)(8936002)(82740400003)(36860700001)(2906002)(356005)(7636003)(86362001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 16:25:51.3416 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a2908811-10df-48c2-45e4-08dc1dc24bf0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8782 Received-SPF: softfail client-ip=2a01:111:f400:7eaa::601; envelope-from=avihaih@nvidia.com; helo=NAM11-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Rename functions related to main migration channel TLS upgrade. This is done in preparation for the next patch which will add a new TLS upgrade API for migration channels with the same name. No functional changes intended. Signed-off-by: Avihai Horon --- migration/tls.h | 6 ++---- migration/channel.c | 2 +- migration/tls.c | 24 ++++++++++-------------- migration/trace-events | 6 +++--- 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/migration/tls.h b/migration/tls.h index 5797d153cb..5435dd4867 100644 --- a/migration/tls.h +++ b/migration/tls.h @@ -32,10 +32,8 @@ QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc, const char *hostname, Error **errp); -void migration_tls_channel_connect(MigrationState *s, - QIOChannel *ioc, - const char *hostname, - Error **errp); +void migration_tls_channel_connect_main(MigrationState *s, QIOChannel *ioc, + const char *hostname, Error **errp); /* Whether the QIO channel requires further TLS handshake? */ bool migrate_channel_requires_tls_upgrade(QIOChannel *ioc); diff --git a/migration/channel.c b/migration/channel.c index f9de064f3b..041a63eb21 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -69,7 +69,7 @@ void migration_channel_connect(MigrationState *s, if (!error) { if (migrate_channel_requires_tls_upgrade(ioc)) { - migration_tls_channel_connect(s, ioc, hostname, &error); + migration_tls_channel_connect_main(s, ioc, hostname, &error); if (!error) { /* tls_channel_connect will call back to this diff --git a/migration/tls.c b/migration/tls.c index fa03d9136c..803cb54c8b 100644 --- a/migration/tls.c +++ b/migration/tls.c @@ -98,17 +98,18 @@ void migration_tls_channel_process_incoming(MigrationState *s, } -static void migration_tls_outgoing_handshake(QIOTask *task, - gpointer opaque) +static void migration_tls_outgoing_handshake_main(QIOTask *task, + gpointer opaque) { MigrationState *s = opaque; QIOChannel *ioc = QIO_CHANNEL(qio_task_get_source(task)); Error *err = NULL; if (qio_task_propagate_error(task, &err)) { - trace_migration_tls_outgoing_handshake_error(error_get_pretty(err)); + trace_migration_tls_outgoing_handshake_main_error( + error_get_pretty(err)); } else { - trace_migration_tls_outgoing_handshake_complete(); + trace_migration_tls_outgoing_handshake_main_complete(); } migration_channel_connect(s, ioc, NULL, err); object_unref(OBJECT(ioc)); @@ -133,10 +134,8 @@ QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc, return qio_channel_tls_new_client(ioc, creds, hostname, errp); } -void migration_tls_channel_connect(MigrationState *s, - QIOChannel *ioc, - const char *hostname, - Error **errp) +void migration_tls_channel_connect_main(MigrationState *s, QIOChannel *ioc, + const char *hostname, Error **errp) { QIOChannelTLS *tioc; @@ -147,13 +146,10 @@ void migration_tls_channel_connect(MigrationState *s, /* Save hostname into MigrationState for handshake */ s->hostname = g_strdup(hostname); - trace_migration_tls_outgoing_handshake_start(hostname); + trace_migration_tls_outgoing_handshake_main_start(hostname); qio_channel_set_name(QIO_CHANNEL(tioc), "migration-tls-outgoing"); - qio_channel_tls_handshake(tioc, - migration_tls_outgoing_handshake, - s, - NULL, - NULL); + qio_channel_tls_handshake(tioc, migration_tls_outgoing_handshake_main, s, + NULL, NULL); } bool migrate_channel_requires_tls_upgrade(QIOChannel *ioc) diff --git a/migration/trace-events b/migration/trace-events index de4a743c8a..9448b5cedf 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -325,9 +325,9 @@ migration_socket_outgoing_connected(const char *hostname) "hostname=%s" migration_socket_outgoing_error(const char *err) "error=%s" # tls.c -migration_tls_outgoing_handshake_start(const char *hostname) "hostname=%s" -migration_tls_outgoing_handshake_error(const char *err) "err=%s" -migration_tls_outgoing_handshake_complete(void) "" +migration_tls_outgoing_handshake_main_start(const char *hostname) "hostname=%s" +migration_tls_outgoing_handshake_main_error(const char *err) "err=%s" +migration_tls_outgoing_handshake_main_complete(void) "" migration_tls_incoming_handshake_start(void) "" migration_tls_incoming_handshake_error(const char *err) "err=%s" migration_tls_incoming_handshake_complete(void) "" From patchwork Thu Jan 25 16:25:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13531237 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A93AFC47422 for ; Thu, 25 Jan 2024 16:28:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT2YH-0002Jj-9h; Thu, 25 Jan 2024 11:26:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YB-0002IK-Cg for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:01 -0500 Received: from mail-dm6nam12on20601.outbound.protection.outlook.com ([2a01:111:f403:2417::601] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2Y9-0000S7-8z for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:25:59 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GGVd+R4XhPacREgncJNYaPPNxwLSazmFqXUlJgh2Z3FZ3ft3jQWG4oa2NzGyWsuC/fYRriUzv1Zfzvu9hY6SQsgXIFsieJ8oqSpvMG4BpkYx2pRPEM3voTRugIjw9+QRYz12M9rP0jeebMFCGLTDmO7M+1yOIegWtdGCRGX6wv+W+MToNlAGBDXUeRETKy271S0DsAOHZl/GCGsiuP0J7eTW9AxKhjqYDPWUCA6jxifKulnHNWtiPu6abJtKyHFGDOqEymbn6naTYjd1xeOLUlZDfbvzkKu/rfaC1EDgSNiUqo0XKPJaQ/ngMmTjoFaBbBkA89uwvbu8QXPVmSmN4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hOBoAuPIPr0iAOOSL33M1VQMH4Og0kQkA7oL4NQJ4D0=; b=dpo1bwltT3dmmBAoYCY657k96wDDjahSomB/uUAMB3iLjlcAa0JxektPRUe4SYoNO0wvD+6ZrLTex+JhMi3OszfCKYgcaejR/cFDFeUVi9zwPMPLwo9K7yNmSYppdN3PdD+mDHfzZm67Tc7MjNJWrmeuwE/FmgIo51Cpf9/qW3cKZCCRNIoIgp6Zl8Rmsc+kfs79NK0jYFW6GqhpzVIvjT5lQUvbggOnXTFdMPEJOybk1FyuenUHwJ+cNnMISamUi/A3mdm6/+LxPdLirH5xJXtoQNQzdyeUyWx46vjQKk9sLENiQS2+W9VoMAqhGaA2uYjqumK8zu00uoNIZeIdpA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hOBoAuPIPr0iAOOSL33M1VQMH4Og0kQkA7oL4NQJ4D0=; b=K3YUNTiDktx4lgKIMU9oNiMbdBXQsQfbrngOF5xmaJkKLnaG1sd1eoVSwJhe5iiflKb39a2ASXwKcuyLy1li2pVVRB8b2pntnK+2c3nYEp0vMJ3BD0sQ7DUMoTdYRREkNSNhiKFoQcwdtiVlr2XIeAIze7MN5o1ycjsLscxbpBj7XBGr/kVsdcj2NNJ2iTpmyv3P4cl5rVXeog5GaeKhvRBXZWVsbdizwSMWEe2duFy81Og5QIInT4rjBbewQsZbW3WyBvGkqZpTKY4zzccrQq2bAS4LQ+ayjHkpJjm6KpavPbhvTfM6eFutpq46g6R3LtgmEW1wDhwWQPd6U9verg== Received: from DM5PR07CA0053.namprd07.prod.outlook.com (2603:10b6:4:ad::18) by DS0PR12MB7928.namprd12.prod.outlook.com (2603:10b6:8:14c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Thu, 25 Jan 2024 16:25:53 +0000 Received: from DS3PEPF000099DC.namprd04.prod.outlook.com (2603:10b6:4:ad:cafe::4d) by DM5PR07CA0053.outlook.office365.com (2603:10b6:4:ad::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.26 via Frontend Transport; Thu, 25 Jan 2024 16:25:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DS3PEPF000099DC.mail.protection.outlook.com (10.167.17.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.16 via Frontend Transport; Thu, 25 Jan 2024 16:25:53 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:42 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:42 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 25 Jan 2024 08:25:41 -0800 From: Avihai Horon To: CC: Peter Xu , Fabiano Rosas , "Avihai Horon" Subject: [PATCH 07/17] migration/tls: Add new migration channel TLS upgrade API Date: Thu, 25 Jan 2024 18:25:18 +0200 Message-ID: <20240125162528.7552-8-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240125162528.7552-1-avihaih@nvidia.com> References: <20240125162528.7552-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DC:EE_|DS0PR12MB7928:EE_ X-MS-Office365-Filtering-Correlation-Id: 111fdf6d-2e16-4e25-49d5-08dc1dc24d39 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UJ52HQPm7K8H7YRIIvjKjQAeGabx0DCJVs5unBM+vPq2bPfbqkEbSrRjj00yh5qlzWECM9aWkpiqnMerVnGK1nOPI9iDkIc78T0a4YgBbksEve3FhHx8zalPKC3UxsoqC/X4VTHmZmywr87qj7PDv833Is1h1PjAdLKxxSq04xN1Cm5x5soKEVldWH7kwQ8jXLEqn+tmw8WrCdrFRytVQRsjvhjA5PRMpcvcWgUYSL0t5fJUSpcFZT9DaKv6X0C0n+jGTi3ot5YBP7uKoqhZ96hNiR4PV6wZIv9hXYRvtJ2t18GTO8gkgKrVEXBnIn72qyAF5qMJqEF8JIILju2A3owHyIWI2NURVv6eLGAxe9mzV/mPiUBrBygmdme5CWSPZyJz4R07J93VA3IIN8C07pD5U+ywg5bbe8W6yrFAGYkzupiTgor6CvIbFCUnZb4WG5PkTC4nWymMooiuCDrRd5VfuJf6RgdIZgH2vOc5/qu6TlyCYDUktKkqRgoCYWUkXcA2kKjv0vDD7uEWiStY1tWxqzJTjMmBTkLo8OczKWMauYW8m8I3+WuED1eqSbLJzqaACka4EkDjL7HXL5G2ww99pKVK7hjesw4kLVnwuLOXeAF4X39Z5PtL4LO4aCHUTOvYPWmvMIJYx+30QsWoCrjWyvyI5aQjoehQxX63I0gEoQ3bnUbKMPtSaJOftBLn7TR/DiXpxDfgecB5/seQ1NzeUb9mDdYuGG6FpMIirCU= X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(346002)(136003)(376002)(39860400002)(396003)(230922051799003)(82310400011)(64100799003)(1800799012)(451199024)(186009)(46966006)(36840700001)(40470700004)(336012)(83380400001)(47076005)(426003)(36860700001)(1076003)(26005)(2616005)(107886003)(8676002)(82740400003)(4326008)(5660300002)(8936002)(6916009)(70586007)(70206006)(7696005)(2906002)(478600001)(316002)(54906003)(7636003)(6666004)(41300700001)(356005)(36756003)(86362001)(40460700003)(40480700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 16:25:53.4666 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 111fdf6d-2e16-4e25-49d5-08dc1dc24d39 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7928 Received-SPF: softfail client-ip=2a01:111:f403:2417::601; envelope-from=avihaih@nvidia.com; helo=NAM12-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Main migration channel, multifd channels and postcopy preempt channel use the QIOChannelTLS API to upgrade their channels to TLS when needed. Each of them has its own code to create a QIOChannelTLS and to perform the TLS handshake. Some of this code is duplicate and can be avoided. Add a new API to TLS upgrade migration channels. This will make the code clearer and avoid duplicate code such as TLS handshake, trace handling and threading. Signed-off-by: Avihai Horon --- migration/tls.h | 27 ++++++++++++++++ migration/tls.c | 72 ++++++++++++++++++++++++++++++++++++++++++ migration/trace-events | 3 ++ 3 files changed, 102 insertions(+) diff --git a/migration/tls.h b/migration/tls.h index 5435dd4867..514529ff38 100644 --- a/migration/tls.h +++ b/migration/tls.h @@ -35,6 +35,33 @@ QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc, void migration_tls_channel_connect_main(MigrationState *s, QIOChannel *ioc, const char *hostname, Error **errp); +typedef void (*MigTLSConCallback)(QIOChannel *ioc, void *opaque, Error *err); + +/** + * migration_tls_channel_connect: + * @ioc: The underlying channel object + * @name: The name of the channel + * @hostname: The user specified server hostname + * @callback: The callback to invoke when completed + * @opaque: Opaque data to pass to @callback + * @run_in_thread: Whether to run TLS handshake in new thread or not + * @errp: Pointer to a NULL-initialized error object pointer + * + * Establishes a TLS connection on top of the provided QIOChannel @ioc. If this + * function succeeds, @callback will be invoked upon completion and + * success/failure will be reported to it via the Error object argument. + * In case multiple channels are TLS upgraded in parallel, @run_in_thread + * should be set to true so the TLS handshake will be performed in a new + * thread, to avoid a potential risk of migration hang. + * + * Returns: True on successful initiation of TLS upgrade process, or false on + * failure. + */ +bool migration_tls_channel_connect(QIOChannel *ioc, const char *name, + const char *hostname, + MigTLSConCallback callback, void *opaque, + bool run_in_thread, Error **errp); + /* Whether the QIO channel requires further TLS handshake? */ bool migrate_channel_requires_tls_upgrade(QIOChannel *ioc); diff --git a/migration/tls.c b/migration/tls.c index 803cb54c8b..e6a0349bd1 100644 --- a/migration/tls.c +++ b/migration/tls.c @@ -152,6 +152,78 @@ void migration_tls_channel_connect_main(MigrationState *s, QIOChannel *ioc, NULL, NULL); } +typedef struct { + QIOChannelTLS *tioc; + MigTLSConCallback callback; + void *opaque; + char *name; + QemuThread thread; +} MigTLSConData; + +static void migration_tls_outgoing_handshake(QIOTask *task, void *opaque) +{ + QIOChannel *ioc = QIO_CHANNEL(qio_task_get_source(task)); + MigTLSConData *data = opaque; + Error *err = NULL; + + if (qio_task_propagate_error(task, &err)) { + trace_migration_tls_outgoing_handshake_error(data->name, + error_get_pretty(err)); + } else { + trace_migration_tls_outgoing_handshake_complete(data->name); + } + + data->callback(ioc, data->opaque, err); + g_free(data->name); + g_free(data); +} + +static void *migration_tls_channel_connect_thread(void *opaque) +{ + MigTLSConData *data = opaque; + + qio_channel_tls_handshake(data->tioc, migration_tls_outgoing_handshake, + data, NULL, NULL); + return NULL; +} + +bool migration_tls_channel_connect(QIOChannel *ioc, const char *name, + const char *hostname, + MigTLSConCallback callback, void *opaque, + bool run_in_thread, Error **errp) +{ + QIOChannelTLS *tioc; + MigTLSConData *data; + g_autofree char *channel_name = NULL; + g_autofree char *thread_name = NULL; + + tioc = migration_tls_client_create(ioc, hostname, errp); + if (!tioc) { + return false; + } + + data = g_new0(MigTLSConData, 1); + data->tioc = tioc; + data->callback = callback; + data->opaque = opaque; + data->name = g_strdup(name); + + trace_migration_tls_outgoing_handshake_start(hostname, name); + channel_name = g_strdup_printf("migration-tls-outgoing-%s", name); + qio_channel_set_name(QIO_CHANNEL(tioc), channel_name); + if (!run_in_thread) { + qio_channel_tls_handshake(tioc, migration_tls_outgoing_handshake, data, + NULL, NULL); + return true; + } + + thread_name = g_strdup_printf("migration-tls-outgoing-worker-%s", name); + qemu_thread_create(&data->thread, thread_name, + migration_tls_channel_connect_thread, data, + QEMU_THREAD_JOINABLE); + return true; +} + bool migrate_channel_requires_tls_upgrade(QIOChannel *ioc) { if (!migrate_tls()) { diff --git a/migration/trace-events b/migration/trace-events index 9448b5cedf..09dd342d37 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -328,6 +328,9 @@ migration_socket_outgoing_error(const char *err) "error=%s" migration_tls_outgoing_handshake_main_start(const char *hostname) "hostname=%s" migration_tls_outgoing_handshake_main_error(const char *err) "err=%s" migration_tls_outgoing_handshake_main_complete(void) "" +migration_tls_outgoing_handshake_start(const char *hostname, const char *name) "hostname=%s, name=%s" +migration_tls_outgoing_handshake_error(const char *name, const char *err) "name=%s, err=%s" +migration_tls_outgoing_handshake_complete(const char *name) "name=%s" migration_tls_incoming_handshake_start(void) "" migration_tls_incoming_handshake_error(const char *err) "err=%s" migration_tls_incoming_handshake_complete(void) "" From patchwork Thu Jan 25 16:25:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13531227 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B8DCDC47422 for ; Thu, 25 Jan 2024 16:26:49 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT2YJ-0002KS-Aq; Thu, 25 Jan 2024 11:26:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YH-0002K5-St for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:05 -0500 Received: from mail-co1nam11on20601.outbound.protection.outlook.com ([2a01:111:f403:2416::601] helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YF-0000Sp-LV for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:05 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=idBi7CPGHGb+/3v6VAA6Nzew5CUJYX6Wo7zD9KyK+jrzcK4DwCLYMEfuq4wTMd1gvfVysBhR5MJ/fGNE5dSNrlfOEEwSUZz3/Rzky6EmC2/68AqqE9DwfJ/MBy5u/Bp2cyhOcMS/ry0m9ZBwv+V7kCKCxH35SpjySsLYh47ZoaV8d2LV06prP+qFPLztvGgh/2DFLac1/vB7t4aNVVYLalCZfM8JM4Kc/EFNThsQ20X1SbMlaYZRxeCBGs/sMq2XRFWWt9+odUfj9txinfw2rAy9/2zyzsXc0tSsMGexTVL4Iv4YUXBfaksgQT1bQo7tRNKUWjo394QVckodvpxhxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8n4unbQ1FG9WGWzdc44omo+MZXrLbpGq+Y1DO8/pKmk=; b=ZJTxPKQ2lkf3Bh4QzqXpELXHUzy77Ffo8GhqM3Mnnx9Qsf3sSYJaDY1oVLh2WDmsbpfT8un3gPQsw3qnvX0Pf/bRjexFyu2Z84su3hCD/XKR5apRBMzUKUgD5XC3zALEL9Ey0Br9mu3n2E3479rFM8xermQsjuYCV4JjtsP66vL6gSttRScJqmkSA1D8QOFRCqPWCCjfrgRDXh979l2/823H/KwzHd8zna5EQaAfvmmODSBXLiFOcXdADfV9dOAU2IfHk6YlgaN3vyTKTlRW53rwXmDMfaL9vka64V+h66+uZs12oqvnwdb8S/cw0nX3WtK3fQvkt23XQiVpekoFcw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8n4unbQ1FG9WGWzdc44omo+MZXrLbpGq+Y1DO8/pKmk=; b=Bi1bNAviKO3+RPa44QKz0ThDqOPRmjFM0AO4nEoziHsDWgNoLnu74GWPaWkClptPa9l8S6N1g4xhD3tN+QRD2ggPchQbtLVinWdtXvBUYDx6dKXVD2uqUNWjGg7hsmZ6JbbN1LNZjzp2l1yFGBtuMgLVCwjQT/bK2+SBY6KgxGtFLv0vGIQexxBqQUXc8qYwQ0/2qkIwwkpxiga3DPYdN7kWFDktk7zKvZwQvlehgGbK5a51ffiLJQ8fNTqEt5G2iK90TY1pKEAF4D8tLjg62okF+jHhMcll0tFOKOEqzHVqzGPrNvQlpWOUaL/EBNMRJ33fubCHuCtnx6ZG+7JofA== Received: from DM5PR07CA0067.namprd07.prod.outlook.com (2603:10b6:4:ad::32) by SA1PR12MB5670.namprd12.prod.outlook.com (2603:10b6:806:239::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.24; Thu, 25 Jan 2024 16:25:54 +0000 Received: from DS3PEPF000099DC.namprd04.prod.outlook.com (2603:10b6:4:ad:cafe::6) by DM5PR07CA0067.outlook.office365.com (2603:10b6:4:ad::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27 via Frontend Transport; Thu, 25 Jan 2024 16:25:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DS3PEPF000099DC.mail.protection.outlook.com (10.167.17.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.16 via Frontend Transport; Thu, 25 Jan 2024 16:25:54 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:44 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:44 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 25 Jan 2024 08:25:42 -0800 From: Avihai Horon To: CC: Peter Xu , Fabiano Rosas , "Avihai Horon" Subject: [PATCH 08/17] migration: Use the new TLS upgrade API for main channel Date: Thu, 25 Jan 2024 18:25:19 +0200 Message-ID: <20240125162528.7552-9-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240125162528.7552-1-avihaih@nvidia.com> References: <20240125162528.7552-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DC:EE_|SA1PR12MB5670:EE_ X-MS-Office365-Filtering-Correlation-Id: f7f97bc0-16dc-4930-a636-08dc1dc24db7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PKL2yhijD+/GWoZvzCwCmDPI6Ij0lJx95rBriHbK+OfDnOfh6jy4W4CUwxQFyQhid5l/o1f3hHym2TFT4INhxuKUmDhVC9wBsgM4tpGz0REaIi2GFeqxAkSh/YYsdAXy7uCxfWyFEFxy6dgJARE9GRNRo3moY+mgQWYUXX7qroN9SfSmIfYtTrALjlIBFzhu9HepYd0J0PHH1Xmx3i68QPlhXSdp+J2bxj2u/fAFgFyffKdTG92/dL4304xzqanXKP7RVRfcT0x+2fvLgGcNE1lLmbDfNATmcStMlChEPFEx4gAWMsja+NXlZsCDltStZKrGgSsbue3OR59gAQ5J3Z6DXqDzVK9tfuYWs0jpb7I+SrWqJPUs8VQ6We8t4HkSNoRdkqU13x70U2MJwKkStGfFGJIK/TDsNRo3epW1nrL6VVwauGpRFNj3qVWoVwI1n7tQuaH21llZkVa92kUVKZdG/M+ofEbZ3boRaoALXyou/FAgE/fr8fZUfyRDZgC85r6DHB0TiKFvcLMb5hKDGKUsbOhUOL0qkhitj1CpMEVn2Py7rGEZwQQUElj9UZW/Rn7C/AUdZ6tkk1688j9plQ5Gc+HAMUcga1lvMQZXnsvwXXbDgE7qg/RSLbxH+N8981hWSuolpKvaVh1/bd0jh4QL570SRDAiu0aoLKeyD/JUkGv8Z9k0I2SHR7ype8EqufjHLS4nz3tZdgQvLjYCS4YYSJ+tPPI/PJAQceVnk0S1QTkUI+1p5oUGQiGydPjD X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(136003)(396003)(346002)(376002)(230922051799003)(186009)(82310400011)(1800799012)(64100799003)(451199024)(40470700004)(46966006)(36840700001)(2906002)(5660300002)(8936002)(8676002)(4326008)(40460700003)(40480700001)(70586007)(70206006)(316002)(54906003)(6916009)(6666004)(1076003)(107886003)(478600001)(7696005)(2616005)(82740400003)(26005)(336012)(426003)(36860700001)(7636003)(36756003)(86362001)(356005)(83380400001)(41300700001)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 16:25:54.3103 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f7f97bc0-16dc-4930-a636-08dc1dc24db7 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5670 Received-SPF: softfail client-ip=2a01:111:f403:2416::601; envelope-from=avihaih@nvidia.com; helo=NAM11-CO1-obe.outbound.protection.outlook.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Use the new TLS upgrade API for main migration channel and remove the old TLS code. Signed-off-by: Avihai Horon --- migration/tls.h | 3 --- migration/channel.c | 24 +++++++++++++++++------- migration/tls.c | 36 ------------------------------------ migration/trace-events | 3 --- 4 files changed, 17 insertions(+), 49 deletions(-) diff --git a/migration/tls.h b/migration/tls.h index 514529ff38..a6babbfa14 100644 --- a/migration/tls.h +++ b/migration/tls.h @@ -32,9 +32,6 @@ QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc, const char *hostname, Error **errp); -void migration_tls_channel_connect_main(MigrationState *s, QIOChannel *ioc, - const char *hostname, Error **errp); - typedef void (*MigTLSConCallback)(QIOChannel *ioc, void *opaque, Error *err); /** diff --git a/migration/channel.c b/migration/channel.c index 041a63eb21..4022b2c9b8 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -50,6 +50,14 @@ void migration_channel_process_incoming(QIOChannel *ioc) } } +static void migration_channel_tls_handshake_main(QIOChannel *ioc, void *opaque, + Error *err) +{ + MigrationState *s = opaque; + + migration_channel_connect(s, ioc, NULL, err); + object_unref(OBJECT(ioc)); +} /** * @migration_channel_connect - Create new outgoing migration channel @@ -69,14 +77,16 @@ void migration_channel_connect(MigrationState *s, if (!error) { if (migrate_channel_requires_tls_upgrade(ioc)) { - migration_tls_channel_connect_main(s, ioc, hostname, &error); - - if (!error) { - /* tls_channel_connect will call back to this - * function after the TLS handshake, - * so we mustn't call migrate_fd_connect until then + /* Save hostname into MigrationState for handshake */ + s->hostname = g_strdup(hostname); + if (migration_tls_channel_connect( + ioc, "main", hostname, migration_channel_tls_handshake_main, + s, false, &error)) { + /* + * migration_channel_tls_handshake_main will call back to this + * function after the TLS handshake, so we mustn't call + * migrate_fd_connect until then. */ - return; } } else { diff --git a/migration/tls.c b/migration/tls.c index e6a0349bd1..99c71e4fb6 100644 --- a/migration/tls.c +++ b/migration/tls.c @@ -97,24 +97,6 @@ void migration_tls_channel_process_incoming(MigrationState *s, NULL); } - -static void migration_tls_outgoing_handshake_main(QIOTask *task, - gpointer opaque) -{ - MigrationState *s = opaque; - QIOChannel *ioc = QIO_CHANNEL(qio_task_get_source(task)); - Error *err = NULL; - - if (qio_task_propagate_error(task, &err)) { - trace_migration_tls_outgoing_handshake_main_error( - error_get_pretty(err)); - } else { - trace_migration_tls_outgoing_handshake_main_complete(); - } - migration_channel_connect(s, ioc, NULL, err); - object_unref(OBJECT(ioc)); -} - QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc, const char *hostname, Error **errp) @@ -134,24 +116,6 @@ QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc, return qio_channel_tls_new_client(ioc, creds, hostname, errp); } -void migration_tls_channel_connect_main(MigrationState *s, QIOChannel *ioc, - const char *hostname, Error **errp) -{ - QIOChannelTLS *tioc; - - tioc = migration_tls_client_create(ioc, hostname, errp); - if (!tioc) { - return; - } - - /* Save hostname into MigrationState for handshake */ - s->hostname = g_strdup(hostname); - trace_migration_tls_outgoing_handshake_main_start(hostname); - qio_channel_set_name(QIO_CHANNEL(tioc), "migration-tls-outgoing"); - qio_channel_tls_handshake(tioc, migration_tls_outgoing_handshake_main, s, - NULL, NULL); -} - typedef struct { QIOChannelTLS *tioc; MigTLSConCallback callback; diff --git a/migration/trace-events b/migration/trace-events index 09dd342d37..80c3c20faa 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -325,9 +325,6 @@ migration_socket_outgoing_connected(const char *hostname) "hostname=%s" migration_socket_outgoing_error(const char *err) "error=%s" # tls.c -migration_tls_outgoing_handshake_main_start(const char *hostname) "hostname=%s" -migration_tls_outgoing_handshake_main_error(const char *err) "err=%s" -migration_tls_outgoing_handshake_main_complete(void) "" migration_tls_outgoing_handshake_start(const char *hostname, const char *name) "hostname=%s, name=%s" migration_tls_outgoing_handshake_error(const char *name, const char *err) "name=%s, err=%s" migration_tls_outgoing_handshake_complete(const char *name) "name=%s" From patchwork Thu Jan 25 16:25:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13531230 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4A275C47422 for ; Thu, 25 Jan 2024 16:27:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT2YJ-0002Ka-Ky; Thu, 25 Jan 2024 11:26:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YF-0002J0-QT for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:03 -0500 Received: from mail-mw2nam10on20601.outbound.protection.outlook.com ([2a01:111:f403:2412::601] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YC-0000SW-Mp for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:02 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IGDNYCvPKxzZm+xqPBVU4D8JPN4rNRTJMQqCokNW+MdVqCUtRKMrvFIfgIZYVKO86TRz+tWkqfWOEUqpiLk5CdPAX3dR+8k0IzSzywgpXio9oMnu19Ni5NB6aCwCzUAlKRpmJqjC0VqOa/Gc5pVleBPQN8xM8r2MOOvIrgP9yP90OGYarwHwfJupIsXARGbu5hdH+pAIbB4S6ju12Eq373esaPC1CDbl7OjRmftE1Zcj7XC6E/VFv9oj03/4t7sCR8UPqjN6Ig7peM7W8j0OAfkI0pjvBqibZXnnuS+jUpssPXhPim5f/12r2xQ6AQfxKs64ekBm7wNgjINSNDCPgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=12XVcAfF7uB2cuFsxerhEBHJIXsw/3ZrNlDzkpyOtb8=; b=BSH+mz7u8D4o2lDdNOgQtEwvAmnshwuWcpo1dtlWKujWmjjbSLmMHFKKfHS4bNitZwHCtyzp1ABRC/0DrLPT/SAnwEcU8gs3jW4/QDKtp/FgWlE1UJ3UJyadzGdgUWMimIp+WxT0oWTaOxOLNr+dcoaI+oooGmtT2EJ1j5LsO+xnrHAEkeC6eXIdMFxAH1N7SYiWRTn68zd7XkbloLbPePnuf/LLaIDiRD0T+/2eqEd3kIczUPbWVW0F6glLlH2U2Ihv5fhhimiTBuGeVT+7GfuHBk0WQ1OJ9Mk5CdwzAEjhdwTqLeCloAL+1m2NfJigVimljaPfLvzsTLOplbLcNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=12XVcAfF7uB2cuFsxerhEBHJIXsw/3ZrNlDzkpyOtb8=; b=jFgxkzeJt5GNb6CRnIG/wFAY3xbr1oVtJEQccSr+NqmHSE8QYgsY2neyp0McxwjE2hzRQGfYw0vAg9RxHcDSpnYUS/yUipleUFr4UBYy33Sp3TdDwjl5rBBhScSeNembbLAQfAjLtSamWqQJe7cGlLmjub1BRCVngtbI3HS8agLIyk8Xnog84GaEkKu3IARJy3DHEo6LfuSen/IDK9wohB5FPC/aQPKMOB8pdObqh8FCn9GJ2Gn9R8dhiclXnDUPZkhxYFXUM7yqKpXeCrjlM1jG0HkvCy+cMnCB41CvBsnBmCBUgaIlcGQ/vmJe4OYFbL4XGIfQeZqbOOxpxuAb0A== Received: from DM6PR17CA0027.namprd17.prod.outlook.com (2603:10b6:5:1b3::40) by CY5PR12MB6083.namprd12.prod.outlook.com (2603:10b6:930:29::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27; Thu, 25 Jan 2024 16:25:55 +0000 Received: from CY4PEPF0000E9DB.namprd05.prod.outlook.com (2603:10b6:5:1b3:cafe::a1) by DM6PR17CA0027.outlook.office365.com (2603:10b6:5:1b3::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22 via Frontend Transport; Thu, 25 Jan 2024 16:25:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by CY4PEPF0000E9DB.mail.protection.outlook.com (10.167.241.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.16 via Frontend Transport; Thu, 25 Jan 2024 16:25:55 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:46 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:45 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 25 Jan 2024 08:25:44 -0800 From: Avihai Horon To: CC: Peter Xu , Fabiano Rosas , "Avihai Horon" Subject: [PATCH 09/17] migration/multifd: Use the new TLS upgrade API for multifd channels Date: Thu, 25 Jan 2024 18:25:20 +0200 Message-ID: <20240125162528.7552-10-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240125162528.7552-1-avihaih@nvidia.com> References: <20240125162528.7552-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9DB:EE_|CY5PR12MB6083:EE_ X-MS-Office365-Filtering-Correlation-Id: 025efc11-0127-4605-bc28-08dc1dc24e4c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Bg1f2xpffwmjthPoczxtQXHBC9bYulYJ8C83SWiFdQcddSuYwdCmbhmxB7KQ51uES6zLKi8uJtlI3NfPyAMAiomoeFCDFTDUpKe1aNDZ+VNsW/QE5o9plW50jw2W8rhr0YbHh1JuLsLImbWhHAq6CqfpYpi65kasnzQ+SevW/UDje9Y7xddbeP0v+YFpgzwvp89mwhgdEyId07A4DPgrNCu0AzE4h9eS513WAZL2QGa0AhN+t3YjFaTkYY1f1ym3geKgkXe2PBSxN/AiCCE0WHwgIxm13RWVbYyqtTfAaRKIAHKQq7BHzdmB9dgrZ9JN+ZwK8O22WG2V1IKXNR3sM77NULU/tJAvnQ+RqewlwkpcNJzJ1pyuFXDeFE1u8ozSrWT03VkEqB/ymtawYl/HyO9F3Vz+QjglRmV1Caf75mngq1SCPYMxd/EQ7BW+bDCMStz/pt0lez5fg6WXGaGiKVC1geSL6oBWt9/7i9aNTDAmZkoMnPakKug0XKpDrpZmKBFHxsbtczILjf8FR7Nnmbe+ABCnjAAjss1zrBNHfq08B1aIoFyaUvZRgCO8bGzNtH7QCH5XvpWwGUBOgNjTOcQW1Z14Q8yszwwwV6OcomIn70aCWUdhyTBekKO4LHcYFq99BBWK70VlnYF+csdWnY3lCjAzC4XYiPf5IJH/PlikvOnS55ASIKNs+0kUn36/e3suaehq7bzLYovOoGCIBU8bBbnHic1PhbGCdiAR7OJx02SFQJXMCApXxVZOOqJ9 X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(136003)(376002)(39860400002)(396003)(346002)(230922051799003)(82310400011)(186009)(64100799003)(451199024)(1800799012)(36840700001)(46966006)(40470700004)(4326008)(8676002)(8936002)(2906002)(82740400003)(2616005)(7696005)(36860700001)(6666004)(47076005)(70586007)(70206006)(316002)(5660300002)(83380400001)(6916009)(54906003)(36756003)(41300700001)(7636003)(86362001)(40460700003)(40480700001)(356005)(426003)(336012)(1076003)(107886003)(478600001)(26005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 16:25:55.3186 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 025efc11-0127-4605-bc28-08dc1dc24e4c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9DB.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6083 Received-SPF: softfail client-ip=2a01:111:f403:2412::601; envelope-from=avihaih@nvidia.com; helo=NAM10-MW2-obe.outbound.protection.outlook.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Use the new TLS upgrade API for multifd channels and remove the old TLS code. Note that p->c is now set only after a successful TLS connection, so need to call object_unref() on QIOChannelTLS in case of error in multifd_tls_outgoing_handshake() (previously it was done in multifd_save_cleanup()). Signed-off-by: Avihai Horon --- migration/multifd.c | 66 ++++++++++-------------------------------- migration/trace-events | 3 -- 2 files changed, 16 insertions(+), 53 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index f0c216f4f9..f4d8cd0023 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -794,22 +794,17 @@ static bool multifd_channel_connect(MultiFDSendParams *p, QIOChannel *ioc, Error **errp); -static void multifd_tls_outgoing_handshake(QIOTask *task, - gpointer opaque) +static void multifd_tls_outgoing_handshake(QIOChannel *ioc, gpointer opaque, + Error *err) { MultiFDSendParams *p = opaque; - QIOChannel *ioc = QIO_CHANNEL(qio_task_get_source(task)); - Error *err = NULL; - if (!qio_task_propagate_error(task, &err)) { - trace_multifd_tls_outgoing_handshake_complete(ioc); + if (!err) { if (multifd_channel_connect(p, ioc, &err)) { return; } } - trace_multifd_tls_outgoing_handshake_error(ioc, error_get_pretty(err)); - migrate_set_error(migrate_get_current(), err); /* * Error happen, mark multifd_send_thread status as 'quit' although it @@ -820,59 +815,30 @@ static void multifd_tls_outgoing_handshake(QIOTask *task, qemu_sem_post(&p->sem_sync); qemu_sem_post(&p->create_sem); error_free(err); -} - -static void *multifd_tls_handshake_thread(void *opaque) -{ - MultiFDSendParams *p = opaque; - QIOChannelTLS *tioc = QIO_CHANNEL_TLS(p->c); - - qio_channel_tls_handshake(tioc, - multifd_tls_outgoing_handshake, - p, - NULL, - NULL); - return NULL; -} - -static bool multifd_tls_channel_connect(MultiFDSendParams *p, - QIOChannel *ioc, - Error **errp) -{ - MigrationState *s = migrate_get_current(); - const char *hostname = s->hostname; - QIOChannelTLS *tioc; - - tioc = migration_tls_client_create(ioc, hostname, errp); - if (!tioc) { - return false; - } - object_unref(OBJECT(ioc)); - trace_multifd_tls_outgoing_handshake_start(ioc, tioc, hostname); - qio_channel_set_name(QIO_CHANNEL(tioc), "multifd-tls-outgoing"); - p->c = QIO_CHANNEL(tioc); - qemu_thread_create(&p->thread, "multifd-tls-handshake-worker", - multifd_tls_handshake_thread, p, - QEMU_THREAD_JOINABLE); - return true; } static bool multifd_channel_connect(MultiFDSendParams *p, QIOChannel *ioc, Error **errp) { - trace_multifd_set_outgoing_channel( - ioc, object_get_typename(OBJECT(ioc)), - migrate_get_current()->hostname); + MigrationState *s = migrate_get_current(); + + trace_multifd_set_outgoing_channel(ioc, object_get_typename(OBJECT(ioc)), + s->hostname); if (migrate_channel_requires_tls_upgrade(ioc)) { /* - * tls_channel_connect will call back to this - * function after the TLS handshake, - * so we mustn't call multifd_send_thread until then + * multifd_tls_outgoing_handshake will call back to this function after + * the TLS handshake, so we mustn't call multifd_send_thread until then. */ - return multifd_tls_channel_connect(p, ioc, errp); + if (migration_tls_channel_connect(ioc, p->name, s->hostname, + multifd_tls_outgoing_handshake, p, + true, errp)) { + object_unref(OBJECT(ioc)); + return true; + } + return false; } qio_channel_set_delay(ioc, false); diff --git a/migration/trace-events b/migration/trace-events index 80c3c20faa..2c328326e8 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -144,9 +144,6 @@ multifd_send_sync_main_wait(uint8_t id) "channel %u" multifd_send_terminate_threads(bool error) "error %d" multifd_send_thread_end(uint8_t id, uint64_t packets, uint64_t normal_pages) "channel %u packets %" PRIu64 " normal pages %" PRIu64 multifd_send_thread_start(uint8_t id) "%u" -multifd_tls_outgoing_handshake_start(void *ioc, void *tioc, const char *hostname) "ioc=%p tioc=%p hostname=%s" -multifd_tls_outgoing_handshake_error(void *ioc, const char *err) "ioc=%p err=%s" -multifd_tls_outgoing_handshake_complete(void *ioc) "ioc=%p" multifd_set_outgoing_channel(void *ioc, const char *ioctype, const char *hostname) "ioc=%p ioctype=%s hostname=%s" # migration.c From patchwork Thu Jan 25 16:25:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13531240 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A40F0C47258 for ; Thu, 25 Jan 2024 16:29:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT2YK-0002Kh-9Y; Thu, 25 Jan 2024 11:26:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YH-0002Jw-Eh for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:05 -0500 Received: from mail-dm6nam12on20601.outbound.protection.outlook.com ([2a01:111:f403:2417::601] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YF-0000TE-MT for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:05 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jtm+ay/FTkDBLZ1zzKr2UIi0Irk/Fiy+3CO4Th8iQmUTm8hHlnazUOkww3IfxYgzoFy1+6iIjj3f3+qoaZJ1v7/GdqdIbp54leZHGXIsaoGzfFPIfNzfkA/HJv5hKPEaRCQCFHEVVVAedUZ4Mhr7Ev3WoaeuiyBGibHdJM8BNhbuwEZ3gWYlPAOUuNt2qvp79Vx00eMfnYisn8ONVbhJc6ZFfhevwEfFjP2oZ460mGCusxJMwGlVssXnKVV+R+carTkzb9EBulXKay21ywT1cBb+CeojIDmUYKt494CKtfqicK5XKNGVwuQ8VgYiSzlQN5IrA3P4svgFr3VJ9EjqCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hMGDN5kBfvfGqyo6Ds6NGGxr7RB3zVAKsYBNcJiHQ+I=; b=TzaluZxHBbTcS72TBLn070+t6xJlpRHT2Ls0SzmNtrWJM0McKfLB67e4elpUKhZr6zjHG6gRtutcUWwgKPEW/au4b7j5xHohFirFH3RFxCZJUBZot0UZMUW3RdmjV38iU5/w+cgzEVDsLfta+WyYYKrZopc7MQuoShimnxhIBiXVmsjqf6qB7O+ueYedHv/tZI/Xk3J8uoA1pJqk+BKG8IJyRhDEiKgpyka/N4RiSEDqaKz4IXCg8PI5qqrsMI7lPOCdfyotRRi2ZEkCj0NKGFNjnQOoV+iMrpeKEHSo9tM+F1p8Kzgafvt3H/oD11Hk3NRzKoz3/U18Vb92DPV9pA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hMGDN5kBfvfGqyo6Ds6NGGxr7RB3zVAKsYBNcJiHQ+I=; b=aMPZyFL2Go9qTuGaueuRmxFp8lHICcIn0coSZ4jPzD3cRP17KCgQGEuTZskI0uZq8VMppjJy/DeOdHT0SZzt6SRhsCmCvx+O96JhdbyNH/oOMTcwQ+3I2qpz5bZRLSLdDbTTPiUtz+MpPIrppkzFAVNVXMzh3TijTU2FUCaOR5lUBdm0N2tBzDHKojXCjpN7Fk/nxtFKYzL5A43hQiT1iwizkxh8MEsfniiXMnA39zu31NgE+X0D1sfizeKciQisYZWfyqP1k5vLvYJ7l8RZ28eUqPPSYuUGHOgLbq4sk0rJz6gSGS33ymxvobvkkUUwCdqXhLxkQ4HgF/9r4uTwcA== Received: from DM6PR07CA0082.namprd07.prod.outlook.com (2603:10b6:5:337::15) by IA1PR12MB7495.namprd12.prod.outlook.com (2603:10b6:208:419::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Thu, 25 Jan 2024 16:25:57 +0000 Received: from CY4PEPF0000E9DA.namprd05.prod.outlook.com (2603:10b6:5:337:cafe::4f) by DM6PR07CA0082.outlook.office365.com (2603:10b6:5:337::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27 via Frontend Transport; Thu, 25 Jan 2024 16:25:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by CY4PEPF0000E9DA.mail.protection.outlook.com (10.167.241.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.16 via Frontend Transport; Thu, 25 Jan 2024 16:25:57 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:47 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:47 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 25 Jan 2024 08:25:46 -0800 From: Avihai Horon To: CC: Peter Xu , Fabiano Rosas , "Avihai Horon" Subject: [PATCH 10/17] migration/postcopy: Use the new TLS upgrade API for preempt channel Date: Thu, 25 Jan 2024 18:25:21 +0200 Message-ID: <20240125162528.7552-11-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240125162528.7552-1-avihaih@nvidia.com> References: <20240125162528.7552-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9DA:EE_|IA1PR12MB7495:EE_ X-MS-Office365-Filtering-Correlation-Id: 7887305b-0140-4651-5116-08dc1dc24f8c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l5lPSuDEljOKW0cG9F3D/5xMt1vQFsj8RnuyaHteazVSLxoSs8pKlRx4YbyUwJUXgna1iPD2WN1Qkr+uj2Lky/NselMEVhsmItKb2kHJF+n6XVhl2yii/1MhT2Vm79RG/Ngy9EWBXi/QQg5b/BkhMXleY64xjiJoEPv7+ZxxobAWNdeR3CjVy/DPwre+CVKD4qbf2VCBgS60h9gYa8r7LzPxPQ3v8OCH5ekV9iVCfnQZZbTnMDwTWjPJS74GKqJljfU1yxPxZGOrD/DBY+bH+BLAUsOuR7iMkPgI2w90exQSrBtHAqScS4c1kkvOcpeNbkrjqtRf1mBZbJx5VDbctBq6mmS/yWW49MF1FYFnujlhaNpf2jS/XxyCcy+/BrahHM2ibOy9zFhv0VkwVnObpwH8BrYgOkCG0ta/jhGw+64N6FCbQxnS4C11nOQ34ylnAcV1C+U0guzJ+rs01N0dT+fmU6fyNhX1/z6kwUoK8TrTDFNkYbfthG0IH4nVnooN7sj2UHXFvZm0aFcerbbMnhjmp6/yUR1ytxQQPdHl+DWDtmmny/JGl4iIuk7aMcRvh9WXl/Ys0sQmP+dUsl/2H9hjMo0Oht+ABFPBN35xo6TJkQE4345sF5M6/gdvd5e4vxh9zd1G6xmog45rg+BW6MrdH7FBqx7yFREpuqJ0Q3Iglsht2GJ6nQimOEkwhmRzrHalfLZRnzrZlCjrCOfj7qQVfvWm8fz6lHt91qAB66HLzxalruBhTJAN4i8hrD7T X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(396003)(346002)(136003)(376002)(230922051799003)(451199024)(1800799012)(82310400011)(186009)(64100799003)(40470700004)(46966006)(36840700001)(2906002)(5660300002)(82740400003)(7636003)(36756003)(478600001)(86362001)(356005)(1076003)(83380400001)(7696005)(107886003)(41300700001)(2616005)(47076005)(36860700001)(426003)(6666004)(26005)(336012)(6916009)(54906003)(316002)(8676002)(8936002)(4326008)(70586007)(70206006)(40460700003)(40480700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 16:25:57.4130 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7887305b-0140-4651-5116-08dc1dc24f8c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9DA.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7495 Received-SPF: softfail client-ip=2a01:111:f403:2417::601; envelope-from=avihaih@nvidia.com; helo=NAM12-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Use the new TLS upgrade API for postcopy preempt channel and remove old TLS code. Signed-off-by: Avihai Horon --- migration/postcopy-ram.c | 20 +++++++------------- migration/trace-events | 1 - 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 5408e028c6..3df937e7da 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -1644,15 +1644,13 @@ postcopy_preempt_send_channel_done(MigrationState *s, qemu_sem_post(&s->postcopy_qemufile_src_sem); } -static void -postcopy_preempt_tls_handshake(QIOTask *task, gpointer opaque) +static void postcopy_preempt_tls_handshake(QIOChannel *ioc, gpointer opaque, + Error *err) { - g_autoptr(QIOChannel) ioc = QIO_CHANNEL(qio_task_get_source(task)); MigrationState *s = opaque; - Error *local_err = NULL; - qio_task_propagate_error(task, &local_err); - postcopy_preempt_send_channel_done(s, ioc, local_err); + postcopy_preempt_send_channel_done(s, ioc, err); + object_unref(ioc); } static void @@ -1660,7 +1658,6 @@ postcopy_preempt_send_channel_new(QIOTask *task, gpointer opaque) { g_autoptr(QIOChannel) ioc = QIO_CHANNEL(qio_task_get_source(task)); MigrationState *s = opaque; - QIOChannelTLS *tioc; Error *local_err = NULL; if (qio_task_propagate_error(task, &local_err)) { @@ -1668,14 +1665,11 @@ postcopy_preempt_send_channel_new(QIOTask *task, gpointer opaque) } if (migrate_channel_requires_tls_upgrade(ioc)) { - tioc = migration_tls_client_create(ioc, s->hostname, &local_err); - if (!tioc) { + if (!migration_tls_channel_connect(ioc, "preempt", s->hostname, + postcopy_preempt_tls_handshake, s, + false, &local_err)) { goto out; } - trace_postcopy_preempt_tls_handshake(); - qio_channel_set_name(QIO_CHANNEL(tioc), "migration-tls-preempt"); - qio_channel_tls_handshake(tioc, postcopy_preempt_tls_handshake, - s, NULL, NULL); /* Setup the channel until TLS handshake finished */ return; } diff --git a/migration/trace-events b/migration/trace-events index 2c328326e8..9a8ec67115 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -297,7 +297,6 @@ postcopy_request_shared_page(const char *sharer, const char *rb, uint64_t rb_off postcopy_request_shared_page_present(const char *sharer, const char *rb, uint64_t rb_offset) "%s already %s offset 0x%"PRIx64 postcopy_wake_shared(uint64_t client_addr, const char *rb) "at 0x%"PRIx64" in %s" postcopy_page_req_del(void *addr, int count) "resolved page req %p total %d" -postcopy_preempt_tls_handshake(void) "" postcopy_preempt_new_channel(void) "" postcopy_preempt_thread_entry(void) "" postcopy_preempt_thread_exit(void) "" From patchwork Thu Jan 25 16:25:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13531239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F2B4AC48260 for ; Thu, 25 Jan 2024 16:29:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT2YK-0002LH-QF; Thu, 25 Jan 2024 11:26:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YI-0002KH-RO for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:06 -0500 Received: from mail-dm6nam12on20600.outbound.protection.outlook.com ([2a01:111:f403:2417::600] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YF-0000T4-O5 for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:06 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LiAcFwp88yrzx3DqWf/E94MfpxFn6rRev3Nhmi2OI9aQ0D+xG7VRwDEXo4ps1/5tPnQavBUXS8dYIPhc8YoMhUjZuEBuiE5o1SBfLzhvCSyYwIfLD9S8tqDzDaZYIleZ6gdBD/5/EqnqdEZcn2NcMMgYSHSV7TY7QQ3bilNob7OlIYaJ/+iBJtptgicYBVolQZQbLux4Q2QOhasNllim3C6G2s0mUTjHV/azuJw/FUu3TI6iaWhxyhuKJN1wdGXjrYPAt/S/pyYeeSgNPwf7/N2oI5NYHtZnwCvjMt9wlHaL43gZxDEpddKYk9rQVl6sjc2Vsr/SI1LnAUQBgsO27w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ba7dWjEyzyQAOMj9XAhXFtUmuD9yH6itYapvDIa1+To=; b=JAPVdFxECBuWdVXuucfaRgAwkyBUbRiCR1/XH8leOL4Dq3ltGdP1vFAF4T5+RFjMuJAEKLC9PVA4o7iDal/zqtMswDFBVThG+vboLEAQ4yJVaO3Vql5syqYmeCT7z5nvjuWEIB8k4Q1p5d3tB9cGmO0moCrM1R7UX+uIutuMHRWhnYCzWGcmXFelkcMQB4sFMV3quMlKRpWLmAaTKzFAjJQ3ShbmfBjoZ3LN7wf05x/520NQfKrx1QqTwRDHVJHow3GxjS1nBuWMjZMZqI3L5hPiu3iw2z1qj4wn/Hd+BFgrrmZtfsV9IjzNoGfiuyEjfUfFr1rUIXhwqMh132PRYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ba7dWjEyzyQAOMj9XAhXFtUmuD9yH6itYapvDIa1+To=; b=BrsqJawmlSAlgpl5JwwZ5sApgm8dE09YwYwUQrhyyiBJ9Pz1LxoG3YrEEUk6x0litMqetVKFV2n6PBroNotZ+NsJEYraxWyCJ6FjYFXkDkbp7pTghgphNrjIeUg+k2tMZBE4KoLHf7kfOzhLN1rTVgr5IeTBMDQGp3Mr/B9hWqui+RQs3EB6DmivsZUGJu0g1kouKSVaM01ODdiNLHIwcR5vXfw1rtw8jNpoFYcuRUvtLix9PcYpd/8fMYB5Wi4ldlv8kubsI4bNgUMB4paXKSD6yon+CuCgrNSufHpBr9Ygb65RRLW73tv0GPLZmZuNdGLuk4KV61wVLbHSl+TgcQ== Received: from DM5PR07CA0065.namprd07.prod.outlook.com (2603:10b6:4:ad::30) by CY5PR12MB6130.namprd12.prod.outlook.com (2603:10b6:930:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27; Thu, 25 Jan 2024 16:25:58 +0000 Received: from DS3PEPF000099DC.namprd04.prod.outlook.com (2603:10b6:4:ad:cafe::72) by DM5PR07CA0065.outlook.office365.com (2603:10b6:4:ad::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.26 via Frontend Transport; Thu, 25 Jan 2024 16:25:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DS3PEPF000099DC.mail.protection.outlook.com (10.167.17.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.16 via Frontend Transport; Thu, 25 Jan 2024 16:25:57 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:49 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:49 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 25 Jan 2024 08:25:48 -0800 From: Avihai Horon To: CC: Peter Xu , Fabiano Rosas , "Avihai Horon" Subject: [PATCH 11/17] migration/tls: Make migration_tls_client_create() static Date: Thu, 25 Jan 2024 18:25:22 +0200 Message-ID: <20240125162528.7552-12-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240125162528.7552-1-avihaih@nvidia.com> References: <20240125162528.7552-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DC:EE_|CY5PR12MB6130:EE_ X-MS-Office365-Filtering-Correlation-Id: 62a66719-4f3f-4f95-14d4-08dc1dc24fef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vPh7GKbpWsvjzGn/iIfd/2SVrjnfyC7ABgTlw7RIlmV1YDxPE3Nbj4xefTJDCC6eDth+vWPJTOp3HdEQk+6aNGDVnCGFSHJEGMQVwQmqeAxCT3cSW/lu8VgJ6tsfzFO4T0S+Snf+GA0p0m9vJPsMn+xW4T+yU3jAwGe7I65xe/jauqbjHb+KmkNm9Xs022gn+oQWeihiO8R8C6clEOp9eAJX7poHazM6EPVdXX7AqqQf3cCSUEy25vbPI2z/QRwMKRLrUBOCKyA57UoRb3QWnVa8a+BVwenY+FQJIk7/y5k3Lg2bwVOb1FnIGP24XKVy6YA8ZIvWr/BxboGFa41U9Ttwh9jvNL2q5v47JgOOHkn2WgAtgbkn3g3CdqiLBIIxJneSDWDWLLAYzv/+2ruRszwxekkokwjFtWWJbZFH2JwxuykbAr9jXV4gDuBkLrQflLcSSBvleULf3gqlgbJPmj6uLn6yFyROul77t48kFuWWJdP6evxF5W8U4gW9npIsRg3kVpmx7P11aaG6V//u2cOX+BtXrtOEaC/VuDEv/BLd8T4Xrdes23nJTdU+te3rkbkNaqq69cqWPrVncWJf4M0zbMoKtzKT8sR+lF7DqMNA7LQlt4UeJj9FQkPObu55MLcfwdZ9e4zsu+zjYReI9j7M4Lgqpj9qFt72obwjUoQF2O5rxsgBn0FDCrbWttrH75swt2N5vaKn9lajt56eD5BwGpuHhhjfsYCmDbZbIQTXNl5NXe3tWuYC5/UmRvaXm2Nu5wUpGVx6B0avLuC4vUWdd+gx1BQhEsrbVKNkcag= X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(376002)(39860400002)(346002)(396003)(136003)(230173577357003)(230273577357003)(230922051799003)(186009)(1800799012)(64100799003)(82310400011)(451199024)(36840700001)(46966006)(40470700004)(336012)(40480700001)(40460700003)(41300700001)(4326008)(36860700001)(7636003)(426003)(356005)(82740400003)(107886003)(2616005)(70206006)(6916009)(54906003)(1076003)(316002)(70586007)(83380400001)(2906002)(8676002)(26005)(8936002)(6666004)(86362001)(7696005)(5660300002)(478600001)(36756003)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 16:25:57.9666 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 62a66719-4f3f-4f95-14d4-08dc1dc24fef X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6130 Received-SPF: softfail client-ip=2a01:111:f403:2417::600; envelope-from=avihaih@nvidia.com; helo=NAM12-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org migration_tls_client_create() is not used externally by anyone. Make it static. Signed-off-by: Avihai Horon --- migration/tls.h | 4 ---- migration/tls.c | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/migration/tls.h b/migration/tls.h index a6babbfa14..87a79b4102 100644 --- a/migration/tls.h +++ b/migration/tls.h @@ -28,10 +28,6 @@ void migration_tls_channel_process_incoming(MigrationState *s, QIOChannel *ioc, Error **errp); -QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc, - const char *hostname, - Error **errp); - typedef void (*MigTLSConCallback)(QIOChannel *ioc, void *opaque, Error *err); /** diff --git a/migration/tls.c b/migration/tls.c index 99c71e4fb6..8f427ecc98 100644 --- a/migration/tls.c +++ b/migration/tls.c @@ -97,7 +97,7 @@ void migration_tls_channel_process_incoming(MigrationState *s, NULL); } -QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc, +static QIOChannelTLS *migration_tls_client_create(QIOChannel *ioc, const char *hostname, Error **errp) { From patchwork Thu Jan 25 16:25:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13531226 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7143DC47422 for ; Thu, 25 Jan 2024 16:26:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT2YK-0002LK-Rh; Thu, 25 Jan 2024 11:26:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YJ-0002KR-7Z for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:07 -0500 Received: from mail-bn8nam12on20600.outbound.protection.outlook.com ([2a01:111:f403:2418::600] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YF-0000T3-Pn for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:06 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TwI5RxOMEbA3u16IPv+rS86uE4qwl6g5VgO7c/VYQzgN+8YKSZprbMmFtbXC8Py+mBJUy18Px1C9kT6mmtmwzkIXBkromTjPGZsR29SNFEpcG0C0T7dJcd7WwlmFHYrGVJjBPtMhS7zmUjrmGxVAfc78bMm90qUCrLNMIkgHSKehzlkG/VohZDYj3keROK6yIhm0+sa0XBEUlCqrG7bwVnwMRGy7W4GyhctrZXSWNGZ9P7yVWa5sZHKodsklvEm6cml2k8EgRWsLWbfmDGHBPiYtX5XpvY1EjW6eYRtb7LRT04yhecmGpWqOFTDiznFckFRYp3WKpXxYbVmJhiHpgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0Ocf0sCT8Krz5mSRKDRKw+1vkobmMVkdNjftn0d7hY0=; b=XVFtz+4d4iKx1wlazdTXHKIGqCy3Q4f0IVMtk21RW736yjyldYSERNdG8IWJbEBSiZJzgTrnlU2536cUR9C8DyaHQSS0TeSYGocZz5Ru7KASRscEmhAkECqTA73DXvOnny49css+A806MXRAK4hw8DowSWMNMyAOfrE9K2V0Ey+IhZ5cg1Q5WxTjRVZpkwYHouf+QHkOF9rRVaB4bVRyW0DXrMCqP6ceUiiA6qic0wz30qZ72mTDcgFUT5iYFets0RXMH9yjQSSDUFzAWcUHYeznovGeQFjYIvgnMDHKFEf7snWObZ0jGRwof+OD5uzm4VWVco8G3w6HlDlQ4U6XNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0Ocf0sCT8Krz5mSRKDRKw+1vkobmMVkdNjftn0d7hY0=; b=iIJHSZANvH6fXVGb9cj0Q6Ica6MQbwIkZuY8u3gxZRrkLvHCtkkQ0+pSQz5EhPSkfzjmirs86omi8BJbllKDyi8b95AjxnGOe2vSmLyeBXh2VJxfN6Dvcwz5huOxQC4Wg2UzyecQJdkmwPjMECKngEIdpQuTzUondHZ95ME10Gwlv18Fpc8grkFIliTFgwhi63alNrXeqHt77o82eTWLa5odAb1+sqbuz02ccLGgyeQ8REw8s+qiF6y850a0NQimG7uUYVrvqnEKnioZ7iT4mjq6cPFiX0QypZ9StCRLRTlf1a4nJ6vnodbFkLthQU9SkvbDv0/0ySFIvSdbaU0kUg== Received: from DM5PR07CA0069.namprd07.prod.outlook.com (2603:10b6:4:ad::34) by IA1PR12MB9063.namprd12.prod.outlook.com (2603:10b6:208:3a9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.37; Thu, 25 Jan 2024 16:25:59 +0000 Received: from DS3PEPF000099DC.namprd04.prod.outlook.com (2603:10b6:4:ad:cafe::92) by DM5PR07CA0069.outlook.office365.com (2603:10b6:4:ad::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27 via Frontend Transport; Thu, 25 Jan 2024 16:25:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DS3PEPF000099DC.mail.protection.outlook.com (10.167.17.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.16 via Frontend Transport; Thu, 25 Jan 2024 16:25:59 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:51 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:50 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 25 Jan 2024 08:25:49 -0800 From: Avihai Horon To: CC: Peter Xu , Fabiano Rosas , "Avihai Horon" Subject: [PATCH 12/17] migration/multifd: Consolidate TLS/non-TLS multifd channel error flow Date: Thu, 25 Jan 2024 18:25:23 +0200 Message-ID: <20240125162528.7552-13-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240125162528.7552-1-avihaih@nvidia.com> References: <20240125162528.7552-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DC:EE_|IA1PR12MB9063:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f592ccd-9e66-4184-e4cf-08dc1dc250a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XXKpo0cbSopFMgmCISfUo7BxtAoceIXl9AFKcp0R942csLL0zd1dLha4c3eMgBd0L5BXahyLrhxyRFcswd+UTS6m+PeyfSwRrLL6CY2Lr2OLu/SpwoIzdG2Gvc21duRunb+KSPrJBajq0vKHLkAsEM8kRsj2prk4ZyL4Ha/m4qwhQrGP9NxPlzO7f0bwd0v64H5Z2LLnk4H5rLibc+tzBajeTL85SsTdK4tBZc554uzVTlgAlPB6grbS7lX7Jx6gqLrW5bE8tmjCIwdlbDW6WK6RAe3lq8WKJr3Gm10jhdi76ysa5biu2FNjF6QkfKftCF6195KNNZQzLH7Q6nnV3p0Z0st47NiXG+4xjrNRKffB04KYs7LV5XH8/DYCBeLm5aeoeqknT99Ztt+BdUVPhfTQsoz9h320UD9gmjtJMkogFd2zks9S5l18DGeBVsqjef1f+sByLDbpJv3NvxvBQ0GQCfE68db74fJCGYDfVfzsY8YAwizLuC+R+EvaU2FhXTh76K98zWebgbfyF8RQO1PPNpbLv4nIopQBVnpCfuP3+vXSd4OTo0io3hxpGBULXI4mg+DEThha4qrvvTWH+b22bJqNO2x8mdu0dYL3uf2fAdRWrVaGDzkBRbbHFhx7doNuODr227ULc1yXN0LQsxU84AcdulmjXrznv/VQFFO2eHHEhD1CbSD0dV12uQgehuZPVTbqIiB05gtg1PBtsrpub7HGTQPFKKvrnVZBUfntVsqwrSxaxhA99I/mY0fj X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(136003)(346002)(376002)(396003)(39860400002)(230922051799003)(82310400011)(64100799003)(186009)(451199024)(1800799012)(46966006)(36840700001)(40470700004)(36860700001)(83380400001)(4326008)(8676002)(356005)(8936002)(82740400003)(86362001)(41300700001)(36756003)(2906002)(7636003)(47076005)(54906003)(5660300002)(316002)(7696005)(107886003)(1076003)(6916009)(40460700003)(40480700001)(70586007)(2616005)(70206006)(478600001)(6666004)(26005)(336012)(426003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 16:25:59.2009 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f592ccd-9e66-4184-e4cf-08dc1dc250a1 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB9063 Received-SPF: softfail client-ip=2a01:111:f403:2418::600; envelope-from=avihaih@nvidia.com; helo=NAM12-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The error flows of TLS and non-TLS multifd channel creation are similar yet they don't share code. Consolidate the flows by using multifd_new_send_channel_cleanup() also in TLS error flow. Signed-off-by: Avihai Horon --- migration/multifd.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index f4d8cd0023..cc9a1182fa 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -794,6 +794,9 @@ static bool multifd_channel_connect(MultiFDSendParams *p, QIOChannel *ioc, Error **errp); +static void multifd_new_send_channel_cleanup(MultiFDSendParams *p, + QIOChannel *ioc, Error *err); + static void multifd_tls_outgoing_handshake(QIOChannel *ioc, gpointer opaque, Error *err) { @@ -805,17 +808,7 @@ static void multifd_tls_outgoing_handshake(QIOChannel *ioc, gpointer opaque, } } - migrate_set_error(migrate_get_current(), err); - /* - * Error happen, mark multifd_send_thread status as 'quit' although it - * is not created, and then tell who pay attention to me. - */ - p->quit = true; - qemu_sem_post(&multifd_send_state->channels_ready); - qemu_sem_post(&p->sem_sync); - qemu_sem_post(&p->create_sem); - error_free(err); - object_unref(OBJECT(ioc)); + multifd_new_send_channel_cleanup(p, ioc, err); } static bool multifd_channel_connect(MultiFDSendParams *p, From patchwork Thu Jan 25 16:25:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13531235 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 89E14C47422 for ; Thu, 25 Jan 2024 16:28:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT2YQ-0002Nw-IR; Thu, 25 Jan 2024 11:26:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YM-0002Ld-10 for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:10 -0500 Received: from mail-mw2nam12on20601.outbound.protection.outlook.com ([2a01:111:f403:200a::601] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YK-0000Ud-FF for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:09 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lXHx0gtNvoxtK656ITuWbqXY9y+qJ8/gDEZhRhtEa7g5fjnfnRc4Zp6x3pttL7TM6br1i/pICDA7Qnuk9cKdoMogtbmF5zhx7S7LaFPRI+NYxhEhHvavTOVzu/IqGAs7Y0UK9YND9cdd1w7Gvv4kUQ0dkccwlTUvsa/hy5L6rMCf6xTI5E4XxIyZM3Ps9BFVFVOCLRnyoJiE8LPYJt6JkjmAUZYI1e7nNn4NG2c06aarHqCxThSks0oY40L/ioLEdz8/bAwbrTXg5XKcy/PAq0LQ4E8tUCABJaa3p6zRxaFK5Stf1d7gp6oxuBRGr+Hov8ZCBTmO8tRyU8Fe7hzP1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KwmzgEVX6nKNGBPsEnFTDyi0KTRJ8ZEj0HC+zADAaq4=; b=b4UYS/TqhRS8o9abjoCCwJ+KF/l/An3kZR47QIjIfQI3/Wig+UYBimTgXOv1Z4Z3r45i4aOn0iZYgkIQsJQtbjY9UZ623fCh5EccyC2gjTBG40KnImr0bj1wjd3mmySiBHimZR4NHht19RnjPpAMeZv5uq+jC3FVabqwScGyrBlzTI2gTroPm6D5M00ypUZCGHV+NJlT5HmMDWB6tVHBH9BuEqn2sHeRIIGiCwWJUtGoRb01ALz82GNAy1QezqhIYNjNm9vzX6dgmWNFYlkB11+4dkxTXcLPZ1yzp5+i3BllJLNYa/elMAxgfJTYMh0NKTpSApn+GYI9DPn1sX9BGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KwmzgEVX6nKNGBPsEnFTDyi0KTRJ8ZEj0HC+zADAaq4=; b=lkSdLCGnXsEBZnRGqop+S/1smm/ZQ9KSz8LnZZTM2lQZxOpqZtVzIsGm3XZO5ldbMWe+covQw9BZWwJXszuU5Gr+JoKZGxHIEn5dNHFt3Ajo2VSlvsmRu3+1YIu4jhjsENM5d3lIgway1uV7MQQ9wSf4QGL+fxgCwwlx1rUMdWTtebVPOAbVue+qk+N3lhCG9Y8IIMuP1M/yd6+uNUzLQAJWjYrniAndkoUYX71PWVLFzFCYOiiM7mDNoqNRP7Imeg9K2E7iNBNA4EIWSkliHImikOmfR9fPeKq/+UYFh7J+5MMc3ZrvgSeDmsh7ZW6uh+rx/XC+3qgTIhtrBllTxQ== Received: from CYZPR12CA0001.namprd12.prod.outlook.com (2603:10b6:930:8b::8) by SN7PR12MB6713.namprd12.prod.outlook.com (2603:10b6:806:273::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Thu, 25 Jan 2024 16:26:03 +0000 Received: from CY4PEPF0000E9DC.namprd05.prod.outlook.com (2603:10b6:930:8b:cafe::1a) by CYZPR12CA0001.outlook.office365.com (2603:10b6:930:8b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27 via Frontend Transport; Thu, 25 Jan 2024 16:26:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by CY4PEPF0000E9DC.mail.protection.outlook.com (10.167.241.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.16 via Frontend Transport; Thu, 25 Jan 2024 16:26:03 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:53 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:52 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 25 Jan 2024 08:25:51 -0800 From: Avihai Horon To: CC: Peter Xu , Fabiano Rosas , "Avihai Horon" Subject: [PATCH 13/17] migration: Store MigrationAddress in MigrationState Date: Thu, 25 Jan 2024 18:25:24 +0200 Message-ID: <20240125162528.7552-14-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240125162528.7552-1-avihaih@nvidia.com> References: <20240125162528.7552-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9DC:EE_|SN7PR12MB6713:EE_ X-MS-Office365-Filtering-Correlation-Id: e3b338b6-61ea-48d0-4ba4-08dc1dc252f3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9FNUenRp3HfKlNm5Hce1hnSx4VEQAGeivIMeIkVbtZfAX9Tqd66PULKXCw/dvJZFflPooglKTFPkdpbkN0EM4DLPrXqLbDJ1Ui0de4kPtoTnqpKnR1R/4pJlv261b7Y7olTWlUuSl7A6mnHfTt8m9znZAfqCeD1V77NWORuUft0r2tT5kjY/Bsx3/H0oXkrp+RU5iKruD5EoUQRHnqmXII4/b4VgSyBHkh7C2YgV4C5bdodufbF3yoIX1jqfpqgjLx0cYTrcInfp9Khc9GEEaPQWhtNQ0P0naLY24VHiLDp/BF7+6FN/iBw0vb5CeIi/vgoDXsqDc7i6V6FQwBynEBv6fU+2SMlVxMIT6RslAUlLINh29xsw0i5HymsxwWnXJC5xxOB+V+1qSjIDsWC1J59SrAQekFGokWHEeK/yZzCdaJhKwrXpwjWhnqNi+yRfwo+uWJauwt28Hwtm+GhhUf/mj4wbC0d7qTG1IUH0rJgzMGyRGt5JUCyq8UOi0NyYwAME0xaicL7/z5vx/fke0zqKpKLj4fqE1IOAhZkb66abHLTZceKLR3mMvjA/HfTAjP1AB9pFiNQgsbWB73wekP+HQHHXMqaVBK3GaQKpIjOW3+BopPBGu4DlM617kvPQNXmun7Mq36yeW3g1f+cbumusTpVGekf1B/XWdlNcdP97tq9/7JsjGF4gN2hRz8QednS94suDOiORlss0E+1JoHOIFaM/8jTTUTCGlFW2gGNeXxPiKhrzBP8WFK4DMQNY X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(136003)(346002)(39860400002)(396003)(376002)(230922051799003)(186009)(82310400011)(64100799003)(451199024)(1800799012)(46966006)(36840700001)(40470700004)(26005)(6916009)(7696005)(6666004)(2616005)(1076003)(70586007)(316002)(54906003)(107886003)(336012)(70206006)(8936002)(4326008)(40460700003)(8676002)(5660300002)(40480700001)(478600001)(47076005)(36860700001)(2906002)(82740400003)(426003)(356005)(86362001)(7636003)(41300700001)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 16:26:03.1367 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e3b338b6-61ea-48d0-4ba4-08dc1dc252f3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9DC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6713 Received-SPF: softfail client-ip=2a01:111:f403:200a::601; envelope-from=avihaih@nvidia.com; helo=NAM12-MW2-obe.outbound.protection.outlook.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This will be used in the new migration channel creation API in the following patches. Signed-off-by: Avihai Horon --- migration/migration.h | 3 +++ migration/migration.c | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/migration/migration.h b/migration/migration.h index 17972dac34..dc370ab3e8 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -470,6 +470,9 @@ struct MigrationState { bool switchover_acked; /* Is this a rdma migration */ bool rdma_migration; + + /* The address used for this migration */ + MigrationAddress *address; }; void migrate_set_state(int *state, int old_state, int new_state); diff --git a/migration/migration.c b/migration/migration.c index d81d96eaa5..deaa79ff14 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1286,6 +1286,8 @@ static void migrate_fd_cleanup(MigrationState *s) s->hostname = NULL; json_writer_free(s->vmdesc); s->vmdesc = NULL; + qapi_free_MigrationAddress(s->address); + s->address = NULL; qemu_savevm_state_cleanup(); @@ -1974,6 +1976,8 @@ void qmp_migrate(const char *uri, bool has_channels, } } + s->address = QAPI_CLONE(MigrationAddress, addr); + if (addr->transport == MIGRATION_ADDRESS_TYPE_SOCKET) { SocketAddress *saddr = &addr->u.socket; if (saddr->type == SOCKET_ADDRESS_TYPE_INET || @@ -2005,6 +2009,8 @@ void qmp_migrate(const char *uri, bool has_channels, } migrate_fd_error(s, local_err); error_propagate(errp, local_err); + qapi_free_MigrationAddress(s->address); + s->address = NULL; return; } } From patchwork Thu Jan 25 16:25:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13531229 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C2E6CC47258 for ; Thu, 25 Jan 2024 16:27:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT2YP-0002NT-4o; Thu, 25 Jan 2024 11:26:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YN-0002ND-IW for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:11 -0500 Received: from mail-dm6nam12on20601.outbound.protection.outlook.com ([2a01:111:f403:2417::601] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YL-0000Uj-A0 for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:11 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a57hk3qdsESaUJkHUKIkcbzHuN+BL7i2LeYrEBkxSBGBOdkDryVnBUK3Pi4s3JJzZHtOGLyGLbi5247LeXciK8gd6kKUPKHKgYWzQDTKalshDgLukBDQuwvBirqIRutT6/PCjuaikb/EYWOKMjbvTepWcFROSuV5R1VmshQY5tbhwBaiZGhnm/3R5ljkVFn/EJ7bSNIiTIjK9rwFXGY9bX7fy16dBAcyMpg2WNB3cstMIebt2EMLE7XmGAZnQCY0Iy9OeRDioabmtijAJNoUj0IQXskdD12mExpSQP993gBylOcEjFTggIHewT6K/GPoTvNt7Z5iTF+bSs0kDiYwxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=e4sha71HdZUhKHTMFOtP5nR8gdgRaObHZiteRWW3SzY=; b=gslR4F/pdgT7L79djA7AiCXDZvw9DLHZzWzYxSsbxQqnYl0bgrurq3j/P8PSBmVdnXTPdRlexyhUkIYpSYAyIOICXfwDg8ni3AqYXsLslu/VwwunDzcQxMQp/9zCzaz+oPDMxvAb2fYPFmbmGODsPGEwUyvqCNxAaL2G0/qZn96e8yPgUa+AcDMVnsYsDOBtCHLKIT+Wf7JV5K6PPikTzOzDh2uukuZzuvY7rU1PJQ7yXA/fvVUYX4IyBg7jvlFqUxEcRJL/TVP2lL7A5ZYA4T/Azm+nkGgeOV4r8pIqBYvUB3EauAXibfZny5CkQH8Q5vz/ad5A/1EKQucnFhJ61w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=e4sha71HdZUhKHTMFOtP5nR8gdgRaObHZiteRWW3SzY=; b=Xx6rvKltuDb+fQeaF6AfZy/7pgxz39tBAZ6NTv524kRd8yUuJosUvZnRx9x+dz0R5z3nKmf//ceHB4/4jgpEKjJE2FN0LJ25seGFqOfxE2QlRF1ZFMTbAt3Bu0jEIJ2jQFjQXjvlKjOHFc72N0m0Lpf41091KKoCmaA5TF6jdoC6XQrysAOt8UGxRA0utvIsPj4n1Mx+9C7Rs1wudIo1EW3WAsJd5xtwhFZoB/fCRYkFwjCbIqnaByvI5SM3tYCvo9D8UcAeDvudArcL93/VXtSy0/PhnFsb8/nhSlKG6yPS8QDk6OK03iHd3icF4iOjAnzIxCeEG8w8W5uz0YbRvg== Received: from DM6PR05CA0043.namprd05.prod.outlook.com (2603:10b6:5:335::12) by MN2PR12MB4376.namprd12.prod.outlook.com (2603:10b6:208:26c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.26; Thu, 25 Jan 2024 16:26:05 +0000 Received: from DS3PEPF000099DF.namprd04.prod.outlook.com (2603:10b6:5:335:cafe::9) by DM6PR05CA0043.outlook.office365.com (2603:10b6:5:335::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.21 via Frontend Transport; Thu, 25 Jan 2024 16:26:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DS3PEPF000099DF.mail.protection.outlook.com (10.167.17.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.16 via Frontend Transport; Thu, 25 Jan 2024 16:26:05 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:54 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:54 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 25 Jan 2024 08:25:53 -0800 From: Avihai Horon To: CC: Peter Xu , Fabiano Rosas , "Avihai Horon" Subject: [PATCH 14/17] migration: Rename migration_channel_connect() Date: Thu, 25 Jan 2024 18:25:25 +0200 Message-ID: <20240125162528.7552-15-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240125162528.7552-1-avihaih@nvidia.com> References: <20240125162528.7552-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DF:EE_|MN2PR12MB4376:EE_ X-MS-Office365-Filtering-Correlation-Id: c510903d-c881-4ffb-7fba-08dc1dc2541f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Bs4Eel3olKC6ekjTFpeCFoJbBfko00ryiJuI0hRhhzUarUlXkugErjyg8xaS4CV7ohmSqwmRvAjasN7jUcqnjzXHsa5kZJwE8qDtJoj+NBqEoYIuL70u6GAVo/1SAU6zVq/H4zAmLCZ10SccpFrEeStCqof2vAQk8mfQMeu4I4+I0xj5JQ5vWL15pi9PNqUZXx4MatduzZIBmC2JMz6f2j3NVR8DL5o9ABHjDnPl1oAS3+BDfbIVyf9ppNwJGD0cKK+/dgKAp+B4MRC647UNb8s7vP40JduqDRx/tqsXpkvv8vikldMhJ4XwzexJ6+jIg9gbv51LuIU08H/ObbQs3YB11filKzk11EspA3qKnZEPglDaz+IHng5nQAqgE8S7QEJ/1hHUtpUnGFclm5els4A9Tt63v50/4G4x+e2qkFK3M4fFdqoknSb4+QT2pSKXlyo3ojpPtVIBd5jpJ2O64HQOvcqwmQI8/yEBAnP08IbsGmm3yeTADciPtRMBlb608CEkgnON68d+Gtasi8eZldFCXmQDw0dMKcna3c0PlWM49Af2Lcb5sFBoV7AdEmmpNKX/2LpyAdc8j3oJR7NjEy3E/Esr6S2h8vHRBuupTR5XtPXwC0cHN3LO53Anm2MCct0VkPoqp4FrUND5N2mBPkk7hTMiyFCTbG49EYeAsGozcUMClK3pCzawI+HGPPJq0+NwQPmZnXfZAMdXkS8hTUne4mKUNzuW2TLS9lhjoh6Hvftwlt2sRNkRPKLr5iFp X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(376002)(346002)(396003)(136003)(230922051799003)(64100799003)(82310400011)(1800799012)(186009)(451199024)(40470700004)(46966006)(36840700001)(40480700001)(40460700003)(47076005)(83380400001)(107886003)(36756003)(7636003)(356005)(86362001)(336012)(8936002)(4326008)(8676002)(5660300002)(426003)(26005)(2616005)(1076003)(82740400003)(316002)(70206006)(36860700001)(54906003)(6916009)(70586007)(2906002)(41300700001)(6666004)(7696005)(478600001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 16:26:05.0729 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c510903d-c881-4ffb-7fba-08dc1dc2541f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DF.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4376 Received-SPF: softfail client-ip=2a01:111:f403:2417::601; envelope-from=avihaih@nvidia.com; helo=NAM12-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The following patches will add a new API to create migration channels with the same name, so rename migration_channel_connect() to migration_channel_connect_main(). No functional changes intended. Signed-off-by: Avihai Horon --- migration/channel.h | 6 ++---- migration/channel.c | 10 ++++------ migration/exec.c | 2 +- migration/fd.c | 2 +- migration/file.c | 2 +- migration/socket.c | 2 +- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/migration/channel.h b/migration/channel.h index 5bdb8208a7..1e36bdd866 100644 --- a/migration/channel.h +++ b/migration/channel.h @@ -20,10 +20,8 @@ void migration_channel_process_incoming(QIOChannel *ioc); -void migration_channel_connect(MigrationState *s, - QIOChannel *ioc, - const char *hostname, - Error *error_in); +void migration_channel_connect_main(MigrationState *s, QIOChannel *ioc, + const char *hostname, Error *error_in); int migration_channel_read_peek(QIOChannel *ioc, const char *buf, diff --git a/migration/channel.c b/migration/channel.c index 4022b2c9b8..c1f7c6d556 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -55,22 +55,20 @@ static void migration_channel_tls_handshake_main(QIOChannel *ioc, void *opaque, { MigrationState *s = opaque; - migration_channel_connect(s, ioc, NULL, err); + migration_channel_connect_main(s, ioc, NULL, err); object_unref(OBJECT(ioc)); } /** - * @migration_channel_connect - Create new outgoing migration channel + * @migration_channel_connect_main - Create new main outgoing migration channel * * @s: Current migration state * @ioc: Channel to which we are connecting * @hostname: Where we want to connect * @error: Error indicating failure to connect, free'd here */ -void migration_channel_connect(MigrationState *s, - QIOChannel *ioc, - const char *hostname, - Error *error) +void migration_channel_connect_main(MigrationState *s, QIOChannel *ioc, + const char *hostname, Error *error) { trace_migration_set_outgoing_channel( ioc, object_get_typename(OBJECT(ioc)), hostname, error); diff --git a/migration/exec.c b/migration/exec.c index 47d2f3b8fb..043fb3f14d 100644 --- a/migration/exec.c +++ b/migration/exec.c @@ -89,7 +89,7 @@ void exec_start_outgoing_migration(MigrationState *s, strList *command, } qio_channel_set_name(ioc, "migration-exec-outgoing"); - migration_channel_connect(s, ioc, NULL, NULL); + migration_channel_connect_main(s, ioc, NULL, NULL); object_unref(OBJECT(ioc)); } diff --git a/migration/fd.c b/migration/fd.c index 0eb677dcae..9d3ff249dc 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -39,7 +39,7 @@ void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error ** } qio_channel_set_name(ioc, "migration-fd-outgoing"); - migration_channel_connect(s, ioc, NULL, NULL); + migration_channel_connect_main(s, ioc, NULL, NULL); object_unref(OBJECT(ioc)); } diff --git a/migration/file.c b/migration/file.c index 5d4975f43e..60cdaead1e 100644 --- a/migration/file.c +++ b/migration/file.c @@ -57,7 +57,7 @@ void file_start_outgoing_migration(MigrationState *s, return; } qio_channel_set_name(ioc, "migration-file-outgoing"); - migration_channel_connect(s, ioc, NULL, NULL); + migration_channel_connect_main(s, ioc, NULL, NULL); } static gboolean file_accept_incoming_migration(QIOChannel *ioc, diff --git a/migration/socket.c b/migration/socket.c index 98e3ea1514..c55129dc9b 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -106,7 +106,7 @@ static void socket_outgoing_migration(QIOTask *task, } out: - migration_channel_connect(data->s, sioc, data->hostname, err); + migration_channel_connect_main(data->s, sioc, data->hostname, err); object_unref(OBJECT(sioc)); } From patchwork Thu Jan 25 16:25:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13531236 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9F425C47258 for ; Thu, 25 Jan 2024 16:28:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT2YW-0002Qj-Ob; Thu, 25 Jan 2024 11:26:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YT-0002Q0-Bm for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:17 -0500 Received: from mail-mw2nam10on20600.outbound.protection.outlook.com ([2a01:111:f403:2412::600] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YR-0000Vu-AW for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:17 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c+P9D87BJMVCV5VvmGHth2kacmnZKz4B5vkZKFJHFv+nj04LMKzlYbk3lUcp5RRxaLUN16CRAsVGljp68yIUQqpci+03GLqaYamQPv5y5lxGQEfJAXqZ5vazrTlTa26LCH1HVxDPk9fHBohntvtUiapqCWUdm7sZMeKZdkRwHsWXVsCi3UbsDS9EWXr5FqToaKIp8um87UmgRQSIahP85CBi7JDiUAhc1oz0SkPVK5dXd7/WqFT3LduKj01toJP9lmA+WSitns/0I/vCDQYT+ZzMPp5kbMZrXz777nOrSHowGd5q1j2samiE5dEVw2ePz+LpYBgVeXvVGjeQpWr22A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rjNWe7F7zYwdGDQLM6D4PmBiqb0D5XI8XKeekITtisQ=; b=Qz8fQZRpjfri7P8L0GyKnKRHbUb6rVTQ/9agStYgBwFUx5kP3Ti1ZEPEF29x5sPH7Q3fQgzLNSdKXiA3Z/LzvMz96L0Ocvl/WQonNEzja7f/3cesosuL1eV7eeB1J0S/3NOTwRjg0vtGcebYxuxMsVrMJ0I/pu4s8FkeuY1E6f7a5FJLUYBy57kUljKXq3imWIY4TCY166AXmRcx+ZVrXknBXDPyoHgoR8HZmoHmkCYZyvlEazt/6UCozvBGgpnUXzqB87k9aCdtdS867HyQzjqD2U+wR8YtN20kwvceRZr20DlrqFKUrsFncNw80IF7OnY7rxfxil6uoRTtu+an/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rjNWe7F7zYwdGDQLM6D4PmBiqb0D5XI8XKeekITtisQ=; b=sJ+jJzcN0ZXyLwLjd3OQcN0ThTNaQlSi1UllBoFd35JmB2XlhZmT297L+JklwPwdZE9psqW6bPVhzUY+bUhInazQ9+H4NdoFdBMo9tHnLeiGGyGRZHA+KmOl+n65WNFH4HjB95yxNqUHBDXq/QSVgON5kf30E6+E/AKsN/Z0NnASgmILK087AR6wAiwDf/w7bC/7b4TeE6YMrwQsN/wUGgZKQ3zGkYTRwaotOuS4rRtuTO2N2h/guH5Tn4hca9m98DC3k4j4wREJUR8aXWoeRYcexAqeysQkieTxv9rDkDEq8KhUS6/cSqJORLKMV7JkoTrFQ+Qs8NsFPN23nYh3ng== Received: from DM6PR05CA0045.namprd05.prod.outlook.com (2603:10b6:5:335::14) by PH8PR12MB6771.namprd12.prod.outlook.com (2603:10b6:510:1c6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Thu, 25 Jan 2024 16:26:07 +0000 Received: from DS3PEPF000099DF.namprd04.prod.outlook.com (2603:10b6:5:335:cafe::4b) by DM6PR05CA0045.outlook.office365.com (2603:10b6:5:335::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.10 via Frontend Transport; Thu, 25 Jan 2024 16:26:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DS3PEPF000099DF.mail.protection.outlook.com (10.167.17.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.16 via Frontend Transport; Thu, 25 Jan 2024 16:26:07 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:56 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:56 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 25 Jan 2024 08:25:54 -0800 From: Avihai Horon To: CC: Peter Xu , Fabiano Rosas , "Avihai Horon" Subject: [PATCH 15/17] migration: Add new migration channel connect API Date: Thu, 25 Jan 2024 18:25:26 +0200 Message-ID: <20240125162528.7552-16-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240125162528.7552-1-avihaih@nvidia.com> References: <20240125162528.7552-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DF:EE_|PH8PR12MB6771:EE_ X-MS-Office365-Filtering-Correlation-Id: 1112b9a6-65c2-47a8-d35e-08dc1dc25557 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V4fKYh6thyY7XM6jYVg9mBISKYRFbHvMn/6T9WGHMXFCFFuln9hBu15CsOfByFo5O977dGp7Nvo6qiwFM4mV4lxdeIQrwhH8ghE6PknhO0mgqwZyPcfPySsFrouCdwAB9ynN2IB90nv/gNu9AFZWBUltVoSNt6g7gMg5Rz5mjlib8l1AhznVFNeCrTlfpIOnmqJVkRcp2XkMFkqDjoz0KWFhX3lIxQ+psgEu40i28UydE76Z/RmP4uXPfHoJhbaNQWIE8rKjy2sZgLz+u/TS1UI8CXL/KucCvAXvLSymQKEHbIMrsz5jVJMzL4Z5dRcY70/0MVZiUbMUwOVQilu5LtkaoQ+Vqd5xNIAlUQO/Vec+DuQ+wbipgvivEveOSwbyE8Vz8TOXEy/eligAdHUpZcipWff2K+JbpxJ0ydoCGofmycCYL11Gyr37byC9gaq6hpYfjYAx7/o4baqYyffYiRN5IXn0OQwTmsrbf69u8txG+lmHY9Y03x3n9Xx61iSh65KiMGZ/FtJMjePsuLAajwPKBNHtxkTJ9M+XIkBF24bQk+YMUUyYDyTWGQohtul+Rq73VJ/UvHYv56uSGmm0nbBNZUl1FPO8eou51ql4P6SGXmZJPnzeD/wN3344ng40dGxgOgX7SPVy/OBayRjdlLmesVRF0cfM1HfQfQeXuAqXONP6j42GpINvimx4xvK719notp4Te6JEXGdcfGqitpeq06teYWXsvdllP8jBrDghirlKD70an/KP0OKDKjpB X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(136003)(396003)(346002)(376002)(230922051799003)(451199024)(1800799012)(64100799003)(186009)(82310400011)(36840700001)(46966006)(40470700004)(41300700001)(336012)(426003)(107886003)(1076003)(26005)(40480700001)(40460700003)(36756003)(478600001)(47076005)(36860700001)(82740400003)(6666004)(7696005)(2616005)(83380400001)(7636003)(356005)(70206006)(70586007)(5660300002)(6916009)(86362001)(2906002)(54906003)(316002)(66899024)(4326008)(8676002)(8936002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 16:26:07.1041 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1112b9a6-65c2-47a8-d35e-08dc1dc25557 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DF.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6771 Received-SPF: softfail client-ip=2a01:111:f403:2412::600; envelope-from=avihaih@nvidia.com; helo=NAM10-MW2-obe.outbound.protection.outlook.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Add a new API to connect additional migration channels other than the main migration channel. This API removes the burden of handling the transport type and TLS upgrade logic, and thus simplifies migration channel connection. It will be used in the next patches to connect multifd and postcopy preempt channels. Export migration_channels_and_transport_compatible() as now it is also used outside of migration.c. Signed-off-by: Avihai Horon --- migration/channel.h | 24 ++++++++++++++ migration/migration.h | 2 ++ migration/channel.c | 74 ++++++++++++++++++++++++++++++++++++++++++ migration/migration.c | 5 ++- migration/trace-events | 3 ++ 5 files changed, 105 insertions(+), 3 deletions(-) diff --git a/migration/channel.h b/migration/channel.h index 1e36bdd866..f0fa94ad9e 100644 --- a/migration/channel.h +++ b/migration/channel.h @@ -27,4 +27,28 @@ int migration_channel_read_peek(QIOChannel *ioc, const char *buf, const size_t buflen, Error **errp); + +typedef void (*MigChannelCallback)(QIOChannel *ioc, void *opaque, Error *err); + +/** + * migration_channel_connect: + * @callback: The callback to invoke when completed + * @name: The name of the channel + * @opaque: Opaque data to pass to @callback + * @tls_in_thread: Whether to run TLS handshake in new thread or not (if TLS is + * needed). + * @errp: Pointer to a NULL-initialized error object pointer + * + * Establishes a new migration channel and TLS upgrades it if needed. If this + * function succeeds, @callback will be invoked upon completion and + * success/failure will be reported to it via the Error object. + * In case multiple channels are established in parallel, @tls_in_thread should + * be set to true so the TLS handshake will be performed in a new thread, to + * avoid a potential risk of migration hang. + * + * Returns: True on successful initiation of channel establishment process, or + * false on failure. + */ +bool migration_channel_connect(MigChannelCallback callback, const char *name, + void *opaque, bool tls_in_thread, Error **errp); #endif diff --git a/migration/migration.h b/migration/migration.h index dc370ab3e8..52b340e00b 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -523,6 +523,8 @@ bool check_dirty_bitmap_mig_alias_map(const BitmapMigrationNodeAliasList *bbm, void migrate_add_address(SocketAddress *address); bool migrate_uri_parse(const char *uri, MigrationChannel **channel, Error **errp); +bool migration_channels_and_transport_compatible(MigrationAddress *addr, + Error **errp); int foreach_not_ignored_block(RAMBlockIterFunc func, void *opaque); #define qemu_ram_foreach_block \ diff --git a/migration/channel.c b/migration/channel.c index c1f7c6d556..741974279f 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -21,6 +21,7 @@ #include "io/channel-socket.h" #include "qemu/yank.h" #include "yank_functions.h" +#include "socket.h" /** * @migration_channel_process_incoming - Create new incoming migration channel @@ -101,6 +102,79 @@ void migration_channel_connect_main(MigrationState *s, QIOChannel *ioc, error_free(error); } +typedef struct { + MigChannelCallback callback; + void *opaque; + char *name; + bool tls_in_thread; +} MigChannelData; + +static void migration_channel_connect_tls_handshake(QIOChannel *ioc, + void *opaque, Error *err) +{ + MigChannelData *data = opaque; + + data->callback(ioc, data->opaque, err); + g_free(data->name); + g_free(data); +} + +static void migration_channel_connect_callback(QIOTask *task, void *opaque) +{ + QIOChannel *ioc = QIO_CHANNEL(qio_task_get_source(task)); + MigChannelData *data = opaque; + MigrationState *s = migrate_get_current(); + Error *err = NULL; + + if (qio_task_propagate_error(task, &err)) { + trace_migration_channel_connect_error(data->name, + error_get_pretty(err)); + goto out; + } + + trace_migration_channel_connect_complete(data->name); + if (!migrate_channel_requires_tls_upgrade(ioc)) { + goto out; + } + + if (migration_tls_channel_connect(ioc, data->name, s->hostname, + migration_channel_connect_tls_handshake, + data, data->tls_in_thread, &err)) { + object_unref(OBJECT(ioc)); + /* data->callback will be invoked after handshake */ + return; + } + +out: + data->callback(ioc, data->opaque, err); + g_free(data->name); + g_free(data); +} + +bool migration_channel_connect(MigChannelCallback callback, const char *name, + void *opaque, bool tls_in_thread, Error **errp) +{ + MigrationState *s = migrate_get_current(); + MigChannelData *data; + + g_assert(s->address); + g_assert(migration_channels_and_transport_compatible(s->address, NULL)); + + data = g_new0(MigChannelData, 1); + data->callback = callback; + data->opaque = opaque; + data->name = g_strdup(name); + data->tls_in_thread = tls_in_thread; + + trace_migration_channel_connect_start(s->hostname, name); + /* + * Currently, creating migration channels other than main channel is + * supported only with socket transport. + */ + socket_send_channel_create(migration_channel_connect_callback, data); + + return true; +} /** * @migration_channel_read_peek - Peek at migration channel, without diff --git a/migration/migration.c b/migration/migration.c index deaa79ff14..6f985e7f74 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -141,9 +141,8 @@ static bool transport_supports_multi_channels(MigrationAddress *addr) return false; } -static bool -migration_channels_and_transport_compatible(MigrationAddress *addr, - Error **errp) +bool migration_channels_and_transport_compatible(MigrationAddress *addr, + Error **errp) { if (migration_needs_multiple_sockets() && !transport_supports_multi_channels(addr)) { diff --git a/migration/trace-events b/migration/trace-events index 9a8ec67115..6c915d8567 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -195,6 +195,9 @@ migration_transferred_bytes(uint64_t qemu_file, uint64_t multifd, uint64_t rdma) # channel.c migration_set_incoming_channel(void *ioc, const char *ioctype) "ioc=%p ioctype=%s" migration_set_outgoing_channel(void *ioc, const char *ioctype, const char *hostname, void *err) "ioc=%p ioctype=%s hostname=%s err=%p" +migration_channel_connect_start(const char *hostname, const char *name) "hostname=%s, name=%s" +migration_channel_connect_error(const char *name, const char *err) "name=%s, err=%s" +migration_channel_connect_complete(const char *name) "name=%s" # global_state.c migrate_state_too_big(void) "" From patchwork Thu Jan 25 16:25:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13531233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8E73BC47422 for ; Thu, 25 Jan 2024 16:27:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT2YS-0002Pk-8n; Thu, 25 Jan 2024 11:26:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YR-0002Pa-4M for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:15 -0500 Received: from mail-bn8nam12on20600.outbound.protection.outlook.com ([2a01:111:f403:2418::600] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YP-0000Vn-8e for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:14 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mzjBmzbga8TrRz2PrFngYMrJ5cJCRL6H2Rp+6BBmubWcDEOsn964FA8U+Z7Qx4wWXlEgcbK8bVLHYp9ABr8sIWAbmCSu8jFCTbbJFySLeEupt16TaJyRUbVFXhAww9OeN6UMg6/HkmEOLXDpH396MkoxekwIefRJgfG8GJ7VdYDpYfLCED+BWD49y9Tvf29WB8UB57Y7+l1havepX9DPejowHdX2ln7bkKhljuJnAJ4guVIus6uv5p5x7XEi2rbThM9raPnFsAZkk6cpiTEi+uz0h/C3nSdM3YkVOeo+MI3Q+483PIpU3n4FobKu3cBOAa13To+5z0TWw2lSSMhoVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4zy4AaUsE8ycrSz5IejZl8Zo89GZWYWXE8niRefWRUw=; b=hhZdQu72SLvNFsvW43OMYqW4subGqQZH3UHfwttMtv7Df437gMpuu7z09o07+8+5jW40RHuWCohzOcCc8B2wkt3oL1uscIZJs8Xe1+pD/Nt4vKkLBYKueon9UkH25vYvjl2m1PlFQ128aO8QR+seJrkFwKfMdMcPzZp980PfZiblrlVlbXOGYWWaSQxl3KItawW7KxJEfDeedrbf4yCfp50QsX7qyUix0W9XkFWZUmg3liMkAxrnX1R9gQXW4b2/hcDWgpFOGTSTBhGkxu/m0sLGXE+muknW/igDNs1hQTb3F8rHFc5+BgvISqgrSl25zIrJKAXXli4eFTlmQynLEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4zy4AaUsE8ycrSz5IejZl8Zo89GZWYWXE8niRefWRUw=; b=fuDfzo08wC0wMuxcCSgzZbOhoznUQGg4sn7mfStm/0Cfg4pfcqZFFemK3+Rurn6DdiX8kc79w9CMIIdnwMsb0dvP1pNB6zazg9ilyXQY2wTds3io89l1UN734yRCBY3Yj/QFw06Wx+W81EAFm8IqbxF+4/EZEdLfhpiiNxgz2mkY3KCtw02cOIxnD5K9MG5rkeEq/5TRVJN9BgupE1K0rBXGzahrECRcJV+u+jkWNOYjQs4gZsqTU5/4v2XifJ2DLlXcEveInWI9hafXkgcJ3Kn6wr6hmRil/C9mIugx+CTnOE5AdBHSljG+9dZ561+GyRY+BIvH8111DLEbkz3ZPQ== Received: from DM5PR07CA0061.namprd07.prod.outlook.com (2603:10b6:4:ad::26) by SJ0PR12MB5453.namprd12.prod.outlook.com (2603:10b6:a03:37f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.24; Thu, 25 Jan 2024 16:26:09 +0000 Received: from DS3PEPF000099DC.namprd04.prod.outlook.com (2603:10b6:4:ad:cafe::f1) by DM5PR07CA0061.outlook.office365.com (2603:10b6:4:ad::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22 via Frontend Transport; Thu, 25 Jan 2024 16:26:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DS3PEPF000099DC.mail.protection.outlook.com (10.167.17.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.16 via Frontend Transport; Thu, 25 Jan 2024 16:26:09 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:58 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:57 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 25 Jan 2024 08:25:56 -0800 From: Avihai Horon To: CC: Peter Xu , Fabiano Rosas , "Avihai Horon" Subject: [PATCH 16/17] migration/multifd: Use the new migration channel connect API for multifd Date: Thu, 25 Jan 2024 18:25:27 +0200 Message-ID: <20240125162528.7552-17-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240125162528.7552-1-avihaih@nvidia.com> References: <20240125162528.7552-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DC:EE_|SJ0PR12MB5453:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e807c04-803e-4577-ea2a-08dc1dc2569e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rdRa8V4Os6bCUACc2DHs7FWmh/NLOzy32iYWEVp1UKLAU9W0tqkph1EfIbyy5AxiV9CdoDUrU7fGi5qkQbZ0XpBK05jgbgV3KKvkY7lnfanY4NoWHObA3IAgvj876dcSVkhMe1v7AIn+2RyUL6e28ZwV9vc19vLJZsRnmSjEXzDnFjmgX1W3NnBIm6cBxEi24A6M0ycDS+hC0NXPbmeIoIiqGHKEEqhFvrP4SoJHKYh8cbzjfY2mr+5iiaFQMXWZq5X/FMDIuk+XmT9RoNDnM02TQlQpPZS9I/CGx586NqcLUvJh2XF/MTxegRf1jTwLVzMaUc8p2qW+pk39ydxSpC74PkBH/QjUvFfCP+qTYsaVhWWKPXAJ8syj+CfuimUmzYPK4paSUW3QJ7kAtexgiflX6NUN7r+xx7JVKQizN0FukiVEgvFNtcK6vBf8tNYJ2YFZvTiq5JznZmEtTCf4bPgccEZHA4RyELWBckGZhVMYW+wVK4k4P1IV2GxDmTWKlq70Egs+EG69uhUKTy4M/won8Bk7sCCfGDSnm+FQsA0nufrZklJyJn6S+0jAw4hukkWY5JhNAjt56iswjRkN+3ReI39TZmb5np9E38HC9+tA3PHrSLHW6RUvP+B0Va+ihPWdd5sfEn6b5TwQbJqBqXMSL7TUPPVAJjofMMDLVy5huygEUG1Oq+QNtxz2/D3CSQ0ewlt4W3Pxa4YS+2tRvcHH3hPQ+xk/431fjkjOO2V+SRXm32DL5CTympS3rpYG X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(346002)(136003)(39860400002)(376002)(396003)(230922051799003)(64100799003)(186009)(82310400011)(1800799012)(451199024)(40470700004)(46966006)(36840700001)(36860700001)(47076005)(2906002)(36756003)(41300700001)(86362001)(7636003)(82740400003)(356005)(54906003)(7696005)(6916009)(316002)(70586007)(70206006)(478600001)(2616005)(6666004)(336012)(426003)(83380400001)(5660300002)(8676002)(4326008)(1076003)(107886003)(8936002)(26005)(40480700001)(40460700003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 16:26:09.2477 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8e807c04-803e-4577-ea2a-08dc1dc2569e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5453 Received-SPF: softfail client-ip=2a01:111:f403:2418::600; envelope-from=avihaih@nvidia.com; helo=NAM12-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Use the new migration channel connect API for multifd and remove old channel connect code. Signed-off-by: Avihai Horon --- migration/multifd.c | 89 ++++++++++-------------------------------- migration/trace-events | 3 -- 2 files changed, 21 insertions(+), 71 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index cc9a1182fa..c679b64721 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -18,10 +18,10 @@ #include "qemu/error-report.h" #include "qapi/error.h" #include "ram.h" +#include "channel.h" #include "migration.h" #include "migration-stats.h" #include "socket.h" -#include "tls.h" #include "qemu-file.h" #include "trace.h" #include "multifd.h" @@ -790,61 +790,6 @@ int multifd_send_channels_created(void) return ret; } -static bool multifd_channel_connect(MultiFDSendParams *p, - QIOChannel *ioc, - Error **errp); - -static void multifd_new_send_channel_cleanup(MultiFDSendParams *p, - QIOChannel *ioc, Error *err); - -static void multifd_tls_outgoing_handshake(QIOChannel *ioc, gpointer opaque, - Error *err) -{ - MultiFDSendParams *p = opaque; - - if (!err) { - if (multifd_channel_connect(p, ioc, &err)) { - return; - } - } - - multifd_new_send_channel_cleanup(p, ioc, err); -} - -static bool multifd_channel_connect(MultiFDSendParams *p, - QIOChannel *ioc, - Error **errp) -{ - MigrationState *s = migrate_get_current(); - - trace_multifd_set_outgoing_channel(ioc, object_get_typename(OBJECT(ioc)), - s->hostname); - - if (migrate_channel_requires_tls_upgrade(ioc)) { - /* - * multifd_tls_outgoing_handshake will call back to this function after - * the TLS handshake, so we mustn't call multifd_send_thread until then. - */ - if (migration_tls_channel_connect(ioc, p->name, s->hostname, - multifd_tls_outgoing_handshake, p, - true, errp)) { - object_unref(OBJECT(ioc)); - return true; - } - return false; - } - - qio_channel_set_delay(ioc, false); - migration_ioc_register_yank(ioc); - p->registered_yank = true; - p->c = ioc; - qemu_thread_create(&p->thread, p->name, multifd_send_thread, p, - QEMU_THREAD_JOINABLE); - p->running = true; - qemu_sem_post(&p->create_sem); - return true; -} - static void multifd_new_send_channel_cleanup(MultiFDSendParams *p, QIOChannel *ioc, Error *err) { @@ -863,26 +808,34 @@ static void multifd_new_send_channel_cleanup(MultiFDSendParams *p, error_free(err); } -static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque) +static void multifd_new_send_channel_callback(QIOChannel *ioc, void *opaque, + Error *err) { MultiFDSendParams *p = opaque; - QIOChannel *ioc = QIO_CHANNEL(qio_task_get_source(task)); - Error *local_err = NULL; - trace_multifd_new_send_channel_async(p->id); - if (!qio_task_propagate_error(task, &local_err)) { - if (multifd_channel_connect(p, ioc, &local_err)) { - return; - } + if (err) { + multifd_new_send_channel_cleanup(p, ioc, err); + return; } - trace_multifd_new_send_channel_async_error(p->id, local_err); - multifd_new_send_channel_cleanup(p, ioc, local_err); + qio_channel_set_delay(ioc, false); + migration_ioc_register_yank(ioc); + p->registered_yank = true; + p->c = ioc; + qemu_thread_create(&p->thread, p->name, multifd_send_thread, p, + QEMU_THREAD_JOINABLE); + p->running = true; + qemu_sem_post(&p->create_sem); } -static void multifd_new_send_channel_create(gpointer opaque) +static void multifd_new_send_channel_create(MultiFDSendParams *p) { - socket_send_channel_create(multifd_new_send_channel_async, opaque); + Error *local_err = NULL; + + if (!migration_channel_connect(multifd_new_send_channel_callback, p->name, + p, true, &local_err)) { + multifd_new_send_channel_cleanup(p, NULL, local_err); + } } int multifd_save_setup(Error **errp) diff --git a/migration/trace-events b/migration/trace-events index 6c915d8567..6ac73b0d85 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -126,8 +126,6 @@ postcopy_preempt_switch_channel(int channel) "%d" postcopy_preempt_reset_channel(void) "" # multifd.c -multifd_new_send_channel_async(uint8_t id) "channel %u" -multifd_new_send_channel_async_error(uint8_t id, void *err) "channel=%u err=%p" multifd_recv(uint8_t id, uint64_t packet_num, uint32_t used, uint32_t flags, uint32_t next_packet_size) "channel %u packet_num %" PRIu64 " pages %u flags 0x%x next packet size %u" multifd_recv_new_channel(uint8_t id) "channel %u" multifd_recv_sync_main(long packet_num) "packet num %ld" @@ -144,7 +142,6 @@ multifd_send_sync_main_wait(uint8_t id) "channel %u" multifd_send_terminate_threads(bool error) "error %d" multifd_send_thread_end(uint8_t id, uint64_t packets, uint64_t normal_pages) "channel %u packets %" PRIu64 " normal pages %" PRIu64 multifd_send_thread_start(uint8_t id) "%u" -multifd_set_outgoing_channel(void *ioc, const char *ioctype, const char *hostname) "ioc=%p ioctype=%s hostname=%s" # migration.c migrate_set_state(const char *new_state) "new state %s" From patchwork Thu Jan 25 16:25:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13531225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0B313C47258 for ; Thu, 25 Jan 2024 16:26:41 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT2YU-0002QZ-Sc; Thu, 25 Jan 2024 11:26:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YT-0002Q7-J9 for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:17 -0500 Received: from mail-co1nam11on20600.outbound.protection.outlook.com ([2a01:111:f403:2416::600] helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2YR-0000Vs-0P for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:26:17 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VRn06frzlnuLYEb6kVJFItMjrCnWs3ApaL6fQ/aClxJ0U3gwzjLPj6pBCB0kDsbDtnfsq+HAp7AwjfaheuUFPUS1QsUpFYJk+SG4JncuCSUxbeRev6ysrvThHbQJbJBEpRuobDd0FO47sYnPhwqJzUWgIZNRTszC1o+7Pi8wV59DgVMLJLicwQLsT+p5BYgi/X50A7QEAdCbkW2r2VbmZ19A6bONSmmkq/9va4jAkbymLpzpskCxvbN7gY00JFAys50yGqR6baxjqFSEiN001kyFl20ZxXL/W4eLVoNoCA3mfniAUqRAvgdxWK4K7SHNoyz6wMWVJgMCgOJFZX+pdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZBG0qsv98gUwGePqCU0WTNzg9t4JoCaKfnYWJBuqw2w=; b=OuTL05SQCj1/Y0LbNCKgOnMyn63c44ba702LFMgqogHPvnOnK6nLS1qejleeoCPQKSWc/d+VXys70qtDsbLA+1yyE4b7jnxt6oSkuBrhZ0x/4U7IJIxlc5K0S3t7c4gf9z2CKvQExayUAk1bx3YY6+gSvijjE9SmbbQl9CJudT8gtvpQl1kaI9EM0kROTfaSKjn76B8fcB/ocL7b+evgcJvJEU7wd9B2fsxjYz19z/0fKvjsbCyr2kIvvw5QxnKb/pRnIvXBDLuIReApdhdlhPaOYJD9GqHbMGl9T8b9fhJwYX8B7B3N1oRBHx0EY5n9br8HoQ+tpeVL0gvDHpIHBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZBG0qsv98gUwGePqCU0WTNzg9t4JoCaKfnYWJBuqw2w=; b=tO/ppWui+Q9+ULGfGYvdopZf4ggEqiOP8ygY2WtQg2y+bHpHQly5rihb+7gA5vIhP4bar2CZGkJmb2tWZe5tlFTxoQCGj+iZT95/CXwYbaphpiuKWqK9nOWqWNi0Q71gy0bq9nbbQPCds2860XL9IiXPt/a6Kgws9I5/hSut0Y3/7cYL34ZZgnOp5sCuBRvug/51NuJKTfM7MhJ3C9PGisf2NCfgY4lvSgCUrX7mCI0Jd7t0H03528L92e9jvXhs48cbja3A5N6xg5h4OPQZkt73I4UC3h87n0vuAjS0nINIYIwCLHH2qwh7ODWwvS3knH2SDYPYKDqhPCpLVW4/Mw== Received: from DM5PR07CA0063.namprd07.prod.outlook.com (2603:10b6:4:ad::28) by CH3PR12MB8971.namprd12.prod.outlook.com (2603:10b6:610:177::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.26; Thu, 25 Jan 2024 16:26:10 +0000 Received: from DS3PEPF000099DC.namprd04.prod.outlook.com (2603:10b6:4:ad:cafe::ce) by DM5PR07CA0063.outlook.office365.com (2603:10b6:4:ad::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.26 via Frontend Transport; Thu, 25 Jan 2024 16:26:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DS3PEPF000099DC.mail.protection.outlook.com (10.167.17.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.16 via Frontend Transport; Thu, 25 Jan 2024 16:26:10 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:59 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 08:25:59 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 25 Jan 2024 08:25:58 -0800 From: Avihai Horon To: CC: Peter Xu , Fabiano Rosas , "Avihai Horon" Subject: [PATCH 17/17] migration/postcopy: Use the new migration channel connect API for postcopy preempt Date: Thu, 25 Jan 2024 18:25:28 +0200 Message-ID: <20240125162528.7552-18-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240125162528.7552-1-avihaih@nvidia.com> References: <20240125162528.7552-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DC:EE_|CH3PR12MB8971:EE_ X-MS-Office365-Filtering-Correlation-Id: e2313c2e-b42e-4651-7f01-08dc1dc25756 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AHcoS9ZSmnlzweQGbSZ9b53lLlZM3V6oB2Vx51HYl7+i8atalc5tFkXZTRs36PXYy2VG7x0TWQhgmcgV/8i5aB6zVz0+0rMCaZObPFDKJkQmyLu0Waf7SsbOleMJDgyKIpVLNpXRecuxsC7VWtC9JSY3wn2tm5IhI120WPZX6GsfJgcuMQqTWcK0tslm1R689nfugB8e4AWgpQros3W3YrCZG/GnxEtvZuBDa4ZL9zQBXPg1VVKDC/N3jU7LrRWekAWx+t3sHzE++KkENdbSzgVMGX55FhAQmb9ZNFCM6vwBKwwXoAOZ8sjq1ObuCPN9jTqVrg+Oni0Lh00Cx2tl8eZFvJqhdSy/Yp4GNDZem4bIxuNw2AkH9JED6Qsr/96qo8HxVuSns4v1QT3Q7heJMM99uTvIZPLUeBNXPDIIE068TiXrQ6p2oVbU9ixDkbMN3SOdtCuSZieojMgMMj5vB3b1sFDfT8PiEQa7XystQeaiwq3GdccxZmIbu21IEFbNYtZx9NRi3QmOBTNWImDysilzTm0Rvtyo63dyQ01leVDxw7zRUxuKhtVMxFn8ibgbsvhPqNZqlOBmS5SE0bRS2j5HxIWqe9sEKlmHM5tRTocq09hRh26TngtN8cYcLJ+2ZfT5svjX9F+IET5/q4MYSRS1oVL7FP5Zk327kVgOYk29sXi8+6c7AOvnSL0Vf++8aERA2mwDwUN4uXeecbx18E0iD2e9Kj+9E1/YLIFJxnJ7tMG1ZRYvWJcS2BJa1+1Q X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(396003)(346002)(376002)(136003)(230922051799003)(1800799012)(64100799003)(82310400011)(186009)(451199024)(40470700004)(46966006)(36840700001)(40480700001)(40460700003)(83380400001)(41300700001)(86362001)(36756003)(356005)(36860700001)(2616005)(107886003)(47076005)(1076003)(82740400003)(26005)(426003)(336012)(7696005)(7636003)(478600001)(2906002)(70586007)(6916009)(70206006)(316002)(54906003)(6666004)(8936002)(4326008)(5660300002)(8676002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 16:26:10.4508 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2313c2e-b42e-4651-7f01-08dc1dc25756 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8971 Received-SPF: softfail client-ip=2a01:111:f403:2416::600; envelope-from=avihaih@nvidia.com; helo=NAM11-CO1-obe.outbound.protection.outlook.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Use the new migration channel connect API for postcopy preempt and remove old channel connect code. Signed-off-by: Avihai Horon --- migration/postcopy-ram.h | 2 +- migration/postcopy-ram.c | 105 +++++++++++++++------------------------ 2 files changed, 42 insertions(+), 65 deletions(-) diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h index 442ab89752..c1b7d9be6d 100644 --- a/migration/postcopy-ram.h +++ b/migration/postcopy-ram.h @@ -192,7 +192,7 @@ enum PostcopyChannels { }; void postcopy_preempt_new_channel(MigrationIncomingState *mis, QEMUFile *file); -void postcopy_preempt_setup(MigrationState *s); +int postcopy_preempt_setup(MigrationState *s); int postcopy_preempt_establish_channel(MigrationState *s); #endif diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 3df937e7da..1d80acc7b4 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -34,9 +34,9 @@ #include "exec/ramblock.h" #include "socket.h" #include "yank_functions.h" -#include "tls.h" #include "qemu/userfaultfd.h" #include "qemu/mmap-alloc.h" +#include "channel.h" #include "options.h" /* Arbitrary limit on size of each discard command, @@ -1620,65 +1620,6 @@ void postcopy_preempt_new_channel(MigrationIncomingState *mis, QEMUFile *file) trace_postcopy_preempt_new_channel(); } -/* - * Setup the postcopy preempt channel with the IOC. If ERROR is specified, - * setup the error instead. This helper will free the ERROR if specified. - */ -static void -postcopy_preempt_send_channel_done(MigrationState *s, - QIOChannel *ioc, Error *local_err) -{ - if (local_err) { - migrate_set_error(s, local_err); - error_free(local_err); - } else { - migration_ioc_register_yank(ioc); - s->postcopy_qemufile_src = qemu_file_new_output(ioc); - trace_postcopy_preempt_new_channel(); - } - - /* - * Kick the waiter in all cases. The waiter should check upon - * postcopy_qemufile_src to know whether it failed or not. - */ - qemu_sem_post(&s->postcopy_qemufile_src_sem); -} - -static void postcopy_preempt_tls_handshake(QIOChannel *ioc, gpointer opaque, - Error *err) -{ - MigrationState *s = opaque; - - postcopy_preempt_send_channel_done(s, ioc, err); - object_unref(ioc); -} - -static void -postcopy_preempt_send_channel_new(QIOTask *task, gpointer opaque) -{ - g_autoptr(QIOChannel) ioc = QIO_CHANNEL(qio_task_get_source(task)); - MigrationState *s = opaque; - Error *local_err = NULL; - - if (qio_task_propagate_error(task, &local_err)) { - goto out; - } - - if (migrate_channel_requires_tls_upgrade(ioc)) { - if (!migration_tls_channel_connect(ioc, "preempt", s->hostname, - postcopy_preempt_tls_handshake, s, - false, &local_err)) { - goto out; - } - /* Setup the channel until TLS handshake finished */ - return; - } - -out: - /* This handles both good and error cases */ - postcopy_preempt_send_channel_done(s, ioc, local_err); -} - /* * This function will kick off an async task to establish the preempt * channel, and wait until the connection setup completed. Returns 0 if @@ -1697,7 +1638,9 @@ int postcopy_preempt_establish_channel(MigrationState *s) * setup phase of migration (even if racy in an unreliable network). */ if (!s->preempt_pre_7_2) { - postcopy_preempt_setup(s); + if (postcopy_preempt_setup(s)) { + return -1; + } } /* @@ -1709,10 +1652,44 @@ int postcopy_preempt_establish_channel(MigrationState *s) return s->postcopy_qemufile_src ? 0 : -1; } -void postcopy_preempt_setup(MigrationState *s) +/* + * Setup the postcopy preempt channel with the IOC. If ERROR is specified, + * setup the error instead. This helper will free the ERROR if specified. + */ +static void postcopy_preempt_send_channel_new_callback(QIOChannel *ioc, + void *opaque, Error *err) +{ + MigrationState *s = opaque; + + if (err) { + migrate_set_error(s, err); + error_free(err); + } else { + migration_ioc_register_yank(ioc); + s->postcopy_qemufile_src = qemu_file_new_output(ioc); + trace_postcopy_preempt_new_channel(); + } + + /* + * Kick the waiter in all cases. The waiter should check upon + * postcopy_qemufile_src to know whether it failed or not. + */ + qemu_sem_post(&s->postcopy_qemufile_src_sem); + object_unref(OBJECT(ioc)); +} + +int postcopy_preempt_setup(MigrationState *s) { - /* Kick an async task to connect */ - socket_send_channel_create(postcopy_preempt_send_channel_new, s); + Error *local_err = NULL; + + if (!migration_channel_connect(postcopy_preempt_send_channel_new_callback, + "preempt", s, false, &local_err)) { + migrate_set_error(s, local_err); + error_report_err(local_err); + return -1; + } + + return 0; } static void postcopy_pause_ram_fast_load(MigrationIncomingState *mis)