From nobody Mon Feb 9 17:41:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1654783447; cv=pass; d=zohomail.com; s=zohoarc; b=JirNI+7BNC+I/buJ9CMavq5CehXauDz98TzJglARqz12D1PC4ovYGWDNw//SaRgQNe1KanwSpNMcONjCw0Cp8yd6yANUV5WnqPnjGtK4dQvr+C94qPLJ59aHm9ZjaBVeKOgoeAQmk+8RgAkWa62JkQQyvS+GCk10Ju2sOSiy7Q4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654783447; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dKLyhRXmd9foly6WSGrPHdyLCHn1LmBo+8gCkrBjBSk=; b=QqMYzDlgaORgXEsj8w/4RtJYAhoPULeNxSDXdi2GuMXNjvuf6D51SaJ6BMw7SWeXrpbmVahtGwpgO9ECs7BjAEjSRjVulcQtHnR7rc8u6zaXMyOkanpa2mbeITR4DYe9y61ELTzjbMgbzZCYWub89Rg+QTBjeMt+PL8bZSirKV8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1654783447752813.2796291658229; Thu, 9 Jun 2022 07:04:07 -0700 (PDT) Received: from localhost ([::1]:50826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzIla-0002cw-Gi for importer@patchew.org; Thu, 09 Jun 2022 10:04:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzCfU-00029E-8f for qemu-devel@nongnu.org; Thu, 09 Jun 2022 03:33:24 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]:57086) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzCfQ-0007u8-Dh for qemu-devel@nongnu.org; Thu, 09 Jun 2022 03:33:23 -0400 Received: from pps.filterd (m0127838.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25964PeN022399; Thu, 9 Jun 2022 00:33:15 -0700 Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2174.outbound.protection.outlook.com [104.47.73.174]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 3gg6y0a3qy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 09 Jun 2022 00:33:14 -0700 Received: from BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) by SA1PR02MB8639.namprd02.prod.outlook.com (2603:10b6:806:1fe::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13; Thu, 9 Jun 2022 07:33:13 +0000 Received: from BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f]) by BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f%5]) with mapi id 15.20.5314.019; Thu, 9 Jun 2022 07:33:13 +0000 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-type : content-transfer-encoding : mime-version; s=proofpoint20171006; bh=dKLyhRXmd9foly6WSGrPHdyLCHn1LmBo+8gCkrBjBSk=; b=e7Jm1FrY+3YKHgIxs3PdT1iswbrn6lCBpblOYW8KPsu0CWguSkTeotx1gsbV2WIl/QpT /b0CiYlr9vsmLqR1JDigix20776Ben3MUuGFP0KhRUy7kF78fkS1O1P3XqKknf11+630 F0yfHtJcAp/ggtDa2CaUbOMv+ex/1RaXJ+dcH2SPfnisPryW/CeXhETb9j0cmBo7JvOl pLbBn+SCDbWn30+NbIjIdgnewD4c2eBowIFBPM8y9W4VZ/sCNUAn0Z3E5MfOw+4/hf7U w4+9xzSKAYsnyPhy0h9hSsTYrrprBPidsPZksajAA26Wb1+GPwqZ4+mGsA01iultFFxS Hw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fpAzvoKJMyU9L2E4V3oek0/atjdH48dND6r72hof31MicsIQlnfy8nL34jr/PtJmlijuF5sZO3pIn/Zwb5tJiek4ozivD2o6ePnddjvpVpNRlqEKmpdbRpkTFc1F6O83CwBPwZ4+uumF7IB80mTpCsb7xU+urWJHjIvL4GiypitU0PXb2TORuoFMEIlpQvGMSQhoKwRaMPyNwoc9Mhw6WMzLkFt0yBbITmyPnR9jrqDrf1qlGZ8w0HGYdRaPaDmzc1thykUaJZai/Sq8Ak1rig/i2DR3fMIEPnaYkZ3tHqW8+vkAf4FUQE5kbShYFm6SYKn+8zFr71mMSIAgjFbLIQ== 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=dKLyhRXmd9foly6WSGrPHdyLCHn1LmBo+8gCkrBjBSk=; b=RMfq9sErGaeg45b4+mps7aHp4T8tg9JJ2ilOAHOrpswzDFTmbsAwfE7p/bDPjwCaVaPLIIpuQkrb2IFbI0hKsDkg8F/hC1RQVaIO+TwB4tSWlDU3jps6ISYMBuOOgS31fQeEVJF8jroG2EKFFZa/NKICVMXYqoMIMporvSDsm0bkZRBDHWGy+hcOQ0PGl1wb1TRgeF+jlh9VPbwuJJVe0pvHEWG6yS5zgwpUseaxq6aFmd6KYYMDbeElYSLcS05/04K7GO3AYUHavaWVYWW1Zr7F4GZZ2CR56BHE6+KcjLHQCxfsllmtrZEN31ado2TF44ESDg6Vh2UFD4gnBgSbSw== 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 From: Het Gala To: qemu-devel@nongnu.org Cc: quintela@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, berrange@redhat.com, armbru@redhat.com, eblake@redhat.com, Het Gala , Manish Mishra Subject: [PATCH 1/4] =?UTF-8?q?Modifying=20=E2=80=98migrate=E2=80=99=20qmp?= =?UTF-8?q?=20command=20to=20add=20multi-FD=20socket=20on=20particular=20s?= =?UTF-8?q?ource=20and=20destination=20pair?= Date: Thu, 9 Jun 2022 07:33:02 +0000 Message-Id: <20220609073305.142515-2-het.gala@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20220609073305.142515-1-het.gala@nutanix.com> References: <20220609073305.142515-1-het.gala@nutanix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BY5PR04CA0002.namprd04.prod.outlook.com (2603:10b6:a03:1d0::12) To BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 14b39540-bfb1-40e9-d0ac-08da49ea4f51 X-MS-TrafficTypeDiagnostic: SA1PR02MB8639:EE_ X-Microsoft-Antispam-PRVS: 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: 1oB9NpCUv8bKZ7kBcYlM/X7KKcgltBK617ZKBTbQB8ElLfJMREzwrr3yA6f+r24koWoEHLEbmTh8IR1t6zdqofJEJfRIvJo+D5kWPhlEbItlvqkxVf+DjP8jQthQrQV2HdmhcgsNYc+FTG50hrNZTi2LuCAY41viutgq/8Otn/FteAfCJVV88U7YPpWO2buVsxy3zOBepylYP68O49Cubzm5+gQgmSLTgqFBi+6g4rip4TnwuCHMFfIrFvwr67vLJjfPXXAkTlXa1Y+aT7GVc1ik4olH+jmG7zafxkiWQh0oIlv6zm2wqLL0YKZdk2c4Gii/QoWddo3fYkzEe/DM6Lh49Or4bTA+pPqMFWeBwO42FoWIAtuOt4KYBBi2Pf5qW19LRcnBgc/CKWgdJhllMfsR85uMyJOV5e7hXKrFbrRtUhyOucqgjOEm7HXk0RZL/jaN9WxzkaHkbHkCcojIYhxemILHqYB5I3SElREW+CNb0vPzaJSIw37+20IkXU94d1EWyRYG/T0IM2eUgk5b3f27Oy4yOe+WPCk24AHomK1QNHQq/OFQh8aZwbp6VLUvf9NJFbZXxOSHXn+YDw+LXzos7l+fTBLnMMsmA1s39ZLbjzzV4fCZ7e/XAgEm1qhtVDUUvpXbYfh1+azJT7XLcNKjdgTUAIhOY/ZUv1hWLVGbxW+IVWn4Jeh2pFhqKz+mrdP83LU4LJ0gQtPxDs/hWxg5Q3Sv8W8/igIPjt7husc= 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:(13230001)(366004)(508600001)(107886003)(6666004)(1076003)(2906002)(8936002)(52116002)(54906003)(86362001)(6506007)(186003)(5660300002)(30864003)(83380400001)(6486002)(44832011)(38350700002)(26005)(38100700002)(36756003)(6512007)(2616005)(316002)(66556008)(66946007)(4326008)(6916009)(66476007)(309714004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?U244U1FUYjI3QWdHMFZjRkpKNUxOOVBXUkpzZTZEQjU4REllYWpmdURWdW5U?= =?utf-8?B?RHRNZkhJczBnaU96ZzJQL0hEVDdaVEJaeEpqV2g3d3Y4NG5Oc295R3lraVpv?= =?utf-8?B?dEhjeHp6cjI3UWFqNmkvaXduOWU3YjF6L0diYWNvcXpvY1NzWTEwS1Y4S3M4?= =?utf-8?B?RFBkNmQ0NFllYWh5RUR6ZEZoSmNFMFJsVUNnd2VXd3d5Nzd6R3lQNFpueko4?= =?utf-8?B?WDdUZDdZSlorcFZDT005M2JMV2xBbExJM0lsZTFOTkJ3YUl5dTdiZlJYMEsr?= =?utf-8?B?UFo0d3hoVXkwOXZiNjNlRDFvcTYvTzdhTExZUEtzUmtGNUFhT045R1pOc2Vt?= =?utf-8?B?SnB2QlFNTW16b2ZnOHN3YXEzY0RkMEVVN2xHV0VldGJ3M2R3UHFUd3h6ekxO?= =?utf-8?B?QVEvSVdydmdyUDhIdDl1NUpsWEF6anBGVHEzc0hqUUdEbXRDTnBxWHc4WUF0?= =?utf-8?B?WWRGN2lUbnJqdHp2ZVIzdWlSTWZkaFlBUE5ONFN2eDRWK3BEZElKL1NqUnZR?= =?utf-8?B?bjA0OHE5NmJvTDQ2UGxwOUV6akRHb3hEYkdyeW5LZFNjaWs1VkVGRjBTWktx?= =?utf-8?B?MUV1TFpvemRKVStzNURWZEpHQkxzVmRSTm9qWXR3ckJVRkZKL1pjZ2QrL0ht?= =?utf-8?B?RkpmU2dtOCtNMGdVSU9XbzRIRlA0S2t2OGZjbEcxLzVCaUZqNlhOcGxldUhr?= =?utf-8?B?eENKUU5BcUk0empCK3poVVFqdU1CbzU3M1UwVzJ5VU1HYjFhNHQ1OExDeHJS?= =?utf-8?B?MWJ4RzlGOHVHb004QVFPeDYxWjdxaFVlemZQa21lWk1kNnRQUU4xZHRjakxv?= =?utf-8?B?MjNFbGhWSkQyREhRMG1IT3RlV0F5UU10RW5lc3BSd2QraDdZZEUrTDI4QnVC?= =?utf-8?B?YXVyN1RteXVYZXRMb2lwMVR6MTBDK1ZCZUxaWklPQmZ3NFoyMW9hREJQM2JU?= =?utf-8?B?YkpmZGFQOGdpN0xKcm9xUXR0bDhhUGVVdVMvQjNkRG1BZG4rMnNYT3NUU3lO?= =?utf-8?B?WnVyaXFpNll4RFVRTDBWL09QdmptZmx1M2JWWURqUndzUUhXd21FMlNaYmV4?= =?utf-8?B?N1pUQ204ZjJSM2RQWm4xSjkrNDZtZE9PMGx2YnE1WnAwMlhWaTNCN091ZWdD?= =?utf-8?B?NTJ1VmgyRG8vMWJyWkt2Sk14WjJFYnIrQ0Z6dWFRVGdpM3BpMklUMUFWd3VI?= =?utf-8?B?bklsRi8xT1V5OU5TV1dpYVRYNTkrTW44NC9ISGNvSjYwcjJJQUl4KzJBVUdD?= =?utf-8?B?MWRmTWxKOFZWcFJHcFJJbzJnMnZvT3NxNmhXN24vMFhmK3BWUTZYYkdHbDNL?= =?utf-8?B?TThzOXArMWJhWWU4OEZiK1c1OG1BeHJNcWNRSzVPN0YxVlUrcGhJVm9UaXY3?= =?utf-8?B?SWJ6eEdFU2JtMkVFZ2U1a0ZiZndNTVBsS2VMWThuL1R4cUNDUmFCRlR2SGNl?= =?utf-8?B?REdGRmdHQXRZd3JQaXNXSjNoUktYQUYzN3VHZTMzQXkyT3J4dGRCMW1KaHFv?= =?utf-8?B?OVo3WVhQZFpmQmtiMDB5MlVnY1RXZUJLNEsvcXhBV3VNbHVEUUY1QmNwZVN5?= =?utf-8?B?d09Xd3A0TVhPZXVMRm85VVdWcmdjUjF1Mm4rN09BcS9Tem4wOHQwc0R2YUJs?= =?utf-8?B?dFdmM09IZExTMGJFYUppWlhhNjFuZEJ1ajkyQ2tiRi9kL3RyaElVbkN4N2Vv?= =?utf-8?B?VWtObEh4TnhYZWF0bWNuTzhMMG1qR2dkbkd6dTBqYVJqRHR0V1VBZnhjUmZn?= =?utf-8?B?K1dPT0M0YUdGSjJnb3RsNXlCRTBmd2w3d0dBMlZyNHROY0piZG9FZEpCTFVr?= =?utf-8?B?OXRxNjVtSnZZU0k3VTVSMExpZmQxVlI2QjBJT2dPanJWYVlHb2d1My8xQkQ0?= =?utf-8?B?UEMzN21PRUZFTERQeGFJMlIxU2xIcWRYdXErVzFwT01sNU5HM3Y3Mk1CZ01T?= =?utf-8?B?Q1FpeWZsSkNhVEtEd2MrVTA5SkNpRzMvN3ZJSnZHWUVuZE4wbExRc3Fvc1FS?= =?utf-8?B?UlowY3BGeVJCMGZrTGgzWFpYbER5VjFISnFwTDA3V2JyOTVYZG9USDUydXZU?= =?utf-8?B?V0NsWUZyTDVWUFJ3TGNIblRPdGNkY1J3Z0V3aHA1ejZwWUFPeStua0JwY1hZ?= =?utf-8?B?YWZGYkJVcmhCSFdQMHJRd1dBNkhPTml5bjlsTTlscHJtUExSM2VwVDdneGVJ?= =?utf-8?B?U1A1YkJ6ZGZpbnFkRFZWNmwxWmFCU0QwUGxFWnA5eW1xWGl2VXI4TTBneW10?= =?utf-8?B?K3Vha0ZTZlhsU1FhVGREdHpjN1Nwc1lQS2lUUmQzWVVHREhtRDk3TnZFTkh3?= =?utf-8?B?eWd2eGhpbG1oOXpXbVVPYmg3bFRLNjZLUE91U2RXVnk3d3QwM3E0RDdHTlcw?= =?utf-8?Q?oQt1So5iIeYeGGBg=3D?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 14b39540-bfb1-40e9-d0ac-08da49ea4f51 X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4343.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2022 07:33:12.9220 (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: UOPxecwBrJCK5kZ2MbEfX7BqdiA6zye37UZiXSM57p02eYESIvy7pKzKyzGXXXGBOtDZweVNz7yllF4v9wPn9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8639 X-Proofpoint-GUID: EuC86nl0_eFHzIdfIumiQdCm512sIRog X-Proofpoint-ORIG-GUID: EuC86nl0_eFHzIdfIumiQdCm512sIRog X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-09_07,2022-06-07_02,2022-02-23_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.151.68; envelope-from=het.gala@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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-Mailman-Approved-At: Thu, 09 Jun 2022 09:30:26 -0400 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @nutanix.com) X-ZM-MESSAGEID: 1654783449836100001 i) Modified the format of the qemu monitor command : 'migrate' by adding a = list, each element in the list consists of multi-FD connection parameters: sou= rce and destination uris and of the number of multi-fd channels between each= pair. ii) Information of all multi-FD connection parameters=E2=80=99 list, length= of the list and total number of multi-fd channels for all the connections together = is stored in =E2=80=98OutgoingArgs=E2=80=99 struct. Suggested-by: Manish Mishra Signed-off-by: Het Gala --- include/qapi/util.h | 9 ++++++++ migration/migration.c | 47 ++++++++++++++++++++++++++++++-------- migration/socket.c | 53 ++++++++++++++++++++++++++++++++++++++++--- migration/socket.h | 17 +++++++++++++- monitor/hmp-cmds.c | 22 ++++++++++++++++-- qapi/migration.json | 43 +++++++++++++++++++++++++++++++---- 6 files changed, 170 insertions(+), 21 deletions(-) diff --git a/include/qapi/util.h b/include/qapi/util.h index 81a2b13a33..3041feb3d9 100644 --- a/include/qapi/util.h +++ b/include/qapi/util.h @@ -56,4 +56,13 @@ int parse_qapi_name(const char *name, bool complete); (tail) =3D &(*(tail))->next; \ } while (0) =20 +#define QAPI_LIST_LENGTH(list) ({ \ + int _len =3D 0; \ + typeof(list) _elem; \ + for (_elem =3D list; _elem !=3D NULL; _elem =3D _elem->next) { \ + _len++; \ + } \ + _len; \ +}) + #endif diff --git a/migration/migration.c b/migration/migration.c index 31739b2af9..c408175aeb 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2328,13 +2328,14 @@ static bool migrate_prepare(MigrationState *s, bool= blk, bool blk_inc, return true; } =20 -void qmp_migrate(const char *uri, bool has_blk, bool blk, +void qmp_migrate(const char *uri, bool has_multi_fd_uri_list, + MigrateUriParameterList *cap, 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 =3D NULL; MigrationState *s =3D migrate_get_current(); - const char *p =3D NULL; + const char *dst_ptr =3D NULL; =20 if (!migrate_prepare(s, has_blk && blk, has_inc && inc, has_resume && resume, errp)) { @@ -2348,20 +2349,46 @@ void qmp_migrate(const char *uri, bool has_blk, boo= l blk, } } =20 + /* + * In case of Multi-FD migration parameters, if uri is provided, + * supports only tcp network protocol. + */ + if (has_multi_fd_uri_list) { + int length =3D QAPI_LIST_LENGTH(cap); + init_multifd_array(length); + for (int i =3D 0; i < length; i++) { + const char *p1 =3D NULL, *p2 =3D NULL; + const char *multifd_dst_uri =3D cap->value->destination_uri; + const char *multifd_src_uri =3D cap->value->source_uri; + uint8_t multifd_channels =3D cap->value->multifd_channels; + if (!strstart(multifd_dst_uri, "tcp:", &p1) || + !strstart(multifd_src_uri, "tcp:", &p2)) { + error_setg(errp, "multi-fd destination and multi-fd source= " + "uri, both should be present and follows tcp protocol only= "); + break; + } else { + store_multifd_migration_params(p1 ? p1 : multifd_dst_uri, + p2 ? p2 : multifd_src_uri, + multifd_channels, i, &local_er= r); + } + cap =3D cap->next; + } + } + migrate_protocol_allow_multi_channels(false); - if (strstart(uri, "tcp:", &p) || + if (strstart(uri, "tcp:", &dst_ptr) || strstart(uri, "unix:", NULL) || strstart(uri, "vsock:", NULL)) { migrate_protocol_allow_multi_channels(true); - socket_start_outgoing_migration(s, p ? p : uri, &local_err); + socket_start_outgoing_migration(s, dst_ptr ? dst_ptr : uri, &local= _err); #ifdef CONFIG_RDMA - } else if (strstart(uri, "rdma:", &p)) { - rdma_start_outgoing_migration(s, p, &local_err); + } else if (strstart(uri, "rdma:", &dst_ptr)) { + rdma_start_outgoing_migration(s, dst_ptr, &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 (strstart(uri, "exec:", &dst_ptr)) { + exec_start_outgoing_migration(s, dst_ptr, &local_err); + } else if (strstart(uri, "fd:", &dst_ptr)) { + fd_start_outgoing_migration(s, dst_ptr, &local_err); } else { if (!(has_resume && resume)) { yank_unregister_instance(MIGRATION_YANK_INSTANCE); diff --git a/migration/socket.c b/migration/socket.c index 4fd5e85f50..7ca6af8cca 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -32,6 +32,17 @@ struct SocketOutgoingArgs { SocketAddress *saddr; } outgoing_args; =20 +struct SocketArgs { + struct SrcDestAddr data; + uint8_t multifd_channels; +}; + +struct OutgoingMigrateParams { + struct SocketArgs *socket_args; + size_t length; + uint64_t total_multifd_channel; +} outgoing_migrate_params; + void socket_send_channel_create(QIOTaskFunc f, void *data) { QIOChannelSocket *sioc =3D qio_channel_socket_new(); @@ -47,6 +58,14 @@ int socket_send_channel_destroy(QIOChannel *send) qapi_free_SocketAddress(outgoing_args.saddr); outgoing_args.saddr =3D NULL; } + + if (outgoing_migrate_params.socket_args !=3D NULL) { + g_free(outgoing_migrate_params.socket_args); + outgoing_migrate_params.socket_args =3D NULL; + } + if (outgoing_migrate_params.length) { + outgoing_migrate_params.length =3D 0; + } return 0; } =20 @@ -117,13 +136,41 @@ socket_start_outgoing_migration_internal(MigrationSta= te *s, } =20 void socket_start_outgoing_migration(MigrationState *s, - const char *str, + const char *dst_str, Error **errp) { Error *err =3D NULL; - SocketAddress *saddr =3D socket_parse(str, &err); + SocketAddress *dst_saddr =3D socket_parse(dst_str, &err); + if (!err) { + socket_start_outgoing_migration_internal(s, dst_saddr, &err); + } + error_propagate(errp, err); +} + +void init_multifd_array(int length) +{ + outgoing_migrate_params.socket_args =3D g_new0(struct SocketArgs, leng= th); + outgoing_migrate_params.length =3D length; + outgoing_migrate_params.total_multifd_channel =3D 0; +} + +void store_multifd_migration_params(const char *dst_uri, + const char *src_uri, + uint8_t multifd_channels, + int idx, Error **errp) +{ + Error *err =3D NULL; + SocketAddress *src_addr =3D NULL; + SocketAddress *dst_addr =3D socket_parse(dst_uri, &err); + if (src_uri) { + src_addr =3D socket_parse(src_uri, &err); + } if (!err) { - socket_start_outgoing_migration_internal(s, saddr, &err); + outgoing_migrate_params.socket_args[idx].data.dst_addr =3D dst_add= r; + outgoing_migrate_params.socket_args[idx].data.src_addr =3D src_add= r; + outgoing_migrate_params.socket_args[idx].multifd_channels + =3D multifd_chann= els; + outgoing_migrate_params.total_multifd_channel +=3D multifd_channel= s; } error_propagate(errp, err); } diff --git a/migration/socket.h b/migration/socket.h index 891dbccceb..bba7f177fe 100644 --- a/migration/socket.h +++ b/migration/socket.h @@ -19,12 +19,27 @@ =20 #include "io/channel.h" #include "io/task.h" +#include "migration.h" + +/* info regarding destination and source uri */ +struct SrcDestAddr { + SocketAddress *dst_addr; + SocketAddress *src_addr; +}; =20 void socket_send_channel_create(QIOTaskFunc f, void *data); int socket_send_channel_destroy(QIOChannel *send); =20 void socket_start_incoming_migration(const char *str, Error **errp); =20 -void socket_start_outgoing_migration(MigrationState *s, const char *str, +void socket_start_outgoing_migration(MigrationState *s, const char *dst_st= r, Error **errp); + +int multifd_list_length(MigrateUriParameterList *list); + +void init_multifd_array(int length); + +void store_multifd_migration_params(const char *dst_uri, const char *src_u= ri, + uint8_t multifd_channels, int idx, + Error **erp); #endif diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 622c783c32..2db539016a 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -56,6 +56,9 @@ #include "migration/snapshot.h" #include "migration/misc.h" =20 +/* Default number of multi-fd channels */ +#define DEFAULT_MIGRATE_MULTIFD_CHANNELS 2 + #ifdef CONFIG_SPICE #include #endif @@ -1574,10 +1577,25 @@ void hmp_migrate(Monitor *mon, const QDict *qdict) bool inc =3D qdict_get_try_bool(qdict, "inc", false); bool resume =3D qdict_get_try_bool(qdict, "resume", false); const char *uri =3D qdict_get_str(qdict, "uri"); + + const char *src_uri =3D qdict_get_str(qdict, "source-uri"); + const char *dst_uri =3D qdict_get_str(qdict, "destination-uri"); + uint8_t multifd_channels =3D qdict_get_try_int(qdict, "multifd-channel= s", + DEFAULT_MIGRATE_MULTIFD_CHANNELS); Error *err =3D NULL; + MigrateUriParameterList *caps =3D NULL; + MigrateUriParameter *value; + + value =3D g_malloc0(sizeof(*value)); + value->source_uri =3D (char *)src_uri; + value->destination_uri =3D (char *)dst_uri; + value->multifd_channels =3D multifd_channels; + QAPI_LIST_PREPEND(caps, value); + + qmp_migrate(uri, !!caps, caps, !!blk, blk, !!inc, + inc, false, false, true, resume, &err); + qapi_free_MigrateUriParameterList(caps); =20 - qmp_migrate(uri, !!blk, blk, !!inc, inc, - false, false, true, resume, &err); if (hmp_handle_error(mon, err)) { return; } diff --git a/qapi/migration.json b/qapi/migration.json index 6130cd9fae..fb259d626b 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1454,12 +1454,38 @@ ## { 'command': 'migrate-continue', 'data': {'state': 'MigrationStatus'} } =20 +## +# @MigrateUriParameter: +# +# Information regarding which source interface is connected to which +# destination interface and number of multifd channels over each interface. +# +# @source-uri: the Uniform Resource Identifier of the source VM. +# Default port number is 0. +# +# @destination-uri: the Uniform Resource Identifier of the destination VM +# +# @multifd-channels: number of parallel multifd channels used to migrate d= ata +# for specific source-uri and destination-uri. Default = value +# in this case is 2 (Since 4.0) +# +## +{ 'struct' : 'MigrateUriParameter', + 'data' : { 'source-uri' : 'str', + 'destination-uri' : 'str', + '*multifd-channels' : 'uint8'} } + ## # @migrate: # # Migrates the current running guest to another Virtual Machine. # # @uri: the Uniform Resource Identifier of the destination VM +# for migration thread +# +# @multi-fd-uri-list: list of pair of source and destination VM Uniform +# Resource Identifiers with number of multifd-channels +# for each pair # # @blk: do block migration (full disk copy) # @@ -1479,20 +1505,27 @@ # 1. The 'query-migrate' command should be used to check migration's progr= ess # and final result (this information is provided by the 'status' member) # -# 2. All boolean arguments default to false +# 2. The uri argument should have the Uniform Resource Identifier of defau= lt +# destination VM. This connection will be bound to default network +# +# 3. All boolean arguments default to false # -# 3. The user Monitor's "detach" argument is invalid in QMP and should not +# 4. The user Monitor's "detach" argument is invalid in QMP and should not # be used # # Example: # -# -> { "execute": "migrate", "arguments": { "uri": "tcp:0:4446" } } +# -> { "execute": "migrate", +# "arguments": { "uri": "tcp:0:4446", "multi-fd-uri-list":= [ { +# "source-uri": "tcp::6900", "destination-u= ri": "tcp:0:4480", +# "multifd-channels": 4}, { "source-uri": "= tcp:10.0.0.0: ", +# "destination-uri": "tcp:11.0.0.0:7789", "= multifd-channels": 5} ] } } # <- { "return": {} } # ## { 'command': 'migrate', - 'data': {'uri': 'str', '*blk': 'bool', '*inc': 'bool', - '*detach': 'bool', '*resume': 'bool' } } + 'data': {'uri': 'str', '*multi-fd-uri-list': ['MigrateUriParameter'], '*= blk': 'bool', + '*inc': 'bool', '*detach': 'bool', '*resume': 'bool' } } =20 ## # @migrate-incoming: --=20 2.22.3 From nobody Mon Feb 9 17:41:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1654784444; cv=pass; d=zohomail.com; s=zohoarc; b=dbeWfP6iFB/txXCLkBLrWspkYk3Ztm+XOw4dPe4y9EAt/3KSRhSaYFehL92HHULQY+LzVi9borKoJicbpo0AtJdI7yfcvC6cduJCnd+CsjBTdbqE4JOiTE1o7foYIaprYmsqtopneJdFI+r1vnDPjRKG8mFPrth2es5PPoG75Ns= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654784444; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fVlopdvxuJj6Cz63nf3fC0gf0KuCacUk6nP1g4zXZXg=; b=Kn/vZoqEKzlCMoIXmwpTu6TVP0AKgdC6BuA6g4HsAyhJP07jJ3tz93Ni9TLIrk5MeE0UhibsJ3eKUSADFc92dkIxpsQHIzX1wzRZPmB4Gav6KPvPcI8W6h+W+zVj0oCwLG+8s14NUXtgW+icNbYVmdBYdODpmwkqUJBSA9syqQ8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1654784444191648.3627697861692; Thu, 9 Jun 2022 07:20:44 -0700 (PDT) Received: from localhost ([::1]:58920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzJ1f-0004jS-1o for importer@patchew.org; Thu, 09 Jun 2022 10:20:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzCfW-0002B3-Jl for qemu-devel@nongnu.org; Thu, 09 Jun 2022 03:33:29 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]:46408) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzCfQ-0007uI-Pm for qemu-devel@nongnu.org; Thu, 09 Jun 2022 03:33:26 -0400 Received: from pps.filterd (m0127838.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25964PeO022399; Thu, 9 Jun 2022 00:33:17 -0700 Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 3gg6y0a3r2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 09 Jun 2022 00:33:17 -0700 Received: from BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) by SA1PR02MB8639.namprd02.prod.outlook.com (2603:10b6:806:1fe::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13; Thu, 9 Jun 2022 07:33:14 +0000 Received: from BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f]) by BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f%5]) with mapi id 15.20.5314.019; Thu, 9 Jun 2022 07:33:14 +0000 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-type : content-transfer-encoding : mime-version; s=proofpoint20171006; bh=fVlopdvxuJj6Cz63nf3fC0gf0KuCacUk6nP1g4zXZXg=; b=JzWOYzA5pBry4s6Gtt9pbvMg44/9p1Hmuz7UmF86SfTP67mxjEGLV0q6gTi4Nw7prZRm wOi7Hxjt7RAKkYFT3YO+WKfi4JudZ1bj8Nr0f8wt3a4I9ShCXAg1HPiD0+3DF3SI5zr1 3tesp6NGgyN3kaEhSfUg7Rjbctv2Ej8oxr8AxC8+LFLzOgvDvSvWthVpfIoU7wLi2K9/ MfAC8qCzWpJdx0QJJYsilpQH6il8IF97KOA8YKCuWjI0ujwmRsrklVJDZRpaOL4IzVe4 SPEUtQWtSEBvQ06mmflhR1JNFwBhMi3Nm4vSr4oJmQvjnFwIvqqiRov22S99Ncaisl2q aQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a06eldtezXhlUyrTH20DfjROPS2UBMs3uNZXV+UoTiSefGiFCmpn1LfNZOjocSE2YyqXk5ZUB3IDGsbLhn1dMuLDYAgL9nnNdZB/9gaM0PxwycsRIhWBPtUlW8hke4dcC04d4xKl3PB1bG94Db9Mkb6sqBJCVbEfW07XpsBrFxgm4bAfEuyCF4vRitqtpSd6BE/QG1pnzfmkOOYh9j0ffati5XtxdMVAS3OnXNHS4mDjN2uY/uQ6wYvuGmFN5ks8aWVSBawL4aRVWNun91sMt2zxZ2g1h1UbY1BQueC79YkBT0OVKgcI5DBLqEgw3N/6VzeaTBnhXdC4SHv8z4jX3Q== 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=fVlopdvxuJj6Cz63nf3fC0gf0KuCacUk6nP1g4zXZXg=; b=M6AqpzVBAvsN0HKwmPGHIzzUrpcLdNNHPRScanHXcbRJFLzdX3pw/w6Q9EENLyqMu0B77AiJ4qS3mzed2xQzF7oR7i49YfLP+uqgQjt/PQZsnJNQ/wZGvA4TQJlHTYpaqUct45wp7sqDG0T480Qo1+UbUPCF7O6ns0rf2wLOmUxHcg3eimQxNivr6Q2jbOcuO6HbrRXHBAEqES2nxCzDNr1QBE8+zA0Q1BqlrOdKwsRsxRvdJltX6M8buoBbvr07oGGQ3l8/YzfvIevSKFdG0JPzby641fAUOTjF31SSyfz9pZY9694ynuiNscoifH6OBZrVDBuIS4yxjoIKigX/zg== 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 From: Het Gala To: qemu-devel@nongnu.org Cc: quintela@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, berrange@redhat.com, armbru@redhat.com, eblake@redhat.com, Het Gala , Manish Mishra Subject: [PATCH 2/4] Adding multi-interface support for multi-FD on destination side Date: Thu, 9 Jun 2022 07:33:03 +0000 Message-Id: <20220609073305.142515-3-het.gala@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20220609073305.142515-1-het.gala@nutanix.com> References: <20220609073305.142515-1-het.gala@nutanix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BY5PR04CA0002.namprd04.prod.outlook.com (2603:10b6:a03:1d0::12) To BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cdc8117f-8c16-4444-832f-08da49ea506d X-MS-TrafficTypeDiagnostic: SA1PR02MB8639:EE_ X-Microsoft-Antispam-PRVS: 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: EXKnHtJQxpJZkOcKncpoxIrqZwkwLDvpe8WCHf3U7tGQqEtqfL6twlWw6CVfrlX0XfgwZSUTIwwsJn2yQ/AvnbCmZUQyIG5as+RAQzlOAZ5RTDMF7Vdwvd002hCkOgYDz9d/a/7v+vWj1hDhz7GTtp5O+LnmuUbX7ZBXrcLHjPbgRd4/0PstcVL+iPJPN34f5LvqnyUIADe/d/C09B+sVQC64R4RIAznDXtieNllLYQszGqxwclGaQyAr1g/XAm9AHpiSg/GChGhOXkTAd1tfmciLOh4Ox0TNdk72B69arlCwvBNFoSej8jpXmCXAJlYYc3ncih1ybSuNnFrLrG+Jh/yzPs534Rx72ulda0MSBs6MWjW9s4vVL6YcZbcntlWyqspSPlpptoMAhrRkkJ9M3D82p9KbIMitEruC2CcvKweZ82ONEe3DC3R1Ixplvm7yA6pkzBkj/xZjCAVnmO16ieiAn/IJUDxhGR89ruzUekGJRGzIzg3Wl1VfmBrBne2lk+1DwFwbU34VwcnYEwJxgoRMsZ5O9PbGkUVegvSKAXx5BaR8D3g1rJUtIzF3NZLrRn7xQFu0NXsKgdMHziHzSlibsKecXbyb5EOW619X3KkuYP4wLb6gM1jTVtRh+ZiG5FpCxDGgcBMtTciun/ZAMkMwzOUfleuT+8CLx5HaOO8TmZVWUCYSZKcL2L6LflMFK+6Z+nQJeIt1Cu82QPygxEIeZGZwvr3KjQIi0qg0Ho= 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:(13230001)(366004)(508600001)(107886003)(6666004)(1076003)(2906002)(8936002)(52116002)(54906003)(86362001)(6506007)(186003)(5660300002)(30864003)(83380400001)(6486002)(44832011)(38350700002)(26005)(38100700002)(36756003)(6512007)(2616005)(316002)(66556008)(66946007)(4326008)(6916009)(8676002)(66476007)(309714004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ejBISmxGTUtNNGVJNFM4STY3SUlyZHJIblhhUVJlOFVQM2ZnM3ZNc0hNUVFs?= =?utf-8?B?LzRxeDlHZy9vcllOVEhrRzFneUJod1B0NGw0eHJtbVRNdXVVUlhhWVB6cEZB?= =?utf-8?B?YjFRSWZ1UVo0ZE1xSFMzbHpsdHVKZkxPRjJoN3VCaFlScS8xZWcxQ1NxK3RQ?= =?utf-8?B?bjI0ZFpJM1ZRQTc0RnBTWDhJRzJhV0lkWVJTWElwbEtFcmpBcFc1MjBibkcy?= =?utf-8?B?MVNlQk14MGIvMkFlOXJBY0hGSjQyYVlONys3VUhoSFBxUU50ejJXNm9lT1Vt?= =?utf-8?B?M1B6RG4wTmlQZWpGMW5sQlVPL2s0aXFwdEsyelFBVDIwWHhXTVZURVI1Y1hX?= =?utf-8?B?c1RiSmVpQ2E0NkwzNVVLbmdQMnhGWSswM09IcDArelRFaXlNeG4wNzFDbjdE?= =?utf-8?B?Mk9OMXl4WitUVTNqajRraWFGTC84VlY1dEFTdkVEdFZHOG5uYTZPT0JoSys2?= =?utf-8?B?QlFqT01WcXBmdmJLRHlGMHk2WUhSbG13YkRPR0FEQlMwQzBmbFVvTU5BWXc3?= =?utf-8?B?V3VKc3hjb01TbEYvTi9Hc1BxMTBHc2xzVFp2RE1mWjk4UmhjbGIxaWtwcVh0?= =?utf-8?B?OHpVRUpvSUc3ZDd0QVRrTFFRQkliTmtjd3BnTWliL3FCWVIwQ1pqZjZscHda?= =?utf-8?B?SFpjbTdjTDAySjJacDFEZnFjQUd6aUdYbWRJSG9iY1kwOUswMlF2VWFkeFdz?= =?utf-8?B?b2FkV08rRkNNRFBFTERVT2EzVFpPZzJHc2dEclVKUC9ha1F0TEUrckVPcEl1?= =?utf-8?B?am9ibFRLb3Y0SDdpcW52MHdpU3VBYVd2QTFyUEFPWHpWVVRIc3pZaVNiMjNX?= =?utf-8?B?RjB5dDAzdVVTdmpxTFpsMEVFOVRUMkNRTG9BYUREUjNpdEtDcUlZazVQZmFE?= =?utf-8?B?dmJUdGp6YXpHbWdPWXhIVXp6QUluZnZ4RGNMVjBsakc4YURJc0YreVEvNGx5?= =?utf-8?B?cy9XM0VRT2dpWjZzWnBEdW82ZGtHcmY0NzlJRitySnYrT1RNdFptd1RkaFBr?= =?utf-8?B?WllLL3poa2pKNG1sL3RXV0pKTDJiNlI0YmtiZDIvTXpoVGNiTXJaRmt4UG1V?= =?utf-8?B?REtnODVXajRLSlFyZjhFRS9Jdm1TWDJyV2JsR0ZCa0dtblc2bWFtNGxJZFVU?= =?utf-8?B?eGF4RCtaOVFMaTBtSWtuN09Xck9pV2VGTEdkbDR4WXJmcTg3NlF2R1grVlBl?= =?utf-8?B?Lzc5RlpUWnV5ZGZMQ1pzTUhYMWxrUXRaNzU0VHJMOXordGNxL3VzN3NpelRJ?= =?utf-8?B?RjFMdlBYaWZTVnhPOGo1TUZINzZ3NnpIYi9SZEI2Zk0xYnhDdnpEQVhtV0lx?= =?utf-8?B?V3BEdlZNZFlYckxza1p4d3MzSEtmL2MvN1ZlOHVmVUJ4YWlEYTY0aGJyNGxQ?= =?utf-8?B?ekVrWXJ2V01NUS9peGZ2RVFtclYvbFJIMUw1STQ3b3RLL0FIQWt6V081eU9K?= =?utf-8?B?cDlkQVBSTjYzSGt3bDU0RjB4SExOeHcrMjVaNksxRFpRN1ZiN25RQjk5cmlw?= =?utf-8?B?WlFYdVlTZXJIeUk3Wk9pMDdFVk10VVhEaGQ5SnJodG56b1FCampvVW41c0Fr?= =?utf-8?B?U3hteFc2QmFGM2xaRi9VQlZtZXNRRHNYMW9qbHJ2dklJMDZWNForVEZBRkM3?= =?utf-8?B?NUJQQmtDNk16U1ZFdWQ5cm55aWZUdW4vRGFmRExmN0JxNi9aRTM0OHJJSith?= =?utf-8?B?akhJUk1JNUs5ME9kS05VZ1p2STVnemVEK0xQeDZUVWw4d3dudlduRTZsZWVM?= =?utf-8?B?MFhQbFI1V0lLNXVjanVqVjlLNTYwcGp3V25LSmNWZ3NCY243WjZudmdKeWsy?= =?utf-8?B?TVBsdkR2cklSMFV2eE1ROGNlaTNUYkZ0Y1R1MW1SK2tZNGRscFR2YUlsWndq?= =?utf-8?B?SW90SkMzMG0xRzJ0cVNWSHlWUzRtWVNWNWlSTW8yREMyZm9QRkJpSFJmWmN3?= =?utf-8?B?ZVh5U3BUajRFOGkzTFd1R1FvT3BMUjh6bS9DaERxN2h5TThLOUNOT1A2R05u?= =?utf-8?B?b2hIaVlhbVNWcCtDdS9FdVpsdEtneEh2REpSNTlncUZPdjNEcEovaTVGdURx?= =?utf-8?B?N3hSSVYvd00xSVhKMitPakJvNSt6SUtTclZSRzUvWnpvbXE3bnBGcENIbVFv?= =?utf-8?B?TEh2S2tJNFhqUHgwM2VkWFZ0c3AzSTdseXcrai9CWDVFb2pOcC9FbWlGMFpB?= =?utf-8?B?Rk9aOTFMZ01WWE1ST1IrSTVlMTYzUmpkSDlmaVpYb0FJQTRVUTA3M3NjdEZX?= =?utf-8?B?VGlweWZpeGU3cVdvM3J4SWhidU5ub0RkOGZiZlNYWlkzdDVKMktYOHdZSFMv?= =?utf-8?B?WGJ5bnNzNm9BazA3U2JydVppQXRlWGVwYWtjVW5LYzlLaUpWK3V6SjgxRDhy?= =?utf-8?Q?KX741jAbvoIz8Cm4=3D?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: cdc8117f-8c16-4444-832f-08da49ea506d X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4343.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2022 07:33:14.7813 (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: V/Rl4oYGR0kkxeOfSoxvvzeyVjralrM3pH6G5RmazfnVxrYcU7YCVhzesNc0cmkow3sAZxfRuua/tuRUSQJpAg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8639 X-Proofpoint-GUID: N7GQt9PTXAnIpREplu6LCjWWbOrFCAX4 X-Proofpoint-ORIG-GUID: N7GQt9PTXAnIpREplu6LCjWWbOrFCAX4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-09_07,2022-06-07_02,2022-02-23_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.151.68; envelope-from=het.gala@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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-Mailman-Approved-At: Thu, 09 Jun 2022 09:30:34 -0400 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @nutanix.com) X-ZM-MESSAGEID: 1654784446177100001 i) Modified the format of qemu monitor command: =E2=80=98migrate-incoming= =E2=80=99 by adding a list, each element in the list is to open listeners with a given number of multiFD channels. ii) Qemu starts with -incoming flag defer and -multi-fd-incoming defer to allow the modified 'migrate-incoming' command to be used. iii) Format for -multi-fd-incoming flag as a comma separated string has been added with each substring containing listener socket address and number of sockets to open. Suggested-by: Manish Mishra Signed-off-by: Het Gala --- include/qapi/util.h | 1 + migration/migration.c | 149 ++++++++++++++++++++++++++++++++++++------ migration/migration.h | 2 + migration/socket.c | 11 ++-- migration/socket.h | 3 +- monitor/hmp-cmds.c | 42 ++++-------- qapi/migration.json | 43 ++++++++++-- qapi/qapi-util.c | 27 ++++++++ qemu-options.hx | 18 +++++ softmmu/vl.c | 30 ++++++++- 10 files changed, 265 insertions(+), 61 deletions(-) diff --git a/include/qapi/util.h b/include/qapi/util.h index 3041feb3d9..88fb2270db 100644 --- a/include/qapi/util.h +++ b/include/qapi/util.h @@ -29,6 +29,7 @@ bool qapi_bool_parse(const char *name, const char *value,= bool *obj, Error **errp); =20 int parse_qapi_name(const char *name, bool complete); +struct strList *strList_from_string(const char *in, char c); =20 /* * For any GenericList @list, insert @element at the front. diff --git a/migration/migration.c b/migration/migration.c index c408175aeb..9b0ad732e7 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -477,28 +477,39 @@ void migrate_add_address(SocketAddress *address) QAPI_CLONE(SocketAddress, address)); } =20 -static void qemu_start_incoming_migration(const char *uri, Error **errp) +static void qemu_start_incoming_migration(const char *uri, uint8_t number, + int idx, Error **errp) { const char *p =3D NULL; =20 - migrate_protocol_allow_multi_channels(false); /* reset it anyway */ - qapi_event_send_migration(MIGRATION_STATUS_SETUP); - if (strstart(uri, "tcp:", &p) || - strstart(uri, "unix:", NULL) || - strstart(uri, "vsock:", NULL)) { - migrate_protocol_allow_multi_channels(true); - socket_start_incoming_migration(p ? p : uri, errp); -#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); + if (number =3D=3D 0) { + migrate_protocol_allow_multi_channels(false); /* reset it anyway */ + qapi_event_send_migration(MIGRATION_STATUS_SETUP); + if (strstart(uri, "tcp:", &p) || + strstart(uri, "unix:", NULL) || + strstart(uri, "vsock:", NULL)) { + migrate_protocol_allow_multi_channels(true); + #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); + } } else { - error_setg(errp, "unknown migration protocol: %s", uri); + /* multi-FD parameters only support tcp network protocols */ + if (!strstart(uri, "tcp:", &p)) { + error_setg(errp, "multifd-destination uri supports " + "tcp protocol only"); + return; + } + store_multifd_migration_params(p ? p : uri, NULL, number, idx, err= p); } + socket_start_incoming_migration(p ? p : uri, number, errp); } =20 static void process_incoming_migration_bh(void *opaque) @@ -2140,7 +2151,17 @@ void migrate_del_blocker(Error *reason) migration_blockers =3D g_slist_remove(migration_blockers, reason); } =20 -void qmp_migrate_incoming(const char *uri, Error **errp) +static inline int incoming_multi_fd_uri_parse(const char *str, char delim) +{ + int count =3D 0; + for (int i =3D 0; i < strlen(str); i++) { + count +=3D (str[i] =3D=3D delim); + } + return count; +} + +/* migrate_incoming comes from -incoming flag in qemu process */ +void migrate_incoming(const char *uri, Error **errp) { Error *local_err =3D NULL; static bool once =3D true; @@ -2154,11 +2175,99 @@ void qmp_migrate_incoming(const char *uri, Error **= errp) return; } =20 + qemu_start_incoming_migration(uri, 0, 0, &local_err); + if (!yank_register_instance(MIGRATION_YANK_INSTANCE, errp)) { return; } =20 - qemu_start_incoming_migration(uri, &local_err); + if (local_err) { + yank_unregister_instance(MIGRATION_YANK_INSTANCE); + error_propagate(errp, local_err); + return; + } + + once =3D false; +} + +/* multi_fd_migrate_incoming comes from -multi-fd-migrate-incoming flag in= qemu process */ +void multi_fd_migrate_incoming(const char *uri, Error **errp) +{ + Error *local_err =3D NULL; + static bool once =3D true; + + if (!once) { + error_setg(errp, "The incoming migration has already been started"= ); + return; + } + if (!runstate_check(RUN_STATE_INMIGRATE)) { + error_setg(errp, "'-multi-fd-incoming' was not specified on the co= mmand line"); + return; + } + + strList *st =3D strList_from_string(uri, ','); + strList *r =3D st; + int length =3D QAPI_LIST_LENGTH(st); + init_multifd_array(length); + + for (int i =3D 0; i < length; i++) { + const char *uri =3D NULL, *ret =3D NULL; + const char *str =3D r->value; + uint8_t multifd_channels =3D DEFAULT_MIGRATE_MULTIFD_CHANNELS; + int parse_count =3D incoming_multi_fd_uri_parse(str, ':'); + if (parse_count < 2 || parse_count > 3) { + error_setg(errp, "Invalid format of string-id %d in " + "'-multi-fd-incoming' flag", i); + return; + } + if (parse_count =3D=3D 3) { + ret =3D strrchr(str, ':'); + uri =3D g_strndup(str, strlen(str) - strlen(ret)); + multifd_channels =3D atoi(ret + 1); + } + qemu_start_incoming_migration(parse_count =3D=3D 2 ? str : uri, + multifd_channels, i, &local_err); + r =3D r->next; + } + + if (local_err) { + yank_unregister_instance(MIGRATION_YANK_INSTANCE); + error_propagate(errp, local_err); + return; + } + + once =3D false; +} + +/* qmp_migrate_incoming comes from qemu qmp monitor command */ +void qmp_migrate_incoming(const char *uri, bool has_multi_fd_uri_list, + MigrateIncomingUriList *cap, Error **errp) +{ + Error *local_err =3D NULL; + static bool once =3D true; + + if (!once) { + error_setg(errp, "The incoming migration has already been started"= ); + return; + } + + if (!yank_register_instance(MIGRATION_YANK_INSTANCE, errp)) { + return; + } + + /* For migration thread */ + qemu_start_incoming_migration(uri, 0, 0, &local_err); + + /* For Multi-FD */ + int length =3D QAPI_LIST_LENGTH(cap); + init_multifd_array(length); + for (int i =3D 0; i < length; i++) { + const char *multifd_dst_uri =3D cap->value->destination_uri; + uint8_t multifd_channels =3D cap->value->multifd_channels; + qemu_start_incoming_migration(multifd_dst_uri, multifd_channels, + i, &local_err); + cap =3D cap->next; + } =20 if (local_err) { yank_unregister_instance(MIGRATION_YANK_INSTANCE); @@ -2194,7 +2303,7 @@ void qmp_migrate_recover(const char *uri, Error **err= p) * 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, 0, 0, errp); } =20 void qmp_migrate_pause(Error **errp) diff --git a/migration/migration.h b/migration/migration.h index 485d58b95f..fa8717ec9e 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -353,6 +353,8 @@ bool migration_is_setup_or_active(int state); bool migration_is_running(int state); =20 void migrate_init(MigrationState *s); +void migrate_incoming(const char *uri, Error **errp); +void multi_fd_migrate_incoming(const char *uri_str, Error **errp); bool migration_is_blocked(Error **errp); /* True if outgoing migration has entered postcopy phase */ bool migration_in_postcopy(void); diff --git a/migration/socket.c b/migration/socket.c index 7ca6af8cca..21e0983df2 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -202,17 +202,17 @@ socket_incoming_migration_end(void *opaque) =20 static void socket_start_incoming_migration_internal(SocketAddress *saddr, - Error **errp) + uint8_t number, Error **errp) { QIONetListener *listener =3D qio_net_listener_new(); MigrationIncomingState *mis =3D migration_incoming_get_current(); size_t i; - int num =3D 1; + uint8_t num =3D 1; =20 qio_net_listener_set_name(listener, "migration-socket-listener"); =20 if (migrate_use_multifd()) { - num =3D migrate_multifd_channels(); + num =3D number; } =20 if (qio_net_listener_open_sync(listener, saddr, num, errp) < 0) { @@ -239,12 +239,13 @@ socket_start_incoming_migration_internal(SocketAddres= s *saddr, } } =20 -void socket_start_incoming_migration(const char *str, Error **errp) +void socket_start_incoming_migration(const char *str, + uint8_t number, Error **errp) { Error *err =3D NULL; SocketAddress *saddr =3D socket_parse(str, &err); if (!err) { - socket_start_incoming_migration_internal(saddr, &err); + socket_start_incoming_migration_internal(saddr, number, &err); } qapi_free_SocketAddress(saddr); error_propagate(errp, err); diff --git a/migration/socket.h b/migration/socket.h index bba7f177fe..b9e3699167 100644 --- a/migration/socket.h +++ b/migration/socket.h @@ -30,7 +30,8 @@ struct SrcDestAddr { void socket_send_channel_create(QIOTaskFunc f, void *data); int socket_send_channel_destroy(QIOChannel *send); =20 -void socket_start_incoming_migration(const char *str, Error **errp); +void socket_start_incoming_migration(const char *str, uint8_t number, + Error **errp); =20 void socket_start_outgoing_migration(MigrationState *s, const char *dst_st= r, Error **errp); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 2db539016a..32a6b67d5f 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -42,6 +42,7 @@ #include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-commands-tpm.h" #include "qapi/qapi-commands-ui.h" +#include "qapi/util.h" #include "qapi/qapi-visit-net.h" #include "qapi/qapi-visit-migration.h" #include "qapi/qmp/qdict.h" @@ -72,32 +73,6 @@ bool hmp_handle_error(Monitor *mon, Error *err) return false; } =20 -/* - * Produce a strList from a comma separated list. - * A NULL or empty input string return NULL. - */ -static strList *strList_from_comma_list(const char *in) -{ - strList *res =3D NULL; - strList **tail =3D &res; - - while (in && in[0]) { - char *comma =3D strchr(in, ','); - char *value; - - if (comma) { - value =3D g_strndup(in, comma - in); - in =3D comma + 1; /* skip the , */ - } else { - value =3D g_strdup(in); - in =3D NULL; - } - QAPI_LIST_APPEND(tail, value); - } - - return res; -} - void hmp_info_name(Monitor *mon, const QDict *qdict) { NameInfo *info; @@ -1117,7 +1092,7 @@ void hmp_announce_self(Monitor *mon, const QDict *qdi= ct) migrate_announce_params()); =20 qapi_free_strList(params->interfaces); - params->interfaces =3D strList_from_comma_list(interfaces_str); + params->interfaces =3D strList_from_string(interfaces_str, ','); params->has_interfaces =3D params->interfaces !=3D NULL; params->id =3D g_strdup(id); params->has_id =3D !!params->id; @@ -1147,8 +1122,19 @@ void hmp_migrate_incoming(Monitor *mon, const QDict = *qdict) { Error *err =3D NULL; const char *uri =3D qdict_get_str(qdict, "uri"); + const char *dst_uri =3D qdict_get_str(qdict, "destination-uri"); + uint8_t multifd_channels =3D qdict_get_try_int(qdict, "multifd-channel= s", + DEFAULT_MIGRATE_MULTIFD_CHANNELS); + MigrateIncomingUriList *caps =3D NULL; + MigrateIncomingUri *value; + + value =3D g_malloc0(sizeof(*value)); + value->destination_uri =3D (char *)dst_uri; + value->multifd_channels =3D multifd_channels; + QAPI_LIST_PREPEND(caps, value); =20 - qmp_migrate_incoming(uri, &err); + qmp_migrate_incoming(uri, !!caps, caps, &err); + qapi_free_MigrateIncomingUriList(caps); =20 hmp_handle_error(mon, err); } diff --git a/qapi/migration.json b/qapi/migration.json index fb259d626b..62a7b22d19 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1527,15 +1527,37 @@ 'data': {'uri': 'str', '*multi-fd-uri-list': ['MigrateUriParameter'], '*= blk': 'bool', '*inc': 'bool', '*detach': 'bool', '*resume': 'bool' } } =20 +## +# @MigrateIncomingUri: +# +# Information regarding which destination listening interface to be connec= ted +# and number of multifd channels over that interface. +# +# @destination-uri: the Uniform Resource Identifier of the destination VM +# +# @multifd-channels: number of channels used to migrate data in parallel f= or +# for specific source-uri and destination-uri. +# Default value in this case is 2 (Since 4.0) +# +## +{ 'struct' : 'MigrateIncomingUri', + 'data' : { 'destination-uri' : 'str', + '*multifd-channels' : 'uint8'} } + ## # @migrate-incoming: # # Start an incoming migration, the qemu must have been started -# with -incoming defer +# with -incoming defer. qemu can also be started with optional +# -multi-fd-incoming defer for opening multifd listening sockets # # @uri: The Uniform Resource Identifier identifying the source or # address to listen on # +# @multi-fd-uri-list: list of pair of source and destination VM Uniform +# Resource Identifiers with number of multifd-channels +# for each pair +# # Returns: nothing on success # # Since: 2.3 @@ -1546,19 +1568,30 @@ # compatible with -incoming and the format of the uri is already exposed # above libvirt. # -# 2. QEMU must be started with -incoming defer to allow migrate-incoming to +# 2. multi-fd-uri-list will have list of destination uri as listening sock= ets +# and multi-fd number of channels on each listening socket. +# +# 3. QEMU must be started with -incoming defer to allow migrate-incoming to # be used. # -# 3. The uri format is the same as for -incoming +# 4. multi-fd-uri-list format is not the same as for -multi-fd-incoming fl= ag. +# For -multi-fd-incoming flag, it is a comma separated list of listener +# sockets with multifd channels. +# Example: -multi-fd-incoming "tcp::6900:4,tcp:11.0.0.0:7789:5". # # Example: # # -> { "execute": "migrate-incoming", -# "arguments": { "uri": "tcp::4446" } } +# "arguments": {"uri": "tcp::6789", +# "multi-fd-uri-list" : [ {"destination-uri" : "tcp::69= 00", +# "multifd-channels": 4}, +# {"destination-uri" : "tcp:11.= 0.0.0:7789", +# "multifd-channels": 5} ] } } # <- { "return": {} } # ## -{ 'command': 'migrate-incoming', 'data': {'uri': 'str' } } +{ 'command': 'migrate-incoming', + 'data': {'uri': 'str', '*multi-fd-uri-list': ['MigrateIncomingUri'] } } =20 ## # @xen-save-devices-state: diff --git a/qapi/qapi-util.c b/qapi/qapi-util.c index 63596e11c5..9cc43ebcd3 100644 --- a/qapi/qapi-util.c +++ b/qapi/qapi-util.c @@ -15,6 +15,7 @@ #include "qapi/error.h" #include "qemu/ctype.h" #include "qapi/qmp/qerror.h" +#include "qapi/qapi-builtin-types.h" =20 CompatPolicy compat_policy; =20 @@ -152,3 +153,29 @@ int parse_qapi_name(const char *str, bool complete) } return p - str; } + +/* + * Produce a strList from a delimiter separated list. + * A NULL or empty input string return NULL. + */ +strList *strList_from_string(const char *in, char c) +{ + strList *res =3D NULL; + strList **tail =3D &res; + + while (in && in[0]) { + char *ch =3D strchr(in, c); + char *value; + + if (ch) { + value =3D g_strndup(in, ch - in); + in =3D ch + 1; /* skip the , */ + } else { + value =3D g_strdup(in); + in =3D NULL; + } + QAPI_LIST_APPEND(tail, value); + } + + return res; +} diff --git a/qemu-options.hx b/qemu-options.hx index 60cf188da4..2e82e41dd5 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4480,6 +4480,24 @@ SRST to issuing the migrate\_incoming to allow the migration to begin. ERST =20 +DEF("multi-fd-incoming", HAS_ARG, QEMU_OPTION_multi_fd_incoming, \ + "-multi-fd-incoming tcp:[host]:port[:channel][,to=3Dmaxport][,ipv4=3Do= n|off][,ipv6=3Don|off]\n" \ + "-multi-fd-incoming defer\n" \ + " wait for the URI to be specified via\n" \ + " multi_fd_migrate_incoming\n", + QEMU_ARCH_ALL) +SRST +``-multi-fd-incoming tcp:[host]:port[:channel][,to=3Dmaxport][,ipv4=3Don|o= ff][,ipv6=3Don|off]`` + Prepare for multi-fd incoming migration, with multi-fd listening socke= ts + on that connection. Default number of multi-fd channels is 2. + +``-multi-fd-incoming defer`` + Wait for the URI to be specified via multi_fd_migrate\_incoming. The + monitor can be used to change settings (such as migration parameters) + prior to issuing the multi_fd_migrate\_incoming to allow the migration + to begin. +ERST + DEF("only-migratable", 0, QEMU_OPTION_only_migratable, \ "-only-migratable allow only migratable devices\n", QEMU_ARCH_ALL) SRST diff --git a/softmmu/vl.c b/softmmu/vl.c index 4c1e94b00e..2f5cf18eff 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -45,7 +45,7 @@ #include "sysemu/seccomp.h" #include "sysemu/tcg.h" #include "sysemu/xen.h" - +#include "migration/migration.h" #include "qemu/error-report.h" #include "qemu/sockets.h" #include "qemu/accel.h" @@ -167,6 +167,7 @@ typedef struct DeviceOption { static const char *cpu_option; static const char *mem_path; static const char *incoming; +static const char *multi_fd_incoming; static const char *loadvm; static const char *accelerators; static bool have_custom_ram_size; @@ -2349,6 +2350,11 @@ static void qemu_validate_options(const QDict *machi= ne_opts) error_report("'preconfig' supports '-incoming defer' only"); exit(EXIT_FAILURE); } + if (multi_fd_incoming && preconfig_requested && + strcmp(multi_fd_incoming, "defer") !=3D 0) { + error_report("'preconfig' supports '-multi-fd-incoming defer' only= "); + exit(EXIT_FAILURE); + } =20 #ifdef CONFIG_CURSES if (is_daemonized() && dpy.type =3D=3D DISPLAY_TYPE_CURSES) { @@ -2621,7 +2627,7 @@ void qmp_x_exit_preconfig(Error **errp) if (incoming) { Error *local_err =3D NULL; if (strcmp(incoming, "defer") !=3D 0) { - qmp_migrate_incoming(incoming, &local_err); + migrate_incoming(incoming, &local_err); if (local_err) { error_reportf_err(local_err, "-incoming %s: ", incoming); exit(1); @@ -2630,6 +2636,20 @@ void qmp_x_exit_preconfig(Error **errp) } else if (autostart) { qmp_cont(NULL); } + + if (multi_fd_incoming) { + Error *local_err =3D NULL; + if (strcmp(multi_fd_incoming, "defer") !=3D 0) { + multi_fd_migrate_incoming(multi_fd_incoming, &local_err); + if (local_err) { + error_reportf_err(local_err, "-multi-fd-incoming %s: ", + multi_fd_incoming); + exit(1); + } + } + } else if (autostart) { + qmp_cont(NULL); + } } =20 void qemu_init(int argc, char **argv, char **envp) @@ -3355,6 +3375,12 @@ void qemu_init(int argc, char **argv, char **envp) } incoming =3D optarg; break; + case QEMU_OPTION_multi_fd_incoming: + if (!multi_fd_incoming) { + runstate_set(RUN_STATE_INMIGRATE); + } + multi_fd_incoming =3D optarg; + break; case QEMU_OPTION_only_migratable: only_migratable =3D 1; break; --=20 2.22.3 From nobody Mon Feb 9 17:41:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1654786199; cv=pass; d=zohomail.com; s=zohoarc; b=Mc+qFSI+5RydZIIJincvdif5bfQXu6ZXOYs1S12+y2aWbA64rHx9c0cK5l7GM9zF0VfbK9ojqKN/mgrFfJH958L6v7mEuT3OUEFqKBMqyd7Skqswq6Pn0De+Ct8qJaUIfC43gwgJDbeGC4jRk/3K9VtvWukZzKXRr7k49fblHqk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654786199; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7+LOV4TNbMSsT83B7FiHwpFKsg7v6LYRFo9WTGpek9Q=; b=O+EfDhXDdvA5tVYMgDULkJ9wOBvoXIO7XWp33SKeuTVusJyEQT35Tu2lGlQ/ezpgMACVy/0/1qjaJRso5vGt+cfGehMdrFpFysCA5m09oEvDByxA7ZLvlYieTsi0aTrRtdcXXRbdcR6joDPCrfV6J5wGrQjOdnRerYb1HWzVLeA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1654786199812128.89815309454082; Thu, 9 Jun 2022 07:49:59 -0700 (PDT) Received: from localhost ([::1]:35876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzJTx-0007Us-Mw for importer@patchew.org; Thu, 09 Jun 2022 10:49:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzCfW-0002B5-UE for qemu-devel@nongnu.org; Thu, 09 Jun 2022 03:33:29 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]:1688) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzCfR-0007uP-1L for qemu-devel@nongnu.org; Thu, 09 Jun 2022 03:33:26 -0400 Received: from pps.filterd (m0127837.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25964eWX027717; Thu, 9 Jun 2022 00:33:19 -0700 Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 3gg3aatafk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 09 Jun 2022 00:33:19 -0700 Received: from BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) by SA1PR02MB8639.namprd02.prod.outlook.com (2603:10b6:806:1fe::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13; Thu, 9 Jun 2022 07:33:17 +0000 Received: from BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f]) by BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f%5]) with mapi id 15.20.5314.019; Thu, 9 Jun 2022 07:33:17 +0000 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=7+LOV4TNbMSsT83B7FiHwpFKsg7v6LYRFo9WTGpek9Q=; b=paowXkW4ALIv6J/uzuQG2R2vBYG0Y4CLyi+B2fA+FBkdyEuof7qDptjBSpRywjIgofO/ U1RBm+nlzcqNdZJZVpTGYL4hrtmvSxrNiWLAp1XiSwaltNa8FG5jZ30QgRNnOjXCEmn7 motD+P3cDFsOWWFp9TS/s16++Whb9ZVjDbX2sNE4JsOBJAfhG+QLr0AGmbC6Pgg3u9OB 2mxttXFzW2Riz6R2L3m8wW8DUS/rXP+k0TXvr5IGjCAc+DKRp3RSKtjTWfzCUxBHd/oQ 1qeOscZbxh6f2pQ6/HaIhQf6tJlKBWx3kd490cvysObVUvxIeRRahyD4gAfcMOLb6iAe 1A== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=elAJyHOELTYrPwCtRDuFg4hhys4f2aCr51aCv1XIDVSb9atTpqpYuGe2oKW7/AJSX+ATDDjqL0eU97IkJE+GMlLo9ov8lImW9W5c8aEQh8vAgpOcb5XKbzZdaYfZHhaE3j+TjskucneGU9XzXiQfGBg/rhvpW+1dB5nCbuAVANz5kCeDtx6G/my5Qf1bLH2NZqRkahrs6zz4eyiy4ethl1BclWPPIhCOixq2R5z4hBYXNfYvirzMNDv2rZ7klQ22KO5xLO1Ol5ajDKNcTwSsj7+FdBEQIQi2umbvJ8Fviuo7aE4VzFMlBzhzO87NPEncyoL0n8KyYeuWWDwz3P0u2A== 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=7+LOV4TNbMSsT83B7FiHwpFKsg7v6LYRFo9WTGpek9Q=; b=hZ16i10EAYeOGgLZ0Pun16vPhkpb9bftO7zPnzxfJLrRcYMoCX4NFAEqwZKfFvDhqUILGXSFM3dQbKC343jyJQrk+jMad624IbTQ7Zs1ebFH5R0Ijw6a8b2HRMkVEX/vAL3HvbWYFm9xMXpP1gYCnooaNnVA+ADbPBcYY1iPXtggZN0Cpv9scLUmNysFRUKl1cLWa+VK4HWK03bAt3nYHpVncZLmIcQEoJ1c+Tj1QvPT2sJX+euZW1FQwQNaqWzARUsdFEiBiBZZ1j5Ce2wuXFd93+gT4mGTJC5bH8yiiBfgF8bFEToqFuv2RMV16D1eOvM8VjFJk4ORGFHddk17EA== 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 From: Het Gala To: qemu-devel@nongnu.org Cc: quintela@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, berrange@redhat.com, armbru@redhat.com, eblake@redhat.com, Het Gala , Manish Mishra Subject: [PATCH 3/4] Establishing connection between any non-default source and destination pair Date: Thu, 9 Jun 2022 07:33:04 +0000 Message-Id: <20220609073305.142515-4-het.gala@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20220609073305.142515-1-het.gala@nutanix.com> References: <20220609073305.142515-1-het.gala@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BY5PR04CA0002.namprd04.prod.outlook.com (2603:10b6:a03:1d0::12) To BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 23c25bc8-a97a-4bb1-7f5b-08da49ea51d5 X-MS-TrafficTypeDiagnostic: SA1PR02MB8639:EE_ X-Microsoft-Antispam-PRVS: 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: z3zPjrVWAgypVcp97VylpyAVZfq8LlrvPwyYXo/CfSok9AhxHd6tuKvqQERJXMRxrvXCtTRzbNzxC5GTjVc2sI94oLVIJQ2q8JZGC7vVU4lc4NA8LyIrN3qhDdmOmGpCLJ7pzcPbfng4yiIna/GkQm6zvdmlLrESjx1wDCJLZY4zClX1D4mCF/a/HUMWnWnZSDgk+ok/5T0nKDMHi4+GFjsaCtRhLSYonKBeCAltUgFj9Ehw37w/HGx39XFI7jklqWlpGcDuFg5UVgO2OVncIRDafNjC8Kxd7eF7cSkeC6zzLBkdNdw1EUYTeR864lGBuTT0rQpIUujChsW4CNtNDhzsm4wn2PQmiZqtzO3t22SzzETgENL7ghw22DUeG9Nr5efVannrBm8vx1+pmAKRAckcZT7G6n5krcpoFalbWaq4dj3SgWrPSYd3qKiReD4AsTpPhcGKRYxdIqj5Ni4iMo/6T+nMw5Zxc3Uix1W4Vi/fqDcvOLMyXtnQg+W/gUjZ/8QG0oEQXIKNMX/zve3HsNgs4dQuXJIOHcEMCiM8nT7MSRM84/FcIMX/ZloPPm0pSWZnFBzRJ+oD0C6dpGrvaeiQJ3gXf63ZCIEx28F4N2drbSZ13iGhuysCG/e3Y93DTkV70jFr/inwaRZhUxbKQc8ylJPOfVE1gLkhlsWPqJUvKYtVgjI7whieXFVht4XnM1YSK0YU/wccYyLAgNt8Hg== 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:(13230001)(366004)(508600001)(107886003)(6666004)(1076003)(2906002)(8936002)(52116002)(54906003)(86362001)(6506007)(186003)(5660300002)(30864003)(83380400001)(66574015)(6486002)(44832011)(38350700002)(26005)(38100700002)(36756003)(6512007)(2616005)(316002)(66556008)(66946007)(4326008)(6916009)(8676002)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?lcj6Sw3ExuixowQ4EdM/YuUgmYqwG8oKw1elvcMhqWH5dhzoWN2z2UclmWI7?= =?us-ascii?Q?NHEDaxuSMIJ9SORms4V01Gyo+TtmeZh3ufRffDT4wLHselOVCAMxVnBjmJL/?= =?us-ascii?Q?DnvT9iD81Pn8hxW6oMHiL7gMQDoQ0pq+CbFfKI+KTnWy5MDaVzo0+1jc5GgY?= =?us-ascii?Q?0eCNR0ye0Oi74sOBVSsj1A1DaN28sRNuybbnuXb++WiKrOWCkkyOw6EpKJQM?= =?us-ascii?Q?7JfIV0ZMGFUbMcWz340sDiedwdqrznBbiwMhrNiy0rEeNVBKprJAEB7gLQHV?= =?us-ascii?Q?fOJPJ+DbqVy+831SmvjVXt/DucTU5SwumhlACEauMl2wT4gKKfNBGtUBGQTT?= =?us-ascii?Q?K98KU2UA2FiK5/0NSi5Jzy76gy4PpNjrbc+jbWu42yzhXPwRiEIAvzsIYqNV?= =?us-ascii?Q?EvbEyHv75YMotaQPOSu58cfvvrk5ja3XV++IMsatRXu44IPN8WXvN4F0sv4x?= =?us-ascii?Q?B3IZSTPijWqqxokb6S8IM5J9Dcg4H5J0DWHodB3/W1oFlN+cu26TXy016iiM?= =?us-ascii?Q?9s5YG7JxvriDIfEfuve9sH+mY9vjmcE1fZ7xhPbqnQ4qPYyANS/aFpscScOK?= =?us-ascii?Q?USsWTrRdNRq3UnbSWkPLEE3MsXOpzRaQuDhuXm4rrGRw6kvBEHJfK2muqLZf?= =?us-ascii?Q?SDPCgLl95Nc634zegFB5GSgSAe+zYwPE0tYUMW9tiS8WI8ncldUVqqECHjDO?= =?us-ascii?Q?o3yrCT8LqymRL2MmvNcHy82oGJZudFGMSB1SrB6w8h0uH1RJ4q+BWQ10AJTt?= =?us-ascii?Q?sY8irg+3D5JNuAQjMlRvXj8s3MPA/rRpGFLwmZSy2Q0DvXzz/GDnV17kozMH?= =?us-ascii?Q?7bC80Yla0Lq0btbZiR94a4tn8o/Po7KiLySBcAYZVNDjLkuUb/V9GsrV36Pm?= =?us-ascii?Q?U/Q37Oop1VagxeFdLB7jsLgIRbiX/uvX9+dVwof891OJe8hsnhB0HgrOV8YA?= =?us-ascii?Q?ieRj8tFDr1QoifhwzDBIUldZhc+g9TTPJ3QeDcRoyXMQsTui27Xukdmppbzn?= =?us-ascii?Q?9LkTnsT3nhPaDcYGewd6Xk8fy4bjFg8ue81Y3dLmVC5svXbvF9tQPePi8r8M?= =?us-ascii?Q?Re5sRJgOXw/dHY7ge4erBX0k609GPQiYxc5t/0OtQJS3aw0MPxOEOCbUnAsa?= =?us-ascii?Q?4D4pDRgq8FGVET5gKAwAwO9AudjQ2ja3KPGPUJfN4bv3zpz4mXH0osrjZKLz?= =?us-ascii?Q?RMyE8Pmk6+X6O+DJPR3sAvK8kF39BSdTBEISA41ffecO3dKZaOsJsKs6m+sB?= =?us-ascii?Q?NdvuPB2k58104qvfjBGRuDzjnNxVwo800pRghkLoKgTedYHgRaGRTZeNhGpW?= =?us-ascii?Q?MLn9rmjc2/PdQF8j2imdnYb55szkgI1d0teYntVPAF9/hX+rzD8T3QjYj4V0?= =?us-ascii?Q?k1DnVtv7n/ZlStD9wmVg8LHa+JIHdvdiMY2RjiRS6Ri0C1GQn9D0q+fda4MX?= =?us-ascii?Q?F5y7OdHIklNSILn4WKJzfn/XEilDrfhrZ3+waYIatHzTEqj1MzXHSEf3BibS?= =?us-ascii?Q?qOXjSwsSXVQaJ/ySg63GOAtMqSULaoCHbAwDNP2lxgsCJT4P3eJ7pN7Xm9Vh?= =?us-ascii?Q?dfWTxWe57rTjimi4J6NoK8dP7zAGDwZj6dqh5Nue6XpkPcq+1joO31kYoBb6?= =?us-ascii?Q?AlLEzp9r4eapR9j5r5r1PPWk1zjYCZCZAnN+GNOmch0RMBsCVqu9rG5hpXSa?= =?us-ascii?Q?iya8V1ipzPiE8hMENTLi988NiaedrLLKRB67mtGi/V09aKQHOyBoUQHWDyhY?= =?us-ascii?Q?nidwMIuUvKrDSsmyjCgumvMBHHfgDlI=3D?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 23c25bc8-a97a-4bb1-7f5b-08da49ea51d5 X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4343.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2022 07:33:17.1561 (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: igLBSBi71NhsVNfDXhGpjEhLo8DnHHM03EtZxvwv0IMv7inuuVFx3nDI1cfwfP57KD31LdFUCrhEjhx37HDKIg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8639 X-Proofpoint-ORIG-GUID: K9vbwjo7tXBeykz6lizvtVKQz9qLKN04 X-Proofpoint-GUID: K9vbwjo7tXBeykz6lizvtVKQz9qLKN04 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-09_07,2022-06-07_02,2022-02-23_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.151.68; envelope-from=het.gala@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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-Mailman-Approved-At: Thu, 09 Jun 2022 09:30:32 -0400 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @nutanix.com) X-ZM-MESSAGEID: 1654786201024100001 Content-Type: text/plain; charset="utf-8" i) Binding of the socket to source ip address and port on the non-default interface has been implemented for multi-FD connection, which was not necessary earlier because the binding was on the default interface itsel= f. ii) Created an end to end connection between all multi-FD source and destination pairs. Suggested-by: Manish Mishra Signed-off-by: Het Gala --- chardev/char-socket.c | 4 +- include/io/channel-socket.h | 26 ++++++----- include/qemu/sockets.h | 6 ++- io/channel-socket.c | 50 ++++++++++++++------ migration/socket.c | 15 +++--- nbd/client-connection.c | 2 +- qemu-nbd.c | 4 +- scsi/pr-manager-helper.c | 1 + tests/unit/test-char.c | 8 ++-- tests/unit/test-io-channel-socket.c | 4 +- tests/unit/test-util-sockets.c | 16 +++---- ui/input-barrier.c | 2 +- ui/vnc.c | 3 +- util/qemu-sockets.c | 71 ++++++++++++++++++++--------- 14 files changed, 135 insertions(+), 77 deletions(-) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index dc4e218eeb..f3725238c5 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -932,7 +932,7 @@ static int tcp_chr_connect_client_sync(Chardev *chr, Er= ror **errp) QIOChannelSocket *sioc =3D qio_channel_socket_new(); tcp_chr_change_state(s, TCP_CHARDEV_STATE_CONNECTING); tcp_chr_set_client_ioc_name(chr, sioc); - if (qio_channel_socket_connect_sync(sioc, s->addr, errp) < 0) { + if (qio_channel_socket_connect_sync(sioc, s->addr, NULL, errp) < 0) { tcp_chr_change_state(s, TCP_CHARDEV_STATE_DISCONNECTED); object_unref(OBJECT(sioc)); return -1; @@ -1120,7 +1120,7 @@ static void tcp_chr_connect_client_task(QIOTask *task, SocketAddress *addr =3D opaque; Error *err =3D NULL; =20 - qio_channel_socket_connect_sync(ioc, addr, &err); + qio_channel_socket_connect_sync(ioc, addr, NULL, &err); =20 qio_task_set_error(task, err); } diff --git a/include/io/channel-socket.h b/include/io/channel-socket.h index 513c428fe4..59d5b1b349 100644 --- a/include/io/channel-socket.h +++ b/include/io/channel-socket.h @@ -83,41 +83,45 @@ qio_channel_socket_new_fd(int fd, /** * qio_channel_socket_connect_sync: * @ioc: the socket channel object - * @addr: the address to connect to + * @dst_addr: the destination address to connect to + * @src_addr: the source address to be connected * @errp: pointer to a NULL-initialized error object * - * Attempt to connect to the address @addr. This method - * will run in the foreground so the caller will not regain - * execution control until the connection is established or + * Attempt to connect to the address @dst_addr with @src_addr. + * This method will run in the foreground so the caller will not + * regain execution control until the connection is established or * an error occurs. */ int qio_channel_socket_connect_sync(QIOChannelSocket *ioc, - SocketAddress *addr, + SocketAddress *dst_addr, + SocketAddress *src_addr, Error **errp); =20 /** * qio_channel_socket_connect_async: * @ioc: the socket channel object - * @addr: the address to connect to + * @dst_addr: the destination address to connect to * @callback: the function to invoke on completion * @opaque: user data to pass to @callback * @destroy: the function to free @opaque * @context: the context to run the async task. If %NULL, the default * context will be used. + * @src_addr: the source address to be connected * - * Attempt to connect to the address @addr. This method - * will run in the background so the caller will regain + * Attempt to connect to the address @dst_addr with the @src_addr. + * This method will run in the background so the caller will regain * execution control immediately. The function @callback - * will be invoked on completion or failure. The @addr + * will be invoked on completion or failure. The @dst_addr * parameter will be copied, so may be freed as soon * as this function returns without waiting for completion. */ void qio_channel_socket_connect_async(QIOChannelSocket *ioc, - SocketAddress *addr, + SocketAddress *dst_addr, QIOTaskFunc callback, gpointer opaque, GDestroyNotify destroy, - GMainContext *context); + GMainContext *context, + SocketAddress *src_addr); =20 =20 /** diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h index 038faa157f..dc863c3df8 100644 --- a/include/qemu/sockets.h +++ b/include/qemu/sockets.h @@ -33,7 +33,8 @@ int inet_ai_family_from_address(InetSocketAddress *addr, Error **errp); int inet_parse(InetSocketAddress *addr, const char *str, Error **errp); int inet_connect(const char *str, Error **errp); -int inet_connect_saddr(InetSocketAddress *saddr, Error **errp); +int inet_connect_saddr(InetSocketAddress *dst_addr, + InetSocketAddress *src_addr, Error **errp); =20 NetworkAddressFamily inet_netfamily(int family); =20 @@ -41,7 +42,8 @@ int unix_listen(const char *path, Error **errp); int unix_connect(const char *path, Error **errp); =20 SocketAddress *socket_parse(const char *str, Error **errp); -int socket_connect(SocketAddress *addr, Error **errp); +int socket_connect(SocketAddress *dst_addr, SocketAddress *src_addr, + Error **errp); int socket_listen(SocketAddress *addr, int num, Error **errp); void socket_listen_cleanup(int fd, Error **errp); int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp= ); diff --git a/io/channel-socket.c b/io/channel-socket.c index dc9c165de1..f8746ad646 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -36,6 +36,12 @@ =20 #define SOCKET_MAX_FDS 16 =20 +struct SrcDestAddress { + SocketAddress *dst_addr; + SocketAddress *src_addr; +}; + + SocketAddress * qio_channel_socket_get_local_address(QIOChannelSocket *ioc, Error **errp) @@ -145,13 +151,14 @@ qio_channel_socket_new_fd(int fd, =20 =20 int qio_channel_socket_connect_sync(QIOChannelSocket *ioc, - SocketAddress *addr, + SocketAddress *dst_addr, + SocketAddress *src_addr, Error **errp) { int fd; =20 - trace_qio_channel_socket_connect_sync(ioc, addr); - fd =3D socket_connect(addr, errp); + trace_qio_channel_socket_connect_sync(ioc, dst_addr); + fd =3D socket_connect(dst_addr, src_addr, errp); if (fd < 0) { trace_qio_channel_socket_connect_fail(ioc); return -1; @@ -177,39 +184,56 @@ int qio_channel_socket_connect_sync(QIOChannelSocket = *ioc, } =20 =20 +static void qio_channel_socket_worker_free(gpointer opaque) +{ + struct SrcDestAddress *data =3D opaque; + if (!data) { + return; + } + qapi_free_SocketAddress(data->dst_addr); + qapi_free_SocketAddress(data->src_addr); + g_free(data); +} + + static void qio_channel_socket_connect_worker(QIOTask *task, gpointer opaque) { QIOChannelSocket *ioc =3D QIO_CHANNEL_SOCKET(qio_task_get_source(task)= ); - SocketAddress *addr =3D opaque; + struct SrcDestAddress *data =3D opaque; Error *err =3D NULL; =20 - qio_channel_socket_connect_sync(ioc, addr, &err); + qio_channel_socket_connect_sync(ioc, data->dst_addr, data->src_addr, &= err); =20 qio_task_set_error(task, err); } =20 =20 void qio_channel_socket_connect_async(QIOChannelSocket *ioc, - SocketAddress *addr, + SocketAddress *dst_addr, QIOTaskFunc callback, gpointer opaque, GDestroyNotify destroy, - GMainContext *context) + GMainContext *context, + SocketAddress *src_addr) { QIOTask *task =3D qio_task_new( OBJECT(ioc), callback, opaque, destroy); - SocketAddress *addrCopy; - - addrCopy =3D QAPI_CLONE(SocketAddress, addr); + struct SrcDestAddress *data =3D g_new0(struct SrcDestAddress, 1); =20 + data->dst_addr =3D QAPI_CLONE(SocketAddress, dst_addr); + if (src_addr) { + data->src_addr =3D QAPI_CLONE(SocketAddress, src_addr); + } else { + data->src_addr =3D NULL; + } /* socket_connect() does a non-blocking connect(), but it * still blocks in DNS lookups, so we must use a thread */ - trace_qio_channel_socket_connect_async(ioc, addr); + trace_qio_channel_socket_connect_async(ioc, dst_addr); qio_task_run_in_thread(task, qio_channel_socket_connect_worker, - addrCopy, - (GDestroyNotify)qapi_free_SocketAddress, + data, + qio_channel_socket_worker_free, context); } =20 diff --git a/migration/socket.c b/migration/socket.c index 21e0983df2..d0cb7cc6a6 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -47,7 +47,7 @@ void socket_send_channel_create(QIOTaskFunc f, void *data) { QIOChannelSocket *sioc =3D qio_channel_socket_new(); qio_channel_socket_connect_async(sioc, outgoing_args.saddr, - f, data, NULL, NULL); + f, data, NULL, NULL, NULL); } =20 int socket_send_channel_destroy(QIOChannel *send) @@ -110,7 +110,7 @@ out: =20 static void socket_start_outgoing_migration_internal(MigrationState *s, - SocketAddress *saddr, + SocketAddress *dst_addr, Error **errp) { QIOChannelSocket *sioc =3D qio_channel_socket_new(); @@ -118,20 +118,17 @@ socket_start_outgoing_migration_internal(MigrationSta= te *s, =20 data->s =3D s; =20 - /* in case previous migration leaked it */ - qapi_free_SocketAddress(outgoing_args.saddr); - outgoing_args.saddr =3D saddr; - - if (saddr->type =3D=3D SOCKET_ADDRESS_TYPE_INET) { - data->hostname =3D g_strdup(saddr->u.inet.host); + if (dst_addr->type =3D=3D SOCKET_ADDRESS_TYPE_INET) { + data->hostname =3D g_strdup(dst_addr->u.inet.host); } =20 qio_channel_set_name(QIO_CHANNEL(sioc), "migration-socket-outgoing"); qio_channel_socket_connect_async(sioc, - saddr, + dst_addr, socket_outgoing_migration, data, socket_connect_data_free, + NULL, NULL); } =20 diff --git a/nbd/client-connection.c b/nbd/client-connection.c index 2a632931c3..4bc505d26e 100644 --- a/nbd/client-connection.c +++ b/nbd/client-connection.c @@ -133,7 +133,7 @@ static int nbd_connect(QIOChannelSocket *sioc, SocketAd= dress *addr, *outioc =3D NULL; } =20 - ret =3D qio_channel_socket_connect_sync(sioc, addr, errp); + ret =3D qio_channel_socket_connect_sync(sioc, addr, NULL, errp); if (ret < 0) { return ret; } diff --git a/qemu-nbd.c b/qemu-nbd.c index 0cd5aa6f02..fe178f271e 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -191,7 +191,7 @@ static int qemu_nbd_client_list(SocketAddress *saddr, Q= CryptoTLSCreds *tls, int i, j; =20 sioc =3D qio_channel_socket_new(); - if (qio_channel_socket_connect_sync(sioc, saddr, &err) < 0) { + if (qio_channel_socket_connect_sync(sioc, saddr, NULL, &err) < 0) { error_report_err(err); goto out; } @@ -284,7 +284,7 @@ static void *nbd_client_thread(void *arg) =20 sioc =3D qio_channel_socket_new(); if (qio_channel_socket_connect_sync(sioc, - saddr, + saddr, NULL, &local_error) < 0) { error_report_err(local_error); goto out; diff --git a/scsi/pr-manager-helper.c b/scsi/pr-manager-helper.c index 3be52a98d5..6e3e00eadf 100644 --- a/scsi/pr-manager-helper.c +++ b/scsi/pr-manager-helper.c @@ -114,6 +114,7 @@ static int pr_manager_helper_initialize(PRManagerHelper= *pr_mgr, qio_channel_set_name(QIO_CHANNEL(sioc), "pr-manager-helper"); qio_channel_socket_connect_sync(sioc, &saddr, + NULL, &local_err); g_free(path); if (local_err) { diff --git a/tests/unit/test-char.c b/tests/unit/test-char.c index 5b3b48ebac..fd5f281777 100644 --- a/tests/unit/test-char.c +++ b/tests/unit/test-char.c @@ -691,7 +691,7 @@ char_socket_addr_to_opt_str(SocketAddress *addr, bool f= d_pass, if (is_listen) { qio_channel_socket_listen_sync(ioc, addr, 1, &error_abort); } else { - qio_channel_socket_connect_sync(ioc, addr, &error_abort); + qio_channel_socket_connect_sync(ioc, addr, NULL, &error_abort); } fd =3D ioc->fd; ioc->fd =3D -1; @@ -748,7 +748,7 @@ char_socket_server_client_thread(gpointer data) SocketAddress *addr =3D data; QIOChannelSocket *ioc =3D qio_channel_socket_new(); =20 - qio_channel_socket_connect_sync(ioc, addr, &error_abort); + qio_channel_socket_connect_sync(ioc, addr, NULL, &error_abort); =20 char_socket_ping_pong(QIO_CHANNEL(ioc), &error_abort); =20 @@ -1147,7 +1147,7 @@ static void char_socket_server_two_clients_test(gcons= tpointer opaque) &closed, NULL, true); =20 ioc1 =3D qio_channel_socket_new(); - qio_channel_socket_connect_sync(ioc1, addr, &error_abort); + qio_channel_socket_connect_sync(ioc1, addr, NULL, &error_abort); qemu_chr_wait_connected(chr, &error_abort); =20 /* switch the chardev to another context */ @@ -1161,7 +1161,7 @@ static void char_socket_server_two_clients_test(gcons= tpointer opaque) * succeed immediately. */ ioc2 =3D qio_channel_socket_new(); - qio_channel_socket_connect_sync(ioc2, addr, &error_abort); + qio_channel_socket_connect_sync(ioc2, addr, NULL, &error_abort); =20 object_unref(OBJECT(ioc1)); /* The two connections should now be processed serially. */ diff --git a/tests/unit/test-io-channel-socket.c b/tests/unit/test-io-chann= el-socket.c index 6713886d02..bc33ce6956 100644 --- a/tests/unit/test-io-channel-socket.c +++ b/tests/unit/test-io-channel-socket.c @@ -72,7 +72,7 @@ static void test_io_channel_setup_sync(SocketAddress *lis= ten_addr, =20 *src =3D QIO_CHANNEL(qio_channel_socket_new()); qio_channel_socket_connect_sync( - QIO_CHANNEL_SOCKET(*src), connect_addr, &error_abort); + QIO_CHANNEL_SOCKET(*src), connect_addr, NULL, &error_abort); qio_channel_set_delay(*src, false); =20 qio_channel_wait(QIO_CHANNEL(lioc), G_IO_IN); @@ -136,7 +136,7 @@ static void test_io_channel_setup_async(SocketAddress *= listen_addr, =20 qio_channel_socket_connect_async( QIO_CHANNEL_SOCKET(*src), connect_addr, - test_io_channel_complete, &data, NULL, NULL); + test_io_channel_complete, &data, NULL, NULL, NULL); =20 g_main_loop_run(data.loop); g_main_context_iteration(g_main_context_default(), FALSE); diff --git a/tests/unit/test-util-sockets.c b/tests/unit/test-util-sockets.c index 63909ccb2b..aa26630045 100644 --- a/tests/unit/test-util-sockets.c +++ b/tests/unit/test-util-sockets.c @@ -89,7 +89,7 @@ static void test_socket_fd_pass_name_good(void) addr.type =3D SOCKET_ADDRESS_TYPE_FD; addr.u.fd.str =3D g_strdup(mon_fdname); =20 - fd =3D socket_connect(&addr, &error_abort); + fd =3D socket_connect(&addr, NULL, &error_abort); g_assert_cmpint(fd, !=3D, -1); g_assert_cmpint(fd, !=3D, mon_fd); close(fd); @@ -121,7 +121,7 @@ static void test_socket_fd_pass_name_bad(void) addr.type =3D SOCKET_ADDRESS_TYPE_FD; addr.u.fd.str =3D g_strdup(mon_fdname); =20 - fd =3D socket_connect(&addr, &err); + fd =3D socket_connect(&addr, NULL, &err); g_assert_cmpint(fd, =3D=3D, -1); error_free_or_abort(&err); =20 @@ -148,7 +148,7 @@ static void test_socket_fd_pass_name_nomon(void) addr.type =3D SOCKET_ADDRESS_TYPE_FD; addr.u.fd.str =3D g_strdup("myfd"); =20 - fd =3D socket_connect(&addr, &err); + fd =3D socket_connect(&addr, NULL, &err); g_assert_cmpint(fd, =3D=3D, -1); error_free_or_abort(&err); =20 @@ -172,7 +172,7 @@ static void test_socket_fd_pass_num_good(void) addr.type =3D SOCKET_ADDRESS_TYPE_FD; addr.u.fd.str =3D g_strdup_printf("%d", sfd); =20 - fd =3D socket_connect(&addr, &error_abort); + fd =3D socket_connect(&addr, NULL, &error_abort); g_assert_cmpint(fd, =3D=3D, sfd); =20 fd =3D socket_listen(&addr, 1, &error_abort); @@ -194,7 +194,7 @@ static void test_socket_fd_pass_num_bad(void) addr.type =3D SOCKET_ADDRESS_TYPE_FD; addr.u.fd.str =3D g_strdup_printf("%d", sfd); =20 - fd =3D socket_connect(&addr, &err); + fd =3D socket_connect(&addr, NULL, &err); g_assert_cmpint(fd, =3D=3D, -1); error_free_or_abort(&err); =20 @@ -217,7 +217,7 @@ static void test_socket_fd_pass_num_nocli(void) addr.type =3D SOCKET_ADDRESS_TYPE_FD; addr.u.fd.str =3D g_strdup_printf("%d", STDOUT_FILENO); =20 - fd =3D socket_connect(&addr, &err); + fd =3D socket_connect(&addr, NULL, &err); g_assert_cmpint(fd, =3D=3D, -1); error_free_or_abort(&err); =20 @@ -246,10 +246,10 @@ static gpointer unix_client_thread_func(gpointer user= _data) =20 for (i =3D 0; i < ABSTRACT_SOCKET_VARIANTS; i++) { if (row->expect_connect[i]) { - fd =3D socket_connect(row->client[i], &error_abort); + fd =3D socket_connect(row->client[i], NULL, &error_abort); g_assert_cmpint(fd, >=3D, 0); } else { - fd =3D socket_connect(row->client[i], &err); + fd =3D socket_connect(row->client[i], NULL, &err); g_assert_cmpint(fd, =3D=3D, -1); error_free_or_abort(&err); } diff --git a/ui/input-barrier.c b/ui/input-barrier.c index 2d57ca7079..ee78654e3b 100644 --- a/ui/input-barrier.c +++ b/ui/input-barrier.c @@ -506,7 +506,7 @@ static void input_barrier_complete(UserCreatable *uc, E= rror **errp) ib->sioc =3D qio_channel_socket_new(); qio_channel_set_name(QIO_CHANNEL(ib->sioc), "barrier-client"); =20 - qio_channel_socket_connect_sync(ib->sioc, &ib->saddr, &local_err); + qio_channel_socket_connect_sync(ib->sioc, &ib->saddr, NULL, &local_err= ); if (local_err) { error_propagate(errp, local_err); return; diff --git a/ui/vnc.c b/ui/vnc.c index 6a05d06147..c3dd84026a 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3931,7 +3931,8 @@ static int vnc_display_connect(VncDisplay *vd, vd->is_unix =3D saddr_list->value->type =3D=3D SOCKET_ADDRESS_TYPE_UNI= X; sioc =3D qio_channel_socket_new(); qio_channel_set_name(QIO_CHANNEL(sioc), "vnc-reverse"); - if (qio_channel_socket_connect_sync(sioc, saddr_list->value, errp) < 0= ) { + if (qio_channel_socket_connect_sync(sioc, saddr_list->value, + NULL, errp) < 0) { object_unref(OBJECT(sioc)); return -1; } diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 13b5b197f9..bbe0dc0ee0 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -226,7 +226,7 @@ static int inet_listen_saddr(InetSocketAddress *saddr, return -1; } =20 - memset(&ai,0, sizeof(ai)); + memset(&ai,0,sizeof(ai)); ai.ai_flags =3D AI_PASSIVE; if (saddr->has_numeric && saddr->numeric) { ai.ai_flags |=3D AI_NUMERICHOST | AI_NUMERICSERV; @@ -282,8 +282,8 @@ static int inet_listen_saddr(InetSocketAddress *saddr, e->ai_protocol =3D IPPROTO_MPTCP; } #endif - getnameinfo((struct sockaddr*)e->ai_addr,e->ai_addrlen, - uaddr,INET6_ADDRSTRLEN,uport,32, + getnameinfo((struct sockaddr *)e->ai_addr, e->ai_addrlen, + uaddr, INET6_ADDRSTRLEN, uport, 32, NI_NUMERICHOST | NI_NUMERICSERV); =20 port_min =3D inet_getport(e); @@ -358,7 +358,8 @@ listen_ok: ((rc) =3D=3D -EINPROGRESS) #endif =20 -static int inet_connect_addr(const InetSocketAddress *saddr, +static int inet_connect_addr(const InetSocketAddress *dst_addr, + const InetSocketAddress *src_addr, struct addrinfo *addr, Error **errp) { int sock, rc; @@ -371,8 +372,28 @@ static int inet_connect_addr(const InetSocketAddress *= saddr, } socket_set_fast_reuse(sock); =20 + /* to bind the socket if src_addr is available */ + + if (src_addr) { + struct sockaddr_in servaddr; + + /* bind to a specific interface in the internet domain */ + /* to make sure the sin_zero filed is cleared */ + memset(&servaddr, 0, sizeof(servaddr)); + + servaddr.sin_family =3D AF_INET; + servaddr.sin_addr.s_addr =3D inet_addr(src_addr->host); + servaddr.sin_port =3D 0; + + if (bind(sock, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0= ) { + error_setg_errno(errp, errno, "Failed to bind socket"); + return -1; + } + } + /* connect to peer */ do { + rc =3D 0; if (connect(sock, addr->ai_addr, addr->ai_addrlen) < 0) { rc =3D -errno; @@ -380,8 +401,14 @@ static int inet_connect_addr(const InetSocketAddress *= saddr, } while (rc =3D=3D -EINTR); =20 if (rc < 0) { - error_setg_errno(errp, errno, "Failed to connect to '%s:%s'", - saddr->host, saddr->port); + if (src_addr) { + error_setg_errno(errp, errno, "Failed to connect '%s:%s' to " + "'%s:%s'", dst_addr->host, dst_addr->port, + src_addr->host, src_addr->port); + } else { + error_setg_errno(errp, errno, "Failed to connect '%s:%s'", + dst_addr->host, dst_addr->port); + } closesocket(sock); return -1; } @@ -446,13 +473,14 @@ static struct addrinfo *inet_parse_connect_saddr(Inet= SocketAddress *saddr, * * Returns: -1 on error, file descriptor on success. */ -int inet_connect_saddr(InetSocketAddress *saddr, Error **errp) +int inet_connect_saddr(InetSocketAddress *dst_addr, + InetSocketAddress *src_addr, Error **errp) { Error *local_err =3D NULL; struct addrinfo *res, *e; int sock =3D -1; =20 - res =3D inet_parse_connect_saddr(saddr, errp); + res =3D inet_parse_connect_saddr(dst_addr, errp); if (!res) { return -1; } @@ -462,12 +490,12 @@ int inet_connect_saddr(InetSocketAddress *saddr, Erro= r **errp) local_err =3D NULL; =20 #ifdef HAVE_IPPROTO_MPTCP - if (saddr->has_mptcp && saddr->mptcp) { + if (dst_addr->has_mptcp && dst_addr->mptcp) { e->ai_protocol =3D IPPROTO_MPTCP; } #endif =20 - sock =3D inet_connect_addr(saddr, e, &local_err); + sock =3D inet_connect_addr(dst_addr, src_addr, e, &local_err); if (sock >=3D 0) { break; } @@ -480,7 +508,7 @@ int inet_connect_saddr(InetSocketAddress *saddr, Error = **errp) return sock; } =20 - if (saddr->keep_alive) { + if (dst_addr->keep_alive) { int val =3D 1; int ret =3D setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val)); @@ -506,7 +534,7 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr, Error *err =3D NULL; =20 /* lookup peer addr */ - memset(&ai,0, sizeof(ai)); + memset(&ai, 0, sizeof(ai)); ai.ai_flags =3D AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG; ai.ai_family =3D inet_ai_family_from_address(sraddr, &err); ai.ai_socktype =3D SOCK_DGRAM; @@ -533,7 +561,7 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr, } =20 /* lookup local addr */ - memset(&ai,0, sizeof(ai)); + memset(&ai, 0, sizeof(ai)); ai.ai_flags =3D AI_PASSIVE; ai.ai_family =3D peer->ai_family; ai.ai_socktype =3D SOCK_DGRAM; @@ -574,7 +602,7 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr, } =20 /* connect to peer */ - if (connect(sock,peer->ai_addr,peer->ai_addrlen) < 0) { + if (connect(sock, peer->ai_addr, peer->ai_addrlen) < 0) { error_setg_errno(errp, errno, "Failed to connect to '%s:%s'", addr, port); goto err; @@ -727,7 +755,7 @@ int inet_connect(const char *str, Error **errp) InetSocketAddress *addr =3D g_new(InetSocketAddress, 1); =20 if (!inet_parse(addr, str, errp)) { - sock =3D inet_connect_saddr(addr, errp); + sock =3D inet_connect_saddr(addr, NULL, errp); } qapi_free_InetSocketAddress(addr); return sock; @@ -1182,25 +1210,26 @@ int socket_address_parse_named_fd(SocketAddress *ad= dr, Error **errp) return 0; } =20 -int socket_connect(SocketAddress *addr, Error **errp) +int socket_connect(SocketAddress *dst_addr, SocketAddress *src_addr, Error= **errp) { int fd; =20 - switch (addr->type) { + switch (dst_addr->type) { case SOCKET_ADDRESS_TYPE_INET: - fd =3D inet_connect_saddr(&addr->u.inet, errp); + fd =3D inet_connect_saddr(&dst_addr->u.inet, src_addr ? + &src_addr->u.inet : NULL, errp); break; =20 case SOCKET_ADDRESS_TYPE_UNIX: - fd =3D unix_connect_saddr(&addr->u.q_unix, errp); + fd =3D unix_connect_saddr(&dst_addr->u.q_unix, errp); break; =20 case SOCKET_ADDRESS_TYPE_FD: - fd =3D socket_get_fd(addr->u.fd.str, errp); + fd =3D socket_get_fd(dst_addr->u.fd.str, errp); break; =20 case SOCKET_ADDRESS_TYPE_VSOCK: - fd =3D vsock_connect_saddr(&addr->u.vsock, errp); + fd =3D vsock_connect_saddr(&dst_addr->u.vsock, errp); break; =20 default: --=20 2.22.3 From nobody Mon Feb 9 17:41:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1654785822; cv=pass; d=zohomail.com; s=zohoarc; b=oH8QkUmDQ727VnG7WdsqRbZNrWG7ZbHhy/ZHkxMBH+XrGCbQ5Sa0jrsENL3Yqo0sqNQrJ0ws0lh9Vp/WLBIApd1SZ5UIyP+W2YcQ7kbeD+Bs65ec08RBc9DQ41ljXRoFfokcl5xiATj8fCa5mGHSUWF18E0wn5tYPO4JOOMbGmM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654785822; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SgdqbDOFodEcUcSC6wl/6KpFmB82pJiFuaR/ner+dVA=; b=nAPC76BXolUXrbqxgQOkFlJuZN0GyQN6emGzOiLCqtkct2rlQlqziGHtGNrbp1mm8E5rNaA5QR/uq3/TNKu3ZUJ1kHkfCplacbp4yOWCTdpcUSO3IIKLwLg0YTaJ3/SEI6YUHBogjN63IcmG6X/qWj/TdcOiGNM4XMmP4Zu21fc= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1654785822824224.01455209906112; Thu, 9 Jun 2022 07:43:42 -0700 (PDT) Received: from localhost ([::1]:54848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzJNt-000139-Ex for importer@patchew.org; Thu, 09 Jun 2022 10:43:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzCfW-0002B2-Cf for qemu-devel@nongnu.org; Thu, 09 Jun 2022 03:33:29 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]:41250) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzCfT-0007w0-2Q for qemu-devel@nongnu.org; Thu, 09 Jun 2022 03:33:26 -0400 Received: from pps.filterd (m0127839.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25964FQm010057; Thu, 9 Jun 2022 00:33:21 -0700 Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 3gg6fha4e9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 09 Jun 2022 00:33:21 -0700 Received: from BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) by SA1PR02MB8639.namprd02.prod.outlook.com (2603:10b6:806:1fe::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13; Thu, 9 Jun 2022 07:33:19 +0000 Received: from BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f]) by BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f%5]) with mapi id 15.20.5314.019; Thu, 9 Jun 2022 07:33:19 +0000 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=SgdqbDOFodEcUcSC6wl/6KpFmB82pJiFuaR/ner+dVA=; b=0NKMZzVEwVoovhz04IgxQTKP1ZtwYqSPAGQpXnv2xradF6nIw6WtsrNxn+hituxfB+k/ bi7s4B+K3GANYFkr98vC40RcfTQ2vreKSzZOkA1Z9aMu1BZ44/dkk8/k/Yq225ga8aGR M5ZiXVNQNoFzgAe3jGCz/0RCsVgUzDBezxvzn6b99DaDq1yLOBdLAHFZHD6dVG318vNi a1XfCls7AXfnThFlYcmH4SK0h0qaDPjiTyHJqWEihz0w123dbM90HZp+zjmDhg+XvYQ4 3dB8Vu24bWMt6uJXGnjW4QdqtcT4XfBwsjcjr5j/W1dmLBz29phUV3EoAhfyVP0QQ5B4 cg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZZR3dxSd4BaVwHapyfpn7j00bBED9b1WXU2qXWnauH46aqzq0L198PLfzIjUBTNvLWRI4YipAiuKdAAC3s5QdAWL2L1Pm2LcT/Yamm3mxzCp+HNIdH5pyatFvcl52tgSDDc+qbPOYWiLuFc+VszwCtWvdaGYg0j7HSoighS4PPP/gl9df6QnwWfmah1UwgcAQJtwLTj0nSMQShOOBAhGDhRiVrheuAAmUaQ1vSN415FlUUcwRvkB8bAoMHyuCrjIVndFnA9lmLA/PJ0y2CCc2CYt/Gpg9f4sefoTTgBEE1tpGFDWAWt7q003wo5vS/eyxsYtJi8oCftpQUY4HBsVPg== 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=SgdqbDOFodEcUcSC6wl/6KpFmB82pJiFuaR/ner+dVA=; b=U8LQrjoDlr8DHaAwpcdAgYmcSVTwZnZxxQbZTE4bdrlQAhWKVn2HzNlCNCjnwBlge0/5mlUmE/V5IzhVA8stOKyzuLoLfljY0KZE5JkqsX+8JnwkgX/9eXUdkxLQZBQV4IxQuZgEOy05BsWgkJy1Fl/yOASSvRzRuJZLcl2fCFJRu5sAG48rnoeVNvRMqjCBxM8cA33WGCF0Tja8HQMU5KjQ10ysxGDlZfJjOsMabK8A4FAVGpGwJCOWC+bbrOFoGt47sws215VHgC72YHlrbgI4YEGHHn1UpI/sMAehwscCfjSWij2fQAi1DWVVMo2sQrHqKkz9U8qbwGfuvS4kiA== 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 From: Het Gala To: qemu-devel@nongnu.org Cc: quintela@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, berrange@redhat.com, armbru@redhat.com, eblake@redhat.com, Het Gala , Manish Mishra Subject: [PATCH 4/4] Adding support for multi-FD connections dynamically Date: Thu, 9 Jun 2022 07:33:05 +0000 Message-Id: <20220609073305.142515-5-het.gala@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20220609073305.142515-1-het.gala@nutanix.com> References: <20220609073305.142515-1-het.gala@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BY5PR04CA0002.namprd04.prod.outlook.com (2603:10b6:a03:1d0::12) To BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b6926655-3f7a-47f2-f45f-08da49ea5314 X-MS-TrafficTypeDiagnostic: SA1PR02MB8639:EE_ X-Microsoft-Antispam-PRVS: 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: N91vxyOOtQHcrwjy0nhoPyxrQlGap2/f3cEz18O2hKLrGF5A1epA9+U4w3ihYkuFnR+geEUpyEK4tR7PNMrlAJ7S38gfkt4YqHaRITy7bjEkLA+L6X3xLYJj2lchsJnF+xHw1bCsigaYBllwRH0blsKwA4AyITtZlyg2iGw/rQqWoRWsEUGFOmu1/YCT33sR3/45qo9EFk8vXwGPeRzzaMGUZ6RKrxtBKO5jYKN8O3/hRFS8A7LtCEAWCLaNcim0mr+U0qpDJQE4eRmbmzdjedcY0su6uNWaaNS8f55XFVdDQKpLW4qbhYZiZ749CywBkopqQ5xa4t3o6YElqJeTQPk3uBLJKe6fsitJlzZ1DLvsa+HWdeJKTaety7HsQyA8Qs27czQ7PN7oDxwmyb4L1dyTqZxUs3FEEemrqRFiBSJS+3KMppgZpr1HPUMVD0E6cg5SikWXil8lnJ8INRShqW8rokCZfIkP/KRef/PGb3OoBYbHexi5Wd+YA1Dh055PF4TGeZGHJNDzM++JidZldmTg7BMsJhiNFZ6VNhsi5rPrjifhd/uY/M8FyfKDWV68cyOdFU5afi0n5bxzztcWlXCIKc+O6q6wrFcNaLJhtt2d9M+07nu5HzXbrRUhyPkpZfZPow9xiEx417WxsEOc2oMhwJ7OH6NXN+kJbPJusEP9nsSvmDOmaMrJUHC3dK3+S34E0Oci76XUGp4fqVkGiA== 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:(13230001)(366004)(508600001)(107886003)(6666004)(1076003)(2906002)(8936002)(52116002)(54906003)(86362001)(6506007)(186003)(5660300002)(30864003)(83380400001)(6486002)(44832011)(38350700002)(26005)(38100700002)(36756003)(6512007)(2616005)(316002)(66556008)(66946007)(4326008)(6916009)(8676002)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?VSX/weg3BjGVSummcLW/MkhLvE4w5lzTRp0Dl6woGO5XrM7kddnCu+xxlQL/?= =?us-ascii?Q?U582LEcR6G3biMxjGtvipv5kvZDKANkBDorLDAdpPEE4gEIFk2GY40z4aCvd?= =?us-ascii?Q?/GQM56B2xyh/VWwhQ32FmY4FiulQdCiIVtyzaZj6ftRbmEm8ugssYMwlhXkD?= =?us-ascii?Q?Zhsnt2kywb07oEW7/vlZBFmv7r+J+oGVhQnu4wdu4j9nZyNcUhMt/k/Jg2CF?= =?us-ascii?Q?mF+fxnTzApUDHy7bM1SsV0xJfw+FLWtMv863Tsb5bfUkNem7ruS87jGtKYOU?= =?us-ascii?Q?hzHdvoeK3XYgMejw+et+Qux5Xts0fmw63tQH7qGuW5W4XcE3uBSPwHgdTgLG?= =?us-ascii?Q?T87S6AmSmOOwKhDVkNPuf0x+5z0MOuzX15jIQIGg1rEFMxcpPt2P4gmIUxGL?= =?us-ascii?Q?ds+HSTCONM03qSoKk3qHpnhRlxOy559Z4BSy8t3wG//F2Mr2bR8YjvlU0iVC?= =?us-ascii?Q?IQBiWmya2pOvYNy2zu17k/UTCvHUr8VRjQX00RV1IDgraJtpO/TuJZfiFqog?= =?us-ascii?Q?+GYA9PRcdWXcooeViU9B0Nyp783MfOjZJ+GQs4homuhAzzkCo9oe/N74n2As?= =?us-ascii?Q?KPN3O7pHdroze3JV5Lq4CFZAUCjgIk7ph3RYyQoTIzXhxxOvT1uMB3Qw9xu6?= =?us-ascii?Q?zu3NtZ2oJAcTAYrCirrRfdJQQUnqSTKjnmk4gQAQKl4TmAnnxm9kdWf1LPDX?= =?us-ascii?Q?l5QsdGmr6aFYZwpCqbnwXbSHbqqCMdfSv1qaUK/VjNbdWQD2hpOPDwUQMq6o?= =?us-ascii?Q?98fLQM5fRPv9cHRXTDSKolJ2f9hX52ZL1iQObchvEi8gahU8EcCVUieT0VCJ?= =?us-ascii?Q?+gkDYDppjlg2lhiwtlyGv6SuieQ22R+FEOKf9F2J9Ztgb90bbROkewq8SKzM?= =?us-ascii?Q?JAZ536IHIu0JHS1RbUQE/A67rwJdj0ppeBO3i6tSiS2vU4pvMKtphZXjiCax?= =?us-ascii?Q?hPNy2Y+xF6rS4jPe8iNw2fKkqaf4K8ec6NtelakFD5g4Atf9RlL6vgMMA5Lq?= =?us-ascii?Q?Epy9v+uI3fRjCn+7NMovXvjjGkz8RbDZ93BSjKhXDwMVFtCR5dqTxIonye2a?= =?us-ascii?Q?eR0f6RQ2RKcbxPpUaPVEfOOO7dLkcCLV/FjulXFTnCEgY9fToioVZzWM+Nhv?= =?us-ascii?Q?pJlN7jOz03PMbC/TntFp4S7D+fmr556DRvzSCG4ncaY76t57RAh7uIenkB4m?= =?us-ascii?Q?NKIx+QxgGr6pmcqgD97ItEm9jWxCrvfxMe+U5NoC5j3NxBwQo32ZcdAHLZIA?= =?us-ascii?Q?sWZq2/ObNNV/MHSTEg/UJwYVmAMECjZDFbhGiH243KLgWiaI3dMhxJeP7OF9?= =?us-ascii?Q?5/w5f2tcs8Unwjlf266yT1qKb0OglysMaKXG+CWul4G22U59cdCu5bFgcW/o?= =?us-ascii?Q?zJsVwdczLJYEcKrpSowB8hsdFsz+xIbiwo61Hs7mH+3vrapSKFxgG2xKw/dv?= =?us-ascii?Q?IIrq0KmvE+oV7trYI05Xk61/++NnmsKAYAseZ2Elx27aKcIY987HjAtHOMVp?= =?us-ascii?Q?eCwtM58vJSZ0Qarf3BqBBulMhr4N52jGkBRZZPKzFabA7gEuA5deDoj5v9Hs?= =?us-ascii?Q?zzyuJAdHj1PAGTGikr5/IExcZVLiWsC8bwmyzUazrpY9n6KnW2aHOLmOGZ9q?= =?us-ascii?Q?2MSxyW+uFPFa4ZLFplkBifu2SNTVxKDM+Hsuv2YhyxAboCSP1KiU32VmlDHZ?= =?us-ascii?Q?Dv+Nn+g9dA9AIswvvHvKXYYPIqhFZCGBMk9m2i0O36ZkiOjDECJlXkJngCmV?= =?us-ascii?Q?kOM1XCzxE/M1BIhyZpmotXJIJ/6sUGs=3D?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6926655-3f7a-47f2-f45f-08da49ea5314 X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4343.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2022 07:33:19.2184 (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: KtmlNjGJAQcQKoXd8EDeEB1lLg8xnm/m5ND9b51IGxS91n/3Nu5xNXWQtf2jMQigMofGvZ7obcmHAAwXXB1WOA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8639 X-Proofpoint-GUID: 6qw_rsmNpvt1WQZskN3ck8W62N9QxCCX X-Proofpoint-ORIG-GUID: 6qw_rsmNpvt1WQZskN3ck8W62N9QxCCX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-09_07,2022-06-07_02,2022-02-23_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.151.68; envelope-from=het.gala@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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-Mailman-Approved-At: Thu, 09 Jun 2022 09:30:28 -0400 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @nutanix.com) X-ZM-MESSAGEID: 1654785825036100001 Content-Type: text/plain; charset="utf-8" i) Dynamically decide appropriate source and destination ip pairs for the corresponding multi-FD channel to be connected. ii) Removed the support for setting the number of multi-fd channels from qmp commands. As now all multiFD parameters will be passed via qmp: migrate command or incoming flag itself. Suggested-by: Manish Mishra Signed-off-by: Het Gala --- migration/migration.c | 15 --------------- migration/migration.h | 1 - migration/multifd.c | 42 +++++++++++++++++++++--------------------- migration/socket.c | 42 +++++++++++++++++++++++++++++++++--------- migration/socket.h | 4 +++- monitor/hmp-cmds.c | 4 ---- qapi/migration.json | 6 ------ 7 files changed, 57 insertions(+), 57 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 9b0ad732e7..57dd4494b4 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1585,9 +1585,6 @@ static void migrate_params_test_apply(MigrateSetParam= eters *params, if (params->has_block_incremental) { dest->block_incremental =3D params->block_incremental; } - if (params->has_multifd_channels) { - dest->multifd_channels =3D params->multifd_channels; - } if (params->has_multifd_compression) { dest->multifd_compression =3D params->multifd_compression; } @@ -1702,9 +1699,6 @@ static void migrate_params_apply(MigrateSetParameters= *params, Error **errp) if (params->has_block_incremental) { s->parameters.block_incremental =3D params->block_incremental; } - if (params->has_multifd_channels) { - s->parameters.multifd_channels =3D params->multifd_channels; - } if (params->has_multifd_compression) { s->parameters.multifd_compression =3D params->multifd_compression; } @@ -2686,15 +2680,6 @@ bool migrate_pause_before_switchover(void) MIGRATION_CAPABILITY_PAUSE_BEFORE_SWITCHOVER]; } =20 -int migrate_multifd_channels(void) -{ - MigrationState *s; - - s =3D migrate_get_current(); - - return s->parameters.multifd_channels; -} - MultiFDCompression migrate_multifd_compression(void) { MigrationState *s; diff --git a/migration/migration.h b/migration/migration.h index fa8717ec9e..9464de8ef7 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -372,7 +372,6 @@ bool migrate_validate_uuid(void); bool migrate_auto_converge(void); bool migrate_use_multifd(void); bool migrate_pause_before_switchover(void); -int migrate_multifd_channels(void); MultiFDCompression migrate_multifd_compression(void); int migrate_multifd_zlib_level(void); int migrate_multifd_zstd_level(void); diff --git a/migration/multifd.c b/migration/multifd.c index 9282ab6aa4..ce017436fb 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -225,7 +225,7 @@ static int multifd_recv_initial_packet(QIOChannel *c, E= rror **errp) return -1; } =20 - if (msg.id > migrate_multifd_channels()) { + if (msg.id > total_multifd_channels()) { error_setg(errp, "multifd: received channel version %u " "expected %u", msg.version, MULTIFD_VERSION); return -1; @@ -410,8 +410,8 @@ static int multifd_send_pages(QEMUFile *f) * using more channels, so ensure it doesn't overflow if the * limit is lower now. */ - next_channel %=3D migrate_multifd_channels(); - for (i =3D next_channel;; i =3D (i + 1) % migrate_multifd_channels()) { + next_channel %=3D total_multifd_channels(); + for (i =3D next_channel;; i =3D (i + 1) % total_multifd_channels()) { p =3D &multifd_send_state->params[i]; =20 qemu_mutex_lock(&p->mutex); @@ -422,7 +422,7 @@ static int multifd_send_pages(QEMUFile *f) } if (!p->pending_job) { p->pending_job++; - next_channel =3D (i + 1) % migrate_multifd_channels(); + next_channel =3D (i + 1) % total_multifd_channels(); break; } qemu_mutex_unlock(&p->mutex); @@ -500,7 +500,7 @@ static void multifd_send_terminate_threads(Error *err) return; } =20 - for (i =3D 0; i < migrate_multifd_channels(); i++) { + for (i =3D 0; i < total_multifd_channels(); i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; =20 qemu_mutex_lock(&p->mutex); @@ -521,14 +521,14 @@ void multifd_save_cleanup(void) return; } multifd_send_terminate_threads(NULL); - for (i =3D 0; i < migrate_multifd_channels(); i++) { + for (i =3D 0; i < total_multifd_channels(); i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; =20 if (p->running) { qemu_thread_join(&p->thread); } } - for (i =3D 0; i < migrate_multifd_channels(); i++) { + for (i =3D 0; i < total_multifd_channels(); i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; Error *local_err =3D NULL; =20 @@ -594,7 +594,7 @@ int multifd_send_sync_main(QEMUFile *f) =20 flush_zero_copy =3D migrate_use_zero_copy_send(); =20 - for (i =3D 0; i < migrate_multifd_channels(); i++) { + for (i =3D 0; i < total_multifd_channels(); i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; =20 trace_multifd_send_sync_main_signal(p->id); @@ -627,7 +627,7 @@ int multifd_send_sync_main(QEMUFile *f) } } } - for (i =3D 0; i < migrate_multifd_channels(); i++) { + for (i =3D 0; i < total_multifd_channels(); i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; =20 trace_multifd_send_sync_main_wait(p->id); @@ -903,7 +903,7 @@ int multifd_save_setup(Error **errp) int thread_count; uint32_t page_count =3D MULTIFD_PACKET_SIZE / qemu_target_page_size(); uint8_t i; - + int idx; if (!migrate_use_multifd()) { return 0; } @@ -912,7 +912,7 @@ int multifd_save_setup(Error **errp) return -1; } =20 - thread_count =3D migrate_multifd_channels(); + thread_count =3D total_multifd_channels(); multifd_send_state =3D g_malloc0(sizeof(*multifd_send_state)); multifd_send_state->params =3D g_new0(MultiFDSendParams, thread_count); multifd_send_state->pages =3D multifd_pages_init(page_count); @@ -945,8 +945,8 @@ int multifd_save_setup(Error **errp) } else { p->write_flags =3D 0; } - - socket_send_channel_create(multifd_new_send_channel_async, p); + idx =3D multifd_index(i); + socket_send_channel_create(multifd_new_send_channel_async, p, idx); } =20 for (i =3D 0; i < thread_count; i++) { @@ -991,7 +991,7 @@ static void multifd_recv_terminate_threads(Error *err) } } =20 - for (i =3D 0; i < migrate_multifd_channels(); i++) { + for (i =3D 0; i < total_multifd_channels(); i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; =20 qemu_mutex_lock(&p->mutex); @@ -1017,7 +1017,7 @@ int multifd_load_cleanup(Error **errp) return 0; } multifd_recv_terminate_threads(NULL); - for (i =3D 0; i < migrate_multifd_channels(); i++) { + for (i =3D 0; i < total_multifd_channels(); i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; =20 if (p->running) { @@ -1030,7 +1030,7 @@ int multifd_load_cleanup(Error **errp) qemu_thread_join(&p->thread); } } - for (i =3D 0; i < migrate_multifd_channels(); i++) { + for (i =3D 0; i < total_multifd_channels(); i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; =20 migration_ioc_unregister_yank(p->c); @@ -1065,13 +1065,13 @@ void multifd_recv_sync_main(void) if (!migrate_use_multifd()) { return; } - for (i =3D 0; i < migrate_multifd_channels(); i++) { + for (i =3D 0; i < total_multifd_channels(); i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; =20 trace_multifd_recv_sync_main_wait(p->id); qemu_sem_wait(&multifd_recv_state->sem_sync); } - for (i =3D 0; i < migrate_multifd_channels(); i++) { + for (i =3D 0; i < total_multifd_channels(); i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; =20 WITH_QEMU_LOCK_GUARD(&p->mutex) { @@ -1166,7 +1166,7 @@ int multifd_load_setup(Error **errp) error_setg(errp, "multifd is not supported by current protocol"); return -1; } - thread_count =3D migrate_multifd_channels(); + thread_count =3D total_multifd_channels(); multifd_recv_state =3D g_malloc0(sizeof(*multifd_recv_state)); multifd_recv_state->params =3D g_new0(MultiFDRecvParams, thread_count); qatomic_set(&multifd_recv_state->count, 0); @@ -1204,7 +1204,7 @@ int multifd_load_setup(Error **errp) =20 bool multifd_recv_all_channels_created(void) { - int thread_count =3D migrate_multifd_channels(); + int thread_count =3D total_multifd_channels(); =20 if (!migrate_use_multifd()) { return true; @@ -1259,5 +1259,5 @@ bool multifd_recv_new_channel(QIOChannel *ioc, Error = **errp) QEMU_THREAD_JOINABLE); qatomic_inc(&multifd_recv_state->count); return qatomic_read(&multifd_recv_state->count) =3D=3D - migrate_multifd_channels(); + total_multifd_channels(); } diff --git a/migration/socket.c b/migration/socket.c index d0cb7cc6a6..c0ac6dbbe2 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -28,9 +28,6 @@ #include "trace.h" =20 =20 -struct SocketOutgoingArgs { - SocketAddress *saddr; -} outgoing_args; =20 struct SocketArgs { struct SrcDestAddr data; @@ -43,20 +40,47 @@ struct OutgoingMigrateParams { uint64_t total_multifd_channel; } outgoing_migrate_params; =20 -void socket_send_channel_create(QIOTaskFunc f, void *data) + +int total_multifd_channels(void) +{ + return outgoing_migrate_params.total_multifd_channel; +} + +int multifd_index(int i) +{ + int length =3D outgoing_migrate_params.length; + int j =3D 0; + int runn_sum =3D 0; + while (j < length) { + runn_sum +=3D outgoing_migrate_params.socket_args[j].multifd_chann= els; + if (i >=3D runn_sum) { + j++; + } else { + break; + } + } + return j; +} + +void socket_send_channel_create(QIOTaskFunc f, void *data, int idx) { QIOChannelSocket *sioc =3D qio_channel_socket_new(); - qio_channel_socket_connect_async(sioc, outgoing_args.saddr, - f, data, NULL, NULL, NULL); + qio_channel_socket_connect_async(sioc, + outgoing_migrate_params.socket_args[idx].data.dst_a= ddr, + f, data, NULL, NULL, + outgoing_migrate_params.socket_args[idx].data.src_a= ddr); } =20 int socket_send_channel_destroy(QIOChannel *send) { /* Remove channel */ object_unref(OBJECT(send)); - if (outgoing_args.saddr) { - qapi_free_SocketAddress(outgoing_args.saddr); - outgoing_args.saddr =3D NULL; + if (outgoing_migrate_params.socket_args !=3D NULL) { + g_free(outgoing_migrate_params.socket_args); + outgoing_migrate_params.socket_args =3D NULL; + } + if (outgoing_migrate_params.length) { + outgoing_migrate_params.length =3D 0; } =20 if (outgoing_migrate_params.socket_args !=3D NULL) { diff --git a/migration/socket.h b/migration/socket.h index b9e3699167..c8b9252384 100644 --- a/migration/socket.h +++ b/migration/socket.h @@ -27,7 +27,9 @@ struct SrcDestAddr { SocketAddress *src_addr; }; =20 -void socket_send_channel_create(QIOTaskFunc f, void *data); +int total_multifd_channels(void); +int multifd_index(int i); +void socket_send_channel_create(QIOTaskFunc f, void *data, int idx); int socket_send_channel_destroy(QIOChannel *send); =20 void socket_start_incoming_migration(const char *str, uint8_t number, diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 32a6b67d5f..9a3d76d6ba 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1281,10 +1281,6 @@ void hmp_migrate_set_parameter(Monitor *mon, const Q= Dict *qdict) p->has_block_incremental =3D true; visit_type_bool(v, param, &p->block_incremental, &err); break; - case MIGRATION_PARAMETER_MULTIFD_CHANNELS: - p->has_multifd_channels =3D true; - visit_type_uint8(v, param, &p->multifd_channels, &err); - break; case MIGRATION_PARAMETER_MULTIFD_COMPRESSION: p->has_multifd_compression =3D true; visit_type_MultiFDCompression(v, param, &p->multifd_compression, diff --git a/qapi/migration.json b/qapi/migration.json index 62a7b22d19..1b1c6d01d3 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -877,11 +877,6 @@ # migrated and the destination must already have acces= s to the # same backing chain as was used on the source. (sinc= e 2.10) # -# @multifd-channels: Number of channels used to migrate data in -# parallel. This is the same number that the -# number of sockets used for migration. The -# default value is 2 (since 4.0) -# # @xbzrle-cache-size: cache size to be used by XBZRLE migration. It # needs to be a multiple of the target page size # and a power of 2 @@ -965,7 +960,6 @@ '*x-checkpoint-delay': { 'type': 'uint32', 'features': [ 'unstable' ] }, '*block-incremental': 'bool', - '*multifd-channels': 'uint8', '*xbzrle-cache-size': 'size', '*max-postcopy-bandwidth': 'size', '*max-cpu-throttle': 'uint8', --=20 2.22.3