From patchwork Fri May 12 14:32:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Het Gala X-Patchwork-Id: 13239399 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 411D9C77B7F for ; Fri, 12 May 2023 14:33:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTpH-0007qc-R8; Fri, 12 May 2023 10:32:55 -0400 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 1pxTpG-0007qP-Bg for qemu-devel@nongnu.org; Fri, 12 May 2023 10:32:54 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pxTpE-0002ai-2g for qemu-devel@nongnu.org; Fri, 12 May 2023 10:32:54 -0400 Received: from pps.filterd (m0127842.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34C9Qai0020415; Fri, 12 May 2023 07:32:49 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=+WKgGW6tXUBQ7Xlk8jGjqtOAvZmWrH0/5OY1yrfbgPw=; b=G1SiC1qiJocksSJZfwVLYIiRpsOCFeI9AhjfqneCSG8o4i8/bPYoBbjAzQE6E9XdxzGJ dvbTx5+FozlozrNVM22+Vkj7wIT0zws7yJVuUlMPfH+0Xaslso/MSur/CGciWJO5jyld pWr2wy/n5qcJTb7+TNkHV9+9AYmtKNiJQewFo/bAMmZoatFHJd/QlfYlpxL4U+i41cPK H/GT16uU3Zgzq6PUZbapIViABJmUSWyM2nNom3MVGZxfvNfaQEsrSLHzCwL7Fpj7m9Gx oVhNdu28LxDnuK/6WZ9ALM/m5Hxw5Vm2CWlJbpljAyvHOYs90gN3rx1TA4kh4pLQCt61 TA== Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2048.outbound.protection.outlook.com [104.47.66.48]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3qf835sx3k-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 May 2023 07:32:49 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jnYw5hib+dvt1C2a+d2VlGFY5DCIrH22Q0ay3dc7AOmsAF4ghTxbmyVA+8yhN1HyBwKzg2eHJ4E5g6T0O9PVBjqKptXSa3KkUQpSJrhtNlo4LLAHvRuM+2ERt7Eo8rLeOhvAp/pr/SnDQOV14BdD+ATDYU8RRehAr5vlw1b53c6fdc/ShoIUCrsA8s8GcvanlSJhpS68k3K4bDB1jLTT+bfSmrQ4xg2fdkpL4w5SZ1632O2FQOgNAA0xBrgiWMIv6R+dcvDSdUk8TkzckdCPYXofVV/X5O1EZ19t3FIMemU1O7ZS4wr3aX/5ZEwzpWO62aOnPgTm4SQn8nZlFAAOUw== 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=+WKgGW6tXUBQ7Xlk8jGjqtOAvZmWrH0/5OY1yrfbgPw=; b=X3og6HErziR2wNj5rJbKdAXLXLjOT+cOngHzeWSo64Gt5tRvTzJMBKFLPQSdvcfA6p1fftbbyLCKEkoXyO+FYVoUWT6/iC3i+WD2753X2J90ruTK5BZUpPGqTZQ3aUCXoSCtjzqbgrzlH6nebzcVGBZ0Mlvtl4+nbs5m06qzVbaadGQFiaS17J8ffXHuLeuay2Yau+3/QgwCp58UsiNLMAFNGZTxkhIWlvSN65FiO1YdCvjlgp8VwQVDeJLf2rsScBjub1Qv1yjMQ0xWSuA2t+SOyug6BkiVlOjCpZWnr5tnLSBxvMcG9azy4jURChM8Co5YRHnMcnU38tP+14DRXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+WKgGW6tXUBQ7Xlk8jGjqtOAvZmWrH0/5OY1yrfbgPw=; b=WDZ8c3saIRX2QP8+USgLCMMOSLqVcTyqqzgPOTAtHPO206qlIXkwW5f98HDZZuEDS9gqU4oDvtTJrZtapr/LwIR3x8yJKcf6fxmRxBcTPvxYfqB3MUMTejyU/VXRBXUx7bV013L1oCprCOvieexL9W3RPvT1Ghd0moQjcgYeNaJaBYIoVTiWjQNCKEM6G80KiMJODs0IQh8FORWNeHRQzXWAy0gseLBoAG6XFuQOn0X53/0t5vHRiCPsDcadA0xf2kdn2u2E2dNmpR2mUnnraM5naa528RRBop93cGqqDTLsPqtSuodqInWMKM4JK3GYltPzNaa4XOlyEzlDLeE85g== Received: from BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) by SA2PR02MB7657.namprd02.prod.outlook.com (2603:10b6:806:140::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.24; Fri, 12 May 2023 14:32:47 +0000 Received: from BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::4500:569:a3d6:71c9]) by BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::4500:569:a3d6:71c9%6]) with mapi id 15.20.6387.020; Fri, 12 May 2023 14:32:47 +0000 From: Het Gala To: qemu-devel@nongnu.org Cc: prerna.saxena@nutanix.com, quintela@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, berrange@redhat.com, armbru@redhat.com, eblake@redhat.com, manish.mishra@nutanix.com, aravind.retnakaran@nutanix.com, Het Gala Subject: [PATCH v4 1/8] migration: introduced 'MigrateAddress' in QAPI for migration wire protocol. Date: Fri, 12 May 2023 14:32:33 +0000 Message-Id: <20230512143240.192504-2-het.gala@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20230512143240.192504-1-het.gala@nutanix.com> References: <20230512143240.192504-1-het.gala@nutanix.com> X-ClientProxiedBy: BY5PR04CA0014.namprd04.prod.outlook.com (2603:10b6:a03:1d0::24) To BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR02MB4343:EE_|SA2PR02MB7657:EE_ X-MS-Office365-Filtering-Correlation-Id: d7d8ad19-7bd6-49cb-b8d9-08db52f5c1a2 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cApt3eIGmc3lQfx3PRdonlv1zfJS2vIzPxx1jfs8roj8F6DoWxW5Y/3hp43IHAfvCeN8TJXA/g+BbX0uutW66/2zQbZusExnyOGuEb44e8wBgB0S8peXgHKkXXNdYUkHTki6ztyujwGV9rOtcC7Q0BZYNavNKfGXJtLd+SOfn/2bnaRFBuKqU844THnOUM5UJhR4jwdB8yhcm7O8bxIkW13tS6yRRsZDYz2CjRBjMfayzS8Dj8jjsst6L5JpfMpcoDXglsSL8KXXkYkqNsErNCSzzJqw6X4IH96Sti2X2h/7oQS62JIqK+NLf31TPlYeTuyaNt1UgKBHiHRZTE9AJH0MNIbwG7BRgoEI1ATuo+8M2HkcqwEO5J/pinShb96P7tXGCWu5rz2dGGjS2g3FzPceXDf3EeYElM8qbWpYyimaZvawgLRbPhjBBFMf/k7+KxlJlGOFFlYn0v3Ava2ijjiZ02QnVCbP4jSS2ebAW370do/Cy3yZQ0yqfsY9i2CoFCTfbZtrMWcGwQ1cNnkvU/de+RdNh5irEeWuYpG26WXmN75BM/thSn6OOl6s4MMOMJe6bFdPnbHExaFGMRw4hVxJLJaEgH2euZ5NJ6yXB+JtcafR88i12840l3k5i/vM X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR02MB4343.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(366004)(376002)(346002)(136003)(39860400002)(396003)(451199021)(36756003)(38100700002)(38350700002)(186003)(26005)(1076003)(6512007)(6506007)(66899021)(107886003)(2906002)(2616005)(86362001)(41300700001)(6666004)(6486002)(52116002)(66946007)(6916009)(4326008)(316002)(66556008)(66476007)(478600001)(5660300002)(44832011)(8936002)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tJRKf27FR9Y0GpUdlGm8d7uP7NryEQClzBCSJ9f7gm9/BlS+dmWUVWBWnfjeO5llXWz7I1UAa+9hmg635eT/acJ6wPAzo8Z+XkWfURJ7GiEnnGNRVOLdL310TfmjieeVaLJey1IRUW0Ob0qNnEk7ub1KykMGLS2+0JMU2D4z8zTfb0OsgEIMF4wXYhjgG6754g4psL1ft5Qkk57+f2HE7HcmahYQS+Q1Jg+sKloWVU+ENskNXXq+PrpowlclEfUzdBOpmYispq6kXw6t6/PMrq1idUzCMwShsJ4JhsamfZlQSav1t9cTJ4C9wgPCmHC8ecHCwNSIuna1GjIqNOjmkrogHdY1v73LUVLW00DBKv5jxc5Sw8P8OxIHpVC/3wib4dtWBV1BzjZkUkp7np8WNxnrfQVHtG/ysAlnkOPUnp91uITiefj/j7eurKf0oE2C3QBmjIpThs9wsyXrYxTFNHd4eMaYP3+MM5sg/PzZaNgQVQ5AVfe9HoQ9hi7t9UbVZ9ZnylNgNMKGQoAkwK7JE0t7ozcHspTp80K4OLqsKVkRPsaWbySSflIn0RIy9jtPKK+vNwoQZUDxtY5gfOK9tbM02XxDTdUIWPDMADs3joEGJ6ftdIvm++MJ4ASvhyouh9d3GVB1sRXD1pt9sH1Bs8Yin9rfwu/81cWfIYmB+xVA02V3dC0wmr0w03LZb4PUMOj7GTlq1Ce1xMkg0beYtMmiAH+kmF2EiYB/nHbunSUiPUs4nY0RQosvMcDKpWTxPY1V2WVw1SqTywN3icb9XgX+MNieZznHObhfi8h4cLLa2G8vCesT+xM1BvdP5L0incqNA4047oSrAYMZPTZhe+PCBh238UYLf374tiky6IlvLWmkDcvHDWSu1FMTTWNAIb8jvIa/1KKUqEh3ItNLRenLL66oz0jncEXiP5L7F2dkvEqNyHHlJcCe6iAPsRMxkBif/4HULwNMFF4DmLvQTWZH/oxWW7mwADlQrdk+l9vLfmKkRTwuxoq4+xiFSEE8KvRmt+Bbh4Qls3hdN5DJMp39bBH19WZTCsrUwVG0iB4eLzIQ4KfsESrPM/r3ZOBJlIA1VdjNbE1/97YYyEZCiAh72sfZ7V9/qOw0Ih+yrd2zRjKCIajlCRGXZfHXE60Cp7x34tbdzSFphMbVziEguuENIaD96hcwnrDMw0weOAJsCQNPjgDCptYwSjAM6vx9fBPyuR2SO20T17vzoFdRo655b4sddNmB/ihZvsEJF0NbRLLIDeGCgseQfjWiC3pQby2IN+d6JOA33jdV8Z9EBRNYC6lt4ao3GGifgiwO8kOU3z4xekJ1uMEZYTTwPQ53ewYdd7h+bGJZsKouPq7SVjOk0eoMfcOHL5c+elMcdRggTV7ErdVwxkQjdQqygkGdWZxCAZ3XsvctoP7t/lmZO2ZnkpuGYvG6RkU1IXW6bswL+WydxUXJkN76XP7+r9LNMqqPzlVF/Av3YaECKBCUF9AcPSiD7+i11JRMvYAzeQ8k5rV8TTYqMvIN/oUO/Jaq6Eg5wFCBfvdQKDQPa0uKFD2nBPIad0B7LSVmZ+ilVWeo86N9qQeNtB5cVzPPYBXf X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: d7d8ad19-7bd6-49cb-b8d9-08db52f5c1a2 X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4343.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2023 14:32:47.4143 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qnU8+P8C1RDf5QLH2/MK8heqcYlNWwYNFqiJihq3WWQ7KRSwbenqr81BhPLzeWHNJQyMcuvVBHTHpm1V37JRWg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR02MB7657 X-Proofpoint-ORIG-GUID: t6UyDk2QoFIgjbvOt8CPopmZ_hNpyNRG X-Proofpoint-GUID: t6UyDk2QoFIgjbvOt8CPopmZ_hNpyNRG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-12_08,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.155.12; envelope-from=het.gala@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=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 patch introduces well defined MigrateAddress struct and its related child objects. The existing argument of 'migrate' and 'migrate-incoming' QAPI - 'uri' is of string type. The current migration flow follows double encoding scheme for fetching migration parameters such as 'uri' and this is not an ideal design. Motive for intoducing struct level design is to prevent double encoding of QAPI arguments, as Qemu should be able to directly use the QAPI arguments without any level of encoding. Suggested-by: Aravind Retnakaran Signed-off-by: Het Gala Reviewed-by: Juan Quintela Reviewed-by: Daniel P. Berrangé --- qapi/migration.json | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/qapi/migration.json b/qapi/migration.json index 82000adce4..bf90bd8fe2 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1423,6 +1423,47 @@ ## { 'command': 'migrate-continue', 'data': {'state': 'MigrationStatus'} } +## +# @MigrateTransport: +# +# The supported communication transport mechanisms for migration +# +# @socket: Supported communication type between two devices for migration. +# Socket is able to cover all of 'tcp', 'unix', 'vsock' and +# 'fd' already +# +# @exec: Supported communication type to redirect migration stream into file. +# +# @rdma: Supported communication type to redirect rdma type migration stream. +# +# Since 8.0 +## +{ 'enum': 'MigrateTransport', + 'data': ['socket', 'exec', 'rdma'] } + +## +# @MigrateExecCommand: + # + # Since 8.0 + ## +{ 'struct': 'MigrateExecCommand', + 'data': {'args': [ 'str' ] } } + +## +# @MigrateAddress: +# +# The options available for communication transport mechanisms for migration +# +# Since 8.0 +## +{ 'union': 'MigrateAddress', + 'base': { 'transport' : 'MigrateTransport'}, + 'discriminator': 'transport', + 'data': { + 'socket': 'SocketAddress', + 'exec': 'MigrateExecCommand', + 'rdma': 'InetSocketAddress' } } + ## # @migrate: # From patchwork Fri May 12 14:32:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Het Gala X-Patchwork-Id: 13239403 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 809C5C77B75 for ; Fri, 12 May 2023 14:34:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTpN-0007ti-CE; Fri, 12 May 2023 10:33:01 -0400 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 1pxTpH-0007qd-PZ for qemu-devel@nongnu.org; Fri, 12 May 2023 10:32:55 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pxTpE-0002b6-Nx for qemu-devel@nongnu.org; Fri, 12 May 2023 10:32:55 -0400 Received: from pps.filterd (m0127838.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34CDMYCK023351; Fri, 12 May 2023 07:32:51 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=N3CyYJTrOs5js3/oO8ouqvtCB1P/3C/fDCKDz9etPGQ=; b=xZnYMuF3eNQbAmz6yH4kvh23AFJlK4r9+LVurnT4Q6koYPfOjQUQnr7X5b5B2ulCteyf 7crtL9w3ImQf/6RkcRBbfPanYc0bVg2d4jqwHKNT+AYpfTOFEwI449wLzzaBIDrZtoqp 2jGJH8GCWqs+9m7FH7RrCXyfZOXvk3nI9wFp63SMHZi1AQ9mCvwPUW2bvFPO+lGkgoTU AHq+3WX8+qndDe+GCICUrDotNbx37ZMyxC67Dq4VmqBhaMVn5x6tJzqp0Q3zpnQ46DA7 EzoNLAc8bpRQ9ruyLF4j1Kc0IOoea75P84MIweStsy5twW1VjFT5EWbU8QyXMolRlsA3 PQ== Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 3qf7a9rdy0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 May 2023 07:32:50 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oZOEroN96UoBYsanX8S+QEChYjV+gwK5pxoARC6kc6vMWFn6UwrUruQP6GVFBtVtvzqN8Uvi4CfrGk/99Vnd2sFVTt8J9QBsXPr3cLxpkp5+LLv7224PGTXS7IAvGbgPQ86yMj+tBVrG1eG1PQDXgtGBu6RxraAsrhu+UcBB9OUJP3mP7dRfzy0qCgMCXDzB7QQUtW56EmqxFOGMDXX3hy1woa+64bxguNmLe27u1A3cuJr6WxhO78E2k/Zri2PvyrSzGr+Q/A7Y1wfdrPdNTpmUvWM0RCjhvzxYb2vPhVTulMBFGYd37bobHXtMHH9o6xj42GUamphDa6VcpBmbQA== 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=N3CyYJTrOs5js3/oO8ouqvtCB1P/3C/fDCKDz9etPGQ=; b=jWHfAYpy9WDhg/8mSUSyTAJQ0xnosIV5Qsi5543yjU7+xuV4s56VsJfjoHgXvp98SjApTIYBlp2FavfBhrEoH40Ql2PGGtkDltPBSIJXuwab9GqcHqOGZAPrdap+zVxBrgxlGvufdPG97A+vbDIPgEZCk2DndQP75Xm7UiaJrF19m+MPBWG+bFVon2mOm9m+jMJ9HciBoqFo4pusLEmIHC46a/r6Rgu3wuFMgzch/uFeNigTGw78ReF7qMX7rToQwCGArAezh2CfpBcaa+Mbs26W2Mo6inYxUzcjpLZv1iMXiWJqaptofprnsScBPHIikfK/+wtAezwL+gHN7DF4uA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N3CyYJTrOs5js3/oO8ouqvtCB1P/3C/fDCKDz9etPGQ=; b=nv1INIAdLknSuELwWpEiSMRGj3cEFeFZPUUNNu5zdks2jT97UalE7LGfmcMgrscL5CAFqUZSKmSXLoN38EhkVt/TX75YDIRB7YKSXy7dcVEKnmpP2ILD/5wYfuHJUtR0YrMAVVg8EDMqSL96wdg9iaBgbe3ryMiLhKeUYuDToDjp6VJOUUGrp/AA6rwbyThOZEvoHpKysw5CKBxiVpws/LQdAq/cUS+y9Dzs4tOvr5xdcbb3tXLAt5INmCMCErHA2yFM4EgbZnYFsYCJKzR6ok+p0Cg6nrmV6skAnjmQSsW9JgvfT5knaUjp1QZG41iEFhejLWfXepmJrO5WfoFcJw== Received: from BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) by SA2PR02MB7657.namprd02.prod.outlook.com (2603:10b6:806:140::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.24; Fri, 12 May 2023 14:32:49 +0000 Received: from BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::4500:569:a3d6:71c9]) by BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::4500:569:a3d6:71c9%6]) with mapi id 15.20.6387.020; Fri, 12 May 2023 14:32:48 +0000 From: Het Gala To: qemu-devel@nongnu.org Cc: prerna.saxena@nutanix.com, quintela@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, berrange@redhat.com, armbru@redhat.com, eblake@redhat.com, manish.mishra@nutanix.com, aravind.retnakaran@nutanix.com, Het Gala Subject: [PATCH v4 2/8] migration: Converts uri parameter into 'MigrateAddress' struct Date: Fri, 12 May 2023 14:32:34 +0000 Message-Id: <20230512143240.192504-3-het.gala@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20230512143240.192504-1-het.gala@nutanix.com> References: <20230512143240.192504-1-het.gala@nutanix.com> X-ClientProxiedBy: BY5PR04CA0014.namprd04.prod.outlook.com (2603:10b6:a03:1d0::24) To BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR02MB4343:EE_|SA2PR02MB7657:EE_ X-MS-Office365-Filtering-Correlation-Id: 85e68baa-08df-490c-6f5f-08db52f5c280 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +AHiXQo840pZvSU3tNIHnK9X45pYOAdBHqPhNdftFehubV5zKoUHR2KcEGBttcn9NJ5+53YWVBDod/1HxJLnoWwubtMXl+eOzjIqVklB8af36fFqmpq+q2ll3ZzIVeOBGN+CbIMJycFsgt8iZFnG0vUTJKxH0mNTJk6xFwfpJ5kQRu+NFKmEkZZKqm8liMfszAKXUUqeDKbE5mic9cI3udpQsFe80OTUGVhQyUopni7DSCPzRFMypiI+Ao5wNSXbRP0n30m0qEAIft1Uymj33Ja8VOFkhMxzO/oBC2f58bqj3x+T+tA/V2VfJm0pRQA0978tSwBeFQTIl8214479rotD3IMSPoPDi3AQuIXsobkPgdx2K6u6H/eT/esErtagXx5CbfMrCU98mAfFYtA6ifV2CUL1gDaI1XqQmW9aWlrdE2s3Owo5ZGp8Rxk2iOBXvvUrJVOVkWRYz616raYoEDJeQVPU+XlZ12a4USJXtk8F62dHfdN9MKdEfq2sIsXiebPoSVjIMILPMsdGtkizVjJXLZqi+OfAejWpZri3sIkzXZlN6CT8RkSIOStSVpiVNAm5FA60fERQaEskpUDEQeaYzvBRvrVjuGV5Zrm2y4GfA3LvGU41z5Vl2SIUxYIB X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR02MB4343.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(366004)(376002)(346002)(136003)(39860400002)(396003)(451199021)(36756003)(38100700002)(38350700002)(186003)(26005)(1076003)(6512007)(6506007)(107886003)(2906002)(2616005)(83380400001)(86362001)(41300700001)(6666004)(6486002)(52116002)(66946007)(6916009)(4326008)(316002)(66556008)(66476007)(478600001)(5660300002)(44832011)(8936002)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uGzYZ/HUGQukeyznPhch3kPRzLko9x99OCR8qK2P9WNOn7o6xwDs3bu6Bs+ibuEaRAYlh3897DL7TrYDJ7jHHRMQ0c62dRKfUJvCgD04f0Fi2xVUEuhDbard/foeCDBC1x1bnhlwPfYZ7G6k8uJM/wAOJQkx+4m3rOXoWufawJkyaA3cmeGmNqF9S09fUFKuE+SGf2N4saO2+MmBdJ09wCpUT2d48cgBuKhyuGtfHyI58PqwQi2bxDGQMvYu+qvGSsuUMZDYTwbgfPS+xyQBp9zldT+S58Bi4h89tbHBZIs9YWGXmc5XUWjQswS1VRkvDOUKabXOQB5PX834v8gTd4icSIXdjr01+7VUqmqjhfABl3rOICrUOJ8nmZHCfKgN3WGi/qZro7nn6OvQl3cCtYLNsbw/Zcyywb4R99Gd72KsrkCQWTNu60G7MfmX9pis5R+bpoXBrfP0mr/m8A0w6wMnfcxbeyeiyLhoVNZb19C05LbYqdA4GzOEE9WFe4eOPym1DmHvOVflIO+XPnYJPjl2wlqdpiflH6aPpSDA5MTvq9IxsB4Yday3eqOKp+Xv82TsBM8RIm1B/mbV+JTzpSyB54h4LGlnGcaoMZ+N0or5nRMKAEIM10gsxpuWuH12DhSUmMisXaqDuDUFz+1pb2Lz2uFaS1wSvkTYNXUGkihKzABR+RKHyP/BsLdFjNjHbAsIgkeempq2dI1XdJTGvCu5lmCTapJ1ImOKXdd0mkT1Lxei/Rsig3CwQnGgIyctRSy7JltwJGirEO5XyQabKIDFH6/V4HjZHQW34ZosaCMh5HU5byJBq8WAQcluDu2dVSjrbh8AcaGpZhs0P1L15JGF85wJQCdRZ0WSVQgwXppWKTCsrSu4VbR0um5OokYwNPJVD1s9SOvKIoOCHKrFhDRMUOiP9cj67YlLrhsvJFBJk/9TinW1FSBLQkHHG0Ih+kWaKN2ul2fwqPr2gaLxcT5fcVfeKrl1wbhA+szD6239ecfoBO5QaIEo3HXP+wd37tt1W/22d2sDuXznrddcL4jSzaU7M0MVGeF414YPE/E51BRUupe1k+2k1frKxtjPAAvlYpBgZMgZf62YxcLT3JyyZuCqzzb5x5FTP6sAV6KlFqT0gzPaCwzqs4ml3UIgAGGblSUevJb47sT0Jn8VZDj2p1KbcUdWFI2O3wSfQkm9VvuNEX3zQFvOglBjDe3mWki9X7sDC8CntYP/yNQJs+L2bnn3U5PX1OvU1qQDEB0GEkkhD9nKnFbVXYaTi3LXkBkkbT+XMASDV0uf+Xyn6vNxoj8P1yW9wprCcPUcuqmZPLxyvGHiFDIn0jz949S43E5ZsqIT1tLxoWgGC8l87Ydlb0q3ivrzi5PDx/nlYW3mcLqOj7t7zhA7nn1RG1VkRLR4OHXW9DIYUCc6VR3HjHd1ZojY8kglv0sHeg758rYgZgiQ+5oggitvDLWge7Yz87b/z5D2EZc5XvvjlDuaqNo3THP2b0X5sufq+dgQ78L3oqRJL8EaTR5spHOPKuOMdUZJPac7jRmmgpiN8xRkJym4zatTcExv3Q5GDdDwG62mm8EJ4V1d6QZWVmGdgSThHXIiXF62gqg94WO1OD24FA== X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85e68baa-08df-490c-6f5f-08db52f5c280 X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4343.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2023 14:32:48.8542 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VHJH3JHMJHpqSumtrj7NXnu/rwgpJ/wr5I0iFZpGWSdbInpScOsr9diaddMXfX473UAeO398cY/6/+o+t6oaGA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR02MB7657 X-Proofpoint-GUID: P2XlSL68VSiLa3uHCN7EG3X9zVrzjY-R X-Proofpoint-ORIG-GUID: P2XlSL68VSiLa3uHCN7EG3X9zVrzjY-R X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-12_08,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.151.68; envelope-from=het.gala@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=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 patch introduces code that can parse 'uri' string parameter and spit out 'MigrateAddress' struct. All the required migration parameters are stored in the struct. Suggested-by: Aravind Retnakaran Signed-off-by: Het Gala --- migration/migration.c | 63 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 0ee07802a5..a7e4e286aa 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -64,6 +64,7 @@ #include "yank_functions.h" #include "sysemu/qtest.h" #include "options.h" +#include "qemu/sockets.h" static NotifierList migration_state_notifiers = NOTIFIER_LIST_INITIALIZER(migration_state_notifiers); @@ -408,13 +409,58 @@ void migrate_add_address(SocketAddress *address) QAPI_CLONE(SocketAddress, address)); } +static bool migrate_uri_parse(const char *uri, + MigrateAddress **channel, + Error **errp) +{ + Error *local_err = NULL; + MigrateAddress *addrs = g_new0(MigrateAddress, 1); + SocketAddress *saddr; + InetSocketAddress *isock = &addrs->u.rdma; + strList **tail = &addrs->u.exec.args; + + if (strstart(uri, "exec:", NULL)) { + addrs->transport = MIGRATE_TRANSPORT_EXEC; + QAPI_LIST_APPEND(tail, g_strdup("/bin/sh")); + QAPI_LIST_APPEND(tail, g_strdup("-c")); + QAPI_LIST_APPEND(tail, g_strdup(uri + strlen("exec:"))); + } else if (strstart(uri, "rdma:", NULL) && + !inet_parse(isock, uri + strlen("rdma:"), errp)) { + addrs->transport = MIGRATE_TRANSPORT_RDMA; + } else if (strstart(uri, "tcp:", NULL) || + strstart(uri, "unix:", NULL) || + strstart(uri, "vsock:", NULL) || + strstart(uri, "fd:", NULL)) { + addrs->transport = MIGRATE_TRANSPORT_SOCKET; + saddr = socket_parse(uri, &local_err); + addrs->u.socket = *saddr; + } + + if (local_err) { + qapi_free_MigrateAddress(addrs); + qapi_free_SocketAddress(saddr); + qapi_free_InetSocketAddress(isock); + error_propagate(errp, local_err); + return false; + } + + *channel = addrs; + return true; +} + static void qemu_start_incoming_migration(const char *uri, Error **errp) { const char *p = NULL; + MigrateAddress *channel = g_new0(MigrateAddress, 1); /* URI is not suitable for migration? */ if (!migration_channels_and_uri_compatible(uri, errp)) { - return; + goto out; + } + + if (uri && !migrate_uri_parse(uri, &channel, errp)) { + error_setg(errp, "Error parsing uri"); + goto out; } qapi_event_send_migration(MIGRATION_STATUS_SETUP); @@ -433,6 +479,9 @@ static void qemu_start_incoming_migration(const char *uri, Error **errp) } else { error_setg(errp, "unknown migration protocol: %s", uri); } + +out: + qapi_free_MigrateAddress(channel); } static void process_incoming_migration_bh(void *opaque) @@ -1638,10 +1687,16 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, Error *local_err = NULL; MigrationState *s = migrate_get_current(); const char *p = NULL; + MigrateAddress *channel = g_new0(MigrateAddress, 1); /* URI is not suitable for migration? */ if (!migration_channels_and_uri_compatible(uri, errp)) { - return; + goto out; + } + + if (!migrate_uri_parse(uri, &channel, &local_err)) { + error_setg(errp, "Error parsing uri"); + goto out; } if (!migrate_prepare(s, has_blk && blk, has_inc && inc, @@ -1688,6 +1743,10 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, error_propagate(errp, local_err); return; } + +out: + qapi_free_MigrateAddress(channel); + return; } void qmp_migrate_cancel(Error **errp) From patchwork Fri May 12 14:32:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Het Gala X-Patchwork-Id: 13239402 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 E9A93C77B7F for ; Fri, 12 May 2023 14:34:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTpN-0007tk-SQ; Fri, 12 May 2023 10:33:01 -0400 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 1pxTpI-0007rA-Cq for qemu-devel@nongnu.org; Fri, 12 May 2023 10:33:00 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pxTpG-0002bW-95 for qemu-devel@nongnu.org; Fri, 12 May 2023 10:32:56 -0400 Received: from pps.filterd (m0127844.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34C9Pmi5017311; Fri, 12 May 2023 07:32:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=4byoTQHgW9p8E0ZdfBu9N/IDzwaj3mwLPK1b8AllrFU=; b=wFjdlxyXpKtLWid+L8PJRtMgMICGTjp9CfpnPc+jgrQXzs6lritDj3mp3a6ksSg6vNhd JHTLzOZ/l7mXLiQyilZJwZB2LCJw5J/kazLmD2w6vuJKdKHpHdfsFQZG1+/OR34cgmhN xPUDj8YEuKN2jsdbD8fBzLf1Pw0U0e/Tal/NHFUIejkgiIRwWaeD9116IQtTP05DEOY/ PUevsysVlQF12y7YGDZL+XpGRC/zbZQk92fZs/YkEoancoBy1H/rClJOLwPqi6UoyrmZ nCy/iIA79YEcwQZLy/QaSzG7tEdkbfAL7Cxwt5bQPJTP8KYOFlQr+G2snSkJKhL3LBNT NA== Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2049.outbound.protection.outlook.com [104.47.66.49]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3qf7vv9x1w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 May 2023 07:32:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aFMOV2jY8vcXywuZl0+abWc4PRsGABKF+iodJjYrN9K+xVGEZ1iNt5ZQ1VIUDPPOsNvvEV3qSrqmgj9fvCdrOq/y0jlZLqOP1ivTiaToCz+HTWB09us50V1jwOfnrrvD9IPoZBfDc43FLQikcpWghUvvbX+b3b9uEhvZRqm5ZQZXfiGz9QdX6lnjUvlU3LPBAXnl76rTNq59vzyD5ztXLl/46PdxfLXL7r59Gcvk7Ag91af6I1xZZJh8DmeECL+ACYHUpzXbbsywkzWgp7bWoMFSPisxuGvAzXrKYyD7Clsm4UsxO8Orz+KE6dNkXCzdN5od/ZO3sAcZrF5LCqiHHw== 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=4byoTQHgW9p8E0ZdfBu9N/IDzwaj3mwLPK1b8AllrFU=; b=Sz2i+VAVLloQmzW8CkKYWoWImcy41zHquvy/zJSoR8GCW993hzVWzJTZWwukw5sMcKSRUKK8nwhlnOlVc5U1iJn7ztk1jWA8ON6FO34Zi7EZOxeSl0HElsxULoJYrFd7gt/yg2bwOyCi9uIByb6Sl9j5DUxXGPk3/4xD4wFpZ1sQEb14TUabmLeEGnzb9AIvAdqFv3qsYW1DZ+6ScWV7rUIHuB0BuTtkkKKyB50yWuQc2OfCwWU7E4GZ43xEB0o+WliGroQHNeKEHsn+p/qZqrnH6zfPPmrp1yfzqx6PAUrSmNWretW6tAGiReCvvssBwYktfrd8FfzDnWFBttrWRQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4byoTQHgW9p8E0ZdfBu9N/IDzwaj3mwLPK1b8AllrFU=; b=nDZBPV49tOVSl6S7+bSsXZlqlZmhsXiNuybMLdIMtHYENMwS87V9N6qDQAX8yGFxXElr8TZDrOmuAMvWOLrXr36Le9yTGDFMFH/lWaZMNmGgbRDjivYry1XISGzHdTS+4SQUXl3IdWFdevUsJ200xxC1LWS/6ghRQ9YTjhdsPBobK8uaiZQeZflf2S2vXkYpX1et9AVDHaDb16BtPvSH9N/Ov7YgNKxW1n/QQ40/SvhlAr89BVkyFRCVIdFXMRuN3pCpB6l53JcD1oXP9fTYyNDdJPL6z3f3jBcewWBoBTbLuBeoaoGLXNK1s3iI0/APz5NL+QrY5CFs/ynYOXIgvg== Received: from BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) by SA2PR02MB7657.namprd02.prod.outlook.com (2603:10b6:806:140::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.24; Fri, 12 May 2023 14:32:50 +0000 Received: from BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::4500:569:a3d6:71c9]) by BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::4500:569:a3d6:71c9%6]) with mapi id 15.20.6387.020; Fri, 12 May 2023 14:32:50 +0000 From: Het Gala To: qemu-devel@nongnu.org Cc: prerna.saxena@nutanix.com, quintela@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, berrange@redhat.com, armbru@redhat.com, eblake@redhat.com, manish.mishra@nutanix.com, aravind.retnakaran@nutanix.com, Het Gala Subject: [PATCH v4 3/8] migration: converts socket backend to accept MigrateAddress struct Date: Fri, 12 May 2023 14:32:35 +0000 Message-Id: <20230512143240.192504-4-het.gala@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20230512143240.192504-1-het.gala@nutanix.com> References: <20230512143240.192504-1-het.gala@nutanix.com> X-ClientProxiedBy: BY5PR04CA0014.namprd04.prod.outlook.com (2603:10b6:a03:1d0::24) To BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR02MB4343:EE_|SA2PR02MB7657:EE_ X-MS-Office365-Filtering-Correlation-Id: 6273225a-0d36-46f7-117f-08db52f5c36a x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dScOlUlfopojwkY0EnkvoTY3inPBBFonLsy/8jKRJzii7kJW4+OeCoSf3Wc5tURl6IqMPxawto4YJbODGcL3x7fej7G8qT5bGf/o6Bx8Y0k0tGM025s+9rKpEKpewUF9hImy1exxfgBLkI1f959LyX7iyPZcyomuteJm4CLcZJRE1gA5EW3LDFeKKepdkCmPRzDkHKE7w9p0DB3/Ouhu09J0LVFxuKPcEinpNJsuxr+c8ueKMIb2SEiYtm5MuUy+DmMfQAdRTQRBWcxDM4rSAfUp/0gIOnVrA/P8udKP056VJ7XFkyBqItadDhwHA2aS/jM4JPNUyMLEFhyqmd/6FI6jQNlqAHFL9X3ZNB7EdOrWOkpiLaJtcmAGoQBicDf7Lhn3DXz/uPB66xzmtJpNJJjVHzAJW4OU5zQ6qfdojIgtmP2pQoc3TkTjH1FN3U624JVwXNqhvNXjaWuDjkpWLQ2ORyHIywLswliM56FjoVL2Ypf1pokhR+uK+dPieQE9c6n6bd1TFI+0eSJ89ODtmD51y1lpSRnNhQmysSU4LdROpOTOQp0CRyThpx0Wmk9hIfk1TplJAhmqpjyBHt9GiRwrSePqRbpfo7TLoRt6TD0tdNFDGEU65bRCwJOD88Ms X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR02MB4343.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(366004)(376002)(346002)(136003)(39860400002)(396003)(451199021)(36756003)(38100700002)(38350700002)(186003)(26005)(1076003)(6512007)(6506007)(107886003)(2906002)(2616005)(83380400001)(86362001)(41300700001)(6666004)(6486002)(52116002)(66946007)(6916009)(4326008)(316002)(66556008)(66476007)(478600001)(5660300002)(44832011)(8936002)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yTreaZj8oQFt4R3LgY7ZIMl87SLyvFhxejoQqLUtMK4jZgCCBSo3BVut/EUfNiDaiWsTWBHe0QhdLCs10Pn3TS/mX5Pm+EiYHFqyf2n2LEdou07Q3ZLE272TauGhL83wnEid9JqMJbaL2R25RUCzBaE4TZW4qad4tLjDk4HLXaIp7pKhRRVnwfTRkSbVGI3ZbAP2KvHFK3T+R3Sq/slCzBJU/gVRubiWKp24ocZZksD+b49R3UZjv+uNyFx8PsQWfiJblHQkSxeiMf0BcriJjXHRMSz6VaifTwr2hesWRr5Un3pgKIzMKxRrS7H0OQwLbjwdy8GSNcTJLZXdvufEhQ2Jwtd0mqkfB7bQ2GlVjmk1mvOBJQCL2k9ojwAv3glliEnqNXy1vZ0t2WtVdKwmzgNZ2rsnd53AvtAgr7FOWkQ5Qb1B4RJAJSA+PPRE01XUCemp3Lohub8Ht5iF3XfA/g6Ea7IHfeUAE+sAp2FGYkJ4pQt7NnKzFf2hUDBZ3q8xlBqtXVf2VG7A2UZnZmggzG2XxdTA0gCE5iOjvBVFDGtvknxSjrmHtYcjqD8mn6skG2vUEe8kr5Cy/Zi8Ir5Lf6boh071MFzKRULdz7vc9pqo3ejrucHS2zRJAA8B8yl9qcnvX6VlzDxhM+qFzuDialC6Ww4yfBZ7D1Kv/nxArnMwb6CkmXTDfHl3IseXXtQsgd6uP+CZIa/Tc20VfvbyswldZOtUe6iv8+3ba5YtywDpLU+wQRgHsopzuEFuP/YcGpY3hASQ9PkNiZYhgBo6lTPp0lEuq8NmTt2tk3FpXP/QgOKgeeTM20zzqFmg9avcA1aohc7RZzpuOhHWPUoihXi7TmNmKdcff+N2itxzgtHL2tcLypQVD6IWolCi97d04/amKqPlm/nV4BqMvYoskOKes/GUdBtYddrvqidQ9zlPNOW7SAmK8es2v/QOWlfwbuuncajTKWH68/w6pQfg2WKDONTpVBani9+KKfQjXDqCzSek01H0xMvHlHW+jKqOhy/Acj4xyPeh8GZKmnedJrpsKVEeekpiWELrgTzMpfajKMOLmPHQixdh3MS0GUm9UStRaQWoZ76DDqSRUSgijcvjJO9Syxv4+CpEssVfaESDRy7ptVKY7xMEYE4ainMiSrguOU6TDmP+1FDTdGoLVf4I+zIYK2nJmZp+uVdgvY0qHzKIfntrKnudbK/P5QL4KvZfLm1zNN5+8QI+kw9/ylpW+ZCJ8I9esy2HdbplUi2d7XpkgAMyLS23NTJjh/xo5ZyUx5YxfjuuKJtJpcpMTcbapjAoaYTko5vXCfsdUfz5CjQlxs3SpaifVLM1xY4YaadQLZRVxSJUQh6JsyGN5PrR058TXLsJK0ztRCao07oNTMyCEoYGsfWQw3waUhouV1BP9b+HF+7jxQvocrrTDIVkDGSarATFffXp1vcVOZaB/zQ27FcwvcRyKTQNN1mceaZIA/ukcOplR/YCVL/CrzDTHhoOW70AhT97JiQ7rdIG5b4Xn7vQUiQAhOPjKzRZy13Q1z7UAarH/iXEeIVwgGUUEgjAl2Zr6a8nOAELRuxTOyBlIxrMm0aHXqiE/rMbDBW+G6vYx8H7u3R9elnRdA== X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6273225a-0d36-46f7-117f-08db52f5c36a X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4343.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2023 14:32:50.4077 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: g38xsVKZWQNIChBVvHzz8o1ZOhX7OvWrGjhzXW8A657aOfGPUBIVX4LcDAsKEFzlrUvqD8uBMRvJNhpvXPWcpg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR02MB7657 X-Proofpoint-ORIG-GUID: Opc0S_bmm_AWNJ9GhI0P0hbb01GE6_Cr X-Proofpoint-GUID: Opc0S_bmm_AWNJ9GhI0P0hbb01GE6_Cr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-12_08,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.155.12; envelope-from=het.gala@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=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 Socket transport backend for 'migrate'/'migrate-incoming' QAPIs accept new wire protocol of MigrateAddress struct. It is achived by parsing 'uri' string and storing migration parameters required for socket connection into well defined SocketAddress struct. Suggested-by: Aravind Retnakaran Signed-off-by: Het Gala --- migration/exec.c | 4 ++-- migration/exec.h | 4 ++++ migration/migration.c | 44 +++++++++++++++++++++++++++++++------------ migration/socket.c | 34 +++++---------------------------- migration/socket.h | 7 ++++--- 5 files changed, 47 insertions(+), 46 deletions(-) diff --git a/migration/exec.c b/migration/exec.c index 2bf882bbe1..c4a3293246 100644 --- a/migration/exec.c +++ b/migration/exec.c @@ -27,7 +27,6 @@ #include "qemu/cutils.h" #ifdef WIN32 -const char *exec_get_cmd_path(void); const char *exec_get_cmd_path(void) { g_autofree char *detected_path = g_new(char, MAX_PATH); @@ -40,7 +39,8 @@ const char *exec_get_cmd_path(void) } #endif -void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp) +void exec_start_outgoing_migration(MigrationState *s, const char *command, + Error **errp) { QIOChannel *ioc; diff --git a/migration/exec.h b/migration/exec.h index b210ffde7a..736cd71028 100644 --- a/migration/exec.h +++ b/migration/exec.h @@ -19,6 +19,10 @@ #ifndef QEMU_MIGRATION_EXEC_H #define QEMU_MIGRATION_EXEC_H + +#ifdef WIN32 +const char *exec_get_cmd_path(void); +#endif void exec_start_incoming_migration(const char *host_port, Error **errp); void exec_start_outgoing_migration(MigrationState *s, const char *host_port, diff --git a/migration/migration.c b/migration/migration.c index a7e4e286aa..61f52d2f90 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -421,7 +421,11 @@ static bool migrate_uri_parse(const char *uri, if (strstart(uri, "exec:", NULL)) { addrs->transport = MIGRATE_TRANSPORT_EXEC; +#ifdef WIN32 + QAPI_LIST_APPEND(tail, g_strdup(exec_get_cmd_path())); +#else QAPI_LIST_APPEND(tail, g_strdup("/bin/sh")); +#endif QAPI_LIST_APPEND(tail, g_strdup("-c")); QAPI_LIST_APPEND(tail, g_strdup(uri + strlen("exec:"))); } else if (strstart(uri, "rdma:", NULL) && @@ -450,8 +454,10 @@ static bool migrate_uri_parse(const char *uri, static void qemu_start_incoming_migration(const char *uri, Error **errp) { + Error *local_err = NULL; const char *p = NULL; MigrateAddress *channel = g_new0(MigrateAddress, 1); + SocketAddress *saddr; /* URI is not suitable for migration? */ if (!migration_channels_and_uri_compatible(uri, errp)) { @@ -463,23 +469,32 @@ static void qemu_start_incoming_migration(const char *uri, Error **errp) goto out; } + saddr = &channel->u.socket; qapi_event_send_migration(MIGRATION_STATUS_SETUP); - if (strstart(uri, "tcp:", &p) || - strstart(uri, "unix:", NULL) || - strstart(uri, "vsock:", NULL)) { - socket_start_incoming_migration(p ? p : uri, errp); + if (channel->transport == MIGRATE_TRANSPORT_SOCKET) { + if (saddr->type == SOCKET_ADDRESS_TYPE_INET || + saddr->type == SOCKET_ADDRESS_TYPE_UNIX || + saddr->type == SOCKET_ADDRESS_TYPE_VSOCK) { + socket_start_incoming_migration(saddr, &local_err); + } else if (saddr->type == SOCKET_ADDRESS_TYPE_FD) { + fd_start_incoming_migration(saddr->u.fd.str, &local_err); + } #ifdef CONFIG_RDMA } else if (strstart(uri, "rdma:", &p)) { rdma_start_incoming_migration(p, errp); #endif } else if (strstart(uri, "exec:", &p)) { exec_start_incoming_migration(p, errp); - } else if (strstart(uri, "fd:", &p)) { - fd_start_incoming_migration(p, errp); } else { error_setg(errp, "unknown migration protocol: %s", uri); } + if (local_err) { + qapi_free_SocketAddress(saddr); + error_propagate(errp, local_err); + return; + } + out: qapi_free_MigrateAddress(channel); } @@ -1688,6 +1703,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, MigrationState *s = migrate_get_current(); const char *p = NULL; MigrateAddress *channel = g_new0(MigrateAddress, 1); + SocketAddress *saddr; /* URI is not suitable for migration? */ if (!migration_channels_and_uri_compatible(uri, errp)) { @@ -1711,18 +1727,21 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, } } - if (strstart(uri, "tcp:", &p) || - strstart(uri, "unix:", NULL) || - strstart(uri, "vsock:", NULL)) { - socket_start_outgoing_migration(s, p ? p : uri, &local_err); + saddr = &channel->u.socket; + if (channel->transport == MIGRATE_TRANSPORT_SOCKET) { + if (saddr->type == SOCKET_ADDRESS_TYPE_INET || + saddr->type == SOCKET_ADDRESS_TYPE_UNIX || + saddr->type == SOCKET_ADDRESS_TYPE_VSOCK) { + socket_start_outgoing_migration(s, saddr, &local_err); + } else if (saddr->type == SOCKET_ADDRESS_TYPE_FD) { + fd_start_outgoing_migration(s, saddr->u.fd.str, &local_err); + } #ifdef CONFIG_RDMA } else if (strstart(uri, "rdma:", &p)) { rdma_start_outgoing_migration(s, p, &local_err); #endif } else if (strstart(uri, "exec:", &p)) { exec_start_outgoing_migration(s, p, &local_err); - } else if (strstart(uri, "fd:", &p)) { - fd_start_outgoing_migration(s, p, &local_err); } else { if (!(has_resume && resume)) { yank_unregister_instance(MIGRATION_YANK_INSTANCE); @@ -1739,6 +1758,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, if (!(has_resume && resume)) { yank_unregister_instance(MIGRATION_YANK_INSTANCE); } + qapi_free_SocketAddress(saddr); migrate_fd_error(s, local_err); error_propagate(errp, local_err); return; diff --git a/migration/socket.c b/migration/socket.c index 1b6f5baefb..8e7430b266 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -108,10 +108,9 @@ out: object_unref(OBJECT(sioc)); } -static void -socket_start_outgoing_migration_internal(MigrationState *s, - SocketAddress *saddr, - Error **errp) +void socket_start_outgoing_migration(MigrationState *s, + SocketAddress *saddr, + Error **errp) { QIOChannelSocket *sioc = qio_channel_socket_new(); struct SocketConnectData *data = g_new0(struct SocketConnectData, 1); @@ -135,18 +134,6 @@ socket_start_outgoing_migration_internal(MigrationState *s, NULL); } -void socket_start_outgoing_migration(MigrationState *s, - const char *str, - Error **errp) -{ - Error *err = NULL; - SocketAddress *saddr = socket_parse(str, &err); - if (!err) { - socket_start_outgoing_migration_internal(s, saddr, &err); - } - error_propagate(errp, err); -} - static void socket_accept_incoming_migration(QIONetListener *listener, QIOChannelSocket *cioc, gpointer opaque) @@ -172,9 +159,8 @@ socket_incoming_migration_end(void *opaque) object_unref(OBJECT(listener)); } -static void -socket_start_incoming_migration_internal(SocketAddress *saddr, - Error **errp) +void socket_start_incoming_migration(SocketAddress *saddr, + Error **errp) { QIONetListener *listener = qio_net_listener_new(); MigrationIncomingState *mis = migration_incoming_get_current(); @@ -213,13 +199,3 @@ socket_start_incoming_migration_internal(SocketAddress *saddr, } } -void socket_start_incoming_migration(const char *str, Error **errp) -{ - Error *err = NULL; - SocketAddress *saddr = socket_parse(str, &err); - if (!err) { - socket_start_incoming_migration_internal(saddr, &err); - } - qapi_free_SocketAddress(saddr); - error_propagate(errp, err); -} diff --git a/migration/socket.h b/migration/socket.h index dc54df4e6c..5e4c33b8ea 100644 --- a/migration/socket.h +++ b/migration/socket.h @@ -19,13 +19,14 @@ #include "io/channel.h" #include "io/task.h" +#include "qemu/sockets.h" void socket_send_channel_create(QIOTaskFunc f, void *data); QIOChannel *socket_send_channel_create_sync(Error **errp); int socket_send_channel_destroy(QIOChannel *send); -void socket_start_incoming_migration(const char *str, Error **errp); +void socket_start_incoming_migration(SocketAddress *saddr, Error **errp); -void socket_start_outgoing_migration(MigrationState *s, const char *str, - Error **errp); +void socket_start_outgoing_migration(MigrationState *s, + SocketAddress *saddr, Error **errp); #endif From patchwork Fri May 12 14:32:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Het Gala X-Patchwork-Id: 13239405 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 D2FBCC77B75 for ; Fri, 12 May 2023 14:34:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTpR-0007vS-6J; Fri, 12 May 2023 10:33:05 -0400 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 1pxTpP-0007uY-Ei for qemu-devel@nongnu.org; Fri, 12 May 2023 10:33:03 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pxTpM-0002cC-UP for qemu-devel@nongnu.org; Fri, 12 May 2023 10:33:03 -0400 Received: from pps.filterd (m0127841.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34C9NQJl024537; Fri, 12 May 2023 07:32:56 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=UDZn05OAEca7HLJfI4lSENEtwMOG6fFshWxgZ2GPeJY=; b=o/XZ57sqce89y64h3iF8YKNd1LhNEUtt53H20EJ4F7MppVnWBNp/4baBu3wjKt8xKdlU 2MO9Kogl0ubRJdvNLttPNHXnUd7fsdBm0fFG7aSBHcq9vzys1kzjAL2TLRfJeCxpuHWL /SWjN7zH9MT4iHXlWPMpolc/1Aoh9OH1on/JchQAWflVFEUnk1/iDhTnnzJVQgpP8m+V +U9/RDrSLnYM4ayKEPsGmyrhEN8wF8XyVf7um6t3xvtSJULhoKQftPNg3fS/345auql2 TKkcYij0wIMLWfEKnQ0OQRlljjFgT40DmSrLJwQLPr8qDkAvSmNGOxi8GBbcB6gKmHnn 2Q== Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2046.outbound.protection.outlook.com [104.47.66.46]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3qf7g6a11r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 May 2023 07:32:55 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SrXKYBDo5/qainL0d+DpKYwSjgCndtHcgV7+lPbw6l07PXjNL2Y1arGwl9thMnBywO8pkvpo8dFP3hznkSSUsPs6rNDq+vtqlKTbFwtnjDP/A/xVwB8VvGrn1vL5jAJZ7V3H2PC79EA/dHanTkYdDqxdTCgg00TfRdOnwrGGkLi9C5IiUUrpB06H+yT1ZJvcOUtGcmnxnznZncSjFYEnNTIJDaJuXR20CPkqvBE8znQIoFCl0kJJDBEnuad5fdJF7EW1PDJhT799f+lWFoslPxGRPrOTODP8aMhJ0bjLBOuK/Z1hCIiOZurMQpQvVSVdaF2PZ+Wu6ashROoFPnaLtQ== 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=UDZn05OAEca7HLJfI4lSENEtwMOG6fFshWxgZ2GPeJY=; b=D1W/CBMtychWZkubpbpRjuqSufN1t5/u1zUv7sUs38DIsqJU7K96HpDLKCUvMPR+AKXUTcy0AbWbVvJAHGlDvi8NsjZFwlQaSgq/Ksh2n6r3/agCaX7k/cG4zJ3qJAtmckirhI56eOTfeBlIPCoS0o6y2EFTXfFP9eGfhGcKcQ5l2rhGa0TYcKnueyhdMb8m3shjIf6k4vIuSZnHO4Q4gU1kvuSQgE7QyjW4cHmQDfta5ozzggpK03GG1KdUJ3vqZmXdkdhBwNZlGJIvjmrEdLJFBxQiWpAZWOuJgl6u7z4ptJD2bHEtFs5PfTb8p0q2r4E1uHaHlJl/pBjJNYRPZw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UDZn05OAEca7HLJfI4lSENEtwMOG6fFshWxgZ2GPeJY=; b=H98u5+1W/3/uSjLaPw+48T9sXVnxNEJbWWeqZXYInn5uhOzH8OY9xD2ZvBeKUZyw+fG5D8EPyZj3OmYhydMPN7CW2BjNZoP8YkXrlB0EXYgUsKiFlOUtK3lp/1/qxVhr5Szs4TjbhoclZyBoUzi9hP3AdTWyYqw4uPjxcRCDm/8mt6vHjE36EekVeDHUOrcRPPeK6lnZHgphfaP6qWGrYOJ7zUXK9L+PPF0ZLJhRrLrmWLtgFdMzKBXHV/c3b4gW4JaANt3NxOcbsfDPGmHnWIhJcPaCW+MKxjDf05nBH+PlwNIUe57DBsPyU3nZWwvk5cF3lDnHNVsRahnARTI1Ug== Received: from BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) by BL3PR02MB8282.namprd02.prod.outlook.com (2603:10b6:208:345::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.23; Fri, 12 May 2023 14:32:52 +0000 Received: from BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::4500:569:a3d6:71c9]) by BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::4500:569:a3d6:71c9%6]) with mapi id 15.20.6387.020; Fri, 12 May 2023 14:32:52 +0000 From: Het Gala To: qemu-devel@nongnu.org Cc: prerna.saxena@nutanix.com, quintela@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, berrange@redhat.com, armbru@redhat.com, eblake@redhat.com, manish.mishra@nutanix.com, aravind.retnakaran@nutanix.com, Het Gala Subject: [PATCH v4 4/8] migration: converts rdma backend to accept MigrateAddress struct Date: Fri, 12 May 2023 14:32:36 +0000 Message-Id: <20230512143240.192504-5-het.gala@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20230512143240.192504-1-het.gala@nutanix.com> References: <20230512143240.192504-1-het.gala@nutanix.com> X-ClientProxiedBy: BY5PR04CA0014.namprd04.prod.outlook.com (2603:10b6:a03:1d0::24) To BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR02MB4343:EE_|BL3PR02MB8282:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c64e46b-80b4-4dd6-3cd5-08db52f5c45d x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KlGiK4a6sKLgMzibT5xFGrjChr/egRI8a11/x23PVTIwyXy6B+3U/2+sO1/9zW1kDOsFwh0hDF8wr64Ifax8deHQPM9rKnZRPrSBjdWZq2NJh4cE9enlmT3O+a25qfIJ8pCnz/MqK1y8oSyCAAlwvainkQmq8LQ5sHIK8SjudgX5u5W9AMDPeA3aM1CFP6wl2FrK7la/sIMogUcjzWSPLqh0N1dLvlPQQw0z9w2p3xK0GEwMOzBaGUC7cb2MALnKKa4/GoSo3IDWTHjsCHDuLc+1PM6kK5JPNzFqFb+hr6B9dUG+S/oX4HA5h5eUWVBihVI2JbjU0mhQudVqh1GkTNJREvNPH5RfZnBBhStw7bOJXwiN/gvmCa6sX9DQcFkahuAsNnvG64b2yaiviKhmXaO6zS4BACMTmMJlNdYgHNRcmV7b+xo9aNOvHa0OMIY31G4+mBKzTp/OrpTL69UjZOHdkVyM6SONjWSap14S8f3muXfQQX3OcVQLQfSpKCs3P1RM10D4Ep+RnHjAicv9woVACboZVOUp14kjJGcH8QUnMtlDXp6xVEvIlRP2bsYAezONF8i9ux3+J66lkjfdD6+eI0LgxNC3/5Ds7vF9FEgFmNRBBvaUNTYWHh6mqzVM X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR02MB4343.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(39860400002)(346002)(396003)(136003)(376002)(366004)(451199021)(5660300002)(26005)(6512007)(83380400001)(1076003)(38350700002)(186003)(52116002)(2616005)(38100700002)(6506007)(2906002)(107886003)(44832011)(8676002)(8936002)(36756003)(478600001)(6486002)(6666004)(41300700001)(316002)(86362001)(66556008)(4326008)(66476007)(66946007)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VcBBoUs7f8ZkoU18cQZKr4GNFrh7dGfuTDDIMik+JSoX9+Sqzf9pjfiSCI9496uJvjycWNfge3omq2hiGq4pSbQrD5aISWVRzJ+2Q4cGsVWewd5QaFQlcI++1uE6qIsmdTH1ktxGxpo2qvnwh+AtDa47xqLmUpAtfZGAlRhPM1z4r5sBsJyfA0eMF5VgPPVjDcB6hB3A9SO2gHUT9Xs+oqhGE60QyeQsOezwVTBpfDEB7mNFoL4QKV3Onee7uNuax2JHCPEFox+KNGw24VqrGF8/6UDW+pOtAIiTZ0ynyB30kOADAV//jLVRZiXDdcxbobVLs7gvtvgBTKow6ziJ8kymMBOIv7YXM9oRx0naXBgsJ1jKXa5RdcE0hpY5jMEjLxQjegpg/9u0Lt8JFnG7OknxQnvuKhiAqoYgZOVOrGaU9wCQa7LUTUZMelbJ+HfY+Hl1n6caluOJe8Hn3Oz13CYSOU3T1SpDfzFjPpHeBieOfHruxCBE0p7zjE3cV/W0yBpv8trbdwVfT9ND19fqBDm672vK5H3op+bxMG23MDMHp1KUQLrLj5hmUo/bUyMaktX5OlS3tcSujmdwJmj05tUWcWusYvguZZoGp/KTXhTIP98l+gPykNTSWAoGbJrazUxht2Y4E+0bispLlS84JGmcZkGSNficmsUYoncif1dSnJZOLoyovvBu4+WJv85Drcn+dzCsZ24djZLoryz3vFbZ+Zw/8eKDICf2olpCAYwoKqGJp3fmd+s9xcsALFg1PgONaN0UZLWUuQI0OY/A1dlrVL0RQADB70cM3LBDYGuxPVZPDFR+K7Y+1PGsse+VpjXSi+yx/usl4pG1r1B6pVii49KlYjv6JnxXkEQEoEN9UDwY37gLhw4CsOrOhoPwczcd2soegD6JhtseLZrCUVQDxsjQmsKpSUXm9y8DSGnstCGsTj71uzXPgUdiok8NuzdrP1DhCOny3RKSASzK4hLd7jy2hejorsohi93zGAmGTeKOS2o4CQ52QZDEX0uU+uD7mCuM6i4lbR6YmNtXzIPMA2GxSt/cUrv7/uL1iFFGf8HdMetNg/cEvrgGqbybsY9OSVW9SfLey819BW0AU2YNLIhhD2sJ0S5uUZYb2+2F4WJ/Tn2v6oMIKnmH3ccx6Qfi0PGwR/Oq6hh3PHSTzTtyiV3ghA7R3YH2cCu2Cp8FfoM1bvr0RY7HOTK7tYezFmYN9rO4GXQDjwmFOxTdZvzx1GablxFKKzPwFn1TjbIQU1SG/NlBQdkOHzW52ZZBrS1wL3UHy7bN8Kr0tJna3IONPeg6SruV+j1BsdRPxpE2HmDwNBv6cLWuStygkoLz7MKVKO+z7RLrMa7BMSRV4eLTR6SXNZCroU5pBcuxcn0K7skYYmh8/hfoz3puPaGLo6d3cFpa02oryG2YnGR2C5Lv9wKynsoj1bHNJdk1o2nB/Re3WHe8iSRIrsJpj6h1CySdX59Cc82rtIJdilSEkR86cXacdnqjW7p8q6xDv9Akf+lRP2IqLLVlM84Bq06BJ3i4GHWWHNo/EyJW4dKk5OnqUq1mEoTIsFdeR7vsJUsqb6m0aqtLUmU51Qdwum3K X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9c64e46b-80b4-4dd6-3cd5-08db52f5c45d X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4343.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2023 14:32:52.0341 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fTUCRl4JOrdL9Qrr14aqXtlbuEcd+WRadNd7uHxAcId8Sncf3EqN7FLPGiaNwKVQJP2RQ8oSXTD7hXPQ+drW8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR02MB8282 X-Proofpoint-GUID: JxDZnpDzS--d4EdDMyVPo8abtnErqe9g X-Proofpoint-ORIG-GUID: JxDZnpDzS--d4EdDMyVPo8abtnErqe9g X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-12_08,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.155.12; envelope-from=het.gala@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=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 RDMA based transport backend for 'migrate'/'migrate-incoming' QAPIs accept new wire protocol of MigrateAddress struct. It is achived by parsing 'uri' string and storing migration parameters required for RDMA connection into well defined InetSocketAddress struct. Suggested-by: Aravind Retnakaran Signed-off-by: Het Gala Reviewed-by: Juan Quintela --- migration/migration.c | 8 ++++---- migration/rdma.c | 38 ++++++++++++++++---------------------- migration/rdma.h | 6 ++++-- 3 files changed, 24 insertions(+), 28 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 61f52d2f90..b7c3b939d5 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -480,8 +480,8 @@ static void qemu_start_incoming_migration(const char *uri, Error **errp) fd_start_incoming_migration(saddr->u.fd.str, &local_err); } #ifdef CONFIG_RDMA - } else if (strstart(uri, "rdma:", &p)) { - rdma_start_incoming_migration(p, errp); + } else if (channel->transport == MIGRATE_TRANSPORT_RDMA) { + rdma_start_incoming_migration(&channel->u.rdma, &local_err); #endif } else if (strstart(uri, "exec:", &p)) { exec_start_incoming_migration(p, errp); @@ -1737,8 +1737,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, fd_start_outgoing_migration(s, saddr->u.fd.str, &local_err); } #ifdef CONFIG_RDMA - } else if (strstart(uri, "rdma:", &p)) { - rdma_start_outgoing_migration(s, p, &local_err); + } else if (channel->transport == MIGRATE_TRANSPORT_RDMA) { + rdma_start_outgoing_migration(s, &channel->u.rdma, &local_err); #endif } else if (strstart(uri, "exec:", &p)) { exec_start_outgoing_migration(s, p, &local_err); diff --git a/migration/rdma.c b/migration/rdma.c index 2cd8f1cc66..32b4b8099e 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -319,7 +319,6 @@ typedef struct RDMALocalBlocks { typedef struct RDMAContext { char *host; int port; - char *host_port; RDMAWorkRequestData wr_data[RDMA_WRID_MAX]; @@ -2455,9 +2454,7 @@ static void qemu_rdma_cleanup(RDMAContext *rdma) rdma->channel = NULL; } g_free(rdma->host); - g_free(rdma->host_port); rdma->host = NULL; - rdma->host_port = NULL; } @@ -2739,28 +2736,17 @@ static void qemu_rdma_return_path_dest_init(RDMAContext *rdma_return_path, rdma_return_path->is_return_path = true; } -static void *qemu_rdma_data_init(const char *host_port, Error **errp) +static void *qemu_rdma_data_init(InetSocketAddress *saddr, Error **errp) { RDMAContext *rdma = NULL; - InetSocketAddress *addr; - if (host_port) { + if (saddr) { rdma = g_new0(RDMAContext, 1); rdma->current_index = -1; rdma->current_chunk = -1; - addr = g_new(InetSocketAddress, 1); - if (!inet_parse(addr, host_port, NULL)) { - rdma->port = atoi(addr->port); - rdma->host = g_strdup(addr->host); - rdma->host_port = g_strdup(host_port); - } else { - ERROR(errp, "bad RDMA migration address '%s'", host_port); - g_free(rdma); - rdma = NULL; - } - - qapi_free_InetSocketAddress(addr); + rdma->host = g_strdup(saddr->host); + rdma->port = atoi(saddr->port); } return rdma; @@ -3360,10 +3346,12 @@ static int qemu_rdma_accept(RDMAContext *rdma) .private_data_len = sizeof(cap), }; RDMAContext *rdma_return_path = NULL; + InetSocketAddress *isock = g_new0(InetSocketAddress, 1); struct rdma_cm_event *cm_event; struct ibv_context *verbs; int ret = -EINVAL; int idx; + char arr[8]; ret = rdma_get_cm_event(rdma->channel, &cm_event); if (ret) { @@ -3375,13 +3363,17 @@ static int qemu_rdma_accept(RDMAContext *rdma) goto err_rdma_dest_wait; } + isock->host = rdma->host; + sprintf(arr,"%d", rdma->port); + isock->port = arr; + /* * initialize the RDMAContext for return path for postcopy after first * connection request reached. */ if ((migrate_postcopy() || migrate_return_path()) && !rdma->is_return_path) { - rdma_return_path = qemu_rdma_data_init(rdma->host_port, NULL); + rdma_return_path = qemu_rdma_data_init(isock, NULL); if (rdma_return_path == NULL) { rdma_ack_cm_event(cm_event); goto err_rdma_dest_wait; @@ -3506,6 +3498,8 @@ static int qemu_rdma_accept(RDMAContext *rdma) err_rdma_dest_wait: rdma->error_state = ret; qemu_rdma_cleanup(rdma); + qapi_free_InetSocketAddress(isock); + g_free(arr); g_free(rdma_return_path); return ret; } @@ -4114,7 +4108,8 @@ static void rdma_accept_incoming_migration(void *opaque) } } -void rdma_start_incoming_migration(const char *host_port, Error **errp) +void rdma_start_incoming_migration(InetSocketAddress *host_port, + Error **errp) { int ret; RDMAContext *rdma; @@ -4160,13 +4155,12 @@ err: error_propagate(errp, local_err); if (rdma) { g_free(rdma->host); - g_free(rdma->host_port); } g_free(rdma); } void rdma_start_outgoing_migration(void *opaque, - const char *host_port, Error **errp) + InetSocketAddress *host_port, Error **errp) { MigrationState *s = opaque; RDMAContext *rdma_return_path = NULL; diff --git a/migration/rdma.h b/migration/rdma.h index de2ba09dc5..ee89296555 100644 --- a/migration/rdma.h +++ b/migration/rdma.h @@ -14,12 +14,14 @@ * */ +#include "qemu/sockets.h" + #ifndef QEMU_MIGRATION_RDMA_H #define QEMU_MIGRATION_RDMA_H -void rdma_start_outgoing_migration(void *opaque, const char *host_port, +void rdma_start_outgoing_migration(void *opaque, InetSocketAddress *host_port, Error **errp); -void rdma_start_incoming_migration(const char *host_port, Error **errp); +void rdma_start_incoming_migration(InetSocketAddress *host_port, Error **errp); #endif From patchwork Fri May 12 14:32:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Het Gala X-Patchwork-Id: 13239406 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 F24B3C77B7F for ; Fri, 12 May 2023 14:34:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTpO-0007uR-Qn; Fri, 12 May 2023 10:33:02 -0400 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 1pxTpN-0007tm-TQ for qemu-devel@nongnu.org; Fri, 12 May 2023 10:33:01 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pxTpM-0002cN-0Z for qemu-devel@nongnu.org; Fri, 12 May 2023 10:33:01 -0400 Received: from pps.filterd (m0127841.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34C9NQJm024537; Fri, 12 May 2023 07:32:57 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=qNf8zk9R1ok9mC1KssQChP9FHfwfh7BRpQvMUbN7qAM=; b=S4GkdDV2PbwUgP09/MtGc2FJ1s/6QQUfin2sY3ST4XC+0v84Mmh4hiSc2mTAXKfPJYTF mJQOCL0+8cvfWuOtsqWUl4J0/NgHVVCF9QYQQLof4z0mVxby9udrNRLVGyOtBAadyN1T yvtGjexgTQ9+XEHZixa8rjpJRjxaUQulW0UDDUrAurk0JKUkzMPcKmwZDYb08u4KUsYJ 3M72pAFeyGaAyT7kfZvzWv+SYfIwnkQt9h8gt/sD/gldfrDhpZ02SuXBW4r+a4AQDstI lSMq+zg51E5iag0rVC3VY1DndQbi6Qvpz5IX+Qt+vPKPMZCiY3Yyh991iE60FpeCYrUW lg== Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2046.outbound.protection.outlook.com [104.47.66.46]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3qf7g6a11r-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 May 2023 07:32:57 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JgC6yd1eodXLY8haUL51Ijc5Fb8TdjvAB9pjRmJ90/rVzHi5D9ULNrMbYjVMt3pc8WuhvCPesDtOHSZcRkm4d75r/qJhbJEc/qoDsTPZbuRjTaVrIXXqTyjqZLxUof5wvvx8gHPj3Su023aHW7NGEADkB+tVdhDbT55WVLf2jt+QpTgrggGqlsE0n8oqhW6V4OT4I+goQSUEC1SQHwAamNhC6eWnPvKUEWwO8VShbziKfze1xlS6teiHddY2y7s0KHbZDuaIUwZeIhAIw9psZ3IKPWEtdw1/Q0nV9YOLLartmVPBSUaOWKhe2iw+VQPjrdNzu1SxKqMgSO7/R+q5BA== 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=qNf8zk9R1ok9mC1KssQChP9FHfwfh7BRpQvMUbN7qAM=; b=KHBjIvXXCbESUmiiROMdfo3EFeE80Mt5SdwcqPynLVdcLdWfnSXxvj3BMr8Sxc6Nk0aUtYhCUzfAHzNPVWwxI7m+1qgrlDhQAnObu1VVU+HdyfIXNQPOzWlQH361FcN4gqYuyjSzdl4TQKLm0OUIfWilx0vMVyHs/yEyT0QgTp3y51RHs3P1fnrXox/1SBpfWqpoGtqhdu4A6YtAfC0HrPanW1uqrRVJNI0EvmB8sun9VjqH0bg0PUCM6z2sQWZSwVxBTrCDl8crYULfB2q2wL6fssnLn79GDWGNI+BE0T9uxTk/8IWTAd/8NTcE7HsSnISUJLD058ICzGwmome4mA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qNf8zk9R1ok9mC1KssQChP9FHfwfh7BRpQvMUbN7qAM=; b=v64U/XxwBL7u5uyvQet8c28ZGhMUxhLteSQ1waLBrwjbiy0Ickb6TT/p+kUld+oLm3U5UQr4W5hb5a+7w2GX2n6oW+KlmbFJ63XzFtEZsI/ME0PTyJ0NPpcAbRXV7E9jprZYRzLN41HmFU67JBpMI4QR1/1k18J+/QDVFBzZK5lCAHKQGx8+OViiUbwMhbMAbzilSsyGj9TJU0LbNWYh4fW8yj5MD7my6U9fCZyDooXZzE4RoxW9KD+uxZ9AZBsQXZb/cmttgz+ktn2cBpTFXyyMtisJsJ5h6TbU22+ShEbnqlaPWlVVCfqsKx1+OVv2oUd+57vSQq+IT1kVnxg3mg== Received: from BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) by BL3PR02MB8282.namprd02.prod.outlook.com (2603:10b6:208:345::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.23; Fri, 12 May 2023 14:32:53 +0000 Received: from BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::4500:569:a3d6:71c9]) by BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::4500:569:a3d6:71c9%6]) with mapi id 15.20.6387.020; Fri, 12 May 2023 14:32:53 +0000 From: Het Gala To: qemu-devel@nongnu.org Cc: prerna.saxena@nutanix.com, quintela@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, berrange@redhat.com, armbru@redhat.com, eblake@redhat.com, manish.mishra@nutanix.com, aravind.retnakaran@nutanix.com, Het Gala Subject: [PATCH v4 5/8] migration: converts exec backend to accept MigrateAddress struct. Date: Fri, 12 May 2023 14:32:37 +0000 Message-Id: <20230512143240.192504-6-het.gala@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20230512143240.192504-1-het.gala@nutanix.com> References: <20230512143240.192504-1-het.gala@nutanix.com> X-ClientProxiedBy: BY5PR04CA0014.namprd04.prod.outlook.com (2603:10b6:a03:1d0::24) To BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR02MB4343:EE_|BL3PR02MB8282:EE_ X-MS-Office365-Filtering-Correlation-Id: aa794c4b-fbca-4cc4-681d-08db52f5c550 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Bi/OsGMq5Z42yb8hppSnKFjjk4TyTyboU31WBj7igRkqymWEWAfhKUZsltEzMq6/r0oGDG5ZHQxYTynzyxiQTakyltmq/4oDDRmfeZLdTVoZfebnsBhZbLosIRKP7M/26fDZ5qfNqa01EIPRyBY8cZr1SlDE4//wnzgbGAlsf8lshsWK/sggyTHQZ/atH7+temtTNsXvuvGZyzO6cPkDxoMqX375SCintqSiSJr1zmRI8Ngd3iFCdGQvOfT7/yAvcuFOhBibKsg437OtihfBZPUlb2JThmgXzBEY4+naMEEPP+FNcU/xj/B09Qsw8xGm3wH0fhVt0tiPiW1ykf3kxFQlPj3taHRA28Sneouay0Tb+zHNJ31g97GkChstEJp20XxOYqUsfs8aUMDbd68TMS/rQr3eK3/KxI4io+WKVqXNnv3ldxtzXz5rL1XC9gWFaZJ1AvCnPpAEaAXkdfvtkVRChJcl86epsmZtDaedOSx5sgWiKeQk27K9SNrs+nCbz6SWvqa6ENlluH+uizxBjaqsT8L5OZb5+GMpK6gGo/i4hlIMZ/InxB+zqsEoMY3kdiWTuBmMy31u0P1J8jba9PtoYcTEDLJR/ZdXsmJ0RaSNuiJUbSZUJbD6/D91yLec X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR02MB4343.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(39860400002)(346002)(396003)(136003)(376002)(366004)(451199021)(5660300002)(26005)(6512007)(83380400001)(1076003)(38350700002)(186003)(52116002)(2616005)(38100700002)(6506007)(2906002)(107886003)(44832011)(8676002)(8936002)(36756003)(478600001)(6486002)(6666004)(41300700001)(316002)(86362001)(66556008)(4326008)(66476007)(66946007)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bgmUd/1pytkp7pfsrmXZFB1uZjkcw4hMoAgzrgQkwFp68gBGMBci3G9jYGBjsPgG6xQd7mxMqrF8qw0I4wWLHFsnA2TrO1BfqwNV4C5hgUemkOqkTlHYvs5sllMZgbOsF9lUknfP3QO90JEA7fPy36uiZ2iDIo97iq/m5UIZ4Pxsb6o18jKIT3dndcsF1JeEjDeoKjjrw7Ectui4IgUzyFcHn2VN5IwD9g1Age47aqzfQ91hu7IoVP5N2M0fgNDC4jpps5dwJfmGXHjpxDxls42kIhC0ZKzi6S0XpyTgcAR8SWw/JRdnTeVwVwM7xas1qv4fBiQO+dH3Y3OnZ4q6jeJgcTYSGb9Gl9J3YzjcStR7AcYta2dcrUSUcJA0p/0V4c/Q247YeEabDvLavJuVemPOzL9ea6YVg530CYp5KML2T8kqBklH25UU+HRyc7GpBP6u9/pkCoCxHTvg451jwG9KHT3O40ykeis2aZKNV5C97ejTDrl4jgGfYgzXoEQcN4Lga35a7+0uXO4h4I4nnpCIeazYsoi6HCF29uMFpBoYikGcSX3XAW3I4Xik49mRrNBPjqzbuBCCES6A9YpO3kV9jwy9P8mny+TxLr3O3wIH2vALRetO3/ogi8HqxjUFh+Drfp2Cwcovj0Pm2IVnazLFuqGiXZCPaf0VeJBijfNiRdv/kFSt2sRv40dfeJ2feQG9NJRDGS1cfA0My1Qt+Ex1UzOy5hy0gRM7ze5TnroLaXrZa5x0140jmuWCFhchL6Jh9eMAggPlZtHhDH5zFqGTCtVyH9BNLfuJpUhH8bN4tBt8zFKafbJU5sJGhgWEPljZpCaoLXyS011MiaxgoxHs9084pAFxtf6sUQQTi4b41MFazQ3Ea7xUxFN9yONSQMSRoRryxYEmYEM1x6GBRwLCqvQi1URCVONJWavkYxhQh4vru+uB5BQD2FL97Usj3BMnZRaV+x4zra5SNhppXPIBkh/i0ANJ/HYhXy3Ppp7UDaU6Sk0SnnanaBwbMG7fN3SQdXMbj5i7zLxQCI8Dusq+y5vxYHO5gB6XJTFVZZKPFK3fGSKBFhcHX8wD4ZVlnth/Cm3Qaw6RFPG2tl5rOx+IeK3O5iy2pQ/VkYVqINDQCIbR4hTaMhuccc5O0G6dxB544Q2MEzmyDknaw+xYKJQvtJFrIhzxvHsI28gnixJVgWZ/UQHiqy7eafl3bzuRSQ4GzpAac14AUzlrmfeerp2DhCF/e9v7YDxSax+ye1E7yKN04+78P4/rC7zbAjPX/a4deUsf1fZ9cHpk6DyGvbm5jx7AgYlTHqO624fMQts4CIO6D/bORhrEqas+4tavZXG+Pl0leNyeOkYQRN/jnoXxYUbsqdlGO7H/h7GLwQ82IrniMVcOSvFv6SJ38Zo9DQzaVqHO65eiWVLgK0dJiA4lL9mhM56N6rNfvDqphVBq8jd4WBL01fyyERy0DtjmSBu8gkWPhiESomc4Y4+ViQuOlHKWR3USWF+erQX7rlwjpWTGFSeiO4YqDplQCqIDYSzKxZE5N15/M/Lo+XD/fXi8EDZJ3s9XAddSIsa16P1Wg2F5QuLLFnFV0JU9N+u1 X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: aa794c4b-fbca-4cc4-681d-08db52f5c550 X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4343.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2023 14:32:53.6387 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IpKwPgak7d2rYH0X1FIDNEbik/o/8Bxg3dJ3fDMnxoC+NdjVHqk7grK4XzLA3j+ritxp/c4o/maL+olUdP49ug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR02MB8282 X-Proofpoint-GUID: wa3f_34T9Oeu-mnISc2Ehy7nIjQ61r3K X-Proofpoint-ORIG-GUID: wa3f_34T9Oeu-mnISc2Ehy7nIjQ61r3K X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-12_08,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.155.12; envelope-from=het.gala@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=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 Exec transport backend for 'migrate'/'migrate-incoming' QAPIs accept new wire protocol of MigrateAddress struct. It is achived by parsing 'uri' string and storing migration parameters required for exec connection into strList struct. Suggested-by: Aravind Retnakaran Signed-off-by: Het Gala Reviewed-by: Juan Quintela --- migration/exec.c | 58 ++++++++++++++++++++++++++++++++----------- migration/exec.h | 4 +-- migration/migration.c | 10 +++----- 3 files changed, 50 insertions(+), 22 deletions(-) diff --git a/migration/exec.c b/migration/exec.c index c4a3293246..210f4e9400 100644 --- a/migration/exec.c +++ b/migration/exec.c @@ -39,22 +39,51 @@ const char *exec_get_cmd_path(void) } #endif -void exec_start_outgoing_migration(MigrationState *s, const char *command, +/* provides the length of strList */ +static int +str_list_length(strList *list) +{ + int len = 0; + strList *elem; + + for (elem = list; elem != NULL; elem = elem->next) { + len++; + } + + return len; +} + +static void +init_exec_array(strList *command, const char **argv, Error **errp) +{ + int i = 0; + strList *lst; + + for (lst = command; lst; lst = lst->next) { + argv[i++] = lst->value; + } + + argv[i] = NULL; + return; +} + +void exec_start_outgoing_migration(MigrationState *s, strList *command, Error **errp) { QIOChannel *ioc; -#ifdef WIN32 - const char *argv[] = { exec_get_cmd_path(), "/c", command, NULL }; -#else - const char *argv[] = { "/bin/sh", "-c", command, NULL }; -#endif + int length = str_list_length(command); + const char **argv = g_malloc0(length * sizeof(const char *)); - trace_migration_exec_outgoing(command); + init_exec_array(command, argv, errp); + char *new_command = g_strjoinv(" ", (char **)argv); + + trace_migration_exec_outgoing(new_command); ioc = QIO_CHANNEL(qio_channel_command_new_spawn(argv, O_RDWR, errp)); if (!ioc) { + g_free(argv); return; } @@ -72,21 +101,22 @@ static gboolean exec_accept_incoming_migration(QIOChannel *ioc, return G_SOURCE_REMOVE; } -void exec_start_incoming_migration(const char *command, Error **errp) +void exec_start_incoming_migration(strList *command, Error **errp) { QIOChannel *ioc; -#ifdef WIN32 - const char *argv[] = { exec_get_cmd_path(), "/c", command, NULL }; -#else - const char *argv[] = { "/bin/sh", "-c", command, NULL }; -#endif + int length = str_list_length(command); + const char **argv = g_malloc0(length * sizeof(const char *)); + + init_exec_array(command, argv, errp); + char *new_command = g_strjoinv(" ", (char **)argv); - trace_migration_exec_incoming(command); + trace_migration_exec_incoming(new_command); ioc = QIO_CHANNEL(qio_channel_command_new_spawn(argv, O_RDWR, errp)); if (!ioc) { + g_free(argv); return; } diff --git a/migration/exec.h b/migration/exec.h index 736cd71028..3107f205e3 100644 --- a/migration/exec.h +++ b/migration/exec.h @@ -23,8 +23,8 @@ #ifdef WIN32 const char *exec_get_cmd_path(void); #endif -void exec_start_incoming_migration(const char *host_port, Error **errp); +void exec_start_incoming_migration(strList *host_port, Error **errp); -void exec_start_outgoing_migration(MigrationState *s, const char *host_port, +void exec_start_outgoing_migration(MigrationState *s, strList *host_port, Error **errp); #endif diff --git a/migration/migration.c b/migration/migration.c index b7c3b939d5..6abd69df8d 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -455,7 +455,6 @@ static bool migrate_uri_parse(const char *uri, static void qemu_start_incoming_migration(const char *uri, Error **errp) { Error *local_err = NULL; - const char *p = NULL; MigrateAddress *channel = g_new0(MigrateAddress, 1); SocketAddress *saddr; @@ -483,8 +482,8 @@ static void qemu_start_incoming_migration(const char *uri, Error **errp) } else if (channel->transport == MIGRATE_TRANSPORT_RDMA) { rdma_start_incoming_migration(&channel->u.rdma, &local_err); #endif - } else if (strstart(uri, "exec:", &p)) { - exec_start_incoming_migration(p, errp); + } else if (channel->transport == MIGRATE_TRANSPORT_EXEC) { + exec_start_incoming_migration(channel->u.exec.args, &local_err); } else { error_setg(errp, "unknown migration protocol: %s", uri); } @@ -1701,7 +1700,6 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, { Error *local_err = NULL; MigrationState *s = migrate_get_current(); - const char *p = NULL; MigrateAddress *channel = g_new0(MigrateAddress, 1); SocketAddress *saddr; @@ -1740,8 +1738,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, } else if (channel->transport == MIGRATE_TRANSPORT_RDMA) { rdma_start_outgoing_migration(s, &channel->u.rdma, &local_err); #endif - } else if (strstart(uri, "exec:", &p)) { - exec_start_outgoing_migration(s, p, &local_err); + } else if (channel->transport == MIGRATE_TRANSPORT_EXEC) { + exec_start_outgoing_migration(s, channel->u.exec.args, &local_err); } else { if (!(has_resume && resume)) { yank_unregister_instance(MIGRATION_YANK_INSTANCE); From patchwork Fri May 12 14:32:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Het Gala X-Patchwork-Id: 13239407 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 A1CF4C77B7F for ; Fri, 12 May 2023 14:34:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTpP-0007ub-HD; Fri, 12 May 2023 10:33:03 -0400 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 1pxTpO-0007tu-4q for qemu-devel@nongnu.org; Fri, 12 May 2023 10:33:02 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pxTpM-0002cj-3g for qemu-devel@nongnu.org; Fri, 12 May 2023 10:33:01 -0400 Received: from pps.filterd (m0127841.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34C9NQJn024537; Fri, 12 May 2023 07:32:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=Z4uInVUScCERyuomqGzFfUMrAQvRXOBlflvcLkl5EzE=; b=iB+38H8Bl+hdMIPVbRWATVU2vPsZ+kW/mg5yUOd1vo3Nm6ytkz+uOE1brCWwhs9Wv3op lR9MNfslcSYQG4Pr+KHd51u2vR3vV7+A0D5wXcdAawGP70mWYcfkfjj50/vEXJKn51m7 fXboQogNizF4d+8sVRUmub0E9IVCruWWxuE/45y2dWjFXhzOf0gkUVGh90DZnDhL8AaL QIOCS0FG01dBvEqarOyJw4vVtRl7gQL3gXYF80NQPatOjWpSEl0kW2K4Dhz63aGtmE/M IMDS6DBLBYiQcqz+HFM65PMRAV0JOBzHtRmGtIOnp2hWyWoNhi7miEf0JiUIfkxvYVeq xw== Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2046.outbound.protection.outlook.com [104.47.66.46]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3qf7g6a11r-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 May 2023 07:32:58 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VLBhr0nitLE9l12P+tk6aL+FxzE+vORPOQfaGw7rd1Q2EkbxxuUYjD4+KsEU+v3eLshxfyOGptRkwI7NPkt3bjwHzacUeN4koW+9gUWXsoVnIf/6N2L4ZKA1x9bcD/2vkPQTCH9GWqQwxe+iSpf3pKeGe28Q7NBp39djXwMyEx+aVcVDRL6Vtv8LqllFXWa9l2ILhuXhmsh3/IWs4mW3lG4JxLc8DnpMzlhS5g+7CVdMO5ZjPVo+s8kCrtwU/mDhB460JIwTvEmSTHTVImO0CDSMyeg+WI+Bp3IOdXzcdhp0WjIfgbn7JuWHRdCdgjJYSfbh/pKqvRWNT2u2gy8HvA== 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=Z4uInVUScCERyuomqGzFfUMrAQvRXOBlflvcLkl5EzE=; b=I3xVsWWlUF67qIihF1WFY11ix8OGK213Bbd0ir8enx//ZUPe2flXhLi7q2kVV5YBBxgjca/95ICYaeh1EagJ5bevyK6UVQAyJKA/ypJhu3nJPG1MjVQXvYAOghVZJj39gq2x5ImsseBf/ZGG8Oc1iGOJkXhuk1q5OiZpmXYYipA32hWgAiREcrhvzkxUDsrLF40qGeB8JG+1LWTAl2BmQZzw78uMCfsN+nR/xIKPcLeyIBXpkyA1b0qtXyDn/ztKxjH9O71Xj3b9+vyffKoebjdMgecRRTYP1S9U0SQczPSAxKdsdwnmApDv8djA1z58OGjOxRAU4kJRdWa893ICUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z4uInVUScCERyuomqGzFfUMrAQvRXOBlflvcLkl5EzE=; b=ZlLgTKtM04SsvmscuXMgUCcYj8MKwOB5Wwdrax8pjSMjo9abVOU8Hgjcx/MGONOHNDoeHcupBNdqf2bhVByBOdvJZXuG5PCtAXi6cw1eK1rcc03N7RSxlpXUCSJJuziNxJ55yrJo9GLAn7xINlJuuzILFWynaPaHgs9VRECWy7aK00pjjDw2gDUHtAgjLwKgsN8QRi34Tq9Ef7HX/4iKfRdtnsLBKkgbdCOVIY2Ouc3vDOOETs5Fp6lVn+0p9lVHawZnliQc+tzQq0NBkQo4o7OTTC1+Bne7tg3FZDwGllNSEq3K9yNTQkdFP3gn2htmWiLMez2oGMIlSJz0fnfa0A== Received: from BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) by BL3PR02MB8282.namprd02.prod.outlook.com (2603:10b6:208:345::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.23; Fri, 12 May 2023 14:32:55 +0000 Received: from BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::4500:569:a3d6:71c9]) by BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::4500:569:a3d6:71c9%6]) with mapi id 15.20.6387.020; Fri, 12 May 2023 14:32:55 +0000 From: Het Gala To: qemu-devel@nongnu.org Cc: prerna.saxena@nutanix.com, quintela@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, berrange@redhat.com, armbru@redhat.com, eblake@redhat.com, manish.mishra@nutanix.com, aravind.retnakaran@nutanix.com, Het Gala Subject: [PATCH v4 6/8] migration: modified 'migrate' QAPI to accept 'channels' argument for migration Date: Fri, 12 May 2023 14:32:38 +0000 Message-Id: <20230512143240.192504-7-het.gala@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20230512143240.192504-1-het.gala@nutanix.com> References: <20230512143240.192504-1-het.gala@nutanix.com> X-ClientProxiedBy: BY5PR04CA0014.namprd04.prod.outlook.com (2603:10b6:a03:1d0::24) To BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR02MB4343:EE_|BL3PR02MB8282:EE_ X-MS-Office365-Filtering-Correlation-Id: b66a786a-d1c5-4928-6a8e-08db52f5c65b x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fXgl/lVsYc4NMuwZ9y7FfeJSnBDtC5nBEoI21CyHqDUwfR9NiW2+Cp81+01EQZtMakACyI3tH+nyijex0+ojq+ctZnufJQ8O7Cg0nduoIbMpRbIqRvABcbpSxBzkYL3kcoJDhaBY7LAroFPkY2ZakSklET5zYd7YNd5KScM9V3kfnWlN+/+15/voHwj+gehRBkFmjmq7AWVxVhykqlW12F1yfuH7ZIpwSsKwxIotbsWmMfF3gXLmWA5nlXkMFr3RlDjPhsIuqja9XTvCvhJnVpvEeDLC/DYqbvfx5LEUYQXX0NutTGcv6nHjMWIRMK6rG2/DIeahhNQPsGgbmbzFSqDbaRIbQsKNKb6Vt9b7onpAlH1WgFhxPrmav5BA0YNWDjiVsVlfIsdU/svx6rFmmlMdm5F4WojIYgaFFJ5MBEzM8l3JbmZlo1MB/tyyyTxfP88648SsvASQJ9EIAKufBFfw4V9V8AI60nvBYK8H5Hh9NgvBXVFlsl2OxPvKjdXB4knAM1pTcWMdJ8ITMxVO3Y1hh0PLVfK7KYMEnKSUjdzvrNzVJf/bBsUk/D8/qzZny1LnMcr/j9b7knHpKkaO0zfku0IsbatZY9bEEu9KwXtmq1okDdyDIzNq3Ofh06EDAwXIlURw+3G0mkwfIl+6bw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR02MB4343.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(39860400002)(346002)(396003)(136003)(376002)(366004)(451199021)(5660300002)(26005)(6512007)(83380400001)(1076003)(38350700002)(186003)(52116002)(2616005)(38100700002)(6506007)(2906002)(107886003)(44832011)(8676002)(8936002)(36756003)(478600001)(6486002)(6666004)(41300700001)(316002)(86362001)(66556008)(4326008)(66476007)(66946007)(6916009)(66899021)(309714004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uPLnRaT/efdqHKkwzbcLw7wwaphUN4IoNbY7v/duSgY7QYCJunoQnS8oAcnsqnQv+kl4zljxjg8QQd3VfltvlAlrpjW22My4naIPjfEIOPPd+tooHPxt7TP5NZktwVP8S630bJl2oGhUEOhAYENNs2LhVbNcKCt9SDz3WEZAaBMCqR6Kg54oKTg5epjmqUN1+qKP21xMx5vAQazOEgEaZUmGgNtmvdr7E27PZ4v+kBrkDxx+BmBoZFhnvVvb9ZiJJW2YK/C8e8NjQ1hoA80fmeqKiNDa1ym5D7Dm8EyIdj8/5mVTdvd7U11zlpyxN3PhHn5th/J6/ZOLUHeeTBBroUrP/DvlD9rmIOsWU7iM0fS9KW+S+4mWqKUxU8vVoArUdKCstJ7/ZCMsUlt7xqYbLtng63hAOJKQPHBkqkf2+PxshJHs/hCY3E8zE/8QCBOnVeLf2aAY8adX8rHmUecAqIWxX8mRa5iTmWBGLVTsj4+X+DCeSqs6zg6PuW2mj8k9X4BR3TbG7B7YXGtn8U6NAbAzC99rmuJ+DVVb/jYV1X86FqTAdDQgxWOYHjZOW9zJvwYR34o9lBPi8t6qgq/pPgd+9mz5UToRwbW7ReTEAj+qI92Jq2D1t6j+5vu2KnSO+VjIiyM0Zn0zJXuvsU6b2Ucirt7JzpHngbImU2lIudPILQsxapzfbkbk7Cc92aR0xLNZxCx9/cvgO7B7AJwt524kjNw9wUEpKwcN4yeJbtORqYpCToB2zJqFoil6NDs1jt5hAJZkb0vWYrPad467bacK94ISdCIlU0Zbc91O4B0Y4PH5XO8/8+ADztxpzBWVlr42vSJbnlAOkPChGWIN/HQnMi2JyO1UO1hw6t81QqBNgifq+MQVXqA9RJ7VOcK1eRLGszYu5pi3BjmQmH3O8eFROA6trCON7Wwf57/yIrDX5hGfaTXSsz/bnblpp8HSxSJjdsZ+rgtlvxauyFMBUbBKh8m1c54QRRwq3CXZPn6sGaHjAZTDPFzusQQfyMvsEy6cVYVqWGY/4XDfWFbB6EehC3JyL3o6YdMDnrPJe7TDMRsIdyupzc1q3C64pVWXXXTLj2E0W7ingOIKcHXgx9ADvTWcA9k+Pcl06dJiDsI87euqR/36KI6rdFSUMkVPa0dIIyu/skyx1fBG9cufFurTehiSZodNbrW279CUpr8UEByS+fJRRRyMS9tpfrTnQVsZJH8jQoS9EaLnOTFsqtWLZ10oMpYzYlLLufqvWdO0J0lQ1k5YNagryGwwf5hwgDcWBVS89Dcj8qpZGAbjn47zfCZlOso0dAzkz4e+ytFANU76elkBhLCxnt8SUfsrSjsJ+nYV12nX1DazylSgynzlX9+LGRXL8lnXcR5OtFM/KWOYMWPMd7eT67yf6BGle9mhPpPckjDaZdQAa1njPyNlP49jm92FgkeVbrQ3AYu4cGhnuBZg6nFye69KCtxvrJVOmSM+cWAOVvbZzbuZFIJAUmi3KLYh/i9QKbQN+0ohMrUNx032v3k+YTy/vOIYEj6J1QAYEnzBNrIqDiu8Mbn5QcWn2N0Wnnd+eveaDKoXgFedr5cG/UPAierOXwBx X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: b66a786a-d1c5-4928-6a8e-08db52f5c65b X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4343.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2023 14:32:55.3468 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xkJ2wDR2Dpy8N53jypynhqbyDJGY04AMQPF5oL+wlFEoal3L3VGzXu+KpxQVJR94mmfvcaivCcIIGC9OAZ6nxg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR02MB8282 X-Proofpoint-GUID: 06RA31VpFQmetFoX2EYIXX58F2Z6J9CO X-Proofpoint-ORIG-GUID: 06RA31VpFQmetFoX2EYIXX58F2Z6J9CO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-12_08,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.155.12; envelope-from=het.gala@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_SBL_A=0.1 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 MigrateChannelList ideally allows to connect accross multiple interfaces. Added MigrateChannelList struct as argument to 'migrate' qapi. Introduced MigrateChannelList in hmp_migrate() and qmp_migrate() functions. Future patchset series plans to include multiple MigrateChannels for multiple interfaces to be connected. That is the reason, 'MigrateChannelList' is the preferred choice of argument over 'MigrateChannel' and making 'migrate' QAPI future proof. For current patch, have just limit size of MigrateChannelList to 1 element as a runtime check. Suggested-by: Aravind Retnakaran Signed-off-by: Het Gala --- migration/migration-hmp-cmds.c | 113 ++++++++++++++++++++++++++++++++- migration/migration.c | 17 ++++- qapi/migration.json | 69 +++++++++++++++++++- 3 files changed, 192 insertions(+), 7 deletions(-) diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index 4e9f00e7dc..f098d04542 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -51,6 +51,101 @@ static void migration_global_dump(Monitor *mon) ms->clear_bitmap_shift); } +static bool +migrate_channel_from_qdict(MigrateChannel **channel, + const QDict *qdict, Error **errp) +{ + Error *err = NULL; + const char *channeltype = qdict_get_try_str(qdict, "channeltype"); + const char *transport_str = qdict_get_try_str(qdict, "transport"); + const char *socketaddr_type = qdict_get_try_str(qdict, "type"); + const char *inet_host = qdict_get_try_str(qdict, "host"); + const char *inet_port = qdict_get_try_str(qdict, "port"); + const char *unix_path = qdict_get_try_str(qdict, "path"); + const char *vsock_cid = qdict_get_try_str(qdict, "cid"); + const char *vsock_port = qdict_get_try_str(qdict, "port"); + const char *fd = qdict_get_try_str(qdict, "str"); + QList *exec = qdict_get_qlist(qdict, "exec"); + MigrateChannel *val = g_new0(MigrateChannel, 1); + MigrateChannelType channel_type; + MigrateTransport transport; + MigrateAddress *addr = g_new0(MigrateAddress, 1); + SocketAddress *saddr = g_new(SocketAddress, 1); + SocketAddressType type; + + channel_type = qapi_enum_parse(&MigrateChannelType_lookup, + channeltype, -1, &err); + if (channel_type < 0) { + goto end; + } + + transport = qapi_enum_parse(&MigrateTransport_lookup, + transport_str, -1, &err); + if (transport < 0) { + goto end; + } + + type = qapi_enum_parse(&SocketAddressType_lookup, + socketaddr_type, -1, &err); + if (type < 0) { + goto end; + } + + addr->transport = transport; + + switch (transport) { + case MIGRATE_TRANSPORT_SOCKET: + saddr->type = type; + + switch (type) { + case SOCKET_ADDRESS_TYPE_INET: + saddr->u.inet.host = (char *)inet_host; + saddr->u.inet.port = (char *)inet_port; + break; + case SOCKET_ADDRESS_TYPE_UNIX: + saddr->u.q_unix.path = (char *)unix_path; + break; + case SOCKET_ADDRESS_TYPE_VSOCK: + saddr->u.vsock.cid = (char *)vsock_cid; + saddr->u.vsock.port = (char *)vsock_port; + break; + case SOCKET_ADDRESS_TYPE_FD: + saddr->u.fd.str = (char *)fd; + break; + default: + error_setg(errp, "%s: Unknown socket type %d", + __func__, saddr->type); + goto end; + } + + addr->u.socket = *saddr; + break; + case MIGRATE_TRANSPORT_EXEC: + addr->u.exec.args = (strList *)exec; + break; + case MIGRATE_TRANSPORT_RDMA: + addr->u.rdma.host = (char *)inet_host; + addr->u.rdma.port = (char *)inet_port; + break; + default: + error_setg(errp, "%s: Unknown migrate transport type %d", + __func__, addr->transport); + goto end; + } + + val->channeltype = channel_type; + val->addr = addr; + *channel = val; + return true; + +end: + error_propagate(errp, err); + qapi_free_MigrateChannel(val); + qapi_free_MigrateAddress(addr); + qapi_free_SocketAddress(saddr); + return false; +} + void hmp_info_migrate(Monitor *mon, const QDict *qdict) { MigrationInfo *info; @@ -702,9 +797,18 @@ void hmp_migrate(Monitor *mon, const QDict *qdict) bool resume = qdict_get_try_bool(qdict, "resume", false); const char *uri = qdict_get_str(qdict, "uri"); Error *err = NULL; + MigrateChannel *channel = g_new0(MigrateChannel, 1); + MigrateChannelList *caps = NULL; + + if (!migrate_channel_from_qdict(&channel, qdict, &err)) { + error_setg(&err, "error in retrieving channel from qdict"); + goto end; + } - qmp_migrate(uri, !!blk, blk, !!inc, inc, - false, false, true, resume, &err); + QAPI_LIST_PREPEND(caps, channel); + qmp_migrate(uri, !!caps, caps, !!blk, blk, !!inc, inc, + false, false, true, resume, &err); + qapi_free_MigrateChannelList(caps); if (hmp_handle_error(mon, err)) { return; } @@ -725,6 +829,11 @@ void hmp_migrate(Monitor *mon, const QDict *qdict) status); timer_mod(status->timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME)); } + +end: + qapi_free_MigrateChannel(channel); + hmp_handle_error(mon, err); + return; } void migrate_set_capability_completion(ReadLineState *rs, int nb_args, diff --git a/migration/migration.c b/migration/migration.c index 6abd69df8d..78f16e5041 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1694,15 +1694,26 @@ static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc, return true; } -void qmp_migrate(const char *uri, bool has_blk, bool blk, - bool has_inc, bool inc, bool has_detach, bool detach, - bool has_resume, bool resume, Error **errp) +void qmp_migrate(const char *uri, bool has_channels, + MigrateChannelList *channels, bool has_blk, bool blk, + bool has_inc, bool inc, bool has_detach, + bool detach, bool has_resume, bool resume, Error **errp) { Error *local_err = NULL; MigrationState *s = migrate_get_current(); MigrateAddress *channel = g_new0(MigrateAddress, 1); SocketAddress *saddr; + /* + * Having preliminary checks for uri and channel + */ + if (uri && has_channels) { + error_setg(errp, "'uri' and 'channels' arguments are mutually " + "exclusive; exactly one of the two should be present in " + "'migrate' qmp command "); + return; + } + /* URI is not suitable for migration? */ if (!migration_channels_and_uri_compatible(uri, errp)) { goto out; diff --git a/qapi/migration.json b/qapi/migration.json index bf90bd8fe2..a71af87ffe 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1464,12 +1464,47 @@ 'exec': 'MigrateExecCommand', 'rdma': 'InetSocketAddress' } } +## +# @MigrateChannelType: +# +# The supported options for migration channel type requests +# +# @main: Support request for main outbound migration control channel +# +# Since 8.0 +## +{ 'enum': 'MigrateChannelType', + 'data': [ 'main' ] } + +## +# @MigrateChannel: +# +# Information regarding migration Channel-type for transferring packets, +# source and corresponding destination interface for socket connection +# and number of multifd channels over the interface. +# +# @channeltype: Name of Channel type for transfering packet information +# +# @addr: Information regarding migration parameters of destination interface +# +# Since 8.0 +## +{ 'struct': 'MigrateChannel', + 'data': { + 'channeltype': 'MigrateChannelType', + 'addr': 'MigrateAddress' } } + ## # @migrate: # # Migrates the current running guest to another Virtual Machine. # # @uri: the Uniform Resource Identifier of the destination VM +# for migration thread +# +# @channels: Struct containing list of migration channel types, with all +# the information regarding destination interfaces required for +# initiating a migration stream. # # @blk: do block migration (full disk copy) # @@ -1494,15 +1529,45 @@ # 3. The user Monitor's "detach" argument is invalid in QMP and should not # be used # +# 4. The uri argument should have the Uniform Resource Identifier of default +# destination VM. This connection will be bound to default network +# +# 5. The 'uri' and 'channel' arguments are mutually exclusive; exactly one +# of the two should be present. +# # Example: # # -> { "execute": "migrate", "arguments": { "uri": "tcp:0:4446" } } # <- { "return": {} } # +# -> { "execute": "migrate", +# "arguments": { +# "channels": [ { "channeltype": "main", +# "addr": { "transport": "socket", "type": "inet", +# "host": "10.12.34.9", +# "port": "1050" } } ] } } +# <- { "return": {} } +# +# -> { "execute": "migrate", +# "arguments": { +# "channels": [ { "channeltype": "main", +# "addr": { "transport": "exec", +# "args": [ "/bin/nc", "-p", "6000", +# "/some/sock" ] } } ] } } +# <- { "return": {} } +# +# -> { "execute": "migrate", +# "arguments": { +# "channels": [ { "channeltype": "main", +# "addr": { "transport": "rdma", +# "host": "10.12.34.9", +# "port": "1050" } } ] } } +# <- { "return": {} } +# ## { 'command': 'migrate', - 'data': {'uri': 'str', '*blk': 'bool', '*inc': 'bool', - '*detach': 'bool', '*resume': 'bool' } } + 'data': {'*uri': 'str', '*channels': [ 'MigrateChannel' ], '*blk': 'bool', + '*inc': 'bool', '*detach': 'bool', '*resume': 'bool' } } ## # @migrate-incoming: From patchwork Fri May 12 14:32:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Het Gala X-Patchwork-Id: 13239400 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 74311C7EE23 for ; Fri, 12 May 2023 14:33:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTpR-0007vv-Qg; Fri, 12 May 2023 10:33:05 -0400 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 1pxTpQ-0007v8-4N for qemu-devel@nongnu.org; Fri, 12 May 2023 10:33:04 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pxTpO-0002eN-9H for qemu-devel@nongnu.org; Fri, 12 May 2023 10:33:03 -0400 Received: from pps.filterd (m0127844.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34C9Pmi7017311; Fri, 12 May 2023 07:33:01 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=sh/OYB5+rwqgBvmcVXyfm1QFTGzSQ/AUHR2vQZWe+HY=; b=azZZq5Gs2BBX0tZ3b7oTZ5/yZEWl7/84VRB3++uV1pMryjA+ajK8mJfswXV7B17cpr3k hAjQ50KOWXAW8l9EL7pJ2DmpHcugmxm5vk5Kemxdg8M3RteDXw6Rm/7n4Tt7pKYuFjzr SLkZO8NVt7B1CLAcULCNc8KFGuAEPsfOxPjHAAxVtsb2ejnRqQ9hrQgBX0unGtBHH+LR sLilTiksZMrAWmmaBhyHD3BJpLlR6hfz5R9s/nrgi3PHoxRoKW9zbUtKXprmfa0XYA6D /J/TnHX44bSfVhes78GkdqeISjq7ImGAkTAmn+rnKu78QZmnlJcPRspqwTKtwK6anJHC 8A== Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2046.outbound.protection.outlook.com [104.47.66.46]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3qf7vv9x22-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 May 2023 07:33:01 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QpTSXl2G+M5NUGFJFBQ/TvQtTTOOnTKM2zjA2BizNGqg0DMxWI7xxA3lMOMdYSqsOsTMmNHCdTKKbAlje/M6u/Eeg0c7axZcfTN9sxINPliaAgNdjFhPdPMOTqwHAfyAAEPWAlst4DKUqZYQ+6A1G6sDD/qblcloSlQuQeo3QJRBbu2ULiKow8LeR/s+ToWOLfupnRWfzRKmoWzBQltgF55xw5t5z/b18RGFnbDT8qupG8OajHO3cRut2s7GX82+CSZ/pFYEYCWj8wJ8gwOrpemIK0DCbMJx0MyqHW2GGNkjlvQl6HDOlTApQ5E+/cT/orgyq44ancJf+4TxPgE9yA== 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=sh/OYB5+rwqgBvmcVXyfm1QFTGzSQ/AUHR2vQZWe+HY=; b=j+yJexp0EASihFZdmTwaVDyT3NXpACVUsqja5F6KFJPF+nzes04PiLMh0/6uNbjB1Q87mXs2ZMbgIx99kU5fZ/WhAuzQo2fbvlT/xcQISieRL7VZzOgP6Z1FL/GRzA9/zkaPAUWQoVxGI2fLAp46Q/FdCTdKdDsh1G+72c+7UG7F3KIMcJW20ryLb7aGP5JUALA+Z24BOBm023Z+zbmfKB7lO9uZNgumVAyezoaQjiJUpgFTFT7Gmk914BSxBNL6LmLovzkf5+Q2v6eHA97PL/Tf9JdjGWQA8qzDQ4zNt2EfG5mr0RSfTIvI7WlVGQXKECKzxUHj9b8R58+mNC9f9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sh/OYB5+rwqgBvmcVXyfm1QFTGzSQ/AUHR2vQZWe+HY=; b=ufO7xasLP31pYYwXb1NpYMPSAIkEu2FCodVcICJ7tVTtILg5FCDS3YkkMmGfAtMEyxCnqREen4vBsUndaxJ2Nh9EuqDMebv1L84JpPm28JVPeVGApSL6IMKvW8rts5/pESRPNM16xcS6eCTAQS47K3dJk16d43NVXQpd69qa1uYg3linR+ny2oXnlYABTfFhuMA59JnXpxStJYXsJLr3qjYhn5fgIuVx6a6drqx78h2ra3oAA0IM992vz5U6TkXeZQQTqyjzomxrpGwN2nD76KTGCgdHSM4sCEfTHHvherGsu2qEVgj9bUUnfvfHS0cCrNA9r82J3SAMbfSlh/lz/A== Received: from BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) by BL3PR02MB8282.namprd02.prod.outlook.com (2603:10b6:208:345::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.23; Fri, 12 May 2023 14:32:57 +0000 Received: from BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::4500:569:a3d6:71c9]) by BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::4500:569:a3d6:71c9%6]) with mapi id 15.20.6387.020; Fri, 12 May 2023 14:32:57 +0000 From: Het Gala To: qemu-devel@nongnu.org Cc: prerna.saxena@nutanix.com, quintela@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, berrange@redhat.com, armbru@redhat.com, eblake@redhat.com, manish.mishra@nutanix.com, aravind.retnakaran@nutanix.com, Het Gala Subject: [PATCH v4 7/8] migration: modified 'migrate-incoming' QAPI to accept 'channels' argument for migration. Date: Fri, 12 May 2023 14:32:39 +0000 Message-Id: <20230512143240.192504-8-het.gala@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20230512143240.192504-1-het.gala@nutanix.com> References: <20230512143240.192504-1-het.gala@nutanix.com> X-ClientProxiedBy: BY5PR04CA0014.namprd04.prod.outlook.com (2603:10b6:a03:1d0::24) To BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR02MB4343:EE_|BL3PR02MB8282:EE_ X-MS-Office365-Filtering-Correlation-Id: a925b616-a353-496f-95f0-08db52f5c74e x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a9UQtQj+dEWuw0tacSMooLqc/DQlLP8a+hl8A+V2quhviTcT5ZObRJK8wIcbalZhdLi2U/9dvHWm9Vkgq5HyBFiEmqFGk0mahMTX5pUUhMF+G2E4U8+Qj++13wdPzAQMmYrOTuc05FLTj7HE7QUMY/94WZ2zIDVtJCrLT4xHBWD/mB9ufhT26l7iJRAgq6lKd6/ILE12xw4qk2sLSyokGR1D11WXnE9xRY++NavnRuBVeWTfyEQvQdy0alne3eDUSPyRS1N0XGe2C7Cupq4fJeIvtSyTHZzclItMBUR8Sfq0IOteuAM6HKB2WXJWKuB/45EPO9cCcOjwLyL9oToiim5oPRDoIVEWjtt3KDckH6PFhy1HZTFlXkksDvd53qYulWqpkgtxJel4CNeSMUh7dLgPhlR9Vdb8rqMmc4kxDi3IqwGXQMwaNwJ5ZvW8iLdkadAcfQhptywjfEtygodt2rk8QXUL4ayxef/xNXkH7KtvzgW22TLMGvX6Z++r0X7UHk9bx5HyZVIJEbf1OtWBj/+uOT2nSgbzt4gzqV8KTi2csrQ+6oZvqhC5F0BQXTNR04QcO6I195VKUofEIyjE1P0lR1vC2WgKU6rksnSU6wef529dbWzvou9sF/nSgDHT2xhSN+N53NbzbRuH+GNVOA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR02MB4343.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(39860400002)(346002)(396003)(136003)(376002)(366004)(451199021)(5660300002)(26005)(6512007)(83380400001)(1076003)(38350700002)(186003)(52116002)(2616005)(38100700002)(6506007)(2906002)(107886003)(44832011)(8676002)(8936002)(36756003)(478600001)(6486002)(6666004)(41300700001)(316002)(86362001)(66556008)(4326008)(66476007)(66946007)(6916009)(66899021)(309714004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: J+SF/s2MAZ6eK90sDga2npvhTh2CemQdOufDlfVaEPaw69G6w6/VYnrUPNOyXbdGHBHtbtjQEuXXRFvYtmV2sZcqc6y1ZQ34ReMPtu3scCNXmuQoOCwUNA4MDs0O1EmBhou+vv1fSbwKHaY4HjhPfMAHU6dK0ueUJ2LpBeEPhF+RsyBAR/ZByf3qnQnUqPSNysSbLhvjKmOpZkA482IX29nEZViIXuly0A+4FzqISmw03ogggfkxtAfHLDdt8A8PTZVc3cegs+TBQGRqMYXfRXFmAC11MI12iSDjOrelK67b6xwuZQDq47GFNPkB62i0Znh9lL0wBTy811g6eUdQtl7vGnd7hQxEoTb3UGHrQNouEQxfb5XtF/lK2u5EXuhuh0+ZZ/POYYt9LicO0xnvGOPQ395uNFWzuAW4QsZwh9IprJRVOfENxePBErn8+Bn4GfhvS3Wdhsd2A2Blxhyf7IzVTlbMukUaCea6N9Q8CSqPss/oNn7c3M70L5ICsI7XXi/nsQ6pvK8MDHRTzUDjnIWKNsHQ7rrLt0b9euPkagbjPVrxNvkZPmMgSCYkXScSDPGQlgXbvcm8CRHWi5gtMseGRegAvmTvLSM6tVVPfOa+XcQ8oLHHVlfntTcSxyjZMcPtZsm5fhrrH+KAdJcXxOJxK+QHNFVkdttDg72Dz82xL3utwkGAAoJfNt6BZTFzW5VBnC26MQEFLkmGcrlpVmj6CWb1sjx9LR1pWz/N+5jDKFBb9UwQiq7wpaij3kcr5Co2u8JHGkqJ0PNFVGIUJbWbH9sep/gOxiXLQy9EN1HEQ7icmhat+/d1AB5hHCYp8rtvMANgd//stQP0hTrwZhD3L61mY8Sd2lrXdKJwNkYt4z8/A0ytJE3ABHjZgeKgfD7E+1D0V9ISMBrL2dBlfYl14CM8JseAkkrcXOQzRe3giofXQx2U3gdCqYq3Z0CWYu9qHii8jepcJF24tZ2zlfWJjvffSTXJ2BGgjC0TfPEAFuvSB2+KWEdgjHiofxRL+e8d4PyTJqI/3t7w6x/eQghmTwO3NE3eqvPYGOS0dzu0NKT0B8UBUrMO/YaiZgmRWhjrfJYFiIMWPBGBqEpJQTLAagukLLAVBU1vt51s4ZL7sU1P6S2A94Rhs8xO+i3FfP73g6WxJZlmNI4H7N7UEIZ+dKWe0wES/wRgCYXhPOLYNvCm56+zHhCgtoHXy9W2SYfr7F5OqyhlkfVpARp1ANfaxE3IYiyEPIGjSSCqnwGmPbLn1KigUXAKWrBMGA2wRNl0pYOcZ76OMrMS+r8KBz4uTUZV/ZU4WauVW2y7W2ULz4FMola3/w2DHN2dFLdKnqEO9KIlgvVGdQqlpLzZEPYLCzEvDuNF1YArY2ISKTmltbeae7VzlEUQv01rG2inH5bdg5f7A0k08c+MfSqP/xZ3+ue8+cwqWq64ia4EpBNrhQt/F0Pdbfbq0pdLH4uyU50ODthiParcrkMs31ZeNi5N06Dm3UmrDMEjiPWgBCzifKDzcQ9CwBwavA2zk6x6bH6upy4sL0trcoTZ81d9QmEf2LaS4+i+0Ma2b+YZU/kZSrgDBzjUAo7VNyQefDPO X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: a925b616-a353-496f-95f0-08db52f5c74e X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4343.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2023 14:32:56.9521 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: f3Z1O1k4tjz/Tkyxs2lLI+17+5BjYlh1Jzhi8dO2qjNggu6Mtt1rIDNu2SfCr/8TPGx44ExNSFC5mGaXPJI2/g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR02MB8282 X-Proofpoint-ORIG-GUID: 9VQM0aToQ52PI5v_lXJ9to4ZWOcY2lUM X-Proofpoint-GUID: 9VQM0aToQ52PI5v_lXJ9to4ZWOcY2lUM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-12_08,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.155.12; envelope-from=het.gala@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=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 MigrateChannelList ideally allows to have multiple listener interfaces up for connection. Added MigrateChannelList struct as argument to 'migrate-incoming' qapi. Introduced MigrateChannelList in hmp_migrate_incoming() and qmp_migrate_incoming() functions. Future patchset series plans to include multiple MigrateChannels to have multiple listening interfaces up. That is the reason, 'MigrateChannelList' is the preferred choice of argument over 'MigrateChannel' and making 'migrate-incoming' QAPI future proof. For current patch, have just limit size of MigrateChannelList to 1 element as a runtime check. Suggested-by: Aravind Retnakaran Signed-off-by: Het Gala --- migration/migration-hmp-cmds.c | 14 +++++++++++++- migration/migration.c | 21 ++++++++++++++++---- qapi/migration.json | 35 +++++++++++++++++++++++++++++++++- softmmu/vl.c | 2 +- 4 files changed, 65 insertions(+), 7 deletions(-) diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index f098d04542..8c11a8c83b 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -518,10 +518,22 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict) { Error *err = NULL; const char *uri = qdict_get_str(qdict, "uri"); + MigrateChannel *channel = g_new0(MigrateChannel, 1); + MigrateChannelList *caps = NULL; + + if (!migrate_channel_from_qdict(&channel, qdict, &err)) { + error_setg(&err, "error in retrieving channel from qdict"); + goto end; + } - qmp_migrate_incoming(uri, &err); + QAPI_LIST_PREPEND(caps, channel); + qmp_migrate_incoming(uri, !!caps, caps, &err); + qapi_free_MigrateChannelList(caps); +end: + qapi_free_MigrateChannel(channel); hmp_handle_error(mon, err); + return; } void hmp_migrate_recover(Monitor *mon, const QDict *qdict) diff --git a/migration/migration.c b/migration/migration.c index 78f16e5041..de058643a6 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -452,12 +452,24 @@ static bool migrate_uri_parse(const char *uri, return true; } -static void qemu_start_incoming_migration(const char *uri, Error **errp) +static void qemu_start_incoming_migration(const char *uri, bool has_channels, + MigrateChannelList *channels, + Error **errp) { Error *local_err = NULL; MigrateAddress *channel = g_new0(MigrateAddress, 1); SocketAddress *saddr; + /* + * Having preliminary checks for uri and channel + */ + if (uri && has_channels) { + error_setg(errp, "'uri' and 'channels' arguments are mutually " + "exclusive; exactly one of the two should be present in " + "'migrate-incoming' qmp command "); + return; + } + /* URI is not suitable for migration? */ if (!migration_channels_and_uri_compatible(uri, errp)) { goto out; @@ -1507,7 +1519,8 @@ void migrate_del_blocker(Error *reason) migration_blockers = g_slist_remove(migration_blockers, reason); } -void qmp_migrate_incoming(const char *uri, Error **errp) +void qmp_migrate_incoming(const char *uri, bool has_channels, + MigrateChannelList *channels, Error **errp) { Error *local_err = NULL; static bool once = true; @@ -1525,7 +1538,7 @@ void qmp_migrate_incoming(const char *uri, Error **errp) return; } - qemu_start_incoming_migration(uri, &local_err); + qemu_start_incoming_migration(uri, has_channels, channels, &local_err); if (local_err) { yank_unregister_instance(MIGRATION_YANK_INSTANCE); @@ -1561,7 +1574,7 @@ void qmp_migrate_recover(const char *uri, Error **errp) * only re-setup the migration stream and poke existing migration * to continue using that newly established channel. */ - qemu_start_incoming_migration(uri, errp); + qemu_start_incoming_migration(uri, false, NULL, errp); } void qmp_migrate_pause(Error **errp) diff --git a/qapi/migration.json b/qapi/migration.json index a71af87ffe..9faecdd048 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1578,6 +1578,10 @@ # @uri: The Uniform Resource Identifier identifying the source or # address to listen on # +# @channels: Struct containing list of migration channel types, with all +# the information regarding destination interfaces required for +# initiating a migration stream. +# # Returns: nothing on success # # Since: 2.3 @@ -1593,14 +1597,43 @@ # # 3. The uri format is the same as for -incoming # +# 4. The 'uri' and 'channel' arguments are mutually exclusive; exactly one +# of the two should be present. +# # Example: # # -> { "execute": "migrate-incoming", # "arguments": { "uri": "tcp::4446" } } # <- { "return": {} } # +# -> { "execute": "migrate", +# "arguments": { +# "channels": [ { "channeltype": "main", +# "addr": { "transport": "socket", "type": "inet", +# "host": "10.12.34.9", +# "port": "1050" } } ] } } +# <- { "return": {} } +# +# -> { "execute": "migrate", +# "arguments": { +# "channels": [ { "channeltype": "main", +# "addr": { "transport": "exec", +# "args": [ "/bin/nc", "-p", "6000", +# "/some/sock" ] } } ] } } +# <- { "return": {} } +# +# -> { "execute": "migrate", +# "arguments": { +# "channels": [ { "channeltype": "main", +# "addr": { "transport": "rdma", +# "host": "10.12.34.9", +# "port": "1050" } } ] } } +# <- { "return": {} } +# ## -{ 'command': 'migrate-incoming', 'data': {'uri': 'str' } } +{ 'command': 'migrate-incoming', + 'data': {'*uri': 'str', + '*channels': [ 'MigrateChannel' ] } } ## # @xen-save-devices-state: diff --git a/softmmu/vl.c b/softmmu/vl.c index 6c2427262b..ade411eb4f 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2633,7 +2633,7 @@ void qmp_x_exit_preconfig(Error **errp) if (incoming) { Error *local_err = NULL; if (strcmp(incoming, "defer") != 0) { - qmp_migrate_incoming(incoming, &local_err); + qmp_migrate_incoming(incoming, false, NULL, &local_err); if (local_err) { error_reportf_err(local_err, "-incoming %s: ", incoming); exit(1); From patchwork Fri May 12 14:32:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Het Gala X-Patchwork-Id: 13239401 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 9A34EC77B75 for ; Fri, 12 May 2023 14:34:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxTpT-0007w5-Cr; Fri, 12 May 2023 10:33:07 -0400 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 1pxTpQ-0007vI-VZ for qemu-devel@nongnu.org; Fri, 12 May 2023 10:33:04 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pxTpO-0002eg-SI for qemu-devel@nongnu.org; Fri, 12 May 2023 10:33:04 -0400 Received: from pps.filterd (m0127844.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34C9Pmi8017311; Fri, 12 May 2023 07:33:02 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=3Yd5kC0D4rNzGKiRIMojhcJTyTVHmGbfKAk22G1gh3k=; b=x+seFw4WxhWZs507L0g0SsiMCsfkznL1uuYNzLCBBkZp5KS/Gjbi707HdPpjFDr42GZJ F7cGwTsN6lH0lRXOZeDeiwCLDwkS8bJrfYQ0t6SOjBYOh4nGgUOO/eM6F5VfjVzgjv6K Yvh08R35JoHWH2E7LqFY0H3MStF6d6Sh12/AoF9MZm42qGCSZGxU52MYmI3vnI2l8Pja AfybKmL1VuAV80dWtu4VK3d3A8FQJcXFgCGev/DB6Aa17BPReIMtG0f47rwWkvp+GIMk noXwlbtGmcF6wiqQ3UAhWGqecDBj6ZIAqtxuTAtfqvtlMf9UKnDQiF09N8fybfxf5X15 QA== Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2046.outbound.protection.outlook.com [104.47.66.46]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3qf7vv9x22-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 May 2023 07:33:01 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X4aA6InTe0kT0cjpjBQxcoVE0+0twdi+XPskJvfd7jo7VVa8Cl7HTO2RpzgEkhLu5Yrikl9B+F9a60fts7BPgEQEPn+XdTUIYEUgYIf2T9OmUr3z51SizArOFCYEcFZ1PEpdYKdsSyMhF5qRBsALtd/fciKVqxmj4qK4eZjCrOK2a/pSsbpfMO52SinKmR0+BD9QR9ET/0WytPfW/BOBuRMbF6t2Zwla7WXfZlhRGBB2wF77hnmPa3D2xkrGeThFqgJzicx1tcYh6WNo0ugOd3QUjrSEay6vcxLDgHQl40348nFmTVH60toUMzlDyigV7LLXVV47CvJT5vqmEw+NTQ== 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=3Yd5kC0D4rNzGKiRIMojhcJTyTVHmGbfKAk22G1gh3k=; b=iWqXVkCZbb+0/r2DLTLsiPP2sDpKaOywVGVrgeTKY0MdGPRXD9v8MhE/NiEUzRBhe0hEwG+kW3OLMzlXKIagvHzsnh/nhvwu4rjOhDRsTQKo2DMS16BruClWAL1vIV4HFjy45sD7nA/9ZLp+Ff77SJ3Wy6SDHNjiwXwMGcn6/sTi2NJg2g8NCk5S9u2unG0qDLWql0EHUSw2+SBi8FwbYNCKBjiW7I3AtW7xKrBBUXs/OMmwTTQq44YCUSAThKJBJH4RxRmGOY+9jpcTQ1bLVDmgZgF3H2DnXJB48k5ftM69kceGRtQs2YkkkHtxN5Ucq4RNT1Fa1Nn0wYfeRtkEJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3Yd5kC0D4rNzGKiRIMojhcJTyTVHmGbfKAk22G1gh3k=; b=MLYrBIPvYWFFRxf0VHxyNWg9O/wJte71XAsdc6DzFwS130KC9YK5Nii8g+Y3z9ShhuMpcM8xv+35Y6Ijaqe5ao6S7BKnJQbZ4TBuMw4BtDIEymAXWRS9r4sp2vbDpJkjAh92yA/0B6pZ2Lj5dFS4EKdrlho223wifMoVDhOYaWtc8TWjAL/+PsBNwh6497dh11v+aJtgiyudXRPyQYq0HtcAV6YJ4gTWPbpeqcrUjPKy3QiaJtnMSONa+U626iKrvPaWON23EJzFHfmbYaNE6fMTc9IvFJWJAWDKlF+zinSWXQOsBxsEK9IZcFl2gh0/8aXjUcbDzqc/1aXd6IZTDQ== Received: from BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) by BL3PR02MB8282.namprd02.prod.outlook.com (2603:10b6:208:345::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.23; Fri, 12 May 2023 14:32:58 +0000 Received: from BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::4500:569:a3d6:71c9]) by BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::4500:569:a3d6:71c9%6]) with mapi id 15.20.6387.020; Fri, 12 May 2023 14:32:58 +0000 From: Het Gala To: qemu-devel@nongnu.org Cc: prerna.saxena@nutanix.com, quintela@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, berrange@redhat.com, armbru@redhat.com, eblake@redhat.com, manish.mishra@nutanix.com, aravind.retnakaran@nutanix.com, Het Gala Subject: [PATCH v4 8/8] migration: Introduced MigrateChannelList struct to migration code flow. Date: Fri, 12 May 2023 14:32:40 +0000 Message-Id: <20230512143240.192504-9-het.gala@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20230512143240.192504-1-het.gala@nutanix.com> References: <20230512143240.192504-1-het.gala@nutanix.com> X-ClientProxiedBy: BY5PR04CA0014.namprd04.prod.outlook.com (2603:10b6:a03:1d0::24) To BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR02MB4343:EE_|BL3PR02MB8282:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c3522b4-98a6-4f69-5ef9-08db52f5c83f x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ej9qIYu8g+EQF4kmorUek2L4HCqT+ulHtBIokVLmc4jMXvudJFwAJiMYo4mpfoRM8CE7e72xtxJDSJgOhdFJ2rsDR7mSL0sljvuhekkXu/chQsUBeHSlw/tjH/04H8gpYYOftSBO91xTEj5qQ1UEd+bSkyMop4a6q0jD2RmzOZLmHWxj4It27YBlXB0Hvw87JKfdF9io4w2e8X639SJeZyvSL7epM1gm/kY17BQyciUJX8ycznipZO8kQS6iiXbFhZsClveZcE0EiSTumGzAbf4qjJ6LVlTLr/0hxrMFA3XjH7GMNx/qW4ygaGNO3lR8st6SPrIkJOv9osnBSW0JrgjNL+C12qnQHtLy6v+JXSsu50KDJ3U29oc9XFz0AxiVE026Z8tCCtBwUGJGjqTFjtZlzOQ+I8g0+detJ4qoFQxjs0vnSDPn7HNIqR7QHeIhBW/8+RVgCt7yG0jmPphXParCFE/vt+V+7B4cPemSJMWMP9OnvNHX/ZMiLTHkVzx5suqRrw6UC2eaHsLKYwJenQ+/nuw1Nm0otovNXqMV+e9qYSF56e5KHrb9yFk997nVUqqvKpPv0RlhVgqNe9R29h4DLLifDi76a3UzvTDlo85xViotVJsWaqR+OkGCiPzQ X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR02MB4343.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(39860400002)(346002)(396003)(136003)(376002)(366004)(451199021)(5660300002)(26005)(6512007)(83380400001)(1076003)(38350700002)(186003)(52116002)(2616005)(38100700002)(6506007)(2906002)(107886003)(44832011)(8676002)(8936002)(36756003)(478600001)(6486002)(6666004)(41300700001)(316002)(86362001)(66556008)(4326008)(66476007)(66946007)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: C15J2YtDlCcU0tgkljPOsvVmFpAS8VuGTNdkUIndROcfUbajIPVRwFEQNhp84vCOZSs8+GHWvGqnMsgWToAS4OCq5pfDSoo9RTxzoC2kWAxKm1TaObO/qd7M+pNYC2q/2a8pelWslcih79WgLP/CT+OaWjo3Hhph8YrXfPaIiaaY4O3iJJlOHitVxmzVFNcr+iZKkXJv+QjUQksOCU6HyUIIJ27Fd1BDErp7Hjbkh1Bpm+KpJu+7ob5AFGxlJvyTR2+BQgvtve4rA3q5hLtlpQyi2OPFZcbqmfIEgMBTAknGFiKbJN5V0VKfnlk4sit2Vq4YMDyBAPRyshMLJMSOO+p2PZJ9YDl8J7i5g9D/DDZyLy70Falk2/imV7CSMmQAV4KyMkZxi+vqMZxhvOd7wkShK3b94DT7qARaTKOW8PB21ZFlSI01PtjRxw5lJ6RIRbYiixnqUXSFKfklVj21PQnyid7H2VKiQAxDnFTJ6yrGzqEN0Q/Xx+fTZ0maXXk0KlPTSfd2KEPmjwHyZ3ri5G2JKCLtqBfBTIMEzKyk37ezuW1EjYG958vW+Z/6OOZUR9TAgDz/ObSR3OA34C5AmsM1zOiW8TZCVRirkLl24z7FrPUP5cWckd5CK0mIe/B+aGI6lDrJxiT6YLOT7X0D8xZnH5ndaLpvy+aQNGdo8CcfCXZn3YqY+lpIH5QRglv/ML19ZOf2uiKbMj/rTh1E5KsonOqd4wE9gY3MuL8GTycHXQZff4AZiNPVoYEp7XlSAH58vjygJK1vEY9cpN5Er8w2DbGjMS7HXQU16v4Hg/ifztJkWpUbP12A5xlZiwK7uZwdSXfLiGBu26pQRXwtSMYObZWOWDyZfVk2wZSjhvT/ULyPe6NrC5lbCafzgl5A9Z+evt8TMelCg0dDflP5NBHxmyPe1xzrwKagnLi1DxiqOABwxqgXSEPQdc4VOba36Ko2UZpn3USdlz4dgRrSHkl9cKFaFUx35IpCcHNrNZ+g70cf8vvrSeNRVbug8HD2m5D852ZirZWKYl3wKi8YDdwy1BgmDmgT4H845chPK3qkEt5yfonxIFujCGuIm6GNYNCGp8CC9oNlwwOPMZEVE4xwOhj55p5ymiLhBzU88HLCvm1fk3dD0g2mmagzFdKG9OvYLJwWasX3sHJndgWnDHq9WFCffzrc+8hZiZzWdBEPtqFKBREO/3xzDBiy818B3tDJFntNHdKHb5YKN1Jxim7GWuKeMx/tDszt9QQKf2qoRqrspFQ11whRUFE04n2Lk9YpFuLbJHj90vrB8v774R/TLOXGoCHY4p5nzjGCVyLGgyBTGI+PQ8SlE+eEeNEJjrjyw1yl1kCQsPID2Eh7Q5QZ5hBZnVmLwsZydGLahdBExbaWa2Ygtp7QN0vQr/eASXK885ZvlzkonhbpSdhzQ5LfV6/1rqJxT8pLR9Mwon5f4+T4TiP3hsfyIkWzrKZan54jcP1dAyOfnFqHrH85iTdhbkOz5iHm9u87LTS05l/UAlm629mRlRAiNSagQfS/ahcLOUPBtyFM4SI3YykM5aOgNmznoD5MrfpG23GufyRB80T1Lw35gZQ+vudyWfUo X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c3522b4-98a6-4f69-5ef9-08db52f5c83f X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4343.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2023 14:32:58.5375 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Srw0PbydX9rf3tQ6XndnMBn1GjhWyR7kvZ6MMbnXBCINCKHWrZWrrfvIL0XgqesenKKCQfWll4QJx5Jz9Y4OCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR02MB8282 X-Proofpoint-ORIG-GUID: tAw8w_gKxIw_L3OKZZinI-jrZD7exRbA X-Proofpoint-GUID: tAw8w_gKxIw_L3OKZZinI-jrZD7exRbA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-12_08,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.155.12; envelope-from=het.gala@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=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 Integrated MigrateChannelList with all transport backends (socket, exec and rdma) for both source and destination migration code flow. Suggested-by: Aravind Retnakaran Signed-off-by: Het Gala --- migration/migration.c | 95 +++++++++++++++++++++++++++---------------- migration/socket.c | 5 ++- 2 files changed, 64 insertions(+), 36 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index de058643a6..a37eba29e3 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -410,10 +410,11 @@ void migrate_add_address(SocketAddress *address) } static bool migrate_uri_parse(const char *uri, - MigrateAddress **channel, + MigrateChannel **channel, Error **errp) { Error *local_err = NULL; + MigrateChannel *val = g_new0(MigrateChannel, 1); MigrateAddress *addrs = g_new0(MigrateAddress, 1); SocketAddress *saddr; InetSocketAddress *isock = &addrs->u.rdma; @@ -441,6 +442,7 @@ static bool migrate_uri_parse(const char *uri, } if (local_err) { + qapi_free_MigrateChannel(val); qapi_free_MigrateAddress(addrs); qapi_free_SocketAddress(saddr); qapi_free_InetSocketAddress(isock); @@ -448,7 +450,9 @@ static bool migrate_uri_parse(const char *uri, return false; } - *channel = addrs; + val->channeltype = MIGRATE_CHANNEL_TYPE_MAIN; + val->addr = addrs; + *channel = val; return true; } @@ -457,8 +461,9 @@ static void qemu_start_incoming_migration(const char *uri, bool has_channels, Error **errp) { Error *local_err = NULL; - MigrateAddress *channel = g_new0(MigrateAddress, 1); + MigrateAddress *addrs; SocketAddress *saddr; + MigrateChannel *channel = NULL; /* * Having preliminary checks for uri and channel @@ -467,22 +472,30 @@ static void qemu_start_incoming_migration(const char *uri, bool has_channels, error_setg(errp, "'uri' and 'channels' arguments are mutually " "exclusive; exactly one of the two should be present in " "'migrate-incoming' qmp command "); - return; - } - - /* URI is not suitable for migration? */ - if (!migration_channels_and_uri_compatible(uri, errp)) { goto out; - } + } else if (channels) { + /* To verify that Migrate channel list has only item */ + if (channels->next) { + error_setg(errp, "Channel list has more than one entries"); + goto out; + } + channel = channels->value; + } else { + /* URI is not suitable for migration? */ + if (!migration_channels_and_uri_compatible(uri, errp)) { + goto out; + } - if (uri && !migrate_uri_parse(uri, &channel, errp)) { - error_setg(errp, "Error parsing uri"); - goto out; + if (uri && !migrate_uri_parse(uri, &channel, errp)) { + error_setg(errp, "Error parsing uri"); + goto out; + } } - saddr = &channel->u.socket; + addrs = channel->addr; + saddr = &channel->addr->u.socket; qapi_event_send_migration(MIGRATION_STATUS_SETUP); - if (channel->transport == MIGRATE_TRANSPORT_SOCKET) { + if (addrs->transport == MIGRATE_TRANSPORT_SOCKET) { if (saddr->type == SOCKET_ADDRESS_TYPE_INET || saddr->type == SOCKET_ADDRESS_TYPE_UNIX || saddr->type == SOCKET_ADDRESS_TYPE_VSOCK) { @@ -491,23 +504,25 @@ static void qemu_start_incoming_migration(const char *uri, bool has_channels, fd_start_incoming_migration(saddr->u.fd.str, &local_err); } #ifdef CONFIG_RDMA - } else if (channel->transport == MIGRATE_TRANSPORT_RDMA) { - rdma_start_incoming_migration(&channel->u.rdma, &local_err); + } else if (addrs->transport == MIGRATE_TRANSPORT_RDMA) { + rdma_start_incoming_migration(&addrs->u.rdma, &local_err); #endif - } else if (channel->transport == MIGRATE_TRANSPORT_EXEC) { - exec_start_incoming_migration(channel->u.exec.args, &local_err); + } else if (addrs->transport == MIGRATE_TRANSPORT_EXEC) { + exec_start_incoming_migration(addrs->u.exec.args, &local_err); } else { error_setg(errp, "unknown migration protocol: %s", uri); } if (local_err) { + qapi_free_MigrateAddress(addrs); qapi_free_SocketAddress(saddr); error_propagate(errp, local_err); return; } out: - qapi_free_MigrateAddress(channel); + qapi_free_MigrateChannel(channel); + return; } static void process_incoming_migration_bh(void *opaque) @@ -1714,8 +1729,9 @@ void qmp_migrate(const char *uri, bool has_channels, { Error *local_err = NULL; MigrationState *s = migrate_get_current(); - MigrateAddress *channel = g_new0(MigrateAddress, 1); + MigrateAddress *addrs; SocketAddress *saddr; + MigrateChannel *channel = NULL; /* * Having preliminary checks for uri and channel @@ -1724,17 +1740,24 @@ void qmp_migrate(const char *uri, bool has_channels, error_setg(errp, "'uri' and 'channels' arguments are mutually " "exclusive; exactly one of the two should be present in " "'migrate' qmp command "); - return; - } - - /* URI is not suitable for migration? */ - if (!migration_channels_and_uri_compatible(uri, errp)) { goto out; - } + } else if (channels) { + /* To verify that Migrate channel list has only item */ + if (channels->next) { + error_setg(errp, "Channel list has more than one entries"); + goto out; + } + channel = channels->value; + } else { + /* URI is not suitable for migration? */ + if (!migration_channels_and_uri_compatible(uri, errp)) { + goto out; + } - if (!migrate_uri_parse(uri, &channel, &local_err)) { - error_setg(errp, "Error parsing uri"); - goto out; + if (!migrate_uri_parse(uri, &channel, &local_err)) { + error_setg(errp, "Error parsing uri"); + goto out; + } } if (!migrate_prepare(s, has_blk && blk, has_inc && inc, @@ -1749,8 +1772,9 @@ void qmp_migrate(const char *uri, bool has_channels, } } - saddr = &channel->u.socket; - if (channel->transport == MIGRATE_TRANSPORT_SOCKET) { + addrs = channel->addr; + saddr = &channel->addr->u.socket; + if (addrs->transport == MIGRATE_TRANSPORT_SOCKET) { if (saddr->type == SOCKET_ADDRESS_TYPE_INET || saddr->type == SOCKET_ADDRESS_TYPE_UNIX || saddr->type == SOCKET_ADDRESS_TYPE_VSOCK) { @@ -1759,11 +1783,11 @@ void qmp_migrate(const char *uri, bool has_channels, fd_start_outgoing_migration(s, saddr->u.fd.str, &local_err); } #ifdef CONFIG_RDMA - } else if (channel->transport == MIGRATE_TRANSPORT_RDMA) { - rdma_start_outgoing_migration(s, &channel->u.rdma, &local_err); + } else if (addrs->transport == MIGRATE_TRANSPORT_RDMA) { + rdma_start_outgoing_migration(s, &addrs->u.rdma, &local_err); #endif - } else if (channel->transport == MIGRATE_TRANSPORT_EXEC) { - exec_start_outgoing_migration(s, channel->u.exec.args, &local_err); + } else if (addrs->transport == MIGRATE_TRANSPORT_EXEC) { + exec_start_outgoing_migration(s, addrs->u.exec.args, &local_err); } else { if (!(has_resume && resume)) { yank_unregister_instance(MIGRATION_YANK_INSTANCE); @@ -1780,6 +1804,7 @@ void qmp_migrate(const char *uri, bool has_channels, if (!(has_resume && resume)) { yank_unregister_instance(MIGRATION_YANK_INSTANCE); } + qapi_free_MigrateAddress(addrs); qapi_free_SocketAddress(saddr); migrate_fd_error(s, local_err); error_propagate(errp, local_err); diff --git a/migration/socket.c b/migration/socket.c index 8e7430b266..98e3ea1514 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -28,6 +28,8 @@ #include "trace.h" #include "postcopy-ram.h" #include "options.h" +#include "qapi/clone-visitor.h" +#include "qapi/qapi-visit-sockets.h" struct SocketOutgoingArgs { SocketAddress *saddr; @@ -114,12 +116,13 @@ void socket_start_outgoing_migration(MigrationState *s, { QIOChannelSocket *sioc = qio_channel_socket_new(); struct SocketConnectData *data = g_new0(struct SocketConnectData, 1); + SocketAddress *addr = QAPI_CLONE(SocketAddress, saddr); data->s = s; /* in case previous migration leaked it */ qapi_free_SocketAddress(outgoing_args.saddr); - outgoing_args.saddr = saddr; + outgoing_args.saddr = addr; if (saddr->type == SOCKET_ADDRESS_TYPE_INET) { data->hostname = g_strdup(saddr->u.inet.host);