From patchwork Tue May 30 14:48:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 1787640 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=YTplwNoY; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QVwJv39rxz20Pc for ; Wed, 31 May 2023 00:49:19 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q40ep-0002O0-As; Tue, 30 May 2023 10:49:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q40ec-00025e-FJ for qemu-devel@nongnu.org; Tue, 30 May 2023 10:48:55 -0400 Received: from mail-dm6nam11on20617.outbound.protection.outlook.com ([2a01:111:f400:7eaa::617] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q40eY-0007ns-CG for qemu-devel@nongnu.org; Tue, 30 May 2023 10:48:53 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YuJvVbSjc6oZAKfoRNtKTLZkrLLLff2XQcQ3ySKG+8j1tmzdCC144wk5iGKfkWTxZwt29VF32DFq8MG/hM/4Nj5mi9BZR/SXFA8TLUsMXXME2zJbyELQzJyfzGyZoEaM5Ydl92L1fcAEtrsJxXT/HZ6wzbaTjUaY/6IdMiDbOHJAIuTU9XZNEXnyPPXqXGpQSyCSe42e66e4OvoZdeW9mToozhHzkhqygbtd9ekKyRBt9fTMo+6cOpqGAwAb2kz3PaNAz+J0NVWUDpb+WjV7TZw7rIlus1LSTdwUd424Qf6rHkKWcI4so5E+kLI4fkhkLFjuVWh/szebmiqJagXfEw== 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/fR/Eo4iI9NOC9O6X9QzwGE4haTxTYTv6T53TiKDIk=; b=f1J5w0DvxRe+hbsm4c5k4zD0CCR9sK5GQGi8pWLzlguO//o60XdtE5Iht7Co+JpBj05QkhjkeSTRb95X5p/CSBjTiQHliPAXZA/Xp1OTP7iFq1IStLUgeSxT+FEsx+IqHdEv3w2u2LeXaqowYqRV6vUlLYxGhUrLmiMl0E+wKyR7SJKHYp9dZfu3sV0x7b0eq8L4d3CAKTcbOhyXA6dXO/3sD19EuCvH2BOGD5Aaq4zE1I67SkmGxpYLvdiFXgbiJOjDvioghUHRucjLuNMENfGT0MWGBp27LPOEhjSBXIR3YF3l9qWqxzH4jVDITnOi6rX00mCsr5tpS3jY2dWx1A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7/fR/Eo4iI9NOC9O6X9QzwGE4haTxTYTv6T53TiKDIk=; b=YTplwNoY3bq4ilFWJO5HOxFElu8nUPG6usRsZ7moScqfTWMz38uzOkyk79GHjyf3Hh0EkhNpHV/K+pCGJ+2c9gEUVwbeftZo+emc+iWTvWulOb/1z7OMfswp4qkbMcjpFH60KfXMChlJIsJAMTRpaCBJdBZADvIOZC076we250IJQQ3SJrRjG6mp8ntWugE2veSihQd+L0lKzvOadDjcsuVGSqb0/+LGomLLE6MhMgqAuqRJX30ho+jYWbOMejoEsnYu/ILdeuGmTFUx5JrnsAKaMhbz+ARLrB05ct8RwSv4ea2MHPBdH87UuSaJTdqIcNx8P4VjSvm6ER83DWy97A== Received: from MW4PR03CA0063.namprd03.prod.outlook.com (2603:10b6:303:b6::8) by MN2PR12MB4438.namprd12.prod.outlook.com (2603:10b6:208:267::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Tue, 30 May 2023 14:48:46 +0000 Received: from CO1NAM11FT098.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b6:cafe::c6) by MW4PR03CA0063.outlook.office365.com (2603:10b6:303:b6::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23 via Frontend Transport; Tue, 30 May 2023 14:48:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT098.mail.protection.outlook.com (10.13.174.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22 via Frontend Transport; Tue, 30 May 2023 14:48:45 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 30 May 2023 07:48:33 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 30 May 2023 07:48:33 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 30 May 2023 07:48:28 -0700 From: Avihai Horon To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Juan Quintela , Peter Xu , Leonardo Bras , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v5 1/9] migration: Add switchover ack capability Date: Tue, 30 May 2023 17:48:13 +0300 Message-ID: <20230530144821.1557-2-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230530144821.1557-1-avihaih@nvidia.com> References: <20230530144821.1557-1-avihaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT098:EE_|MN2PR12MB4438:EE_ X-MS-Office365-Filtering-Correlation-Id: b1a136d4-d791-4250-d51d-08db611cf85e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DZIu9MG9O1gHnt+CmExV9iciE0IzphdHk3n7lyLjldrGQelWJWQv2X/nebDi3l7QFs3DQ8jbZRzroGAx5yco04pEWXDwjqgcFPflu3OPeAlfxJVV9D7WfEU/NzrtuX1H9GwmrUx2TKv1O6J9EhS7lcDOCfKAuiErepOHvh9K/4o5WQFYR+Ln0JhnadYn7LhvMGVAFVTY31dKrsMHuaM5196JX00JsW1/JwGyNhCkFceDCUVeqvaveyXlH+Pk+NbTiT6we+cKxgwjmA7inMhSR+G7jriJzJ1abT5/uvHjbFx6rJlGFoxig86NSarFcVgUjzwbajMCYgqHu9M2xgZChaICY5wK08R7amRQRhfcFG8SlRwA+0pJDEMqc/8Y3MMl3/aCJwtJ0R9Y/ofARcl/PVQqc3eqmNled+7N+acu+r3vYXd/NUPt5C1ob57ft3qo5BMz9lfJ+ViAOjSBSzs5GjfTYInfVTu5ZPqS+qBfzqZ54r4JMOdohmGKdALSa0HGsuZYmL8rNJFpil/OMHndgTKfDFsshOB0oZ9XxllnXB3Uiv5HFUMV4bo7ORNBA7BAKU4lc/lrgLekW4aM4NEVSUAe2dzb+v7EXEBQLkvDUIi1BnsfD5peq7ZXlwK4c5xkBfyjyTD2/XKK3O02FWRc2fK5i00ree8LvTr/DsUGK7vnfg9YM/I7UQ9wdnd1sCtWANVcziZJmQkA67/sxu09rOHO1xq5ZLrx4ZsFZJ39hM4wy4Y9H6i0NlYZBZAwhteC X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(346002)(396003)(39860400002)(376002)(136003)(451199021)(46966006)(40470700004)(36840700001)(186003)(2906002)(2616005)(54906003)(478600001)(426003)(336012)(26005)(1076003)(47076005)(83380400001)(86362001)(40460700003)(36860700001)(7696005)(356005)(7636003)(8936002)(8676002)(82740400003)(41300700001)(40480700001)(70586007)(5660300002)(70206006)(36756003)(6666004)(316002)(82310400005)(7416002)(4326008)(6916009); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 14:48:45.5906 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b1a136d4-d791-4250-d51d-08db611cf85e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT098.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4438 Received-SPF: softfail client-ip=2a01:111:f400:7eaa::617; envelope-from=avihaih@nvidia.com; helo=NAM11-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Migration downtime estimation is calculated based on bandwidth and remaining migration data. This assumes that loading of migration data in the destination takes a negligible amount of time and that downtime depends only on network speed. While this may be true for RAM, it's not necessarily true for other migrated devices. For example, loading the data of a VFIO device in the destination might require from the device to allocate resources, prepare internal data structures and so on. These operations can take a significant amount of time which can increase migration downtime. This patch adds a new capability "switchover ack" that prevents the source from stopping the VM and completing the migration until an ACK is received from the destination that it's OK to do so. This can be used by migrated devices in various ways to reduce downtime. For example, a device can send initial precopy metadata to pre-allocate resources in the destination and use this capability to make sure that the pre-allocation is completed before the source VM is stopped, so it will have full effect. This new capability relies on the return path capability to communicate from the destination back to the source. The actual implementation of the capability will be added in the following patches. Signed-off-by: Avihai Horon Reviewed-by: Peter Xu Acked-by: Markus Armbruster Tested-by: YangHang Liu --- qapi/migration.json | 12 +++++++++++- migration/options.h | 1 + migration/options.c | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/qapi/migration.json b/qapi/migration.json index 179af0c4d8..061ea512e0 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -487,6 +487,16 @@ # and should not affect the correctness of postcopy migration. # (since 7.1) # +# @switchover-ack: If enabled, migration will not stop the source VM +# and complete the migration until an ACK is received from the +# destination that it's OK to do so. Exactly when this ACK is +# sent depends on the migrated devices that use this feature. +# For example, a device can use it to make sure some of its data +# is sent and loaded in the destination before doing switchover. +# This can reduce downtime if devices that support this capability +# are present. 'return-path' capability must be enabled to use +# it. (since 8.1) +# # Features: # # @unstable: Members @x-colo and @x-ignore-shared are experimental. @@ -502,7 +512,7 @@ 'dirty-bitmaps', 'postcopy-blocktime', 'late-block-activate', { 'name': 'x-ignore-shared', 'features': [ 'unstable' ] }, 'validate-uuid', 'background-snapshot', - 'zero-copy-send', 'postcopy-preempt'] } + 'zero-copy-send', 'postcopy-preempt', 'switchover-ack'] } ## # @MigrationCapabilityStatus: diff --git a/migration/options.h b/migration/options.h index 45991af3c2..9aaf363322 100644 --- a/migration/options.h +++ b/migration/options.h @@ -40,6 +40,7 @@ bool migrate_postcopy_ram(void); bool migrate_rdma_pin_all(void); bool migrate_release_ram(void); bool migrate_return_path(void); +bool migrate_switchover_ack(void); bool migrate_validate_uuid(void); bool migrate_xbzrle(void); bool migrate_zero_blocks(void); diff --git a/migration/options.c b/migration/options.c index b62ab30cd5..16007afca6 100644 --- a/migration/options.c +++ b/migration/options.c @@ -185,6 +185,8 @@ Property migration_properties[] = { DEFINE_PROP_MIG_CAP("x-zero-copy-send", MIGRATION_CAPABILITY_ZERO_COPY_SEND), #endif + DEFINE_PROP_MIG_CAP("x-switchover-ack", + MIGRATION_CAPABILITY_SWITCHOVER_ACK), DEFINE_PROP_END_OF_LIST(), }; @@ -308,6 +310,13 @@ bool migrate_return_path(void) return s->capabilities[MIGRATION_CAPABILITY_RETURN_PATH]; } +bool migrate_switchover_ack(void) +{ + MigrationState *s = migrate_get_current(); + + return s->capabilities[MIGRATION_CAPABILITY_SWITCHOVER_ACK]; +} + bool migrate_validate_uuid(void) { MigrationState *s = migrate_get_current(); @@ -547,6 +556,18 @@ bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp) } } + if (new_caps[MIGRATION_CAPABILITY_SWITCHOVER_ACK]) { + if (!new_caps[MIGRATION_CAPABILITY_RETURN_PATH]) { + error_setg(errp, "Capability 'switchover-ack' requires capability " + "'return-path'"); + return false; + } + + /* Disable this capability until it's implemented */ + error_setg(errp, "'switchover-ack' is not implemented yet"); + return false; + } + return true; } From patchwork Tue May 30 14:48:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 1787641 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=eyTf6yqq; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QVwJw0whYz20Q5 for ; Wed, 31 May 2023 00:49:20 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q40ep-0002RT-Fo; Tue, 30 May 2023 10:49:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q40ef-00028j-Rf for qemu-devel@nongnu.org; Tue, 30 May 2023 10:48:58 -0400 Received: from mail-mw2nam12on20616.outbound.protection.outlook.com ([2a01:111:f400:fe5a::616] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q40eb-0007oT-6j for qemu-devel@nongnu.org; Tue, 30 May 2023 10:48:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RJbrjOAJ30f3Fto5BRq0gnm/sUv36IWMHNrxNY0psWIlD0dxQt54pMt1ZhVPR5FuqdRQ7Jqg4DZ7q7VJMsGEbkDy9XjhEK/c9cpR2Fmf+Y4h1fEwF1PPDWsOPFPbdGtuAQlnXvT/QySKpptjFoHu5xA69CzVcNSFdnr5mJ9SYYSmbakN8QTQho+i995l6w3jPT63LLai92VCP3LYtz0oGJcw6ZouQxF7QykzvCB0U2asUC9o/hE/A0Z5Gj1inPVtIi9f6/WewHMKkKBK4/pFYAv8VGshZgnfXQB1+LwkNByJi/0lY+U60HsF9u1+l6MQR9fHC7Vz+vendvoZ8/C1KQ== 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=4g3Vt2zEePujTl2d5dCruBxjiGEeUjQp0BkvnpUOj9c=; b=K7/VTxC0bYWZjHUgIDst9VMqcnszTHX+2IX5MHr77ouFusS5Jxt1D7dOqlZB2puMX7ru+DWA5SPsGvVyU/ig2O0rMTQ8H69py8qGWTFTvh3AzqFWKTG4gYnC04mc58ci29pr0fRk3uRokD0x23c6pJhngzfz5CoWtYsvoRU5h0XyuVDDLvHWdeUAg16JLYhB1weFPdUNppFGmgLHtoMIC8rDq1mcKpNxUy998xOSdMqebwgSboq6nzrO/mTut47ddiIEX/v+/lmyQ53hR2GxYz18O3/5s5Cz8KyiPkrvH6/nQRFfAB3uGSFppTm1nGJ65Q3A2uBkhTdBuyNnoc/wtw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4g3Vt2zEePujTl2d5dCruBxjiGEeUjQp0BkvnpUOj9c=; b=eyTf6yqqTK72LweA4xqk4iDfowzYnbUX+s/WerIJFPkLTrQika1yr/xjoSrarRtZgIcZ9bo7N4ipsmzGiSukJAtwGechyegRiy8cC13dF7SWchqI4QXwgAl8B6mLDvKySV6MNCePEI7zMQLMHDqX6iFUU5k4vnNEX4LgDvvYqkMIKN7F8u6Q78aSTg3/G0d1uqA5abkdeSkgjDEOCl+WzXQhtYc1R3yBfqXvrCMdsllGkxzT0aq5Lg36JX/t71vF36+ZAlGrI+1qnA7+HmuvVUrhSh9+Vzwu3N83cmQU3hsATdGGC7t0kzmsKyjCJ722+9JnaUY89oQAbS9aTHfKnQ== Received: from DM6PR06CA0061.namprd06.prod.outlook.com (2603:10b6:5:54::38) by PH8PR12MB7279.namprd12.prod.outlook.com (2603:10b6:510:221::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.22; Tue, 30 May 2023 14:48:48 +0000 Received: from DM6NAM11FT019.eop-nam11.prod.protection.outlook.com (2603:10b6:5:54:cafe::f9) by DM6PR06CA0061.outlook.office365.com (2603:10b6:5:54::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23 via Frontend Transport; Tue, 30 May 2023 14:48:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT019.mail.protection.outlook.com (10.13.172.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22 via Frontend Transport; Tue, 30 May 2023 14:48:48 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 30 May 2023 07:48:39 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 30 May 2023 07:48:38 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 30 May 2023 07:48:33 -0700 From: Avihai Horon To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Juan Quintela , Peter Xu , Leonardo Bras , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v5 2/9] migration: Implement switchover ack logic Date: Tue, 30 May 2023 17:48:14 +0300 Message-ID: <20230530144821.1557-3-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230530144821.1557-1-avihaih@nvidia.com> References: <20230530144821.1557-1-avihaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT019:EE_|PH8PR12MB7279:EE_ X-MS-Office365-Filtering-Correlation-Id: 62b151d3-f041-4af5-92b5-08db611cf9e5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Hh/z2Xb2/lCrY3ZYl7gBceUCSNHt/KmHAyHCwL55M41Gr2T4ST9papDSZ3vU2OyU7nHvEnCBoyKLbQkzmEkMQ6FQzCi2/nJNKyPQbp0N4rPDY0w8U7quWGYDw0sO8BHCempIazX8p5lEj+qeLCV18Lm2WFV+FouSx070PJW8B0QzIlPVRHZifmgd38po7x3Nb6b1iHwmgTyKpBfIqknOdvjDW/X9Y48xZJfGR5SPWRvSs1redmtoXMLGSSxIc+sOe5FSO5FkPaxAVb/zBrWVOGY9Akg0NHtKtSfJUGhUWY81a5yfUjyduY2yxjGYduPweHSPJr2tGTGYxQMEHjXabx+P7wXdZrpsSrHOnHyzh1lqpCWei1bC6rfhfsZ3h7eJ9PEMm7FnzhjYqnZdooFuoRgPJ7qVIQVtVhMB74VE1/mng/X6AMlgRyCtaT0NgTxp/wenW9BGezlTInB1tS+9mo3M1OhR0KiH9tM+EMUzC3PcJb+5/eK7F2EEzgRp0Qa9xTJtijUdFrKonMSP6iD/OOypM6QlJ+41XWlqWAB2pMZUu78KwjhzjEsi4Gad9uV5RmWB9XFJR/3uHsHTF8l8/n1IoDk4agM0pCnX3NNpnr8Jp5R9GOWwTtodZb46j3Rl3Ix3+XnqdKWGgotpUy788/nxTLjZSBCi8QKzzQBh+5vrk3pfoVL+B2MNQQ3H/PGozHgeyvvG60lfHgsHreaZzDIOAUFUMekuyGAgF9aGprg= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(136003)(39860400002)(376002)(396003)(346002)(451199021)(36840700001)(46966006)(40470700004)(36860700001)(26005)(1076003)(41300700001)(6666004)(7696005)(186003)(47076005)(83380400001)(426003)(336012)(2616005)(478600001)(40460700003)(54906003)(4326008)(82740400003)(6916009)(70586007)(356005)(7636003)(40480700001)(316002)(5660300002)(70206006)(8676002)(8936002)(7416002)(30864003)(82310400005)(2906002)(86362001)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 14:48:48.1045 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 62b151d3-f041-4af5-92b5-08db611cf9e5 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT019.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7279 Received-SPF: softfail client-ip=2a01:111:f400:fe5a::616; envelope-from=avihaih@nvidia.com; helo=NAM12-MW2-obe.outbound.protection.outlook.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Implement switchover ack logic. This prevents the source from stopping the VM and completing the migration until an ACK is received from the destination that it's OK to do so. To achieve this, a new SaveVMHandlers handler switchover_ack_needed() and a new return path message MIG_RP_MSG_SWITCHOVER_ACK are added. The switchover_ack_needed() handler is called during migration setup in the destination to check if switchover ack is used by the migrated device. When switchover is approved by all migrated devices in the destination that support this capability, the MIG_RP_MSG_SWITCHOVER_ACK return path message is sent to the source to notify it that it's OK to do switchover. Signed-off-by: Avihai Horon Reviewed-by: Peter Xu --- include/migration/register.h | 2 ++ migration/migration.h | 14 ++++++++++ migration/savevm.h | 1 + migration/migration.c | 32 +++++++++++++++++++-- migration/savevm.c | 54 ++++++++++++++++++++++++++++++++++++ migration/trace-events | 3 ++ 6 files changed, 104 insertions(+), 2 deletions(-) diff --git a/include/migration/register.h b/include/migration/register.h index a8dfd8fefd..90914f32f5 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -71,6 +71,8 @@ typedef struct SaveVMHandlers { int (*load_cleanup)(void *opaque); /* Called when postcopy migration wants to resume from failure */ int (*resume_prepare)(MigrationState *s, void *opaque); + /* Checks if switchover ack should be used. Called only in dest */ + bool (*switchover_ack_needed)(void *opaque); } SaveVMHandlers; int register_savevm_live(const char *idstr, diff --git a/migration/migration.h b/migration/migration.h index 48a46123a0..1e92ba7b1d 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -209,6 +209,13 @@ struct MigrationIncomingState { * contains valid information. */ QemuMutex page_request_mutex; + + /* + * Number of devices that have yet to approve switchover. When this reaches + * zero an ACK that it's OK to do switchover is sent to the source. No lock + * is needed as this field is updated serially. + */ + unsigned int switchover_ack_pending_num; }; MigrationIncomingState *migration_incoming_get_current(void); @@ -437,6 +444,12 @@ struct MigrationState { /* QEMU_VM_VMDESCRIPTION content filled for all non-iterable devices. */ JSONWriter *vmdesc; + + /* + * Indicates whether an ACK from the destination that it's OK to do + * switchover has been received. + */ + bool switchover_acked; }; void migrate_set_state(int *state, int old_state, int new_state); @@ -477,6 +490,7 @@ int migrate_send_rp_message_req_pages(MigrationIncomingState *mis, void migrate_send_rp_recv_bitmap(MigrationIncomingState *mis, char *block_name); void migrate_send_rp_resume_ack(MigrationIncomingState *mis, uint32_t value); +int migrate_send_rp_switchover_ack(MigrationIncomingState *mis); void dirty_bitmap_mig_before_vm_start(void); void dirty_bitmap_mig_cancel_outgoing(void); diff --git a/migration/savevm.h b/migration/savevm.h index fb636735f0..e894bbc143 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -65,6 +65,7 @@ int qemu_loadvm_state(QEMUFile *f); void qemu_loadvm_state_cleanup(void); int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis); int qemu_load_device_state(QEMUFile *f); +int qemu_loadvm_approve_switchover(void); int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f, bool in_postcopy, bool inactivate_disks); diff --git a/migration/migration.c b/migration/migration.c index 5de7f734b9..c73261118c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -78,6 +78,7 @@ enum mig_rp_message_type { MIG_RP_MSG_REQ_PAGES, /* data (start: be64, len: be32) */ MIG_RP_MSG_RECV_BITMAP, /* send recved_bitmap back to source */ MIG_RP_MSG_RESUME_ACK, /* tell source that we are ready to resume */ + MIG_RP_MSG_SWITCHOVER_ACK, /* Tell source it's OK to do switchover */ MIG_RP_MSG_MAX }; @@ -760,6 +761,11 @@ bool migration_has_all_channels(void) return true; } +int migrate_send_rp_switchover_ack(MigrationIncomingState *mis) +{ + return migrate_send_rp_message(mis, MIG_RP_MSG_SWITCHOVER_ACK, 0, NULL); +} + /* * Send a 'SHUT' message on the return channel with the given value * to indicate that we've finished with the RP. Non-0 value indicates @@ -1405,6 +1411,7 @@ void migrate_init(MigrationState *s) s->vm_was_running = false; s->iteration_initial_bytes = 0; s->threshold_size = 0; + s->switchover_acked = false; } int migrate_add_blocker_internal(Error *reason, Error **errp) @@ -1721,6 +1728,7 @@ static struct rp_cmd_args { [MIG_RP_MSG_REQ_PAGES_ID] = { .len = -1, .name = "REQ_PAGES_ID" }, [MIG_RP_MSG_RECV_BITMAP] = { .len = -1, .name = "RECV_BITMAP" }, [MIG_RP_MSG_RESUME_ACK] = { .len = 4, .name = "RESUME_ACK" }, + [MIG_RP_MSG_SWITCHOVER_ACK] = { .len = 0, .name = "SWITCHOVER_ACK" }, [MIG_RP_MSG_MAX] = { .len = -1, .name = "MAX" }, }; @@ -1959,6 +1967,11 @@ retry: } break; + case MIG_RP_MSG_SWITCHOVER_ACK: + ms->switchover_acked = true; + trace_source_return_path_thread_switchover_acked(); + break; + default: break; } @@ -2700,6 +2713,20 @@ static void migration_update_counters(MigrationState *s, bandwidth, s->threshold_size); } +static bool migration_can_switchover(MigrationState *s) +{ + if (!migrate_switchover_ack()) { + return true; + } + + /* No reason to wait for switchover ACK if VM is stopped */ + if (!runstate_is_running()) { + return true; + } + + return s->switchover_acked; +} + /* Migration thread iteration status */ typedef enum { MIG_ITERATE_RESUME, /* Resume current iteration */ @@ -2715,6 +2742,7 @@ static MigIterateState migration_iteration_run(MigrationState *s) { uint64_t must_precopy, can_postcopy; bool in_postcopy = s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE; + bool can_switchover = migration_can_switchover(s); qemu_savevm_state_pending_estimate(&must_precopy, &can_postcopy); uint64_t pending_size = must_precopy + can_postcopy; @@ -2727,14 +2755,14 @@ static MigIterateState migration_iteration_run(MigrationState *s) trace_migrate_pending_exact(pending_size, must_precopy, can_postcopy); } - if (!pending_size || pending_size < s->threshold_size) { + if ((!pending_size || pending_size < s->threshold_size) && can_switchover) { trace_migration_thread_low_pending(pending_size); migration_completion(s); return MIG_ITERATE_BREAK; } /* Still a significant amount to transfer */ - if (!in_postcopy && must_precopy <= s->threshold_size && + if (!in_postcopy && must_precopy <= s->threshold_size && can_switchover && qatomic_read(&s->start_postcopy)) { if (postcopy_start(s)) { error_report("%s: postcopy failed to start", __func__); diff --git a/migration/savevm.c b/migration/savevm.c index 03795ce8dc..285b814726 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2360,6 +2360,21 @@ static int loadvm_process_command(QEMUFile *f) error_report("CMD_OPEN_RETURN_PATH failed"); return -1; } + + /* + * Switchover ack is enabled but no device uses it, so send an ACK to + * source that it's OK to switchover. Do it here, after return path has + * been created. + */ + if (migrate_switchover_ack() && !mis->switchover_ack_pending_num) { + int ret = migrate_send_rp_switchover_ack(mis); + if (ret) { + error_report( + "Could not send switchover ack RP MSG, err %d (%s)", ret, + strerror(-ret)); + return ret; + } + } break; case MIG_CMD_PING: @@ -2586,6 +2601,23 @@ static int qemu_loadvm_state_header(QEMUFile *f) return 0; } +static void qemu_loadvm_state_switchover_ack_needed(MigrationIncomingState *mis) +{ + SaveStateEntry *se; + + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + if (!se->ops || !se->ops->switchover_ack_needed) { + continue; + } + + if (se->ops->switchover_ack_needed(se->opaque)) { + mis->switchover_ack_pending_num++; + } + } + + trace_loadvm_state_switchover_ack_needed(mis->switchover_ack_pending_num); +} + static int qemu_loadvm_state_setup(QEMUFile *f) { SaveStateEntry *se; @@ -2789,6 +2821,10 @@ int qemu_loadvm_state(QEMUFile *f) return -EINVAL; } + if (migrate_switchover_ack()) { + qemu_loadvm_state_switchover_ack_needed(mis); + } + cpu_synchronize_all_pre_loadvm(); ret = qemu_loadvm_state_main(f, mis); @@ -2862,6 +2898,24 @@ int qemu_load_device_state(QEMUFile *f) return 0; } +int qemu_loadvm_approve_switchover(void) +{ + MigrationIncomingState *mis = migration_incoming_get_current(); + + if (!mis->switchover_ack_pending_num) { + return -EINVAL; + } + + mis->switchover_ack_pending_num--; + trace_loadvm_approve_switchover(mis->switchover_ack_pending_num); + + if (mis->switchover_ack_pending_num) { + return 0; + } + + return migrate_send_rp_switchover_ack(mis); +} + bool save_snapshot(const char *name, bool overwrite, const char *vmstate, bool has_devices, strList *devices, Error **errp) { diff --git a/migration/trace-events b/migration/trace-events index cdaef7a1ea..5259c1044b 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -7,6 +7,7 @@ qemu_loadvm_state_section_partend(uint32_t section_id) "%u" qemu_loadvm_state_post_main(int ret) "%d" qemu_loadvm_state_section_startfull(uint32_t section_id, const char *idstr, uint32_t instance_id, uint32_t version_id) "%u(%s) %u %u" qemu_savevm_send_packaged(void) "" +loadvm_state_switchover_ack_needed(unsigned int switchover_ack_pending_num) "Switchover ack pending num=%u" loadvm_state_setup(void) "" loadvm_state_cleanup(void) "" loadvm_handle_cmd_packaged(unsigned int length) "%u" @@ -23,6 +24,7 @@ loadvm_postcopy_ram_handle_discard_end(void) "" loadvm_postcopy_ram_handle_discard_header(const char *ramid, uint16_t len) "%s: %ud" loadvm_process_command(const char *s, uint16_t len) "com=%s len=%d" loadvm_process_command_ping(uint32_t val) "0x%x" +loadvm_approve_switchover(unsigned int switchover_ack_pending_num) "Switchover ack pending num=%u" postcopy_ram_listen_thread_exit(void) "" postcopy_ram_listen_thread_start(void) "" qemu_savevm_send_postcopy_advise(void) "" @@ -180,6 +182,7 @@ source_return_path_thread_loop_top(void) "" source_return_path_thread_pong(uint32_t val) "0x%x" source_return_path_thread_shut(uint32_t val) "0x%x" source_return_path_thread_resume_ack(uint32_t v) "%"PRIu32 +source_return_path_thread_switchover_acked(void) "" migration_thread_low_pending(uint64_t pending) "%" PRIu64 migrate_transferred(uint64_t tranferred, uint64_t time_spent, uint64_t bandwidth, uint64_t size) "transferred %" PRIu64 " time_spent %" PRIu64 " bandwidth %" PRIu64 " max_size %" PRId64 process_incoming_migration_co_end(int ret, int ps) "ret=%d postcopy-state=%d" From patchwork Tue May 30 14:48:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 1787659 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=moqXVpXP; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QVwM01qcfz20Q4 for ; Wed, 31 May 2023 00:51:08 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q40f5-0003ci-46; Tue, 30 May 2023 10:49:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q40em-0002KO-1G for qemu-devel@nongnu.org; Tue, 30 May 2023 10:49:05 -0400 Received: from mail-mw2nam10on20616.outbound.protection.outlook.com ([2a01:111:f400:7e89::616] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q40ei-0007pp-Dp for qemu-devel@nongnu.org; Tue, 30 May 2023 10:49:03 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mnJtjssKlmkSfQp8mUfITjNUx+mAJjB+JLbacFyMX5PqCFj29ayPg6CCHBpHpkA5RbxpRSMozv8PBhY96oDG8gd1ILRJv/n04LLRS1jic9atEvxgP+zuAto/dGqu+A2Um9mYOScMAD6NlHcqa6v80sc11dqjmQeZLa7fT5bO3XrXYWPo447Ktc7TnrXDTVZ5fYf5bohijU6bofSjFowXLMnKG8k5fkgdLfp27rns/tLLZTfZnr0bpv9GfMxyhseDpIrHim544amMZNm2lcxiuqejbn0fkClDFVnchPCnaYBqSNAKWEtxVcu1nCUZdAHs21WizfusIAAabrd4Hh/WhQ== 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=H8qr/4vY6rROCFN+GNRissWhsvrGsoPf1KWa7EDU66U=; b=ngP6TUP37dTZhn9MEWvl4wVakLA2Swz8xKCTdkvAXVvj6ZbC8DLwfcdX5QIgL9wtqbdlkbHDID38HUMbOLXsavpZfKaUJ3l36jH5YkR9C3z2CMJROS45skFB16fIzjdPlo7gaxTYdSfuhhtUmzEGmUG6MEvZS1QRP0qPrRJTIwIDiMpcWpDVMKvUBqWqv8Fh02AOymX0GWkFO2ZDvR47PsUoxkuRpvbIyE2FOpkCOCTay/TxByiDpoPGyocaLtPs7gSGvYHDhbP8dGGktCVfnQZat4CZ8H1iQhyhjiXQcpYzxrO8qu4uAquuMqCv7PeWn9lyJD+0KoXz9fA0KBa7Rg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H8qr/4vY6rROCFN+GNRissWhsvrGsoPf1KWa7EDU66U=; b=moqXVpXPBMlPA9TLQXys0bgabq1OLd7PNPBVG4ilCbQ/g64lywOgWiXNUmbWfwXKQWgzQT6Gb91YIpmim1opL5Ax0mWJtMoX08SuTX3RENQXXPgsU6P5v4wTA0ynhCL3GrHOTiKzQO2h1TyCazjIckree/lmKlA54veTxr0N433sJjZfhvdK+U3p9TQtuX3upZGKNa7bjET06mLuhOnLky/4eGP3Xtm88zTz3oc17a+W8SYBaRkuoZx3KlhikZbW4lU2RL5pUFL0+p/xSdnpk9uHAN36vAYm9kR7aM3mGWOQjNdUIxOA4RYCqV91CjUPERi3wzoQ+RajFKVDiA5VVg== Received: from MW4PR04CA0049.namprd04.prod.outlook.com (2603:10b6:303:6a::24) by SJ2PR12MB7895.namprd12.prod.outlook.com (2603:10b6:a03:4c6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.16; Tue, 30 May 2023 14:48:55 +0000 Received: from CO1NAM11FT042.eop-nam11.prod.protection.outlook.com (2603:10b6:303:6a:cafe::d0) by MW4PR04CA0049.outlook.office365.com (2603:10b6:303:6a::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22 via Frontend Transport; Tue, 30 May 2023 14:48:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT042.mail.protection.outlook.com (10.13.174.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22 via Frontend Transport; Tue, 30 May 2023 14:48:55 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 30 May 2023 07:48:44 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 30 May 2023 07:48:44 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 30 May 2023 07:48:39 -0700 From: Avihai Horon To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Juan Quintela , Peter Xu , Leonardo Bras , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v5 3/9] migration: Enable switchover ack capability Date: Tue, 30 May 2023 17:48:15 +0300 Message-ID: <20230530144821.1557-4-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230530144821.1557-1-avihaih@nvidia.com> References: <20230530144821.1557-1-avihaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT042:EE_|SJ2PR12MB7895:EE_ X-MS-Office365-Filtering-Correlation-Id: 6080e51c-a9f6-4df6-e00a-08db611cfe43 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pcMeUzEkPfyHKZYfDIeb4bavFHLrH92ihctrUT0G/bssu4HOboCmuSbsTWAy8XpjZ0NlatvHyehQge2U0NRAr7r9V7pIF9CeGnBz+CBXlupTbyt1Xtzr32233i60wg5IKu0oja5fvwHwgHJ9aCZX7Ghkc//FUd3t8C1tv50ITpbv0K0fwn5HZUPV2GMe7hv9KSk7wJpe5LP9xuhfrzfohEXd2N1JJDEE+KF+GNUL6l/Bh+TO+6ekeYRmGDscQ8Z8MMDQwTTsdZw/oE2fNmNafrJsM0L5TuY7Shg67SCUz19RV96DRnrjDXLEIGHzgN18g0hrsnxqcZIIr6WzQZWQgsQ3eN41yGIw0d+u5n0DP1VGxOi5jmSpZT1CXHnbpwGK7m+fUz0ibAFBt0bN1lZuyn9JQyr5KGgcM1BxqvWtrijv6oNS9Wxl86PkFrmIV1xJWmggVjEc67uG+YwrCtob5wmzlS/zCjiZ7hktQ4NmjmiqjKWOve9G4Lp9ogS58admNw45I0GW346u6x/gEZWvcghMSfdOvWsKwfTVCM/4jB/XRR1QeU/lb7ohlYZ0Hvyuuk+wSUM3kvA36HGJN50WPNbw0vgR250hGlaTUnCMXoPfM3OfUQ3urSSQELEJgUBI9Bk9bRYA4pejvjD5gSvGaG/WadBETYkXnqkrwWjVHgY2Ns183/VRuLhd9+CLf9e88enjhSwZF7o+c9n+o64p124E+o83c2gexamJ5u8xYpk= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(346002)(136003)(396003)(376002)(451199021)(36840700001)(40470700004)(46966006)(82310400005)(86362001)(1076003)(7636003)(356005)(40480700001)(36756003)(7416002)(40460700003)(26005)(426003)(5660300002)(83380400001)(336012)(47076005)(4744005)(2616005)(2906002)(478600001)(70206006)(70586007)(54906003)(8936002)(7696005)(8676002)(41300700001)(6916009)(6666004)(4326008)(316002)(186003)(82740400003)(36860700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 14:48:55.4803 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6080e51c-a9f6-4df6-e00a-08db611cfe43 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT042.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7895 Received-SPF: softfail client-ip=2a01:111:f400:7e89::616; envelope-from=avihaih@nvidia.com; helo=NAM10-MW2-obe.outbound.protection.outlook.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Now that switchover ack logic has been implemented, enable the capability. Signed-off-by: Avihai Horon Reviewed-by: Juan Quintela Reviewed-by: Peter Xu --- migration/options.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/migration/options.c b/migration/options.c index 16007afca6..5a9505adf7 100644 --- a/migration/options.c +++ b/migration/options.c @@ -562,10 +562,6 @@ bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp) "'return-path'"); return false; } - - /* Disable this capability until it's implemented */ - error_setg(errp, "'switchover-ack' is not implemented yet"); - return false; } return true; From patchwork Tue May 30 14:48:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 1787654 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=pn8oLZR9; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QVwKv5L05z20Q4 for ; Wed, 31 May 2023 00:50:11 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q40f3-0003M5-Mf; Tue, 30 May 2023 10:49:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q40ew-0002r7-OO for qemu-devel@nongnu.org; Tue, 30 May 2023 10:49:14 -0400 Received: from mail-mw2nam04on20613.outbound.protection.outlook.com ([2a01:111:f400:7e8c::613] helo=NAM04-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q40es-0007rH-Tj for qemu-devel@nongnu.org; Tue, 30 May 2023 10:49:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ixQ5+CbcXV9g9/HSsGF7Cq3AXKsa4BnAr92dxJZl2NqcGWqbQXCDpAtB8hTDPofZF/m5iJedpCVn88KMX2VI0VlEg/iE5Nrrx2SISxlcMuOsm/VniLld1sK4hQ+g7UT7J4JOwaXgelMB7xQOgqpfFkbfnFJjB7+DzrBCHsIooOqB2kGeV8XPW/pYEwKNqOqoRaSPRbVz6a7L8HArJ2TMLC3Dq5OBRKWm11VhjpagEN5fgEOELGXrfPVJIH2IYVi7ahQ+RaSpOasZ4Seoc0n6XAI3IDYpAJWWtQvX/ocmWxr5Qr8maUTm4DUGDgvtXkX63YysdBs8rWDSduAyJjxsGQ== 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=Ty9CIV2fh2WcvJCAV9AeKyGJqCBOuEfLaT2SmeXbeCY=; b=l6RSuSJ9qAPvvYN35vovv4nR2ajzgzcLZsIe2gpCa1W0NRGO1Nb3OARa9b5cpbRMcPCz7/3xoeQd5xUpw7Ysq9gxUobbYM3mvTb1NgceMWqHbnYpzrwbb7thbPgxDs/fntkPTzTt9VMz+8BawRMrf2RRh6+IRaaMqMTHBk9NhfOAGG2/ubtaGW0V40P3g5BooZWTsCmvVuWNNiYDkbYeVU4No6XIRaBJGgcUwbO9UqPtgAsK1IzdPPG5uDlKMgBYb+/k4hJNlkNnmO9866YdG32AkuH+LLuuGPeaN+DMqIml4so80KH02samP68J/xykwFj1J6QmK+lgZ/KZeQt5GA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ty9CIV2fh2WcvJCAV9AeKyGJqCBOuEfLaT2SmeXbeCY=; b=pn8oLZR9Uz3OKW9N5L4FNFO0/FSfnqGsv1iyrnLIgM/OlnW5sQIKzgwHeDS3zwZPy2XI+2C9y///MLDMvHW0mviJASuYJqieQ6eGvQ5WOy6OwuaEMv1Dl3Gk8avQ4Nx5BGciT5obFvdS9RGxhhDzz1kFxCOgm1RE3aYsKZsg86CRrmDeJI0o+4HL1ureYndidkwOiDBL/fVDxe+3EziUsiA53stOwX3yDOXmpgQlylP/7IEassKolHpP2Inu1srn/5nuqkVGZUHYdtbwWVpSDrksuFw3BmefYT8Nma0t1y56ExMDBnMmoOdP4oWVYa2roQjZDyafHfXwRZKd/hm4pw== Received: from DM5PR07CA0069.namprd07.prod.outlook.com (2603:10b6:4:ad::34) by SA0PR12MB4462.namprd12.prod.outlook.com (2603:10b6:806:95::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Tue, 30 May 2023 14:49:05 +0000 Received: from DM6NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:4:ad:cafe::37) by DM5PR07CA0069.outlook.office365.com (2603:10b6:4:ad::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23 via Frontend Transport; Tue, 30 May 2023 14:49:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT032.mail.protection.outlook.com (10.13.173.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22 via Frontend Transport; Tue, 30 May 2023 14:49:04 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 30 May 2023 07:48:50 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 30 May 2023 07:48:49 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 30 May 2023 07:48:44 -0700 From: Avihai Horon To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Juan Quintela , Peter Xu , Leonardo Bras , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v5 4/9] tests: Add migration switchover ack capability test Date: Tue, 30 May 2023 17:48:16 +0300 Message-ID: <20230530144821.1557-5-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230530144821.1557-1-avihaih@nvidia.com> References: <20230530144821.1557-1-avihaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT032:EE_|SA0PR12MB4462:EE_ X-MS-Office365-Filtering-Correlation-Id: 77f7372c-a24a-45df-f5e1-08db611d03c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h/aEewhVLnkFW+OaOvIwM9QhGprgThlMrh671wvhB1TVbdNYXB1U+6/jvIIy6Z2LRGuLlZY6Bq7hM1oQXdLBJdmdN4Q2pzFAyhjDicp8yuQvXH4v0H7Rl19j3Jpyir6qZk01jhdrzssyxc8MyAGQLvPtNMrugKZLQkTZ8L6u/qsoSCcePVi38dAT34pB8KnzYBPiupVJmLXfpDXVttULUpTHngKd/bYkqQSmOhstTVwZGx9y5hHMnV0FFKLS12UJKiaR/jpXnLCZfvGWFDUPGvggXDoe9q06NqQSJO7235ec0gqsW7aEpY4bwlnUKXl6EIb5DYhyAcDH4XC9NYaKTnjGHu21NxA33rTKDdP2O/lGTHhPygWlvXe8Bb1n6zCLCRzUjMG4NhgoK6mMMY89rcgew+oVYa+BAlovD8i5kMIgUSvUlo6tfh2Z//GGo4XvYFVb88+u1Ecn4cXfBfa8dUdDs1l+QoE19uQibaf1YioG/L13ZddtCNeXdwm90Xb6Jy47X3fbCLHBcwH9ccguug6EG6WeYhqOhxO+4nEXEEP73j3XQYcrr7cVg6PvN9f+Q+0qnF4BiMId4Zpf5SPTI94Y4pENuqEq9rF6aPQxMlE45+3zbZwSoqjqHJl5CeosrOD8ybxeW50u4eUvfMCrJRZxDRaY2RHjjUvRmikZZ6gxFAtFXiC5/bZqFGhl8b3WvUp/t0rQnX6zsPV/k8uzS8LcB4TueBxN5sRCws/LCkat4kShBX0+D5NRhMFL9rUb X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(136003)(39860400002)(376002)(396003)(346002)(451199021)(46966006)(40470700004)(36840700001)(82310400005)(86362001)(41300700001)(7696005)(40480700001)(40460700003)(6916009)(6666004)(4326008)(316002)(36756003)(7416002)(70586007)(70206006)(36860700001)(5660300002)(2906002)(186003)(478600001)(26005)(1076003)(2616005)(47076005)(426003)(336012)(8676002)(54906003)(8936002)(82740400003)(356005)(7636003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 14:49:04.6549 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 77f7372c-a24a-45df-f5e1-08db611d03c2 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4462 Received-SPF: softfail client-ip=2a01:111:f400:7e8c::613; envelope-from=avihaih@nvidia.com; helo=NAM04-MW2-obe.outbound.protection.outlook.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add migration switchover ack capability test. The test runs without devices that support this capability, but is still useful to make sure it didn't break anything. Signed-off-by: Avihai Horon Reviewed-by: Juan Quintela Reviewed-by: Peter Xu --- tests/qtest/migration-test.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index b99b49a314..d246a5bbc5 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1648,6 +1648,28 @@ static void test_precopy_tcp_plain(void) test_precopy_common(&args); } +static void *test_migrate_switchover_ack_start(QTestState *from, QTestState *to) +{ + + migrate_set_capability(from, "return-path", true); + migrate_set_capability(to, "return-path", true); + + migrate_set_capability(from, "switchover-ack", true); + migrate_set_capability(to, "switchover-ack", true); + + return NULL; +} + +static void test_precopy_tcp_switchover_ack(void) +{ + MigrateCommon args = { + .listen_uri = "tcp:127.0.0.1:0", + .start_hook = test_migrate_switchover_ack_start, + }; + + test_precopy_common(&args); +} + #ifdef CONFIG_GNUTLS static void test_precopy_tcp_tls_psk_match(void) { @@ -2695,6 +2717,10 @@ int main(int argc, char **argv) #endif /* CONFIG_GNUTLS */ qtest_add_func("/migration/precopy/tcp/plain", test_precopy_tcp_plain); + + qtest_add_func("/migration/precopy/tcp/plain/switchover-ack", + test_precopy_tcp_switchover_ack); + #ifdef CONFIG_GNUTLS qtest_add_func("/migration/precopy/tcp/tls/psk/match", test_precopy_tcp_tls_psk_match); From patchwork Tue May 30 14:48:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 1787642 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=Df9ddKI5; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QVwJz1FT9z20Pc for ; Wed, 31 May 2023 00:49:23 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q40f0-0003BD-JJ; Tue, 30 May 2023 10:49:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q40et-0002cK-67 for qemu-devel@nongnu.org; Tue, 30 May 2023 10:49:11 -0400 Received: from mail-bn8nam04on20631.outbound.protection.outlook.com ([2a01:111:f400:7e8d::631] helo=NAM04-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q40en-0007qo-Tq for qemu-devel@nongnu.org; Tue, 30 May 2023 10:49:10 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=diFkmGboWATu2VhqosjNvHZQzFavK5VIg0fq5LHvaZJM5HrBKfu2RPOcj/ugM9OtikqCgKhuJ/QgQSSBRbStjDKdVeJ+KeVbU0JRj2QoTOv9I/osT0okU5DEP+CHDdM+vHE6caBxyrzAKYwS2p9+hVtIKsD9+h1dUJzOkz3CSX5FyT+qywVmmo1flf82GrNEXLKtTenoVtO5rh5IsADDaIsAJa5+cDKnbsXvrNcUOaHpLPMNISMC7jncOEbD2J3WfSydJXomd3ZnSp/crsinLGvslKKk+cNpPEiAiIYzigBQRoo0dTDwPs236+Nq8lrpx9xBkT1n2wnMY4rvqoXtyA== 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=h68j4Dm1Q/+H4wT8g4CxjcyAuM4Dnwee3te5mdFcdNY=; b=Z8pjTdAN8t1cvzyWYvEYvGnK0vLnxdH+93RxsBFYraT4pgXtcevwkQswjM0KHtpXLBNvbwL2boE+OYOnaE6YE+zOviQwtjE3sQT5LztvJGKbJRomYmPcxsnJFjZiKBxRNGaOGHJnPxTnd9AzWaxqP1dvrYTFPZfV8y6ypk+AfWZ0swV3BIVyeq/gaUJcLwWUbcKdL07lLus1mCrPM8Cr1EnUFuH6BlHbUamVTdUOhu3RG/tdeNEakvrROoouIA5c5ZmWNZRwOEEcEpEVbTI6tJxXNIl9jbFs8VR8FDea2E0Ol2tv1c3HFOtaNxWCw3qP5nFSlbi0EUhqubMh7/fPkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=h68j4Dm1Q/+H4wT8g4CxjcyAuM4Dnwee3te5mdFcdNY=; b=Df9ddKI5u6Fdx96bu3qIWUpdciJJ2lJQqaannMMugSvykUE3sFMIF0Cw4fAK2a220IUa+LRGU1LK+jkMEA/5LKaTd6S8ieaf0pVMr6MrtDyjsP8TgliFVfHURrVHfvDOZgt76wsA+AFwIB0W6trBfJWJb4/wTzooxA8NurFd94PB3tzHoDmeN3M0ArpB8/142zEDvC9wDWY/HpUCIqubjWmbQACYz62RuAcU2shqscXHfKis5ZsCkfFAwHYhWmNdrz9aMr5O/Lxo4vCiOs+r4QfWaM+t4Di2E2eRSeAoBLimKJw5vsps/0WbAk9WGQrGTOprfJbO1YIA6ToKjiMAmA== Received: from MW4PR04CA0043.namprd04.prod.outlook.com (2603:10b6:303:6a::18) by DM6PR12MB4314.namprd12.prod.outlook.com (2603:10b6:5:211::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Tue, 30 May 2023 14:49:01 +0000 Received: from CO1NAM11FT042.eop-nam11.prod.protection.outlook.com (2603:10b6:303:6a:cafe::7) by MW4PR04CA0043.outlook.office365.com (2603:10b6:303:6a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22 via Frontend Transport; Tue, 30 May 2023 14:49:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT042.mail.protection.outlook.com (10.13.174.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22 via Frontend Transport; Tue, 30 May 2023 14:49:01 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 30 May 2023 07:48:55 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 30 May 2023 07:48:55 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 30 May 2023 07:48:50 -0700 From: Avihai Horon To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Juan Quintela , Peter Xu , Leonardo Bras , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v5 5/9] vfio/migration: Refactor vfio_save_block() to return saved data size Date: Tue, 30 May 2023 17:48:17 +0300 Message-ID: <20230530144821.1557-6-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230530144821.1557-1-avihaih@nvidia.com> References: <20230530144821.1557-1-avihaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT042:EE_|DM6PR12MB4314:EE_ X-MS-Office365-Filtering-Correlation-Id: 48838fa7-2e3c-4faa-047f-08db611d01e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5JJ1oRs7AjBcpgTqusncJtVhTTLQxJukAFILpIySNEHlMGW/2hME9h3xpwpn5FVS7vBBj/cMKJmJ4wmXXoaKil/UFlzapDD0FnNA2kavMiGD27B8e+h0lN09PVJL+cYYFqHyLhLH9dAf8hAtL5RssGgABiCeAQBEFSjPGgOn8O1lSLtyXsiGlopFQarJOzW0VHuyKORyu0kyZPjznQmTn4/2OPERopYbwH754YNfJFTy00AdwxFiPCDgGmWgzKzX7IJ4w5w9Ts5CZjM5+QUVD4xet8ILRTJLdRa2CU1dJAFT5x9iOqcJWYjVrbyU52TrwweqZ08F0T0neo1HQMg7i/EO55heP945RqZvhd3mTzhJRZuuViVwgxrDOEEAQYpAIV4JkVFkrY2Vpzky8XI5jGQOIn73PGlOXezMJAwxbVb+HfT7yy9l6mXODoIqais6m4obnB8CLOMP/xzEiukVFUzPa7tJX3YZ8pte+7sA4Dz5DRbiajPlnqxufHiL2+QtRrvA/m5tRAUylEovPLYsYvx6T/6DILWxw+mEYt28p2uMPAp6NBQTgTeMuam8tRddMMJ8uwjXurvLY72sv/Eafm01gfDkbCiOsPzv4Pyt7+FZ+dOCN0zDZ7dFryyq3D9wCut2cwoyNA254sPEs0CskZArtHhailz9T3mLUrCoVBLXuPmezN5IaW/oeTeKerskVaB9UcE9USd67ZT9WK1wyjYhArZgHRVUPqkNyvyx5lUaPtajrtxMvZThXxGVOX7w X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(396003)(376002)(346002)(136003)(451199021)(40470700004)(46966006)(36840700001)(478600001)(40460700003)(54906003)(8936002)(8676002)(7416002)(5660300002)(82310400005)(36756003)(2906002)(86362001)(356005)(4326008)(7636003)(6916009)(70206006)(70586007)(82740400003)(316002)(40480700001)(41300700001)(2616005)(186003)(1076003)(26005)(47076005)(36860700001)(66574015)(6666004)(7696005)(426003)(336012)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 14:49:01.6048 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48838fa7-2e3c-4faa-047f-08db611d01e8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT042.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4314 Received-SPF: softfail client-ip=2a01:111:f400:7e8d::631; envelope-from=avihaih@nvidia.com; helo=NAM04-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Refactor vfio_save_block() to return the size of saved data on success and -errno on error. This will be used in next patch to implement VFIO migration pre-copy support. Signed-off-by: Avihai Horon Reviewed-by: Cédric Le Goater Reviewed-by: Juan Quintela --- hw/vfio/migration.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 6b58dddb88..235978fd68 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -241,8 +241,8 @@ static int vfio_query_stop_copy_size(VFIODevice *vbasedev, return 0; } -/* Returns 1 if end-of-stream is reached, 0 if more data and -errno if error */ -static int vfio_save_block(QEMUFile *f, VFIOMigration *migration) +/* Returns the size of saved data on success and -errno on error */ +static ssize_t vfio_save_block(QEMUFile *f, VFIOMigration *migration) { ssize_t data_size; @@ -252,7 +252,7 @@ static int vfio_save_block(QEMUFile *f, VFIOMigration *migration) return -errno; } if (data_size == 0) { - return 1; + return 0; } qemu_put_be64(f, VFIO_MIG_FLAG_DEV_DATA_STATE); @@ -262,7 +262,7 @@ static int vfio_save_block(QEMUFile *f, VFIOMigration *migration) trace_vfio_save_block(migration->vbasedev->name, data_size); - return qemu_file_get_error(f); + return qemu_file_get_error(f) ?: data_size; } /* ---------------------------------------------------------------------- */ @@ -335,6 +335,7 @@ static void vfio_state_pending_exact(void *opaque, uint64_t *must_precopy, static int vfio_save_complete_precopy(QEMUFile *f, void *opaque) { VFIODevice *vbasedev = opaque; + ssize_t data_size; int ret; /* We reach here with device state STOP only */ @@ -345,11 +346,11 @@ static int vfio_save_complete_precopy(QEMUFile *f, void *opaque) } do { - ret = vfio_save_block(f, vbasedev->migration); - if (ret < 0) { - return ret; + data_size = vfio_save_block(f, vbasedev->migration); + if (data_size < 0) { + return data_size; } - } while (!ret); + } while (data_size); qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); ret = qemu_file_get_error(f); From patchwork Tue May 30 14:48:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 1787650 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=ZoAoHk/l; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QVwKH6Cy8z20Pc for ; Wed, 31 May 2023 00:49:39 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q40fF-0004iB-NQ; Tue, 30 May 2023 10:49:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q40f0-0003BW-5M for qemu-devel@nongnu.org; Tue, 30 May 2023 10:49:18 -0400 Received: from mail-bn8nam12on2062b.outbound.protection.outlook.com ([2a01:111:f400:fe5b::62b] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q40ex-0007sd-24 for qemu-devel@nongnu.org; Tue, 30 May 2023 10:49:17 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JdwYDJU2s1g67/B9YFUj/MiFznDX7r+XqcapE4J9h/Ftxz2GGNnJ4uP62Q4sQFl9DjTairPgQ0k4uAMDgeSWgYK5+u0/4QdCfSvawLLPhbHbr+49LmkODDl0oZdWYkHhI+0l6TSNkQY/SCzGOPaog6kl7tCtva3C+JhJIT7oawWHNC7gh8uOOo73I5Cajnpq7Onhc6Mcj+BM7K/zlv8An4ujRF8/s9MzqrmeTiRA+oAzfVc0vcKVL1ZFxFFkWnCd6L3V7/lwOZJpKtn7y5RzaPXna7m8i5TbA7KPTP4JVe7Q+qEClBwpS4pWuIMLoIwp5lHV/rgNUPufeLHcLB2U4A== 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=ZhA/YmiyC04Ww+XJicjCWGfho1lz+NY/70626nKviN8=; b=ecMU4XHv+WRkn/dpfX5eO7/9FE/UzyrjYXrMjfQwlMKlFY7sSUEabFtAORj/106YyKQemxXSMtQYT94vhHQCxd/Tk5wOx8Z5JL68FWmxYrelU/zfWGF9vlj6R8HH36I2dsjO2PjamGJbiZkeeVa89moLbj24pb+Rlol/Ifa83/BKApsORVcQ6Z45bz20vvKbebAbMsr77GR99lfskyGLypOwCYbiEHyDhXykCUuVXsnkWK4FN4UxEJe8kwOuB/4jc+TUDoo7U6kOujU65kP5K9yVwSRMJGeqB1VAMnV62QGGR1OpsFszMUEdHhe96pPI8AfC3ywmeeRPvxP2tzjBFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZhA/YmiyC04Ww+XJicjCWGfho1lz+NY/70626nKviN8=; b=ZoAoHk/lUjEo0WwzyxdEX56l5ZL8RTqgi+jLjZkUkVF4IIM/Fn1qQ2wQRfitxHtcqMbbor0LHAO68LSbPvcFvn0m2h5tFBDtAhYitAWI6mudoUMnHzuM6qGDmiBX/n1qTZKoBOhjhijwla5xRBCOwXmidPwsY7kljp6RJusfcyK6rObH2mrMQYT6hARQTRjOlfe71cZdLP02y7BPxtqMPK2Tu5ztVoUNgKxGEstESoD9Yyf3R4R4l/cNiFf5bOFBKGpOBMxXw8wC1A0mLIaouKNjnqNoninZiJf11rAZSZYD7iKIHs0YjMMWhyGFTaNhykO32iqkqHjWxq9+fGInzQ== Received: from DM6PR02CA0155.namprd02.prod.outlook.com (2603:10b6:5:332::22) by DM4PR12MB5817.namprd12.prod.outlook.com (2603:10b6:8:60::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Tue, 30 May 2023 14:49:10 +0000 Received: from DM6NAM11FT105.eop-nam11.prod.protection.outlook.com (2603:10b6:5:332:cafe::33) by DM6PR02CA0155.outlook.office365.com (2603:10b6:5:332::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23 via Frontend Transport; Tue, 30 May 2023 14:49:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT105.mail.protection.outlook.com (10.13.173.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22 via Frontend Transport; Tue, 30 May 2023 14:49:10 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 30 May 2023 07:49:01 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 30 May 2023 07:49:01 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 30 May 2023 07:48:56 -0700 From: Avihai Horon To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Juan Quintela , Peter Xu , Leonardo Bras , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v5 6/9] vfio/migration: Store VFIO migration flags in VFIOMigration Date: Tue, 30 May 2023 17:48:18 +0300 Message-ID: <20230530144821.1557-7-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230530144821.1557-1-avihaih@nvidia.com> References: <20230530144821.1557-1-avihaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT105:EE_|DM4PR12MB5817:EE_ X-MS-Office365-Filtering-Correlation-Id: a8ea0f01-8469-4325-b76e-08db611d070e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eduXI9+gfFq5XwrCc3O8hxRwl6Bo3MXkrBSmEixJs7h5LjSbLRZBk5YvKT0sdjgyRJY1/4vG3y1RCoV4EOY7MNeIC27fTAtLAQB+8IWVTVEEryC42bESSJoPETFpXR+qxGIASuV/vBd5Y0F/5an6DGyb4mFtesttkMLTmxaldBI0Tgvg/21IiSju40O/yEjZWMdowF+lonP5Y5zQlvZkg4qzKUk3pM/9Hf/9Rt25DDfZp0dPZnsR66xEaXz3Nlgr4H73qaXdlWH7IX89y1Ol/hfip/OhwYTMumEwAVHZBghTZajUUUCRachMpd/Pb8h4C7r7AYOP0PtdcSEwI51PRSmgU28C42+UlqDPefBKSI9B69MOZJjFBqf6P53q1RCoqIbKLNzrGRUtftHk1RA90UHq2UbU2foqvX0mHMVg3PEAumb9Y/x5OdlZe8AN9MX+0inWhFt07AJX+8j3lVBnSOjJD6ZZvnVJYNlQc+hswtlQxEHYO4kJ7hI7uyWgWU80+P/M0lBPsInQgxu/7ryy8/XyOeukdzSHRpld/rM47W8ahauE/eKCivQ2zy/WtE44vNXk+3RqDFr2D9jXg/GoaBEbtHc6AAIBam+49fbfx8ziIRmpoDNSLWA+IrOCk0f9twt/IffpzXjOmZirF0D385Vh4RCiG2u/wumesYjQNE9oTgSBuHYZyKu0KD+LQlLvdLEvT1M7zYmfzt9p0VrX4cGIscYv3fz+flShrfAIGJsmgSm8grLJNhVbL/T1i9Mw X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(346002)(376002)(136003)(39860400002)(396003)(451199021)(46966006)(36840700001)(40470700004)(54906003)(478600001)(40460700003)(8936002)(7416002)(5660300002)(8676002)(2906002)(86362001)(82310400005)(6916009)(70206006)(70586007)(82740400003)(4326008)(7636003)(356005)(316002)(40480700001)(36756003)(41300700001)(2616005)(336012)(426003)(186003)(1076003)(26005)(47076005)(7696005)(36860700001)(6666004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 14:49:10.1533 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a8ea0f01-8469-4325-b76e-08db611d070e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT105.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5817 Received-SPF: softfail client-ip=2a01:111:f400:fe5b::62b; envelope-from=avihaih@nvidia.com; helo=NAM12-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org VFIO migration flags are queried once in vfio_migration_init(). Store them in VFIOMigration so they can be used later to check the device's migration capabilities without re-querying them. This will be used in the next patch to check if the device supports precopy migration. Signed-off-by: Avihai Horon Reviewed-by: Cédric Le Goater --- include/hw/vfio/vfio-common.h | 1 + hw/vfio/migration.c | 1 + 2 files changed, 2 insertions(+) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index eed244f25f..5f29dab839 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -66,6 +66,7 @@ typedef struct VFIOMigration { int data_fd; void *data_buffer; size_t data_buffer_size; + uint64_t mig_flags; } VFIOMigration; typedef struct VFIOAddressSpace { diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 235978fd68..8d33414379 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -603,6 +603,7 @@ static int vfio_migration_init(VFIODevice *vbasedev) migration->vbasedev = vbasedev; migration->device_state = VFIO_DEVICE_STATE_RUNNING; migration->data_fd = -1; + migration->mig_flags = mig_flags; vbasedev->dirty_pages_supported = vfio_dma_logging_supported(vbasedev); From patchwork Tue May 30 14:48:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 1787658 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=RSzrvLxn; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QVwLb2DdPz20Q4 for ; Wed, 31 May 2023 00:50:47 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q40f7-0003m2-QK; Tue, 30 May 2023 10:49:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q40f5-0003fW-AB for qemu-devel@nongnu.org; Tue, 30 May 2023 10:49:23 -0400 Received: from mail-bn1nam02on2060c.outbound.protection.outlook.com ([2a01:111:f400:7eb2::60c] helo=NAM02-BN1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q40f0-0007tZ-I0 for qemu-devel@nongnu.org; Tue, 30 May 2023 10:49:23 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NJebkwNbbFzow3DgO8BFmN6hdCGU+1LQk1Q4pke+CeC8FmFnD/H4mWeaA2mhCUenLnMYECtL0x9uXvOVz7WIuSmrR1Bus4nZVt+VxyqpWaU/kSIzKExB2XLPUZeUrG8T8p2UNN0SzCyE6OkBh8wVm8IbwCpjy10WB+ib1Xpsxo/q6dYwuJ8FCA40pgETFevHNB3jL0iTSUYKHJC8LNb7EwGlkVqx/Ne8Z7RXEPcfT32rkYz7wVXO/zVgquXIyHbmmnhwCMT0BrhpwVKVhhI/Gs7P98bqFs7ORwecUuy9eu7ChG+cJyJgSy5k1dQFlcv2/BcjR2b8pe8NSZt3udOr1w== 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=/oZU+HNaDXjCE88v99GPoErk1i83ZqSF8dxeplJClB8=; b=AtfDN/nxsUjjDEfD17t0Gr78Zhwv5ERwOu68ogyIZa9hRkl9URYIk+YbKN2HuyzO3Sd1txYv3r/iczC8Q4h1Za4VgHALvuMtE/8W3jRG+l2zUF+o5La20joJ7YSSjvTX1kii9pi2X/Y8oBVd9r4RTfhDksFf01zF+9yfe+hMRoYvtbiTE1Y2lvXhtWOaMb2f6FQ0DYBi2EZO6oiZGUvhWOIBtzlsvF7hnQWvirhBwNcTdHIVNZOugvjhzbPNYBbpjTU03fD/MqvkIYJt3CFMLpOBsLHQ5VKNiWBQVeL6GMJUnVXirbcF+ddap02TSiwsqZpOyegi80tzXAmBW2ZzTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/oZU+HNaDXjCE88v99GPoErk1i83ZqSF8dxeplJClB8=; b=RSzrvLxn++AmgE2fRpQKWt1ybAo48wlaDZTZY+LdL+IvjlY8zP/euvwXj2hyIbYFs8EkmaBSR2za83JiFBzL/rvt1cFBtpIyGNgJehww+pcWcRtC89/NSLzJnHb+JTzmBFyREICxragbW0kS+5AuDrciFmauQ850SpQEp/Vo0dMwVMhmzAvowJ+rccWi2ldcd21SFQY9DH0CfxGEJKOHVkWBV3If8FKVPeewO+GPtsZwp4quIT749m1HBcRX9k35XMqmAm4DGEwyb5xUgvNVERgd4Kr5nFvs0FnVZd96Yq+9Sg1t+gm4X21wTN5y6OvpybO44XzxpLq/GEjCZqtXUQ== Received: from BN0PR04CA0209.namprd04.prod.outlook.com (2603:10b6:408:e9::34) by IA1PR12MB6114.namprd12.prod.outlook.com (2603:10b6:208:3ea::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Tue, 30 May 2023 14:49:14 +0000 Received: from BN8NAM11FT079.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e9:cafe::d6) by BN0PR04CA0209.outlook.office365.com (2603:10b6:408:e9::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22 via Frontend Transport; Tue, 30 May 2023 14:49:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN8NAM11FT079.mail.protection.outlook.com (10.13.177.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22 via Frontend Transport; Tue, 30 May 2023 14:49:14 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 30 May 2023 07:49:07 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 30 May 2023 07:49:06 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 30 May 2023 07:49:01 -0700 From: Avihai Horon To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Juan Quintela , Peter Xu , Leonardo Bras , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v5 7/9] vfio/migration: Add VFIO migration pre-copy support Date: Tue, 30 May 2023 17:48:19 +0300 Message-ID: <20230530144821.1557-8-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230530144821.1557-1-avihaih@nvidia.com> References: <20230530144821.1557-1-avihaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT079:EE_|IA1PR12MB6114:EE_ X-MS-Office365-Filtering-Correlation-Id: 970190cf-02ca-4021-9438-08db611d099c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +SZet5DzTV8n2dlQ59Y4O1M4R75I/nL2FWEI+8y5z79cGkpbKDCrjYjmOcR6LxaKKgZYfS/rZi4wklbRDQFln8i/9tV7UA5zlnc+43ZFKweWOiEK6+pOLNULql9/cyJCRn/NAn3YzPaW+hEtoE8nYDw5duMVDAGjyV/ua1vtsPNoURdEd9hQ1krXdMDexZll/vCNzdDnJVIlTA3qK8MPw4vw3SEBq908/cNdEhMnzZFbEk9fJ6fmSdhl5bIF+ajarb62xtjyJhiAd125HjbkReziUZViIOYCwa776eYwlHQxl6zi0eifcHShAPfiNMeEjcwC06oDR0aps+t0lfgV0smKuhn6hVB1NAKXIx+kAZy8Q+03PkV8o3luXcl72avxSf65C12ULcmCLdXwQCScaSeZxjER9TOss7NjJrxU6kouGbmQhMeVE3IakhXr/vqaHjt8L3DKASfSZv6PTjULnu4PU3ELIjE5FDoY6lmudd6k01yaoOzh7pvBKSaov51xVfFFrLv/sokKzuYF06Cm2nucEr+e7z/q81KaVJdI52Wd6heQVnnxbd/feJvmelDOOSA+m1SBMIdr5SNUym1lffiaZ+RCZhp9bbSSEFg8AtRpHiebeypbtdcMlUYdAjrYzN59HfkmINPCcD0JPxHHuHvUH9PY+kFBfx5sL4zMZXB8y6eQfrPQCsWwqECLYlgwtBBnHI+NJKkxZGf+zsaJNniJMMazeX8ilabpsILds88GT/dqTrlIClZ3buQKhbXs X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(346002)(136003)(396003)(39860400002)(376002)(451199021)(40470700004)(46966006)(36840700001)(186003)(2616005)(41300700001)(426003)(336012)(83380400001)(1076003)(26005)(66574015)(7696005)(6666004)(36860700001)(47076005)(478600001)(40460700003)(54906003)(7636003)(4326008)(356005)(82740400003)(70206006)(70586007)(6916009)(40480700001)(316002)(8936002)(8676002)(5660300002)(7416002)(2906002)(86362001)(82310400005)(30864003)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 14:49:14.4384 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 970190cf-02ca-4021-9438-08db611d099c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT079.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6114 Received-SPF: softfail client-ip=2a01:111:f400:7eb2::60c; envelope-from=avihaih@nvidia.com; helo=NAM02-BN1-obe.outbound.protection.outlook.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Pre-copy support allows the VFIO device data to be transferred while the VM is running. This helps to accommodate VFIO devices that have a large amount of data that needs to be transferred, and it can reduce migration downtime. Pre-copy support is optional in VFIO migration protocol v2. Implement pre-copy of VFIO migration protocol v2 and use it for devices that support it. Full description of it can be found in the following Linux commit: 4db52602a607 ("vfio: Extend the device migration protocol with PRE_COPY"). Signed-off-by: Avihai Horon Reviewed-by: Cédric Le Goater --- docs/devel/vfio-migration.rst | 35 +++++--- include/hw/vfio/vfio-common.h | 2 + hw/vfio/common.c | 6 +- hw/vfio/migration.c | 165 ++++++++++++++++++++++++++++++++-- hw/vfio/trace-events | 4 +- 5 files changed, 190 insertions(+), 22 deletions(-) diff --git a/docs/devel/vfio-migration.rst b/docs/devel/vfio-migration.rst index 1b68ccf115..e896b2a673 100644 --- a/docs/devel/vfio-migration.rst +++ b/docs/devel/vfio-migration.rst @@ -7,12 +7,14 @@ the guest is running on source host and restoring this saved state on the destination host. This document details how saving and restoring of VFIO devices is done in QEMU. -Migration of VFIO devices currently consists of a single stop-and-copy phase. -During the stop-and-copy phase the guest is stopped and the entire VFIO device -data is transferred to the destination. - -The pre-copy phase of migration is currently not supported for VFIO devices. -Support for VFIO pre-copy will be added later on. +Migration of VFIO devices consists of two phases: the optional pre-copy phase, +and the stop-and-copy phase. The pre-copy phase is iterative and allows to +accommodate VFIO devices that have a large amount of data that needs to be +transferred. The iterative pre-copy phase of migration allows for the guest to +continue whilst the VFIO device state is transferred to the destination, this +helps to reduce the total downtime of the VM. VFIO devices opt-in to pre-copy +support by reporting the VFIO_MIGRATION_PRE_COPY flag in the +VFIO_DEVICE_FEATURE_MIGRATION ioctl. Note that currently VFIO migration is supported only for a single device. This is due to VFIO migration's lack of P2P support. However, P2P support is planned @@ -29,10 +31,20 @@ VFIO implements the device hooks for the iterative approach as follows: * A ``load_setup`` function that sets the VFIO device on the destination in _RESUMING state. +* A ``state_pending_estimate`` function that reports an estimate of the + remaining pre-copy data that the vendor driver has yet to save for the VFIO + device. + * A ``state_pending_exact`` function that reads pending_bytes from the vendor driver, which indicates the amount of data that the vendor driver has yet to save for the VFIO device. +* An ``is_active_iterate`` function that indicates ``save_live_iterate`` is + active only when the VFIO device is in pre-copy states. + +* A ``save_live_iterate`` function that reads the VFIO device's data from the + vendor driver during iterative pre-copy phase. + * A ``save_state`` function to save the device config space if it is present. * A ``save_live_complete_precopy`` function that sets the VFIO device in @@ -111,8 +123,10 @@ Flow of state changes during Live migration =========================================== Below is the flow of state change during live migration. -The values in the brackets represent the VM state, the migration state, and +The values in the parentheses represent the VM state, the migration state, and the VFIO device state, respectively. +The text in the square brackets represents the flow if the VFIO device supports +pre-copy. Live migration save path ------------------------ @@ -124,11 +138,12 @@ Live migration save path | migrate_init spawns migration_thread Migration thread then calls each device's .save_setup() - (RUNNING, _SETUP, _RUNNING) + (RUNNING, _SETUP, _RUNNING [_PRE_COPY]) | - (RUNNING, _ACTIVE, _RUNNING) - If device is active, get pending_bytes by .state_pending_exact() + (RUNNING, _ACTIVE, _RUNNING [_PRE_COPY]) + If device is active, get pending_bytes by .state_pending_{estimate,exact}() If total pending_bytes >= threshold_size, call .save_live_iterate() + [Data of VFIO device for pre-copy phase is copied] Iterate till total pending bytes converge and are less than threshold | On migration completion, vCPU stops and calls .save_live_complete_precopy for diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 5f29dab839..1db901c194 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -67,6 +67,8 @@ typedef struct VFIOMigration { void *data_buffer; size_t data_buffer_size; uint64_t mig_flags; + uint64_t precopy_init_size; + uint64_t precopy_dirty_size; } VFIOMigration; typedef struct VFIOAddressSpace { diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 78358ede27..b73086e17a 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -492,7 +492,8 @@ static bool vfio_devices_all_dirty_tracking(VFIOContainer *container) } if (vbasedev->pre_copy_dirty_page_tracking == ON_OFF_AUTO_OFF && - migration->device_state == VFIO_DEVICE_STATE_RUNNING) { + (migration->device_state == VFIO_DEVICE_STATE_RUNNING || + migration->device_state == VFIO_DEVICE_STATE_PRE_COPY)) { return false; } } @@ -537,7 +538,8 @@ static bool vfio_devices_all_running_and_mig_active(VFIOContainer *container) return false; } - if (migration->device_state == VFIO_DEVICE_STATE_RUNNING) { + if (migration->device_state == VFIO_DEVICE_STATE_RUNNING || + migration->device_state == VFIO_DEVICE_STATE_PRE_COPY) { continue; } else { return false; diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 8d33414379..d8f6a22ae1 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -68,6 +68,8 @@ static const char *mig_state_to_str(enum vfio_device_mig_state state) return "STOP_COPY"; case VFIO_DEVICE_STATE_RESUMING: return "RESUMING"; + case VFIO_DEVICE_STATE_PRE_COPY: + return "PRE_COPY"; default: return "UNKNOWN STATE"; } @@ -241,6 +243,25 @@ static int vfio_query_stop_copy_size(VFIODevice *vbasedev, return 0; } +static int vfio_query_precopy_size(VFIOMigration *migration) +{ + struct vfio_precopy_info precopy = { + .argsz = sizeof(precopy), + }; + + migration->precopy_init_size = 0; + migration->precopy_dirty_size = 0; + + if (ioctl(migration->data_fd, VFIO_MIG_GET_PRECOPY_INFO, &precopy)) { + return -errno; + } + + migration->precopy_init_size = precopy.initial_bytes; + migration->precopy_dirty_size = precopy.dirty_bytes; + + return 0; +} + /* Returns the size of saved data on success and -errno on error */ static ssize_t vfio_save_block(QEMUFile *f, VFIOMigration *migration) { @@ -249,6 +270,14 @@ static ssize_t vfio_save_block(QEMUFile *f, VFIOMigration *migration) data_size = read(migration->data_fd, migration->data_buffer, migration->data_buffer_size); if (data_size < 0) { + /* + * Pre-copy emptied all the device state for now. For more information, + * please refer to the Linux kernel VFIO uAPI. + */ + if (errno == ENOMSG) { + return 0; + } + return -errno; } if (data_size == 0) { @@ -265,6 +294,38 @@ static ssize_t vfio_save_block(QEMUFile *f, VFIOMigration *migration) return qemu_file_get_error(f) ?: data_size; } +static void vfio_update_estimated_pending_data(VFIOMigration *migration, + uint64_t data_size) +{ + if (!data_size) { + /* + * Pre-copy emptied all the device state for now, update estimated sizes + * accordingly. + */ + migration->precopy_init_size = 0; + migration->precopy_dirty_size = 0; + + return; + } + + if (migration->precopy_init_size) { + uint64_t init_size = MIN(migration->precopy_init_size, data_size); + + migration->precopy_init_size -= init_size; + data_size -= init_size; + } + + migration->precopy_dirty_size -= MIN(migration->precopy_dirty_size, + data_size); +} + +static bool vfio_precopy_supported(VFIODevice *vbasedev) +{ + VFIOMigration *migration = vbasedev->migration; + + return migration->mig_flags & VFIO_MIGRATION_PRE_COPY; +} + /* ---------------------------------------------------------------------- */ static int vfio_save_setup(QEMUFile *f, void *opaque) @@ -285,6 +346,28 @@ static int vfio_save_setup(QEMUFile *f, void *opaque) return -ENOMEM; } + if (vfio_precopy_supported(vbasedev)) { + int ret; + + switch (migration->device_state) { + case VFIO_DEVICE_STATE_RUNNING: + ret = vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_PRE_COPY, + VFIO_DEVICE_STATE_RUNNING); + if (ret) { + return ret; + } + + vfio_query_precopy_size(migration); + + break; + case VFIO_DEVICE_STATE_STOP: + /* vfio_save_complete_precopy() will go to STOP_COPY */ + break; + default: + return -EINVAL; + } + } + trace_vfio_save_setup(vbasedev->name, migration->data_buffer_size); qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); @@ -299,26 +382,42 @@ static void vfio_save_cleanup(void *opaque) g_free(migration->data_buffer); migration->data_buffer = NULL; + migration->precopy_init_size = 0; + migration->precopy_dirty_size = 0; vfio_migration_cleanup(vbasedev); trace_vfio_save_cleanup(vbasedev->name); } +static void vfio_state_pending_estimate(void *opaque, uint64_t *must_precopy, + uint64_t *can_postcopy) +{ + VFIODevice *vbasedev = opaque; + VFIOMigration *migration = vbasedev->migration; + + if (migration->device_state != VFIO_DEVICE_STATE_PRE_COPY) { + return; + } + + *must_precopy += + migration->precopy_init_size + migration->precopy_dirty_size; + + trace_vfio_state_pending_estimate(vbasedev->name, *must_precopy, + *can_postcopy, + migration->precopy_init_size, + migration->precopy_dirty_size); +} + /* * Migration size of VFIO devices can be as little as a few KBs or as big as * many GBs. This value should be big enough to cover the worst case. */ #define VFIO_MIG_STOP_COPY_SIZE (100 * GiB) -/* - * Only exact function is implemented and not estimate function. The reason is - * that during pre-copy phase of migration the estimate function is called - * repeatedly while pending RAM size is over the threshold, thus migration - * can't converge and querying the VFIO device pending data size is useless. - */ static void vfio_state_pending_exact(void *opaque, uint64_t *must_precopy, uint64_t *can_postcopy) { VFIODevice *vbasedev = opaque; + VFIOMigration *migration = vbasedev->migration; uint64_t stop_copy_size = VFIO_MIG_STOP_COPY_SIZE; /* @@ -328,8 +427,48 @@ static void vfio_state_pending_exact(void *opaque, uint64_t *must_precopy, vfio_query_stop_copy_size(vbasedev, &stop_copy_size); *must_precopy += stop_copy_size; + if (migration->device_state == VFIO_DEVICE_STATE_PRE_COPY) { + vfio_query_precopy_size(migration); + + *must_precopy += + migration->precopy_init_size + migration->precopy_dirty_size; + } + trace_vfio_state_pending_exact(vbasedev->name, *must_precopy, *can_postcopy, - stop_copy_size); + stop_copy_size, migration->precopy_init_size, + migration->precopy_dirty_size); +} + +static bool vfio_is_active_iterate(void *opaque) +{ + VFIODevice *vbasedev = opaque; + VFIOMigration *migration = vbasedev->migration; + + return migration->device_state == VFIO_DEVICE_STATE_PRE_COPY; +} + +static int vfio_save_iterate(QEMUFile *f, void *opaque) +{ + VFIODevice *vbasedev = opaque; + VFIOMigration *migration = vbasedev->migration; + ssize_t data_size; + + data_size = vfio_save_block(f, migration); + if (data_size < 0) { + return data_size; + } + qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); + + vfio_update_estimated_pending_data(migration, data_size); + + trace_vfio_save_iterate(vbasedev->name, migration->precopy_init_size, + migration->precopy_dirty_size); + + /* + * A VFIO device's pre-copy dirty_bytes is not guaranteed to reach zero. + * Return 1 so following handlers will not be potentially blocked. + */ + return 1; } static int vfio_save_complete_precopy(QEMUFile *f, void *opaque) @@ -338,7 +477,7 @@ static int vfio_save_complete_precopy(QEMUFile *f, void *opaque) ssize_t data_size; int ret; - /* We reach here with device state STOP only */ + /* We reach here with device state STOP or STOP_COPY only */ ret = vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_STOP_COPY, VFIO_DEVICE_STATE_STOP); if (ret) { @@ -457,7 +596,10 @@ static int vfio_load_state(QEMUFile *f, void *opaque, int version_id) static const SaveVMHandlers savevm_vfio_handlers = { .save_setup = vfio_save_setup, .save_cleanup = vfio_save_cleanup, + .state_pending_estimate = vfio_state_pending_estimate, .state_pending_exact = vfio_state_pending_exact, + .is_active_iterate = vfio_is_active_iterate, + .save_live_iterate = vfio_save_iterate, .save_live_complete_precopy = vfio_save_complete_precopy, .save_state = vfio_save_state, .load_setup = vfio_load_setup, @@ -470,13 +612,18 @@ static const SaveVMHandlers savevm_vfio_handlers = { static void vfio_vmstate_change(void *opaque, bool running, RunState state) { VFIODevice *vbasedev = opaque; + VFIOMigration *migration = vbasedev->migration; enum vfio_device_mig_state new_state; int ret; if (running) { new_state = VFIO_DEVICE_STATE_RUNNING; } else { - new_state = VFIO_DEVICE_STATE_STOP; + new_state = + (migration->device_state == VFIO_DEVICE_STATE_PRE_COPY && + (state == RUN_STATE_FINISH_MIGRATE || state == RUN_STATE_PAUSED)) ? + VFIO_DEVICE_STATE_STOP_COPY : + VFIO_DEVICE_STATE_STOP; } /* diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 646e42fd27..4150b59e58 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -162,6 +162,8 @@ vfio_save_block(const char *name, int data_size) " (%s) data_size %d" vfio_save_cleanup(const char *name) " (%s)" vfio_save_complete_precopy(const char *name, int ret) " (%s) ret %d" vfio_save_device_config_state(const char *name) " (%s)" +vfio_save_iterate(const char *name, uint64_t precopy_init_size, uint64_t precopy_dirty_size) " (%s) precopy initial size 0x%"PRIx64" precopy dirty size 0x%"PRIx64 vfio_save_setup(const char *name, uint64_t data_buffer_size) " (%s) data buffer size 0x%"PRIx64 -vfio_state_pending_exact(const char *name, uint64_t precopy, uint64_t postcopy, uint64_t stopcopy_size) " (%s) precopy 0x%"PRIx64" postcopy 0x%"PRIx64" stopcopy size 0x%"PRIx64 +vfio_state_pending_estimate(const char *name, uint64_t precopy, uint64_t postcopy, uint64_t precopy_init_size, uint64_t precopy_dirty_size) " (%s) precopy 0x%"PRIx64" postcopy 0x%"PRIx64" precopy initial size 0x%"PRIx64" precopy dirty size 0x%"PRIx64 +vfio_state_pending_exact(const char *name, uint64_t precopy, uint64_t postcopy, uint64_t stopcopy_size, uint64_t precopy_init_size, uint64_t precopy_dirty_size) " (%s) precopy 0x%"PRIx64" postcopy 0x%"PRIx64" stopcopy size 0x%"PRIx64" precopy initial size 0x%"PRIx64" precopy dirty size 0x%"PRIx64 vfio_vmstate_change(const char *name, int running, const char *reason, const char *dev_state) " (%s) running %d reason %s device state %s" From patchwork Tue May 30 14:48:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 1787655 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=NiUTITLY; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QVwKw2bkKz20Q5 for ; Wed, 31 May 2023 00:50:12 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q40fd-0006TR-3s; Tue, 30 May 2023 10:49:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q40fF-0004iS-IC for qemu-devel@nongnu.org; Tue, 30 May 2023 10:49:33 -0400 Received: from mail-mw2nam12on20627.outbound.protection.outlook.com ([2a01:111:f400:fe5a::627] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q40fB-0007wH-OD for qemu-devel@nongnu.org; Tue, 30 May 2023 10:49:33 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i8IvR4ebtSvMR8HuqHvww44hNxi1LzdKt3cvLBH7W7fSB0sjg0lCq1+154z/3Fn/IHcY2ISV39gT97GbUK9dEL1pWj1WeRZmtm30TkCxDPmWVXmyl+3n+2Gq2g2p/NraWeDlx0/YvyiqUDvohFYUiAUwEBZwT6cGAFmpPgDoWZzpYUcbKRxxGGBfy2ah/HYXlxXr5MJLtLkHt4/PXHAdJeFGR4JI1DGOZ+lpqvaxdbC0zsIS8LNVGFyPIzzLXSblFSjxsRK9n8cj3rS3Sge4KOJM3asxsD4+uli7Ggvg9kee7eEnvoMb6rbeGrWzJCJEU6RGOVN7s+jT7HM8m5ba8g== 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=y8EMmkAUj7UEj6LiCM3s48xo/zMKo4/HfkUMdq2oR8I=; b=VVu+3e4vzO9jm1mQ7C7R6VLZF4DPRhZS0cxF7Gg1rr3/jB+m9ZmArAoNI3FcbYyUiLJ//nMU3hPn4YDVXmzp+zVPP+E/+A102M/QsJudtZXlA+5JW/VLTA7kklf2n8UpCpe5DY30cLsld/m5SVehtlExEOcHjLiIRU6hS6e0Umy+1f+4T3i8VLq9ts6a9w4S5JNCMancvPSN35kcFiGBUEEOrRTsc6EJ4T/Tjz36t4Efr17EtJOtG1VpHvIccI6wUo9eVDkSFbZDqop8Gq5xJHP19p965enRYeW6x5MHDcQrkT/Pc/4VY/A66OLkLHoE/lM24RXeTLLPp3ukMgiT6A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=y8EMmkAUj7UEj6LiCM3s48xo/zMKo4/HfkUMdq2oR8I=; b=NiUTITLYBzd7LR+DBkJXCLcyUy2W54V/jZI6CtHRCyC8aebtivXPPuxylEMOQCGjKVQURQEjg34gDdFdmTF0ev2CukbcGxrESj8XcBa9fQrrL00ajK6NuPfseUDp7cHQkhSjmz3qvIMUHG3QUK6u17voNYc//b4LMN5Pz2zH109WWRR6zzQQnETsM0XZmtUza2r3+7mykeWX1JIazyN7aH1YzS27Nz9BJ8EDrgoITug0Boj40Vo+3leHCKYa/APpoimM5w1LtJEFgUN/U1Hfi9Sq74eFXS/jjMk+8ZkvMOmjsbq0hVNPo3hAky8tX8a2FjrMbNX3+PDnjchK9MFHwQ== Received: from BN0PR04CA0107.namprd04.prod.outlook.com (2603:10b6:408:ec::22) by CYYPR12MB9015.namprd12.prod.outlook.com (2603:10b6:930:c8::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Tue, 30 May 2023 14:49:25 +0000 Received: from BN8NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ec:cafe::26) by BN0PR04CA0107.outlook.office365.com (2603:10b6:408:ec::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22 via Frontend Transport; Tue, 30 May 2023 14:49:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN8NAM11FT050.mail.protection.outlook.com (10.13.177.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22 via Frontend Transport; Tue, 30 May 2023 14:49:25 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 30 May 2023 07:49:12 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 30 May 2023 07:49:12 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 30 May 2023 07:49:07 -0700 From: Avihai Horon To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Juan Quintela , Peter Xu , Leonardo Bras , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v5 8/9] vfio/migration: Add x-allow-pre-copy VFIO device property Date: Tue, 30 May 2023 17:48:20 +0300 Message-ID: <20230530144821.1557-9-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230530144821.1557-1-avihaih@nvidia.com> References: <20230530144821.1557-1-avihaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT050:EE_|CYYPR12MB9015:EE_ X-MS-Office365-Filtering-Correlation-Id: 0ecb00e1-423b-4018-edc9-08db611d1017 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uFv70Q1+tEZFOkDyXRfHM+rYzNg2SswIHzTCtqTYoWAlIs5uDFIz+ul7dcZbTPgr3ccr/qL0XqOKIi2MQUx5QqxpE1qnXh8c+rPZVrtUNpdpqHUfMD0zk53yyFMl8oNS5zPLjgEyPGqdjGNZ3vU49HIhkpVGSlPLIg31XMnpmfNfqq7RhvzNDJplAxqGm3zIdHNxUC2OK3woifBsDmJUph9haa7b7sDmRYRfGtg37+55XnQcrPpTN2qrECbYNl3nGUfycBG7QQorBCuBl6u/WHlAQBXYThinUw5NwS8raWOKNVzJjRxpxok/SIFsaARE0qM2kTk7ZsaQhSdbQCrbu+iK2bHMBJeMCSGNn+h1liM3IN3oIL4mHp58/ZZMlIugNI22uZEcTOz7D00WWOLaYXhIxARchKAPRBd1xp3BfTre7MdVnwYya7dG8hWVo36XIBdbqswHG4/TtLi5xDgjeQMZNTmuLxaE5jZHOoFx0VcRijo3NEVxBEGg0zmhYNL9OWVi0pNtl0ULHMkIVGlbonCC5aoQzXnDfi0Cc9Be1HoWr3kY3UmqMj6TlwN0goTvhyHKLeMleItxgQlWtEBX9Ec3GZe0ld+Cidwsl+J1z414rm1Z3ebGNVE8e2hdmVjgYQK4L82fKGU6HK+zq2dmSklURXKMJu9h9WBT1Fn/tpRoYYf7LexgUZEdOaSfow/fz+x8RxwCylwTMtrruhIYmygYpwWLDr5zUF6ybpynLDKBFWHod/J9k9quaANIJcLA X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(396003)(346002)(39860400002)(376002)(136003)(451199021)(36840700001)(46966006)(40470700004)(54906003)(478600001)(40460700003)(8936002)(7416002)(5660300002)(8676002)(2906002)(86362001)(82310400005)(6916009)(70206006)(70586007)(82740400003)(4326008)(356005)(7636003)(316002)(40480700001)(36756003)(41300700001)(186003)(36860700001)(66574015)(1076003)(26005)(47076005)(7696005)(336012)(426003)(6666004)(83380400001)(2616005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 14:49:25.3131 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0ecb00e1-423b-4018-edc9-08db611d1017 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB9015 Received-SPF: softfail client-ip=2a01:111:f400:fe5a::627; envelope-from=avihaih@nvidia.com; helo=NAM12-MW2-obe.outbound.protection.outlook.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add a new VFIO device property x-allow-pre-copy to keep migration compatibility to/from older QEMU versions that don't have VFIO pre-copy support. Signed-off-by: Avihai Horon Reviewed-by: Cédric Le Goater --- include/hw/vfio/vfio-common.h | 1 + hw/core/machine.c | 1 + hw/vfio/migration.c | 3 ++- hw/vfio/pci.c | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 1db901c194..a53ecbe2e0 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -146,6 +146,7 @@ typedef struct VFIODevice { VFIOMigration *migration; Error *migration_blocker; OnOffAuto pre_copy_dirty_page_tracking; + bool allow_pre_copy; bool dirty_pages_supported; bool dirty_tracking; } VFIODevice; diff --git a/hw/core/machine.c b/hw/core/machine.c index 1000406211..64ac3fe38e 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -41,6 +41,7 @@ GlobalProperty hw_compat_8_0[] = { { "migration", "multifd-flush-after-each-section", "on"}, + { "vfio-pci", "x-allow-pre-copy", "false" }, }; const size_t hw_compat_8_0_len = G_N_ELEMENTS(hw_compat_8_0); diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index d8f6a22ae1..cb6923ed3f 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -323,7 +323,8 @@ static bool vfio_precopy_supported(VFIODevice *vbasedev) { VFIOMigration *migration = vbasedev->migration; - return migration->mig_flags & VFIO_MIGRATION_PRE_COPY; + return vbasedev->allow_pre_copy && + migration->mig_flags & VFIO_MIGRATION_PRE_COPY; } /* ---------------------------------------------------------------------- */ diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 73874a94de..c69813af7f 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3335,6 +3335,8 @@ static Property vfio_pci_dev_properties[] = { DEFINE_PROP_ON_OFF_AUTO("x-pre-copy-dirty-page-tracking", VFIOPCIDevice, vbasedev.pre_copy_dirty_page_tracking, ON_OFF_AUTO_ON), + DEFINE_PROP_BOOL("x-allow-pre-copy", VFIOPCIDevice, + vbasedev.allow_pre_copy, true), DEFINE_PROP_ON_OFF_AUTO("display", VFIOPCIDevice, display, ON_OFF_AUTO_OFF), DEFINE_PROP_UINT32("xres", VFIOPCIDevice, display_xres, 0), From patchwork Tue May 30 14:48:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 1787657 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=VKTdsLjh; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QVwLS6DyLz20Q4 for ; Wed, 31 May 2023 00:50:40 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q40fO-0005ZV-Cb; Tue, 30 May 2023 10:49:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q40fM-0005UP-K1 for qemu-devel@nongnu.org; Tue, 30 May 2023 10:49:40 -0400 Received: from mail-dm6nam12on20608.outbound.protection.outlook.com ([2a01:111:f400:fe59::608] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q40fI-0007yA-ND for qemu-devel@nongnu.org; Tue, 30 May 2023 10:49:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lf52lOltIF4qEG7IODhkDzOvK+uhLeUDqr66ZAN5xyUCnFHPZxuOP2gjdc7+JT+hOzP+agTm97TuDjidnrM1hNAem6qSEQgc6o3VLRUOBQYC/8WdUpJ7jfp/3K/LassPudSEOynL0CzerSBaHOE2f6nmhJG3eGAOLDBw0Le5h8r7T3jG6mJBi7qFNkfgxn6GGATZND39+siUjDgwRfXmrGX2IY/GKb2OwMHxzgEcaLpsGTo1M9l7M6UlDPzxUwgfj7UGA4ND+WlsQTYG7jq+YbD4VSnbUSENyNeYNks+tkkveP0nWZk5Vxn8lxnbP2UQaWOysK0Eth5OixPhA8MGBA== 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=27F7Ri/Y0M8H2u+JoESRWW1H0K+P0QrLumfhQi20sNg=; b=i9bh9IRpRgpIRXtcQIc59f87Miqo8BG4tpvZKar/CglsEBxytPbdt32yfNuYFW0YVa3h3ZknP5RXce3aA9u/CUbj1etdoPrUyJO0tc/ZRfQHzYsDDNafWA6MXLnzXW0j10GzKDAV30W2M1nU43/k2BP/SeKQbjqKHbb1uRGR/s2bSufMfHNxU+aUOt/uLuAgCALC2/fwOWEx68YzbfVm+BQNp4bZAbRVXYjevRt5t6dHoljDWf/ZJFGhv7PGiozv1brMljiuMHRHRDoGapKsEIEVDZqTHjaXXcY8k6u9t0vpjesvd7N7aeASptOy1hAcejHGpwC8kjBhGO8OLoo4lw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=27F7Ri/Y0M8H2u+JoESRWW1H0K+P0QrLumfhQi20sNg=; b=VKTdsLjh+15ql7BNoz88NFm0ocyG3hCp2cqycUrd+zWrwtpO2Cy3yEACoK/pp9DLsMt2Y+fyn3aDqwPjiGOEXNcDx8Tn/8cxnurKxLaPygaSTtiGZnNRsCDRndN+1BR7IbukybdK3YsSv42i2eUblYCNtG0XI+7H+IDrN7Lb74MWpr8QVsN4H9Fs/X19iFCk/hil2HEzmrZukTN+ZUtyyuH1x7KpWCY+HREN2rZim+iNPnaW421fwjNo6TMgVR2Kis8Rps9xaEGyrMmQYktBiuvatO8yDnmNKMPkQwNc2PEoSB/6r8ar03DieXx7sWRI6xFoY5SuhccakIVunzsbXg== Received: from DS7P222CA0001.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::7) by DS0PR12MB9037.namprd12.prod.outlook.com (2603:10b6:8:f1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Tue, 30 May 2023 14:49:33 +0000 Received: from DM6NAM11FT110.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2e:cafe::c9) by DS7P222CA0001.outlook.office365.com (2603:10b6:8:2e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23 via Frontend Transport; Tue, 30 May 2023 14:49:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT110.mail.protection.outlook.com (10.13.173.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22 via Frontend Transport; Tue, 30 May 2023 14:49:32 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 30 May 2023 07:49:18 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 30 May 2023 07:49:17 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 30 May 2023 07:49:12 -0700 From: Avihai Horon To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Juan Quintela , Peter Xu , Leonardo Bras , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v5 9/9] vfio/migration: Add support for switchover ack capability Date: Tue, 30 May 2023 17:48:21 +0300 Message-ID: <20230530144821.1557-10-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230530144821.1557-1-avihaih@nvidia.com> References: <20230530144821.1557-1-avihaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT110:EE_|DS0PR12MB9037:EE_ X-MS-Office365-Filtering-Correlation-Id: 453c6842-54cd-4584-8806-08db611d1474 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KpSrLIASNLHba6ISvpwKl7/1Z/Av94/4XQoQph1ZFmEl1JyNt0s7ZsIzZQ2LpNro5e8rcHSmSzECqymblMbZq+t0fYeySFWXRIBKFEbXgJGvAJG7VsqkFNYSolG6uc408rghyzuaUtPfF1wec1Hnj9qZUUT63gdUjAT8pvloClqFfM1uokZArJbqXu+RsXGbXxAyeBqxVdBN+i04C+Ui0ebM6EZhSvhu8SQrdpK/DerMxpwfR/Psm1Z4jHOdQECvSbCLymJTHnojcMvwnXGPSOvYNBsyRAyWWNl7UxJeMMnM2OBUWjZgh8u+4Dtg7iDf87rVKLiXoA1TQSn9zeGzQfDQQAV6wTyW2l8lDuAFL6N3ptYxrnZnvDhXbUMCU6ED7n4gDvNKaxZSxSwjTlIn6pqTtYdCbCWQ/jNcsSiXtvjriGFpDFMhY0RJeV/tpvkhTjo/kMUKMqcagCqkmOQeqHh52anYYODloWjZh1NmNbJ2itvmBAFDu9uPCSw2F8IfzZMxj0kgXd6K+Nm6Sc2S6+F+FFZQKoSURQtRjpQ4x1XMDXkUfR3Jb4UBrfWzadKr4YqGe3iEj/pzcUxcNYlwjaamfCxjpJpOLenLblx5r3s3lEmEu1UBbSUz5fk1DxmoZuahNJ3YdzyOX1BQivG/HUw2LbnJ7zjYVkXqHjsfdIao+sAdOdRAblNBUxJjvBIN+Cwn+PNO625zVe6B13az2R0HXIHANX+fLEjOZEVlMoAK/6XXydHNB3YTKH4CJaNU X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(346002)(136003)(39860400002)(376002)(396003)(451199021)(40470700004)(36840700001)(46966006)(186003)(2616005)(41300700001)(426003)(336012)(83380400001)(1076003)(26005)(7696005)(6666004)(36860700001)(47076005)(478600001)(40460700003)(54906003)(356005)(7636003)(4326008)(82740400003)(70206006)(70586007)(6916009)(40480700001)(316002)(8936002)(8676002)(5660300002)(7416002)(2906002)(86362001)(82310400005)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 14:49:32.6778 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 453c6842-54cd-4584-8806-08db611d1474 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT110.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB9037 Received-SPF: softfail client-ip=2a01:111:f400:fe59::608; envelope-from=avihaih@nvidia.com; helo=NAM12-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Loading of a VFIO device's data can take a substantial amount of time as the device may need to allocate resources, prepare internal data structures, etc. This can increase migration downtime, especially for VFIO devices with a lot of resources. To solve this, VFIO migration uAPI defines "initial bytes" as part of its precopy data stream. Initial bytes can be used in various ways to improve VFIO migration performance. For example, it can be used to transfer device metadata to pre-allocate resources in the destination. However, for this to work we need to make sure that all initial bytes are sent and loaded in the destination before the source VM is stopped. Use migration switchover ack capability to make sure a VFIO device's initial bytes are sent and loaded in the destination before the source stops the VM and attempts to complete the migration. This can significantly reduce migration downtime for some devices. As precopy support and precopy initial bytes support come together in VFIO migration, use x-allow-pre-copy device property to control usage of this feature as well. Signed-off-by: Avihai Horon Reviewed-by: Cédric Le Goater --- docs/devel/vfio-migration.rst | 10 +++++++++ include/hw/vfio/vfio-common.h | 1 + hw/vfio/migration.c | 39 ++++++++++++++++++++++++++++++++++- 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/docs/devel/vfio-migration.rst b/docs/devel/vfio-migration.rst index e896b2a673..b433cb5bb2 100644 --- a/docs/devel/vfio-migration.rst +++ b/docs/devel/vfio-migration.rst @@ -16,6 +16,13 @@ helps to reduce the total downtime of the VM. VFIO devices opt-in to pre-copy support by reporting the VFIO_MIGRATION_PRE_COPY flag in the VFIO_DEVICE_FEATURE_MIGRATION ioctl. +When pre-copy is supported, it's possible to further reduce downtime by +enabling "switchover-ack" migration capability. +VFIO migration uAPI defines "initial bytes" as part of its pre-copy data stream +and recommends that the initial bytes are sent and loaded in the destination +before stopping the source VM. Enabling this migration capability will +guarantee that and thus, can potentially reduce downtime even further. + Note that currently VFIO migration is supported only for a single device. This is due to VFIO migration's lack of P2P support. However, P2P support is planned to be added later on. @@ -45,6 +52,9 @@ VFIO implements the device hooks for the iterative approach as follows: * A ``save_live_iterate`` function that reads the VFIO device's data from the vendor driver during iterative pre-copy phase. +* A ``switchover_ack_needed`` function that checks if the VFIO device uses + "switchover-ack" migration capability when this capability is enabled. + * A ``save_state`` function to save the device config space if it is present. * A ``save_live_complete_precopy`` function that sets the VFIO device in diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index a53ecbe2e0..3677aba4f4 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -69,6 +69,7 @@ typedef struct VFIOMigration { uint64_t mig_flags; uint64_t precopy_init_size; uint64_t precopy_dirty_size; + bool initial_data_sent; } VFIOMigration; typedef struct VFIOAddressSpace { diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index cb6923ed3f..53f5787f0e 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -18,6 +18,8 @@ #include "sysemu/runstate.h" #include "hw/vfio/vfio-common.h" #include "migration/migration.h" +#include "migration/options.h" +#include "migration/savevm.h" #include "migration/vmstate.h" #include "migration/qemu-file.h" #include "migration/register.h" @@ -45,6 +47,7 @@ #define VFIO_MIG_FLAG_DEV_CONFIG_STATE (0xffffffffef100002ULL) #define VFIO_MIG_FLAG_DEV_SETUP_STATE (0xffffffffef100003ULL) #define VFIO_MIG_FLAG_DEV_DATA_STATE (0xffffffffef100004ULL) +#define VFIO_MIG_FLAG_DEV_INIT_DATA_SENT (0xffffffffef100005ULL) /* * This is an arbitrary size based on migration of mlx5 devices, where typically @@ -385,6 +388,7 @@ static void vfio_save_cleanup(void *opaque) migration->data_buffer = NULL; migration->precopy_init_size = 0; migration->precopy_dirty_size = 0; + migration->initial_data_sent = false; vfio_migration_cleanup(vbasedev); trace_vfio_save_cleanup(vbasedev->name); } @@ -458,10 +462,17 @@ static int vfio_save_iterate(QEMUFile *f, void *opaque) if (data_size < 0) { return data_size; } - qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); vfio_update_estimated_pending_data(migration, data_size); + if (migrate_switchover_ack() && !migration->precopy_init_size && + !migration->initial_data_sent) { + qemu_put_be64(f, VFIO_MIG_FLAG_DEV_INIT_DATA_SENT); + migration->initial_data_sent = true; + } else { + qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); + } + trace_vfio_save_iterate(vbasedev->name, migration->precopy_init_size, migration->precopy_dirty_size); @@ -580,6 +591,24 @@ static int vfio_load_state(QEMUFile *f, void *opaque, int version_id) } break; } + case VFIO_MIG_FLAG_DEV_INIT_DATA_SENT: + { + if (!vfio_precopy_supported(vbasedev) || + !migrate_switchover_ack()) { + error_report("%s: Received INIT_DATA_SENT but switchover ack " + "is not used", vbasedev->name); + return -EINVAL; + } + + ret = qemu_loadvm_approve_switchover(); + if (ret) { + error_report( + "%s: qemu_loadvm_approve_switchover failed, err=%d (%s)", + vbasedev->name, ret, strerror(-ret)); + } + + return ret; + } default: error_report("%s: Unknown tag 0x%"PRIx64, vbasedev->name, data); return -EINVAL; @@ -594,6 +623,13 @@ static int vfio_load_state(QEMUFile *f, void *opaque, int version_id) return ret; } +static bool vfio_switchover_ack_needed(void *opaque) +{ + VFIODevice *vbasedev = opaque; + + return vfio_precopy_supported(vbasedev); +} + static const SaveVMHandlers savevm_vfio_handlers = { .save_setup = vfio_save_setup, .save_cleanup = vfio_save_cleanup, @@ -606,6 +642,7 @@ static const SaveVMHandlers savevm_vfio_handlers = { .load_setup = vfio_load_setup, .load_cleanup = vfio_load_cleanup, .load_state = vfio_load_state, + .switchover_ack_needed = vfio_switchover_ack_needed, }; /* ---------------------------------------------------------------------- */