From nobody Sat May 18 15:49:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1687345970; cv=pass; d=zohomail.com; s=zohoarc; b=HoTympeRpUK0P/+8m6//z71rL3aJ/w3LWveYsA/yHNOK7pq4OeISldKt1RB113ari+mDoQURmZK4/Vx8bARX4hQiuaMEdn+Fz4i1FEOHdeelnEH722+aBPSEyMo7OTVaK/caFQ8eSGpAlATqmMaDFPfBgQ0bWYgbG5p8jvR4u98= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687345970; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LtmNao+Ts2PBgxw4CivpKVU9TEzIOEAaDK3Qsww19p0=; b=DxV2GkeRZG1SUkl1xT9z0vnFEoniK7EP12Ns656G0yvr1+B7ZnbGzV/8JFGRB/Pxw4V49LrMynHhRaaAbj9h6bMReOb7nMj996mw1iQrcSZJwCy3n1Jr/TBJBl8mMUSUBTEAxo+8GmkPb3U+8I+BaN7VhnZw5qRBtwyuZ/HS9XI= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1687345970317770.6717281741888; Wed, 21 Jun 2023 04:12:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBvlH-0007IN-Sy; Wed, 21 Jun 2023 07:12:31 -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 1qBvlE-0007Hk-OM for qemu-devel@nongnu.org; Wed, 21 Jun 2023 07:12:30 -0400 Received: from mail-dm6nam10on2061a.outbound.protection.outlook.com ([2a01:111:f400:7e88::61a] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBvlB-0002UO-Iy for qemu-devel@nongnu.org; Wed, 21 Jun 2023 07:12:28 -0400 Received: from CY5PR19CA0108.namprd19.prod.outlook.com (2603:10b6:930:83::27) by MN2PR12MB4271.namprd12.prod.outlook.com (2603:10b6:208:1d7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 21 Jun 2023 11:12:21 +0000 Received: from CY4PEPF0000EDD5.namprd03.prod.outlook.com (2603:10b6:930:83:cafe::45) by CY5PR19CA0108.outlook.office365.com (2603:10b6:930:83::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23 via Frontend Transport; Wed, 21 Jun 2023 11:12:20 +0000 Received: from mail.nvidia.com (216.228.117.161) by CY4PEPF0000EDD5.mail.protection.outlook.com (10.167.241.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21 via Frontend Transport; Wed, 21 Jun 2023 11:12:20 +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; Wed, 21 Jun 2023 04:12:11 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Wed, 21 Jun 2023 04:12:11 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 21 Jun 2023 04:12:07 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eZHvstqH0yPSTgamn3zMWjZvp+3dCtWdKd4s72O1/qxzlw9X7JE09XaIHvO177fUVhu/nO6JB/8CjzLG5x/YvqXQQlTOhQBlvw0u/s5RCTzKuICh5IGV16Htb2FBK6x3IOydYAz5LxtXCsKnLopOXI0OZojmZI3UhIpyt6Nnq1WbCuE4ctlkwAnaM9ImPAAwSj0mZvZfM5UlvC4+36W0BxGXauQOPXfWr8jLgwVsaaPrS7hDetfNQo9F6KWf7mVVDskwjaG+O+SFm49K6fHyZZDw6F8tEV8hok8LrvgPdH49cPoRiVA0zAADUeuObL7jalOtrAVGMT2WXUnuphtAsA== 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=LtmNao+Ts2PBgxw4CivpKVU9TEzIOEAaDK3Qsww19p0=; b=e7Tn6vh3Z1pVWEw+CWQ5UTZZVK3VvLi9TDw6bvL+OZgLAuGvpAu0Gv/bS8dBnP8v0tHZdTbpMsTdzNnsRNFij09ZspgbmHlNJPZ4DSDm32dXxW6kAIhMm9Jd95pTCXlXgx3z4TEZrrJxlqiOjGzils09l6xug72IjMnbP5UQ+WRIEC0IdzZmnMTuQLtHoDVMSEP0OBncgeqT1CPJn8z9d2MmlcYfdR9kLVKUM01/6V34qg+5u6HvA5ipe7YMZMs7VfUNDmyRhHKvBlrxazmlN+9lB87UfyUoBbIJf4DpWDxZ9ELANiuwXTpKN6d5W0oghS8rSfiPln51t3IlXUq6TA== 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=LtmNao+Ts2PBgxw4CivpKVU9TEzIOEAaDK3Qsww19p0=; b=UoxyxuWECzkGnmVyjAmP/SeThcrI3q+QOeMiZnPL0dU437iV/VvTETJn4jPkcOSCIyp5qg9taDhfNh06Esspo5XUXO51M8slzdmaNJySxd35L9VogH9W2vKNcpXX7yYOEDmHz2zA8R5m+I1STaRqVDiDOP1MjSglsD3fic9BQbLpsrXxSeO+rOMRJBKeVk+/iEBnFEywpFc2nzAglgLBJ4thi5Hn1Pw2lc5fJ36TCRkXuhL+0nGc4FNRTCXjcXI1fXDtCbh3DdmJ0PlEt1WnAC8LqGfGP8FmcewygysueJucQIWQUnl5ClaL1d4pe/V0WBCc2/qHZecK0tU8utLHrg== 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (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 From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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 v6 1/8] migration: Add switchover ack capability Date: Wed, 21 Jun 2023 14:11:54 +0300 Message-ID: <20230621111201.29729-2-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230621111201.29729-1-avihaih@nvidia.com> References: <20230621111201.29729-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD5:EE_|MN2PR12MB4271:EE_ X-MS-Office365-Filtering-Correlation-Id: 83012599-3131-41b1-91de-08db724861f0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lI4dtONyois8f2UsnKsN7d4j0dAkNZ/KXKyXP24BdKeTP5872nLGkVlzC4NfVlD1WjMS8DGW0hv2tloL/bMGZUCAsiL5ZbBdyzDVUu/pNKGJTwVYMDO71gd50Lu6ZjxEMqQ3nhbTfaX2s/EGJSiKv4YGhjalYBzxR+HQQIA1XRjz53n0Z0+53RYku+TjkVYvnyPWZEjWwM+8QFPL59IkspoYYjBt8ZJNmTVzQJMY8tZbWeerBqs445iLrzjJnlqma/fv30w/OLQwT16CKopG2fK9YcYQPls0KSzQ9JF/RMwk6Dwcj3rdi/g1Bon0eNnWSIgsr2S3OUZnaTsDzdmi/pa2E8O4L0kCB1z2dfhdYQ+LMv8cWcvB5eodaQpKEJl/yCWOiJN+HJ292ztbgb3h8aLEzXZ5Hlibh2texe+hfZcNmaMAJM5uic1LSoRkY29VNYcZmWYaakpzdqFjSntQvcVo15u3xCF4bKFAJekqdaDEm5ura8b4rrBtkJAgTEDw67lVbc09A1/tGyxkXtZgalDMqfTxviU1dAX1ocxmMIxQauZdwmrn4o4vOn3MjsjZUlbQa2+WrRlPies1kU8X1IQa1UGf8MNHOZWuDNqhwMlokDtL/cjfRcNWSmEz7LvTsNG50FjjYB1TrSagOLtESoy6r2BxuqfEnr13CqtnZpfBjTy1rqClKR3eQ3KMR5SS1z5RyLKEZREg5qkoMavC27cbcEp2jzgfe80j3sAtRij4gTkIIE2bQgG/zw8vCYiJ 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)(39860400002)(396003)(136003)(346002)(376002)(451199021)(46966006)(40470700004)(36840700001)(54906003)(478600001)(7696005)(6666004)(70206006)(70586007)(1076003)(26005)(186003)(2906002)(82310400005)(41300700001)(4326008)(316002)(6916009)(7416002)(5660300002)(8936002)(8676002)(7636003)(356005)(82740400003)(40460700003)(86362001)(36756003)(47076005)(83380400001)(2616005)(36860700001)(40480700001)(426003)(336012); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 11:12:20.8018 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 83012599-3131-41b1-91de-08db724861f0 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: CY4PEPF0000EDD5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4271 Received-SPF: softfail client-ip=2a01:111:f400:7e88::61a; envelope-from=avihaih@nvidia.com; helo=NAM10-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1687345970806100001 Content-Type: text/plain; charset="utf-8" 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 Acked-by: Alex Williamson --- 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 5bb5ab82a0..47dfef0278 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'] } =20 ## # @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[] =3D { 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), =20 DEFINE_PROP_END_OF_LIST(), }; @@ -308,6 +310,13 @@ bool migrate_return_path(void) return s->capabilities[MIGRATION_CAPABILITY_RETURN_PATH]; } =20 +bool migrate_switchover_ack(void) +{ + MigrationState *s =3D migrate_get_current(); + + return s->capabilities[MIGRATION_CAPABILITY_SWITCHOVER_ACK]; +} + bool migrate_validate_uuid(void) { MigrationState *s =3D migrate_get_current(); @@ -547,6 +556,18 @@ bool migrate_caps_check(bool *old_caps, bool *new_caps= , Error **errp) } } =20 + if (new_caps[MIGRATION_CAPABILITY_SWITCHOVER_ACK]) { + if (!new_caps[MIGRATION_CAPABILITY_RETURN_PATH]) { + error_setg(errp, "Capability 'switchover-ack' requires capabil= ity " + "'return-path'"); + return false; + } + + /* Disable this capability until it's implemented */ + error_setg(errp, "'switchover-ack' is not implemented yet"); + return false; + } + return true; } =20 --=20 2.26.3 From nobody Sat May 18 15:49:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1687346011; cv=pass; d=zohomail.com; s=zohoarc; b=WUorahnLO4gVTF1NAXSHahLOeGS2JDlcMrTSNNtYwR0hADyn1Ab21qwKB+3PAg2DzBCFgE9y1ljqOFV7JGlrPsEhz6wJZr7g4W3tuDG4J/rCKnBgY3ASWYFcbfR8/vy2pdn/g81VJeZwtPG4c1e7EKQgzymqfDr/KkxZY0RUu+c= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687346011; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nNK+eS3m27SmtBDe3I7Lwe8yCPma8axVl+RCe4lHXiM=; b=Y0zb0UAix1/QrBxYWiXVi0Banx+P693fMQKJW4lI96moVG6zKCET5uMeYo5y4bfZVJlTSemUrf1/PX9hYYa7l5ASbWghPsfJrAHvnP1vaKf2SKH5KXk9XGyf1cMy8lEnLOyN9VMVSrMGy/HZns3RBpJw0Cj+ipUUOL11c1FxFnU= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16873460111881009.1774930741476; Wed, 21 Jun 2023 04:13:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBvlR-0007KM-Gu; Wed, 21 Jun 2023 07:12:41 -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 1qBvlQ-0007KE-A4 for qemu-devel@nongnu.org; Wed, 21 Jun 2023 07:12:40 -0400 Received: from mail-bn8nam12on20615.outbound.protection.outlook.com ([2a01:111:f400:fe5b::615] 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 1qBvlN-0002W9-T1 for qemu-devel@nongnu.org; Wed, 21 Jun 2023 07:12:40 -0400 Received: from DM6PR06CA0055.namprd06.prod.outlook.com (2603:10b6:5:54::32) by DM4PR12MB7768.namprd12.prod.outlook.com (2603:10b6:8:102::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.39; Wed, 21 Jun 2023 11:12:32 +0000 Received: from DM6NAM11FT113.eop-nam11.prod.protection.outlook.com (2603:10b6:5:54:cafe::b) by DM6PR06CA0055.outlook.office365.com (2603:10b6:5:54::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37 via Frontend Transport; Wed, 21 Jun 2023 11:12:32 +0000 Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT113.mail.protection.outlook.com (10.13.173.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.38 via Frontend Transport; Wed, 21 Jun 2023 11:12:32 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) 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; Wed, 21 Jun 2023 04:12:16 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 21 Jun 2023 04:12:16 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 21 Jun 2023 04:12:11 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PHcw4pda9xpfTeoRqeevmeW79KHK0Fq9pgQ4DJiusFR9k1KU0Ngl5DWF8hrOAT2YakhEj5JJ+1dnmB6H2eJ+dFmroVMDlBMEvEvOG0YGXG/S3OLAOPinw6jS6WkYtiAlskCXb1OGglWphEkd/eWZQqMoehiCVtQHRxXICMpn1jTBv+8Yeq73YwdjUrhcX4yb+VMNmvt/kfQjPEr981ZBnMzNHs+BqUPX+hRgq4OgOuO/mEFScPI8PfYev73Ri/YaFCtfQ8eUC/jCibgtxTF3GNqIO+FL3zk0pOh5Jej3oU2WAfBDKAMjpAF09cZgvex+3amBqFCzPeiflQVwV83QyQ== 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=nNK+eS3m27SmtBDe3I7Lwe8yCPma8axVl+RCe4lHXiM=; b=UcNRl0ZQrXzuRjEVK3Ic8o+e2QXcauHQ0IkbJx2JRBylo3Mnkexnyj/kNK/Ep/qampR+ilu3sMmriFXxxS/b0iN6f9EWo4iC/nRVvgbyFEGblinOzY1JRRhsNWmDa31pqcI17larV42VT+RWOFHEc9JYAkas5SNpwRaIil+zl9zJfWuk86LH8LdbwtQaIQSB8lVsMSIUTqlXkTTCh/Q7D0H+FBRoZ79rn++FRjQGJNT0+zqwA/pNLo/mfjyZD8ciBJdVo7JfmhBuh/sZqcQc7wqmktjwuQ/HQdHOKk1NQyXFQxJx4TD8gNzjWGxk5LG84oeaJKmYo0vp+pbTPnZXKw== 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=nNK+eS3m27SmtBDe3I7Lwe8yCPma8axVl+RCe4lHXiM=; b=aktSgoM+I78CSJv/Em9/ETYVOxcWPQ/TDiNywYmzAbbq8b5En3cUSJ7Y/Bek3j6gNSxUY7wmu8ohv/qAHEqtEaiI65Gl/XT7Z115KBzenjbKnUEPlP91CSuijO29jrBdBwmJ6dhIAbcifuswPVYeRrTEh7kVonhaM/EQlRsmOSGZolk9Cz3aKHMLQP3JKLKH7zlK+e4Y9kJ+2RGLvwwqNtUISryqQGtdgoJxBnEJDf5GZ+HPaDYBonuyJBG0NlmtoDxFFgohJa6T8NgpO47UUyEF59kv0tcCWN9wjil2X5tD25UAjwJ1Cs4Oqws7uXbaOo0FQeniOEiFQcMkEQyNQw== 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (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 From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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 v6 2/8] migration: Implement switchover ack logic Date: Wed, 21 Jun 2023 14:11:55 +0300 Message-ID: <20230621111201.29729-3-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230621111201.29729-1-avihaih@nvidia.com> References: <20230621111201.29729-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT113:EE_|DM4PR12MB7768:EE_ X-MS-Office365-Filtering-Correlation-Id: 00614445-04b1-412e-084e-08db724868ee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S7OT+ithOK5tvde0kzLBOuOW3VYNJIvXvPd2X2Jkvcsb155Sd4XgUk8/66Uj2yE4HsD1aQvAjitI0AYqTe1yK8DbbPoyS29MCNmGV7pIf8urikedroECRkgmh8DgSP5u+yChi5fnCrS/GMBX4zTXAwgyhD8H35Z4Jq7aAExpiPOO+ZkhlWKU7RurBKuexjP2nGbMI2gxqD7ZzfQ4XVuYsbFUp/Lif3pG03x5YNHe8lwExrvj6tyDYD/J0c4zARq85SGy6BtUwF3JKItmc6LezkxUJGhBoYweoioxez4PC2wpVacarfKnjkclpm53Vk6GwD6+SY5XPVX6ed9aQ4RsAWaWdxjOjVZeb36DdMTQa6C96AMlQ9AUXgIz2HRpqBxucgm6rEdG4GBbZG8A2H0FyT6eArKREEQoouJAp/Gvp+YhOUSePCs4LpAjjEwXKtxEj01AZW4zvl8WhvGzXYobj407Wfs4+gq0Z582ljk4GgkVP0p/sNSMmDql8lDVScmJ3l8iDRk2wyeEqkDXFvgY7dZ6jbZK4TbHvI4vV8pyRi23Xy5qEjJ1AAVJllLEuj1F0ipk1QAmkNHrZS3oPoCpAY9yjk054w5dr9zkGfuJLecjRS3EAg1Y40KtqRVHxYF8/xHpFr6OrtaC8zmwaBImMlvpPrG2Zyum+iK3/JZ07e6xzZmk6Pmt6H6y9Qkses5BuEl1fq440EnFUpj6O0zNqhYcCt7c1hRDYgy5haWu8wE= 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)(136003)(346002)(376002)(451199021)(46966006)(36840700001)(40470700004)(41300700001)(8676002)(8936002)(7696005)(5660300002)(7416002)(186003)(30864003)(40460700003)(336012)(426003)(2616005)(2906002)(478600001)(36860700001)(47076005)(54906003)(86362001)(83380400001)(36756003)(6916009)(316002)(70586007)(70206006)(26005)(4326008)(1076003)(82310400005)(6666004)(356005)(7636003)(82740400003)(40480700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 11:12:32.5292 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 00614445-04b1-412e-084e-08db724868ee 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: DM6NAM11FT113.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7768 Received-SPF: softfail client-ip=2a01:111:f400:fe5b::615; envelope-from=avihaih@nvidia.com; helo=NAM12-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1687346013455100005 Content-Type: text/plain; charset="utf-8" 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 Tested-by: YangHang Liu Acked-by: Alex Williamson --- 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; =20 int register_savevm_live(const char *idstr, diff --git a/migration/migration.h b/migration/migration.h index 30c3e97635..c859a0d35e 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -210,6 +210,13 @@ struct MigrationIncomingState { * contains valid information. */ QemuMutex page_request_mutex; + + /* + * Number of devices that have yet to approve switchover. When this re= aches + * 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; }; =20 MigrationIncomingState *migration_incoming_get_current(void); @@ -440,6 +447,12 @@ struct MigrationState { =20 /* 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; }; =20 void migrate_set_state(int *state, int old_state, int new_state); @@ -480,6 +493,7 @@ int migrate_send_rp_message_req_pages(MigrationIncoming= State *mis, void migrate_send_rp_recv_bitmap(MigrationIncomingState *mis, char *block_name); void migrate_send_rp_resume_ack(MigrationIncomingState *mis, uint32_t valu= e); +int migrate_send_rp_switchover_ack(MigrationIncomingState *mis); =20 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); =20 diff --git a/migration/migration.c b/migration/migration.c index dc05c6f6ea..7653787f74 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 */ =20 MIG_RP_MSG_MAX }; @@ -760,6 +761,11 @@ bool migration_has_all_channels(void) return true; } =20 +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_old_state =3D -1; s->iteration_initial_bytes =3D 0; s->threshold_size =3D 0; + s->switchover_acked =3D false; } =20 int migrate_add_blocker_internal(Error *reason, Error **errp) @@ -1721,6 +1728,7 @@ static struct rp_cmd_args { [MIG_RP_MSG_REQ_PAGES_ID] =3D { .len =3D -1, .name =3D "REQ_PAGES_ID= " }, [MIG_RP_MSG_RECV_BITMAP] =3D { .len =3D -1, .name =3D "RECV_BITMAP"= }, [MIG_RP_MSG_RESUME_ACK] =3D { .len =3D 4, .name =3D "RESUME_ACK" = }, + [MIG_RP_MSG_SWITCHOVER_ACK] =3D { .len =3D 0, .name =3D "SWITCHOVER_A= CK" }, [MIG_RP_MSG_MAX] =3D { .len =3D -1, .name =3D "MAX" }, }; =20 @@ -1959,6 +1967,11 @@ retry: } break; =20 + case MIG_RP_MSG_SWITCHOVER_ACK: + ms->switchover_acked =3D true; + trace_source_return_path_thread_switchover_acked(); + break; + default: break; } @@ -2693,6 +2706,20 @@ static void migration_update_counters(MigrationState= *s, bandwidth, s->threshold_size); } =20 +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 */ @@ -2708,6 +2735,7 @@ static MigIterateState migration_iteration_run(Migrat= ionState *s) { uint64_t must_precopy, can_postcopy; bool in_postcopy =3D s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE; + bool can_switchover =3D migration_can_switchover(s); =20 qemu_savevm_state_pending_estimate(&must_precopy, &can_postcopy); uint64_t pending_size =3D must_precopy + can_postcopy; @@ -2720,14 +2748,14 @@ static MigIterateState migration_iteration_run(Migr= ationState *s) trace_migrate_pending_exact(pending_size, must_precopy, can_postco= py); } =20 - if (!pending_size || pending_size < s->threshold_size) { + if ((!pending_size || pending_size < s->threshold_size) && can_switcho= ver) { trace_migration_thread_low_pending(pending_size); migration_completion(s); return MIG_ITERATE_BREAK; } =20 /* Still a significant amount to transfer */ - if (!in_postcopy && must_precopy <=3D s->threshold_size && + if (!in_postcopy && must_precopy <=3D s->threshold_size && can_switcho= ver && 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 bc284087f9..cdf4793924 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 pat= h has + * been created. + */ + if (migrate_switchover_ack() && !mis->switchover_ack_pending_num) { + int ret =3D migrate_send_rp_switchover_ack(mis); + if (ret) { + error_report( + "Could not send switchover ack RP MSG, err %d (%s)", r= et, + strerror(-ret)); + return ret; + } + } break; =20 case MIG_CMD_PING: @@ -2586,6 +2601,23 @@ static int qemu_loadvm_state_header(QEMUFile *f) return 0; } =20 +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_n= um); +} + static int qemu_loadvm_state_setup(QEMUFile *f) { SaveStateEntry *se; @@ -2789,6 +2821,10 @@ int qemu_loadvm_state(QEMUFile *f) return -EINVAL; } =20 + if (migrate_switchover_ack()) { + qemu_loadvm_state_switchover_ack_needed(mis); + } + cpu_synchronize_all_pre_loadvm(); =20 ret =3D qemu_loadvm_state_main(f, mis); @@ -2862,6 +2898,24 @@ int qemu_load_device_state(QEMUFile *f) return 0; } =20 +int qemu_loadvm_approve_switchover(void) +{ + MigrationIncomingState *mis =3D 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=3D%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=3D%s len=3D%d" loadvm_process_command_ping(uint32_t val) "0x%x" +loadvm_approve_switchover(unsigned int switchover_ack_pending_num) "Switch= over ack pending num=3D%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 ban= dwidth, uint64_t size) "transferred %" PRIu64 " time_spent %" PRIu64 " band= width %" PRIu64 " max_size %" PRId64 process_incoming_migration_co_end(int ret, int ps) "ret=3D%d postcopy-stat= e=3D%d" --=20 2.26.3 From nobody Sat May 18 15:49:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1687345972; cv=pass; d=zohomail.com; s=zohoarc; b=eb6uFV7qNBxVfRpXDs4JEBKVNojimwoiqYI26G9PfaAfszjDkVQacPiwuF8MCD/VBaDA3U0y0HGH93dzIv8x/8ZdZdzUM/Yc1QjpthlMay4i/Qqu+2KzqiVYcW3ZPUyaeju8jQnKKGWt3QkoIpqFFiyjRu6DP3EWY3B/CsemipU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687345972; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zw/7kW+MZRDVjVwbSnR9Hu2tiTTqZuOHYZIYbCoAxtY=; b=HZudtP0SXUr0SDOinpRk5HX4pkp7H3TouOuEqa1pbjR+7p3/mQHusvEZfg2xYpHNW9IHGM/avEtniaod0e30tq6GAdSE0y4wrn5gTDIeS+zuwR1l42JkxGehaZLs6Xo1o5zjmtRgMpBlqDE3OwX15TvutYOFD5cqzykECNMHX0g= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1687345972137540.2791045817476; Wed, 21 Jun 2023 04:12:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBvlM-0007Jb-Mg; Wed, 21 Jun 2023 07:12:36 -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 1qBvlM-0007JS-2s for qemu-devel@nongnu.org; Wed, 21 Jun 2023 07:12:36 -0400 Received: from mail-dm6nam10on2062c.outbound.protection.outlook.com ([2a01:111:f400:7e88::62c] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBvlK-0002Vc-Ey for qemu-devel@nongnu.org; Wed, 21 Jun 2023 07:12:35 -0400 Received: from CY5PR19CA0097.namprd19.prod.outlook.com (2603:10b6:930:83::23) by SA1PR12MB7341.namprd12.prod.outlook.com (2603:10b6:806:2ba::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 21 Jun 2023 11:12:31 +0000 Received: from CY4PEPF0000EDD5.namprd03.prod.outlook.com (2603:10b6:930:83:cafe::a) by CY5PR19CA0097.outlook.office365.com (2603:10b6:930:83::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23 via Frontend Transport; Wed, 21 Jun 2023 11:12:30 +0000 Received: from mail.nvidia.com (216.228.117.161) by CY4PEPF0000EDD5.mail.protection.outlook.com (10.167.241.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21 via Frontend Transport; Wed, 21 Jun 2023 11:12:30 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) 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; Wed, 21 Jun 2023 04:12:21 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 21 Jun 2023 04:12:20 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 21 Jun 2023 04:12:16 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J/bn7quszxssk1d/d58LJYH5r8B5wgGMVQ3jGWCs3idnYaj4d3duKiZHkcwf9CNRM+npQOJQ25jKOc3ZqgTt+N1emrHkS98KMxtXbOdMZf5qZPlCyEcsV/nZmdWJBlo8Olawz4TqVqx4TSlmI1+kEjMdGtcPudaEHZf3vptuY0V+P1SdeUEU+D9iBJwK5/k8fSu0QYNb7ZuAERI1VH5ozZTNZiWR++AMTMyTYYalqVmrgQmo9XD509ov8oRgcd5DHZrAvd28NYOsjL5cmLyet4Ec6JOQie2KZdK480p6aicU1SEkeWc81W8+UuQhJwsciRP057PriswlDqphqlqMWg== 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=zw/7kW+MZRDVjVwbSnR9Hu2tiTTqZuOHYZIYbCoAxtY=; b=nGMChMZfZbP4z/M5DggrIai071MzLmxqdyHT0aBZ36ZEb6sGkLIoOLFdmPp2dO3viga+GRAV8PTm2dLfWSfPIgKWMpmcJsHG/kbTIMKtLwhomCAmZ156U0QG5hikvufMo193SgW4kvSxeUpF9gg/U/rtFd0GOwrFIGPJRm3fZJ1ZIW4mfbs5IoHMfc8fC54wGIjebiTGIEU9LmcM3gHHynnCsmB3WQnYt5LHRtF2lF0P4mx1Hn98Up1xWwb126Zi7xa51MQLEjO3Tzu4d8oTn/P6Yu8MGT5M+cfBRX8SlT8Kvdq2Kh/BQxqcnlUeeZhC+MJHFW2iKsvhAfrWXqhTnA== 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=zw/7kW+MZRDVjVwbSnR9Hu2tiTTqZuOHYZIYbCoAxtY=; b=SF6VCVt2SHPDyyc4XHO5XoTnhXfgsllkgs0XZYDVkASB7rm4U5dkVCEJL6cXArVyS4Qt/5fwDXuKXAH0m1tD4c1kR92vv/qhNmmwtDfjM/GaeJeRovPs0NH6oLTKzCZi7BvT3/3fA+2KBmNzlJmpzRcDPKnXj+ftqJggL++AQFzZeJ4RAze34G4P6x7G7Na2nyPQDP+j+9r6SEs68Nu7wLXj0osfaOxbnwz/MF01U4NwLfFoqiZA1OiZWxYy4xsx2rNxxgSBFUsxwexpi5AqrVZ+dNZBkpvO+wXlRK0kMDiHzTHZvBc6+0Efj3xUOYtyQ4HMxdffMZnUDzXT523mwQ== 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (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 From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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 v6 3/8] migration: Enable switchover ack capability Date: Wed, 21 Jun 2023 14:11:56 +0300 Message-ID: <20230621111201.29729-4-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230621111201.29729-1-avihaih@nvidia.com> References: <20230621111201.29729-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD5:EE_|SA1PR12MB7341:EE_ X-MS-Office365-Filtering-Correlation-Id: 91a4ca32-585c-4ae9-655b-08db724867d3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YhoZGEl+nnY1c4E1oajJHfKzDSAgXjcGabB+4nmPkq7nuKoIWb7cvDJf/SbSjvDHhGEfhTU092svPcauMndr3MNoK3cSSRb0b+UgrQB/ppeZTyU0MxyWQD/yOmT4PmJhKl43QqWcGsWr7PXgCXHy9z9Q2vCSd+h0QiY7m7Vuan9rML0B9TF4JUeBlulBtNWkndAcDbtomTDsodnhXRznoop9w8G/PeFFFxVrZejgRsYKcfDwElQbp7LzjmIac/v48sejbZErgIlNXq7j6mP08ChSWMrhtAcLOIv6ccgSC8dGyfHnci3W7/eOC7s+XTakOdAfeybPSy2+xApEh+jeMYY2qmzCYv+CHvxxWtNJOzN1/yc4SGgYiPh8JzwNvwZBPt9dHkAiVJLTB21rDekk/KfW5DTV6yAVBB33QqhXAs+OhTIWK4nqo00XjH8x+4oeoWG6I4vicpdbi2XwVo3yR/TJXIjRe+JSzPmZY85j6acqBH9ijoXTUE9xvaRFF8u+hbgj3ZVJhTYHI3Oq30uyQWinSlwS09LxotB7MMbrFZPRpkGHFQlQLWBCQNuigI2IPikaL4TkQGCujul2zPqr1Zt0OcaQokoHH5830+lJ1qu3UNBRxAaf0cNQTQrn3OYOh2r0KsnwGn7Xs4Qm+UYGo5cBwloA6EwfpurRGuZnCuQ1a1jG/WzRVxHkSh6SPMeaCB8xB+tXT4zKXphPqREz1bGLPvRYFmJ2QY5yebu7bV4= 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)(39860400002)(396003)(136003)(376002)(451199021)(46966006)(40470700004)(36840700001)(40460700003)(4744005)(2906002)(7696005)(82310400005)(82740400003)(6666004)(356005)(7636003)(2616005)(83380400001)(336012)(426003)(47076005)(1076003)(26005)(186003)(36860700001)(41300700001)(86362001)(54906003)(478600001)(316002)(40480700001)(70586007)(70206006)(36756003)(6916009)(4326008)(8676002)(8936002)(7416002)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 11:12:30.6769 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 91a4ca32-585c-4ae9-655b-08db724867d3 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: CY4PEPF0000EDD5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7341 Received-SPF: softfail client-ip=2a01:111:f400:7e88::62c; envelope-from=avihaih@nvidia.com; helo=NAM10-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1687345973375100005 Content-Type: text/plain; charset="utf-8" Now that switchover ack logic has been implemented, enable the capability. Signed-off-by: Avihai Horon Reviewed-by: Juan Quintela Reviewed-by: Peter Xu Tested-by: YangHang Liu Acked-by: Alex Williamson --- 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; } =20 return true; --=20 2.26.3 From nobody Sat May 18 15:49:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1687345981; cv=pass; d=zohomail.com; s=zohoarc; b=cZjg9/hizg/rzbQIHmdngTOJQkEd6UnqhlCx3KqSl7QK7T0s2zztBTY8tCiZXk63oAFSIMQvRgmvLfPblDtTRHegke5fD7QtG2GrdZdi6fGxbg6+VksKj/rWlQDOSZXsum01VMPd+0S6CXWlY6EC4gXv5WMZcEmlMhpEuUp+208= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687345981; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Qp9EOiY1w+VKf/IO9gHThKFauztz3H/ct8vopuxXUAU=; b=NtRlggE6xKY+wdJx2iqNbBtqa+WTrAWgLHLXVHnfz9nFHtBWfWc3lTW1XD3suIXMm7Tj/FJ9G/KXCSjnZs1ZG3JHZDX4smE88JGBW7vtMsy4y6ZI5yuJ6kygiwnd9+F0ProLlhYYNyQsouchcTHp/fMQp70EbXMLT7Ra6Horm8o= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1687345981204654.9735344287104; Wed, 21 Jun 2023 04:13:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBvlU-0007LG-43; Wed, 21 Jun 2023 07:12:44 -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 1qBvlS-0007Kk-MY for qemu-devel@nongnu.org; Wed, 21 Jun 2023 07:12:42 -0400 Received: from mail-dm6nam11on2062c.outbound.protection.outlook.com ([2a01:111:f400:7eaa::62c] 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 1qBvlQ-0002We-TU for qemu-devel@nongnu.org; Wed, 21 Jun 2023 07:12:42 -0400 Received: from DS7PR03CA0011.namprd03.prod.outlook.com (2603:10b6:5:3b8::16) by SA0PR12MB7090.namprd12.prod.outlook.com (2603:10b6:806:2d5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 21 Jun 2023 11:12:37 +0000 Received: from DM6NAM11FT054.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b8:cafe::bc) by DS7PR03CA0011.outlook.office365.com (2603:10b6:5:3b8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21 via Frontend Transport; Wed, 21 Jun 2023 11:12:37 +0000 Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT054.mail.protection.outlook.com (10.13.173.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.38 via Frontend Transport; Wed, 21 Jun 2023 11:12:36 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) 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; Wed, 21 Jun 2023 04:12:26 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 21 Jun 2023 04:12:25 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 21 Jun 2023 04:12:21 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dX++p0X3Xb/CxrTFXEEiQwyDGJmW/g5Msxe+BL+zl5+xHCYz4mvLhLYZT/zLpsjchCS/+WnFBXEAZD3EQNsiSgHRrg6QU5lUhXfnlM198pXaZx/huSRpTKCsCzXInLfixzCE/D0RR1cC3BCiMxoRqOI5cE3oN7HzXbiM6HPNG3FjXT6siRQ/Jv/eSqNRaCSmBVaL3OzOIerHXJoKh2FSSAnfMIADPz6lHPp26Dz4vKrGE5Z4Rejr75eIY9e6KX3uHnzJFCjr82i/74LADyjs1ckcjE/xpXHGaPUloTe4pUKBPUeOH2slbFTZxSG93L9n8EqFj/SQQSJif+ElGkaXQQ== 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=Qp9EOiY1w+VKf/IO9gHThKFauztz3H/ct8vopuxXUAU=; b=K3tpoWwhC+yPE6fN6wNGbDTWvVadPFtpCWelpOAzIia/qBXbbrv3JnXQZGS6HPJV0ww477MsIr4Ef0z00gp7FtuAFz1A55qatdJ7lt96BxxqJuclzQIPhl/UGN6jvP4goEzhBZ0UGkhJbqHJM7KZ8bjl4al14yJowUpumjPicE1QaKeW6jEu3IrRLBbz+f/hIvh7DBX3cY6vxY+WZD9QANXSmpeVgUhWhlFYHuSBlv8Q/YaD1NBnPv2NrKCmiH1OYlwJnhJzGs09IgXC4RmkpQXur563wlzngJCDVZRsM5FLTAbxsP74yM5sHiotLXaUR/KbXWIbp/dtXWG6RIZECg== 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=Qp9EOiY1w+VKf/IO9gHThKFauztz3H/ct8vopuxXUAU=; b=Ks1eG/YwCqluoSw11WCdW+3fMFqBjJCrvg3W1Kj5SJrl8wj/CM9Vk2aAghZdgJvzZ80ggKq2QmcBNHkIS7HmxtofhsFFNi6q4ckHUqsJla7iQ6IM1FYo+dodtvA4Y+h9v4Jib74qjkDYHINxiBAbIHVflE/Z3IjP9JZ9ExKdiGCHS4Gli7+TxC7aHkmRLlkSXJxWTwuZ568964irbRsVRKPZF9Z1gYtUjWjzwXmqwLWjrHJ72ZbOXjKqzcs8fGj+wd3xv8G19fASf428g2ISdCl74IT0n1RpLDEoWpwOVYjPCx4bWw54ihfsLTHLjeDQXkPcY0S+64qstwWV06r9pA== 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (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 From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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 v6 4/8] tests: Add migration switchover ack capability test Date: Wed, 21 Jun 2023 14:11:57 +0300 Message-ID: <20230621111201.29729-5-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230621111201.29729-1-avihaih@nvidia.com> References: <20230621111201.29729-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT054:EE_|SA0PR12MB7090:EE_ X-MS-Office365-Filtering-Correlation-Id: b1db685e-31dd-4b43-c77b-08db72486b76 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Yz7XNBHfO9kBYBF3w18rL4yJMWS38yMruak7bQSScncG4KmL1StBBWpKJ2SehtjZ3uNzGUkVWW++B1t8BPPJH9KRUZ1F41cuE7s2f3vLPVb9zh9O9dLfDuNKQCJIOT/VpKoMQxdkHo9UXo3D6sW3PNPoo6NX9UbNbIMpgmJt3cqK/cqs4loH+SXH02CK0aOsYEs3L7TP8iI88yT2Rk6SIHyXuZGpR5ogsiWSl/dB1Is7hm8HPH1hcg3jTmv/X5+CDSJYY/XWz74kgS2wM0yAvq/IRbjKLYznr82q07wOPCAael5SBQu1GTFYOKgXl8/rDiGMph3T3y2r9RIdmcfgK6b1dP3Yh0O0JyTBf2uMHdqmNtyoOhe2l2VWtBFnDfdw/z8lTyl3Oci8yJx8EPQeXDPZPvZY4mBZQel8V1Hfw2dTOunsu5d7xxoHp4CpwRJZRRv8s+0i2qNxNh1976zIm053Y1LDxFbWa8qW5OMMm7AIGziEhMtVX8gB4sPmBbybHuba4jRRfVUPWafjxSqDBp+90IzTuoYhWYp747QWj4LK4eJpqr8gossnBhjdgtDRTrvoCKZV4pw3iKp0McRXH1HZFjQluXSLxsQ/BIEVwSMJSXuVakgSyqaeJlLT7afK5ni8egzbhpRFe8sXzW7duMtOx3M4THqPcuGb5lSfHibZ4RjSawBdgFnCsDZpuf/wb0BdF5KQGVOpeOp+WghfxYjrX9gMKd0siPXdEyxVIEfATjgDDP+25RKf90Ikw+Z2 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)(36840700001)(40470700004)(46966006)(40460700003)(83380400001)(426003)(336012)(2906002)(186003)(47076005)(36860700001)(6916009)(70586007)(6666004)(54906003)(4326008)(316002)(7696005)(70206006)(26005)(7416002)(5660300002)(478600001)(1076003)(8936002)(41300700001)(8676002)(2616005)(40480700001)(356005)(7636003)(82740400003)(36756003)(86362001)(82310400005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 11:12:36.7809 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b1db685e-31dd-4b43-c77b-08db72486b76 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: DM6NAM11FT054.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB7090 Received-SPF: softfail client-ip=2a01:111:f400:7eaa::62c; envelope-from=avihaih@nvidia.com; helo=NAM11-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1687345981428100001 Content-Type: text/plain; charset="utf-8" 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 Tested-by: YangHang Liu Acked-by: Alex Williamson --- tests/qtest/migration-test.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index b0c355bbd9..b9cc194100 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1693,6 +1693,33 @@ static void test_precopy_tcp_plain(void) test_precopy_common(&args); } =20 +static void *test_migrate_switchover_ack_start(QTestState *from, QTestStat= e *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 =3D { + .listen_uri =3D "tcp:127.0.0.1:0", + .start_hook =3D test_migrate_switchover_ack_start, + /* + * Source VM must be running in order to consider the switchover A= CK + * when deciding to do switchover or not. + */ + .live =3D true, + }; + + test_precopy_common(&args); +} + #ifdef CONFIG_GNUTLS static void test_precopy_tcp_tls_psk_match(void) { @@ -2737,6 +2764,10 @@ int main(int argc, char **argv) #endif /* CONFIG_GNUTLS */ =20 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); --=20 2.26.3 From nobody Sat May 18 15:49:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1687346011; cv=pass; d=zohomail.com; s=zohoarc; b=FVygcN+b1zfXhFlCBeiZsKEE9iTkeBu7+sXEBBtR+PNeySyhzhbxQV9ftTYOMOMOWT6jrX1n5s6wqbK9AUJLHZYyJjnIueoK9u/SaLP5P4sHZghpHOZLbc9WIz/gR/9UjpnLIIRXNM0MB4bYSbsTXNQZSdRavZJDYr744d5wFGw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687346011; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2x4zCSxKb7rP9YzA5xOn59RCxNucU5BY6IkAtnQ2zDs=; b=jRA1SLy6id1dGmxTydx2v6RLKyw4/XpqJJ9pRnpuz8V7epXq3RKH5Eiw/qjoVKD0lzJfLN9a0gPjfWyCTzVW7wHfLYEfjCIh7ffk1XrjsRoNNQ8CFsNsFY4h1XSks8gO9hiJcAi5y29KVRo4jsig0VOLnXmVxN+ROB3DoOrl6XA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1687346011256766.3072805508774; Wed, 21 Jun 2023 04:13:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBvla-0007PR-BB; Wed, 21 Jun 2023 07:12:51 -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 1qBvlX-0007ME-VL for qemu-devel@nongnu.org; Wed, 21 Jun 2023 07:12:48 -0400 Received: from mail-bn7nam10on2062c.outbound.protection.outlook.com ([2a01:111:f400:7e8a::62c] helo=NAM10-BN7-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBvlV-0002Xq-8S for qemu-devel@nongnu.org; Wed, 21 Jun 2023 07:12:47 -0400 Received: from CY8PR11CA0018.namprd11.prod.outlook.com (2603:10b6:930:48::7) by DM4PR12MB8473.namprd12.prod.outlook.com (2603:10b6:8:183::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Wed, 21 Jun 2023 11:12:41 +0000 Received: from CY4PEPF0000EDD4.namprd03.prod.outlook.com (2603:10b6:930:48:cafe::b6) by CY8PR11CA0018.outlook.office365.com (2603:10b6:930:48::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23 via Frontend Transport; Wed, 21 Jun 2023 11:12:41 +0000 Received: from mail.nvidia.com (216.228.117.161) by CY4PEPF0000EDD4.mail.protection.outlook.com (10.167.241.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.20 via Frontend Transport; Wed, 21 Jun 2023 11:12:40 +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; Wed, 21 Jun 2023 04:12:30 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Wed, 21 Jun 2023 04:12:30 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 21 Jun 2023 04:12:26 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bhDbLVvGSn7WjrIj+ho/EICdapmyn7zntY+6anhJsxjKIULjvHa729DEz/0bV8zZD7IGB3sTPlkJ3fGcKq292RdIEISDWcqycNFhnrxivVDBjE+fFZPwq4j8st+lw7thrfYveg3QXLcOfEdylO5VLe1e9z9sHSh7wZwGf5zpUnl7WJV4Kk12XxtsuEMf01Y2qeFeyj2oT0ucbhNJBnWmHYUfMqrpGNAttr1N36vR/88DSjbw0qccw4+dode36wEsp26tVURWX6Mr8oQfIZwhxhAmF5N/+FQLDFoTwdT6+TxOuB6PayjJcBMM94fSAC8L/rwMBp5mj4vfqtETOpgQKQ== 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=2x4zCSxKb7rP9YzA5xOn59RCxNucU5BY6IkAtnQ2zDs=; b=JPZKpn36d/J9IrOEKV+uqFdCIRDoZj2ZsD0RkT1vHOT6jwKMMvBk1ASXfWaKUi78/fuGZERoydZrzFJCAKiXaRqbmnXMr+FuXIgVQ8gLP/7l/wfMIF73htmYlWkOsc1qsFuq8n/NWSkOuhzRf3oTkg9ANANE2eHoVNkcNcTPxVjxOFj2xBD9uUVK+KixMNMLpJtpmERS0ln8u2Vct4u5ovaE98xvT+F47tL3ERMNn/GpdlpcAU+/nXdrCoCIx+wU3Hm+ql+lOo8pAXFSUGiAXur9W04C4ix8ppohdnVWzC4lo3XkMSQJg7YsrUhVLv7pPMjuOVJ9NOKAe70uxJri2Q== 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=2x4zCSxKb7rP9YzA5xOn59RCxNucU5BY6IkAtnQ2zDs=; b=C7iAN4NkUVDAhhpY2iEqkZvdH5rv6v7+B/ry1QQhWY/RvSGO78lHzVbYdMcGU1/PNUqcyFKgLARd2cWsGaCAEVmI8URgy7Yzlo7+LMUmpHk8xbriqVFPgJgHh7W+kQ+ii6R+iZPTl515DCLyjv5toEzyePyKd/+/9+t7fYgMtTyhRNl6/kKNIqzc8v/zmlKMnvTTVQI6QEKGRKhvIfU7M4nvxDaAVj6I7F1xx/SpN2TTVjXOGpNK+vSN3qrC/9fZIQl/fL+ySevG7VjXy5GPwh1rpDKfoasL8vNcX/OHhroJ7Ppk5unyjNzWK9xjK7Bm+cNn9YGYY7ulD3tn/JV4bQ== 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (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 From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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 v6 5/8] vfio/migration: Refactor vfio_save_block() to return saved data size Date: Wed, 21 Jun 2023 14:11:58 +0300 Message-ID: <20230621111201.29729-6-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230621111201.29729-1-avihaih@nvidia.com> References: <20230621111201.29729-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD4:EE_|DM4PR12MB8473:EE_ X-MS-Office365-Filtering-Correlation-Id: 5214141c-9e72-476d-dee5-08db72486dc1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OWAu8NBjRjMgPzuaBScYck6fEx55iLdi14OWrINY1uzhOAnZZjh6c7WMhxgN8h7Uavryt0ikaB645q78bmd48YMZbqcrob0ejKx2Wa3rJG7f5Fs5mw4G+UViYyFmBvkHomaQxJ42Np1mZ41o8n/+G705oJ0G2avl+EZtpv8DyiVLV83ctSdh1xaA6ur2dpHr2XDkHi14Ejb480bnvI1MzuPkocsajSy2V/34kw8FGalnVZyh9ESJN8BPBA9Am9qvW4feMcUxkatIDjPrHHSSMioVLpOq/uqeQ0xOX04z6rcb159wJX/OvuQjt3myWyOtXMRM/B0X6+K0NWN4Q6/Jh9YVI2Qy43By2CpAb7hRYZ7vWxpn68uh9UlVnRSm3DaU7z5R/gA5xvlmxq7G+DpH/AWhHth3+yYlgGnHmltZykkyv6b/So0mjJRnAXsW/P7sltDB+Y1G2dNekG1L+Yq1DLWJnHYwdkL7xmlrlga9ztNLybG7+HeKy2yEBACwetJicMqgSbNE9UQs62wqgbYgzR3Shic0E6g1EGYdGv0U6cvCEP27QKq5cCnB6tkmMjRPblymu11iT6qFryL2QRfMoYhgi4WmXpNJJivX0pjD8T7ZMk93GK3wcEwP22JV87FiGu1qu35dvIbSqXbCNZvOgs7Szi27te9hoIdKEZKlzu9hUQaEGXujn9htKQ0qpm0gW2ygXrsalT9OrwmHsM2m9YHGhszkugZ9ayfJq90TMApW38J7UC/Y9AjCktBvKIBF 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)(39860400002)(376002)(346002)(396003)(136003)(451199021)(40470700004)(36840700001)(46966006)(70586007)(41300700001)(70206006)(40460700003)(4326008)(6916009)(2616005)(7636003)(186003)(356005)(82310400005)(86362001)(26005)(36860700001)(1076003)(66574015)(83380400001)(47076005)(426003)(336012)(82740400003)(478600001)(36756003)(7696005)(6666004)(54906003)(40480700001)(2906002)(5660300002)(7416002)(8936002)(8676002)(316002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 11:12:40.6284 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5214141c-9e72-476d-dee5-08db72486dc1 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: CY4PEPF0000EDD4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB8473 Received-SPF: softfail client-ip=2a01:111:f400:7e8a::62c; envelope-from=avihaih@nvidia.com; helo=NAM10-BN7-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1687346013333100001 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=C3=A9dric Le Goater Reviewed-by: Juan Quintela Tested-by: YangHang Liu Acked-by: Alex Williamson --- 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 *vbased= ev, return 0; } =20 -/* Returns 1 if end-of-stream is reached, 0 if more data and -errno if err= or */ -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; =20 @@ -252,7 +252,7 @@ static int vfio_save_block(QEMUFile *f, VFIOMigration *= migration) return -errno; } if (data_size =3D=3D 0) { - return 1; + return 0; } =20 qemu_put_be64(f, VFIO_MIG_FLAG_DEV_DATA_STATE); @@ -262,7 +262,7 @@ static int vfio_save_block(QEMUFile *f, VFIOMigration *= migration) =20 trace_vfio_save_block(migration->vbasedev->name, data_size); =20 - return qemu_file_get_error(f); + return qemu_file_get_error(f) ?: data_size; } =20 /* ---------------------------------------------------------------------- = */ @@ -335,6 +335,7 @@ static void vfio_state_pending_exact(void *opaque, uint= 64_t *must_precopy, static int vfio_save_complete_precopy(QEMUFile *f, void *opaque) { VFIODevice *vbasedev =3D opaque; + ssize_t data_size; int ret; =20 /* We reach here with device state STOP only */ @@ -345,11 +346,11 @@ static int vfio_save_complete_precopy(QEMUFile *f, vo= id *opaque) } =20 do { - ret =3D vfio_save_block(f, vbasedev->migration); - if (ret < 0) { - return ret; + data_size =3D vfio_save_block(f, vbasedev->migration); + if (data_size < 0) { + return data_size; } - } while (!ret); + } while (data_size); =20 qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); ret =3D qemu_file_get_error(f); --=20 2.26.3 From nobody Sat May 18 15:49:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1687346011; cv=pass; d=zohomail.com; s=zohoarc; b=n6cpg224aTArgzNJ68+99BOevDXJQ6ijGIPszorBQHGJ3Zo1S6bblRqtcP68SSo5ux+QJN5MNcJt1htZEgEkFBufOS27jk2CyjoFTorO5O/FeV3mM3fevSZh32D1uIVCSyTl2eHDkdcj6MKRMnc42jhnwXZ1VuKZyNZkGkmlfSM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687346011; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/FhmB2+Xyuy1oef2WkwLBFJTvUzrCEpjFJAaiUT1s3Q=; b=D5LXZ0XtksizoYjM5+yC8KTSd8isGuNMSzPwe/JorCvAC5trABZZ9yl0auwWMK8WWfsMJgSDfbv0dEodZoyvqUr1cfdomUlw6wBGzDFDnFyMLaYCewPzzo78uXrQ2xZEdouyApU+jgV6JZnlVAEKemFdIyMfNdWw56LedZIfBe0= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1687346011797271.39398707539294; Wed, 21 Jun 2023 04:13:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBvlp-00080K-Pj; Wed, 21 Jun 2023 07:13:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBvlm-0007wQ-3c for qemu-devel@nongnu.org; Wed, 21 Jun 2023 07:13:02 -0400 Received: from mail-co1nam11on2061c.outbound.protection.outlook.com ([2a01:111:f400:7eab::61c] helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBvlj-0002aj-Q3 for qemu-devel@nongnu.org; Wed, 21 Jun 2023 07:13:01 -0400 Received: from DS7PR05CA0064.namprd05.prod.outlook.com (2603:10b6:8:57::26) by PH0PR12MB5484.namprd12.prod.outlook.com (2603:10b6:510:eb::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 21 Jun 2023 11:12:54 +0000 Received: from DM6NAM11FT093.eop-nam11.prod.protection.outlook.com (2603:10b6:8:57:cafe::29) by DS7PR05CA0064.outlook.office365.com (2603:10b6:8:57::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.9 via Frontend Transport; Wed, 21 Jun 2023 11:12:54 +0000 Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT093.mail.protection.outlook.com (10.13.172.235) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.41 via Frontend Transport; Wed, 21 Jun 2023 11:12:54 +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; Wed, 21 Jun 2023 04:12:35 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Wed, 21 Jun 2023 04:12:35 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 21 Jun 2023 04:12:30 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VaD47/Hj4evgcmzl3u+QQXI6nVK2mgCygf431w/rCNgBjn1GIFPsv+D5RAG6AydWrLWkdVNpm5qumuAcINPHyV6o8tocGsCoOJ2T7zHE7WLf76ZzaLJbANBSEMVLDPrvmqRUuj15Fgp8390yu3LvQf++S2UFdtcu35iv2Pw8J8u6izk2Gwa1IubEoS6bLdiSGtI2mbyRg779HwjI5swdIyxdnX5C/pEYq7nQIwk+odHyR+kYPe4FgBD1eaVQr4Ga3sjcUahczwGd9x0PsGVy5UCKFt2dmMGNKdImtY1Rqu/kr10xy+6BCGIdWKsnwzjV+hT7paMT/ar30qHjm5C8Nw== 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=/FhmB2+Xyuy1oef2WkwLBFJTvUzrCEpjFJAaiUT1s3Q=; b=bhoSAsvdKqrgur2q/ebP9481A/a8DlKZh1S0Mx4+2ZeEmWrSjor/Z83VZOE8Ue70/q2xVjIAgislla3/SP4DU2ezFMtlu0ZVxmpqiWipQJMquRJ6BJacFMq1OmL1jPWYsMpt32tRrber/zn30Hn30K7fsSVjyFfyh3CrlC/hphjrniAmlHddDzfIfaUPE467O61O9UOk25hycyk+yGGIsndUdEq1q/6YF4tLK7m4dxveGy0HVlwR6rPOx4YFNTqU7o0Fpmy3OR+KiMj5KavToPSTBwODYUTK0AWeG9lKPTXb5LeF31Y7o7N0wbX7nZhj5Qm5hheaiDadouwx9prLtQ== 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=/FhmB2+Xyuy1oef2WkwLBFJTvUzrCEpjFJAaiUT1s3Q=; b=S0XvcrHxl6w9jyBqcwAvLHVhH9/e64KAafco+c2/e7iPX44cjzGGASgGoJjaTu9983+x7ws1PFTHOkib8awd7QOhoGXfAiZuWwvSuAmu9sGiFLo02/+IXLslDZ6dtX8YcP2OTxa9OfBTXVudInyr+L7acR3YfDvE6fEa1fGl+JDithoDDnjmd3J34n4uX3vR1mTEjGQXYbGGToSPXumpcEsOpzOylAbp8r5KpG6b99tmFCcbjzCJnEQSLCg7HXYwkRqiuQS0lYCfp0cLBm0acfHS7FQ76fS+bU8gjghm4SePw+BB71woR0U6MVMfY5M7ew7Dgs75amL5mPE2Eih+dw== 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (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 From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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 v6 6/8] vfio/migration: Store VFIO migration flags in VFIOMigration Date: Wed, 21 Jun 2023 14:11:59 +0300 Message-ID: <20230621111201.29729-7-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230621111201.29729-1-avihaih@nvidia.com> References: <20230621111201.29729-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT093:EE_|PH0PR12MB5484:EE_ X-MS-Office365-Filtering-Correlation-Id: d443d339-0909-43f1-8055-08db72487611 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9WpxAyBcTTSFRy3ZRumO2sq2gliV9W+bAVW9N+L8rzuhst3fvs5E9urAhD2ZG0wRFAKUmsuRVfy8hX36pL1rp3Q2/cZPX4/wK4JoAh82xBQFRx3XPftLbnn0yEiYVaEoVSXHVllJLEVp38qyxgMLqZoQg19/BJYRysRHrCK+gH/mw2xBtE9Hj4v3zb9VwT+tTzL5MFdZSm3t6eCF2Q6y+ANv04RB4T+pZk6HzOQY+3okZ8O0xiFHo7hDJtX5yLiUXcGQa4Ho6LXsNXb2mM+VzUg4sezAfH7OePTimT5HMroGvQ3VKg1ftm2jrto7jTK+5Rcb7cRyE13tc3bMjoxM3OALsgVIJzKN+YqtWlcbHUbqDw41VuyS6Vi0zD41W+TehI1uznro3Ey47/A2UMQMSNzKjycKbOrsh+FKtDaBtQi2lMNOCwg2NE1RayNgQPzp50W2S4GdGkjq8dGwmhFVPrFDmJS2ViBP4QY+38MiRfyk+eH46diXRdDZKiMP3pHFqgL/S8SlBVLkFdHorH/XTneSawh7GLeIMDwXYY3EiUSI9Ej1RrxgvQsfxJQqIfrZCY5PkinYE/A0JALKKBaSh/2h5CUzV7qzKMeyN4jMNgFDgvzNxYPPL8KC6SSPKPzSxfA1FrpSth0gl9UanJKfjXr/lNO5d2cPhTQuUGBOerbbtunAPq+d0dcQR0HRhuHAVMGFqvxt2gbC0c3364T8H40/qexORFNGP+7BsLABfDYnpy6Aav0f7iKsZZ2XB57e 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)(376002)(396003)(346002)(136003)(39860400002)(451199021)(46966006)(36840700001)(40470700004)(54906003)(478600001)(6666004)(70206006)(6916009)(70586007)(82310400005)(26005)(186003)(2616005)(1076003)(336012)(7696005)(40460700003)(4326008)(41300700001)(5660300002)(316002)(8936002)(8676002)(7416002)(40480700001)(2906002)(356005)(7636003)(82740400003)(36756003)(86362001)(36860700001)(426003)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 11:12:54.5721 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d443d339-0909-43f1-8055-08db72487611 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: DM6NAM11FT093.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5484 Received-SPF: softfail client-ip=2a01:111:f400:7eab::61c; envelope-from=avihaih@nvidia.com; helo=NAM11-CO1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1687346013338100002 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=C3=A9dric Le Goater Tested-by: YangHang Liu Acked-by: Alex Williamson --- 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; =20 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 =3D vbasedev; migration->device_state =3D VFIO_DEVICE_STATE_RUNNING; migration->data_fd =3D -1; + migration->mig_flags =3D mig_flags; =20 vbasedev->dirty_pages_supported =3D vfio_dma_logging_supported(vbasede= v); =20 --=20 2.26.3 From nobody Sat May 18 15:49:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1687346017; cv=pass; d=zohomail.com; s=zohoarc; b=j3kUJ4jVhF4FQ/GW5coYjRWB42tyMimK8b/oWt3gh+Lqvk4xmTFgfBYM3Zk17LxP/I7Bq8pvHU1C2WoZcy92a1VMO8aAUzbKPAfQFPct5NS4KUN3OKZdES+jQmqpnPC2C7PzS0Cc0ofyZQtER7iISCdOvJxY2gn5jCmN6AmdPNQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687346017; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tJq0xMszeOLcyGEbtXa1IsYcQ/4w3H/XVBmMsUDmm3I=; b=Vu9iax6mdZplnCYufOVSzSdBFsFMO00Y7elk3hYp/YngSsvaqBLUhcvZ7UwecBjp5+RPUMxRuJBO0yO7Iii0L5+gkppXWbYOp93meygAf5FrJBwF+Y6tL5InYBjTvQ0EZzfP6rnfUNGKgrtSVSLenFlFhTkLrlOZeH0y5xeOmnA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1687346017475361.2908380417182; Wed, 21 Jun 2023 04:13:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBvli-0007kD-Up; Wed, 21 Jun 2023 07:12: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 1qBvlg-0007fm-GI for qemu-devel@nongnu.org; Wed, 21 Jun 2023 07:12:57 -0400 Received: from mail-bn7nam10on20630.outbound.protection.outlook.com ([2a01:111:f400:7e8a::630] helo=NAM10-BN7-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBvld-0002ZY-N2 for qemu-devel@nongnu.org; Wed, 21 Jun 2023 07:12:56 -0400 Received: from DM6PR13CA0020.namprd13.prod.outlook.com (2603:10b6:5:bc::33) by CY8PR12MB7267.namprd12.prod.outlook.com (2603:10b6:930:55::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 21 Jun 2023 11:12:49 +0000 Received: from CY4PEPF0000EDD1.namprd03.prod.outlook.com (2603:10b6:5:bc:cafe::cb) by DM6PR13CA0020.outlook.office365.com (2603:10b6:5:bc::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23 via Frontend Transport; Wed, 21 Jun 2023 11:12:49 +0000 Received: from mail.nvidia.com (216.228.117.161) by CY4PEPF0000EDD1.mail.protection.outlook.com (10.167.241.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.20 via Frontend Transport; Wed, 21 Jun 2023 11:12:49 +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; Wed, 21 Jun 2023 04:12:40 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Wed, 21 Jun 2023 04:12:39 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 21 Jun 2023 04:12:35 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NUGKI73eWxkTBLAqkmK/VkO2ID3qAqC4hz+lFUdzKE6xLsg10ebHTHZ7CTyvLuqG7vKF6TvO8jQKstZS+4e7dVu0gxu9MaJDMtfG8UZujNBvO5Ai/abZd/2Wgad2GfFg+msN2iJwn5t+gNJF7cZ0TaXqKmvj737hG8nK2/EPDmeMjlv1vTEgdueyDabjQT019NeyPiF6ncLWiLgWeB3I/eNfGhi55AVrPiiIxZaNIJXRdg0KjlbbHOguqUAYSVPywNBY4RbPgTLa0N79k/k/Hw3UmqoKDjb2+0I4Su6+6O8YlazmwlnY2B5MShxtYHCpGD+QWRPhY/X9UMF20GNAZg== 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=tJq0xMszeOLcyGEbtXa1IsYcQ/4w3H/XVBmMsUDmm3I=; b=mpcZYJ6FglFAgaXIL2dLwOkMEdms6OauoS4WY6lVIY6a5sQEfbstwHxG/AV1uvWQM2rkm3ydnDVY3YLTMStWv9/pUx+Fte5SKTuLFqnO94R3mlTXyEQpuBj6JsHTUkDSaHiRjOyOLEi5DfZMmzFMQ/EeKmqu1ImrnaB3QMM/7pwVYiSzigIf4AOyhVtNRuiHMcC+Homuo0vNLgzxl8BoFiPA1IrN4wNHmpyer5wS+whpDdjDWjjXsw8xfdFxmNU6JlTa/G59i9CXMDjKitnPxmeYwj2c6NnWSBNoOhtRQRQhr3rxsCymd68ZBkC48p+iPNhhcyILXT1fzrXgbiYZhQ== 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=tJq0xMszeOLcyGEbtXa1IsYcQ/4w3H/XVBmMsUDmm3I=; b=r9fR2Oqk+9GZ4DpdVI//vF4DqfsxrPfowFUc9oKLGkTLjCJymtZN6L6csqe/t3AvORYpTcGPs+aK2vBnqh+wFJfJE43uJpGU+dnA28uKC1nxBTXp+L7WyMb6obKFe/tTcDm6/X5wkBZkUQBhth5cryCHw0AaO0l74TTNgNzOeVXCq1tPNWAGau9Es/9OFIC8uHyTQzvBk2HmGIsvizuFtT3PAVVIkL8PA9WPmo02+UADz+ShpsF0wX6u7cFUGgpehWBbz4rX4HqfsAQLvU0iAMwB/SUqbZPvwxGVH8hCElEswZ2JW4JjaDYXjngzSthmq8DVMVWUEjd2oci6Zo2Ovg== 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (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 From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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 v6 7/8] vfio/migration: Add VFIO migration pre-copy support Date: Wed, 21 Jun 2023 14:12:00 +0300 Message-ID: <20230621111201.29729-8-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230621111201.29729-1-avihaih@nvidia.com> References: <20230621111201.29729-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD1:EE_|CY8PR12MB7267:EE_ X-MS-Office365-Filtering-Correlation-Id: dadfe3db-2341-4362-78e5-08db724872fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uEJAkvOHV6MKs5rGkkYd6pNoDuGm4pKiXXvMZptio9TeLiqPTf3Tv4rHZ62st6RNYjuLlzHpPiJrhSCv2zpxRBvMhXUfWg2SqSYiedvTRcO00uLGwOXaYBUn8VSVAF33LrobtE3R63Q5kCfn0ZqzKO8d1Q/kL1kWIZxWXwQOEeJDdVVYj6G8Htth6eJB8dqbA7edFj9TjXf4zuAmHyNjQI4cvCMMiG665OYRPyZ2yJ6oit0rk0lUNQUZqYBcIuWoLWU/uVVRwE66BaY+xIDahgTb855HNpWkr8aW/M1LeFVVAJHJpvKGHZ5qJfGpz3pBbc/AyMMmMJp0WYY087eDE8/4X2Tq8XFdtmtnPjoZMzoxxFEzdSunwAaw2fHqKhtgjVsLW7FV/rwICD7jwvCMfzC25kI6Q0OZm0VxG0TqlawB0MwozzmmuVN7Tqeg4EC/7t4VbPHyPZ1KP+6NYVnMxBsHiPYOEZPwevPSQsToGHrdZrHib2TcrfH0LGS6B1FXaJI8G2SF6oyt/4Ro1ySED1+WBmSssay8EH1UFxYZhBZ6+HpiFyxo8B9YIHdVPNbBEyhiyAg8GzTodUPrxTsZSf2Cn1HkKtYGUnFydzVY0I5ax+5ybuR+qKm/NbN4i8hzoMER6ha9usEKwr7ulv7YAbhufPFMtdEuhhqc+6j6pIiSCM2W0Hpr+VzQlkpOKNykdGEDlCvnxAsLXJLOypAdHkhnfSwXHy6gjYIPn4XnjYUa9ll2tWmMDu0lUjkGoHJC 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)(39860400002)(136003)(346002)(396003)(376002)(451199021)(40470700004)(46966006)(36840700001)(356005)(7636003)(82740400003)(7416002)(40480700001)(30864003)(2906002)(66574015)(83380400001)(47076005)(426003)(36860700001)(36756003)(86362001)(2616005)(1076003)(82310400005)(26005)(186003)(7696005)(40460700003)(336012)(6666004)(54906003)(478600001)(70586007)(70206006)(6916009)(316002)(8676002)(8936002)(5660300002)(41300700001)(4326008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 11:12:49.4011 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dadfe3db-2341-4362-78e5-08db724872fc 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: CY4PEPF0000EDD1.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7267 Received-SPF: softfail client-ip=2a01:111:f400:7e8a::630; envelope-from=avihaih@nvidia.com; helo=NAM10-BN7-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1687346019379100001 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=C3=A9dric Le Goater Tested-by: YangHang Liu Acked-by: Alex Williamson --- 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 sa= ved state on the destination host. This document details how saving and restoring of VFIO devices is done in QEMU. =20 -Migration of VFIO devices currently consists of a single stop-and-copy pha= se. -During the stop-and-copy phase the guest is stopped and the entire VFIO de= vice -data is transferred to the destination. - -The pre-copy phase of migration is currently not supported for VFIO device= s. -Support for VFIO pre-copy will be added later on. +Migration of VFIO devices consists of two phases: the optional pre-copy ph= ase, +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 gues= t to +continue whilst the VFIO device state is transferred to the destination, t= his +helps to reduce the total downtime of the VM. VFIO devices opt-in to pre-c= opy +support by reporting the VFIO_MIGRATION_PRE_COPY flag in the +VFIO_DEVICE_FEATURE_MIGRATION ioctl. =20 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 pl= anned @@ -29,10 +31,20 @@ VFIO implements the device hooks for the iterative appr= oach as follows: * A ``load_setup`` function that sets the VFIO device on the destination in _RESUMING state. =20 +* 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 V= FIO + device. + * A ``state_pending_exact`` function that reads pending_bytes from the ven= dor driver, which indicates the amount of data that the vendor driver has ye= t to save for the VFIO device. =20 +* 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 prese= nt. =20 * A ``save_live_complete_precopy`` function that sets the VFIO device in @@ -111,8 +123,10 @@ Flow of state changes during Live migration =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 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 sup= ports +pre-copy. =20 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_exac= t() + (RUNNING, _ACTIVE, _RUNNING [_PRE_COPY]) + If device is active, get pending_bytes by .state_pending_{estimate,e= xact}() If total pending_bytes >=3D threshold_size, call .save_live_iter= ate() + [Data of VFIO device for pre-copy phase is copied] Iterate till total pending bytes converge and are less than thresh= old | On migration completion, vCPU stops and calls .save_live_complete_precop= y 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; =20 typedef struct VFIOAddressSpace { diff --git a/hw/vfio/common.c b/hw/vfio/common.c index fa8fd949b1..25801de173 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -492,7 +492,8 @@ static bool vfio_devices_all_dirty_tracking(VFIOContain= er *container) } =20 if (vbasedev->pre_copy_dirty_page_tracking =3D=3D ON_OFF_AUTO_= OFF && - migration->device_state =3D=3D VFIO_DEVICE_STATE_RUNNING) { + (migration->device_state =3D=3D VFIO_DEVICE_STATE_RUNNING = || + migration->device_state =3D=3D VFIO_DEVICE_STATE_PRE_COPY= )) { return false; } } @@ -537,7 +538,8 @@ static bool vfio_devices_all_running_and_mig_active(VFI= OContainer *container) return false; } =20 - if (migration->device_state =3D=3D VFIO_DEVICE_STATE_RUNNING) { + if (migration->device_state =3D=3D VFIO_DEVICE_STATE_RUNNING || + migration->device_state =3D=3D 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 *vbase= dev, return 0; } =20 +static int vfio_query_precopy_size(VFIOMigration *migration) +{ + struct vfio_precopy_info precopy =3D { + .argsz =3D sizeof(precopy), + }; + + migration->precopy_init_size =3D 0; + migration->precopy_dirty_size =3D 0; + + if (ioctl(migration->data_fd, VFIO_MIG_GET_PRECOPY_INFO, &precopy)) { + return -errno; + } + + migration->precopy_init_size =3D precopy.initial_bytes; + migration->precopy_dirty_size =3D 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, VFIOMigrat= ion *migration) data_size =3D 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 informa= tion, + * please refer to the Linux kernel VFIO uAPI. + */ + if (errno =3D=3D ENOMSG) { + return 0; + } + return -errno; } if (data_size =3D=3D 0) { @@ -265,6 +294,38 @@ static ssize_t vfio_save_block(QEMUFile *f, VFIOMigrat= ion *migration) return qemu_file_get_error(f) ?: data_size; } =20 +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 =3D 0; + migration->precopy_dirty_size =3D 0; + + return; + } + + if (migration->precopy_init_size) { + uint64_t init_size =3D MIN(migration->precopy_init_size, data_size= ); + + migration->precopy_init_size -=3D init_size; + data_size -=3D init_size; + } + + migration->precopy_dirty_size -=3D MIN(migration->precopy_dirty_size, + data_size); +} + +static bool vfio_precopy_supported(VFIODevice *vbasedev) +{ + VFIOMigration *migration =3D vbasedev->migration; + + return migration->mig_flags & VFIO_MIGRATION_PRE_COPY; +} + /* ---------------------------------------------------------------------- = */ =20 static int vfio_save_setup(QEMUFile *f, void *opaque) @@ -285,6 +346,28 @@ static int vfio_save_setup(QEMUFile *f, void *opaque) return -ENOMEM; } =20 + if (vfio_precopy_supported(vbasedev)) { + int ret; + + switch (migration->device_state) { + case VFIO_DEVICE_STATE_RUNNING: + ret =3D vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_P= RE_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); =20 qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); @@ -299,26 +382,42 @@ static void vfio_save_cleanup(void *opaque) =20 g_free(migration->data_buffer); migration->data_buffer =3D NULL; + migration->precopy_init_size =3D 0; + migration->precopy_dirty_size =3D 0; vfio_migration_cleanup(vbasedev); trace_vfio_save_cleanup(vbasedev->name); } =20 +static void vfio_state_pending_estimate(void *opaque, uint64_t *must_preco= py, + uint64_t *can_postcopy) +{ + VFIODevice *vbasedev =3D opaque; + VFIOMigration *migration =3D vbasedev->migration; + + if (migration->device_state !=3D VFIO_DEVICE_STATE_PRE_COPY) { + return; + } + + *must_precopy +=3D + 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) =20 -/* - * Only exact function is implemented and not estimate function. The reaso= n 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 useles= s. - */ static void vfio_state_pending_exact(void *opaque, uint64_t *must_precopy, uint64_t *can_postcopy) { VFIODevice *vbasedev =3D opaque; + VFIOMigration *migration =3D vbasedev->migration; uint64_t stop_copy_size =3D VFIO_MIG_STOP_COPY_SIZE; =20 /* @@ -328,8 +427,48 @@ static void vfio_state_pending_exact(void *opaque, uin= t64_t *must_precopy, vfio_query_stop_copy_size(vbasedev, &stop_copy_size); *must_precopy +=3D stop_copy_size; =20 + if (migration->device_state =3D=3D VFIO_DEVICE_STATE_PRE_COPY) { + vfio_query_precopy_size(migration); + + *must_precopy +=3D + migration->precopy_init_size + migration->precopy_dirty_size; + } + trace_vfio_state_pending_exact(vbasedev->name, *must_precopy, *can_pos= tcopy, - stop_copy_size); + stop_copy_size, migration->precopy_init= _size, + migration->precopy_dirty_size); +} + +static bool vfio_is_active_iterate(void *opaque) +{ + VFIODevice *vbasedev =3D opaque; + VFIOMigration *migration =3D vbasedev->migration; + + return migration->device_state =3D=3D VFIO_DEVICE_STATE_PRE_COPY; +} + +static int vfio_save_iterate(QEMUFile *f, void *opaque) +{ + VFIODevice *vbasedev =3D opaque; + VFIOMigration *migration =3D vbasedev->migration; + ssize_t data_size; + + data_size =3D 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 zer= o. + * Return 1 so following handlers will not be potentially blocked. + */ + return 1; } =20 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; =20 - /* We reach here with device state STOP only */ + /* We reach here with device state STOP or STOP_COPY only */ ret =3D 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 =3D { .save_setup =3D vfio_save_setup, .save_cleanup =3D vfio_save_cleanup, + .state_pending_estimate =3D vfio_state_pending_estimate, .state_pending_exact =3D vfio_state_pending_exact, + .is_active_iterate =3D vfio_is_active_iterate, + .save_live_iterate =3D vfio_save_iterate, .save_live_complete_precopy =3D vfio_save_complete_precopy, .save_state =3D vfio_save_state, .load_setup =3D vfio_load_setup, @@ -470,13 +612,18 @@ static const SaveVMHandlers savevm_vfio_handlers =3D { static void vfio_vmstate_change(void *opaque, bool running, RunState state) { VFIODevice *vbasedev =3D opaque; + VFIOMigration *migration =3D vbasedev->migration; enum vfio_device_mig_state new_state; int ret; =20 if (running) { new_state =3D VFIO_DEVICE_STATE_RUNNING; } else { - new_state =3D VFIO_DEVICE_STATE_STOP; + new_state =3D + (migration->device_state =3D=3D VFIO_DEVICE_STATE_PRE_COPY && + (state =3D=3D RUN_STATE_FINISH_MIGRATE || state =3D=3D RUN_ST= ATE_PAUSED)) ? + VFIO_DEVICE_STATE_STOP_COPY : + VFIO_DEVICE_STATE_STOP; } =20 /* diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index cfb60c354d..e328d644d2 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 p= recopy_dirty_size) " (%s) precopy initial size 0x%"PRIx64" precopy dirty si= ze 0x%"PRIx64 vfio_save_setup(const char *name, uint64_t data_buffer_size) " (%s) data b= uffer size 0x%"PRIx64 -vfio_state_pending_exact(const char *name, uint64_t precopy, uint64_t post= copy, uint64_t stopcopy_size) " (%s) precopy 0x%"PRIx64" postcopy 0x%"PRIx6= 4" stopcopy size 0x%"PRIx64 +vfio_state_pending_estimate(const char *name, uint64_t precopy, uint64_t p= ostcopy, uint64_t precopy_init_size, uint64_t precopy_dirty_size) " (%s) pr= ecopy 0x%"PRIx64" postcopy 0x%"PRIx64" precopy initial size 0x%"PRIx64" pre= copy dirty size 0x%"PRIx64 +vfio_state_pending_exact(const char *name, uint64_t precopy, uint64_t post= copy, uint64_t stopcopy_size, uint64_t precopy_init_size, uint64_t precopy_= dirty_size) " (%s) precopy 0x%"PRIx64" postcopy 0x%"PRIx64" stopcopy size 0= x%"PRIx64" precopy initial size 0x%"PRIx64" precopy dirty size 0x%"PRIx64 vfio_vmstate_change(const char *name, int running, const char *reason, con= st char *dev_state) " (%s) running %d reason %s device state %s" --=20 2.26.3 From nobody Sat May 18 15:49:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1687346039; cv=pass; d=zohomail.com; s=zohoarc; b=JjSud4epFHjuIoebU7QicVy3GM0k5zy0FYWdgPnvB0zKz8FEqbX+YCtCAhwqk9DKhznVjJfDttxFGIwkyk1D7es4HWYCAOWlMmsYyVCAuoh5qONHaAHNkgs0su3cBV9ibeGK8H1Hn2y6k7yuiSNnGRcbZ/9+QV04hngPGmu5+Ss= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687346039; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=go2NA/nyi2HtwKPRDB3OYy2WQbs8bK1OWD8hj4be3QA=; b=DooKU4a2qwX6nJcSp25vAjDp13mzd+fnPkV1mgppTdGwRjBA24ExUBdEROE1PEZIyHNGrP2BfL2pQu8iRCGwqOB1U1RJwyeKf2C+zNZJHFfnbZe59QRtlldZzEtzkZTZOrY6J+CM+8rqSd3ZYC5syuciAAzECANRdYFLiMFcaxk= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1687346039195474.05013640709444; Wed, 21 Jun 2023 04:13:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBvlx-0008VV-B0; Wed, 21 Jun 2023 07:13:13 -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 1qBvlu-0008EU-6O for qemu-devel@nongnu.org; Wed, 21 Jun 2023 07:13:10 -0400 Received: from mail-mw2nam10on2060f.outbound.protection.outlook.com ([2a01:111:f400:7e89::60f] 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 1qBvlh-0002aG-JF for qemu-devel@nongnu.org; Wed, 21 Jun 2023 07:13:09 -0400 Received: from DM6PR08CA0046.namprd08.prod.outlook.com (2603:10b6:5:1e0::20) by MN0PR12MB5764.namprd12.prod.outlook.com (2603:10b6:208:377::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 21 Jun 2023 11:12:53 +0000 Received: from CY4PEPF0000EDD2.namprd03.prod.outlook.com (2603:10b6:5:1e0:cafe::dd) by DM6PR08CA0046.outlook.office365.com (2603:10b6:5:1e0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23 via Frontend Transport; Wed, 21 Jun 2023 11:12:52 +0000 Received: from mail.nvidia.com (216.228.117.161) by CY4PEPF0000EDD2.mail.protection.outlook.com (10.167.241.206) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23 via Frontend Transport; Wed, 21 Jun 2023 11:12:52 +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; Wed, 21 Jun 2023 04:12:45 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Wed, 21 Jun 2023 04:12:44 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 21 Jun 2023 04:12:40 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RVB4WFG+pbFmjVrOHWZr7bJ6Xi6JsEjcuwCYR0OWhPJFYdHg20S4XQ2GEXcPF3+cLbbF8EWaHOdzqZD2jxxEPh/ptM8f/jOLCTM3b1U+17zaHvhcEyU1hLbPbS5svybW+IL0RusTrXYaiBGudJ3h60Pc1VmE2dCCfluEsAjJdyXcXYNt8afuwHEmewAIk/0ZyRJfyOddMXVWAyTI9fOHzdIgxud6CvQYRnfFLauBzx0pVfrqzaeCGPHpPjIp/AsWJMxxOcBHXTlg3RWTH1Qqkqzya3TaCvTIpPAATqnu048hUB6i0Rk1tp9t5s360o4cN199Z5FN0reKqRKRgPEwLw== 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=go2NA/nyi2HtwKPRDB3OYy2WQbs8bK1OWD8hj4be3QA=; b=BEBV/V/jLqekwBjsDnhtuABqvudK5MmGEaJ/kRI9PDcazvd1qaqNGMyuPr12X6XfqtiS5RkoYkl+K3F6zUGEyMe8unag90cpoHKjn67n/8lYCu4LwxWi+0pwydgYZHpI9r508z7V4HYCdLwG7ebzRvdayqmSnvtnW64vosFMohivGVRv+lRi03WFumihuy2u6LQ3yDLp/H93PDucZ1sv9pL/kfrSClXSFB+PPttBgrlYPh+WALWkPASAT25dVmgStOiJBXNA+Ds7jOwP8KZKv056dGB7Xd/k3qq503bzaTykOboYd2eox6Dxh5EPZockCugLpuJqyfWvRiycuJXq7g== 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=go2NA/nyi2HtwKPRDB3OYy2WQbs8bK1OWD8hj4be3QA=; b=oam0XSZJDqGCLCGpX8gjVW9rruy/d+F8mYZ8i3TxC1lI5gVHLJl9bdKkkFCWMcp8pwOu3B1mCx2YyfswLE7aZWLKPCnhMqpykTK2OrEyijRGsKyHx2/SCyytGt3+U9IE5rnKfyyIU5hGRGpLGKvTqmlLa8Ar8VbQiU80gkgu2a+0lmtookNb2EVJz2ehy+FeS0cckvhrk6fvsSnvhEwq0BJhS5kI6WPAlM8SPP0eKQKTXL68KRqDeiwOt4qI3L63e1Rqn400nFgYd+aTrVy3qU9BEaaCbmYQhATqcKvFlyo51fq2/Bx90ibh/gD7fLtv7DF0lVrso9CN0mkIbV+ZCw== 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (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 From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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 v6 8/8] vfio/migration: Add support for switchover ack capability Date: Wed, 21 Jun 2023 14:12:01 +0300 Message-ID: <20230621111201.29729-9-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230621111201.29729-1-avihaih@nvidia.com> References: <20230621111201.29729-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD2:EE_|MN0PR12MB5764:EE_ X-MS-Office365-Filtering-Correlation-Id: c43d76d3-cb3d-40c2-7697-08db724874e5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aa7ePa2Et49BW/18Uem/LSCeVqYhokxxMllYmRvNqy60I1bLwdsdnGhAII2qXfhA0oFmM+fUJLpsOuUlCJfZTP/U/mO1h/0FokrYbovFzf2RdLaYgb91O87P93g+skW8O9ux25m2ZNHA6cJ2msLRDA124X4QJVH4HClPtiGur6NsnZ/Yh6DmmaUeuAJMm+JSDc3ioDsSjJpgR12zuddNLlT5OQHIuM0u0nQKNHYliPtbCsd1fV0XzmXUy/peN/AierO+jQA1M6jFGz4VAKCCZE7Y8s7wbsNKXBu1Ous+HwQBQXm7iZjbCetezmkXpEi45USjMnCIUAxsCnLbj8hDyyZDScxDsvr+UdZzy9emfVF+4SqEZOdRZM3y1vyhg8eKnurhhAeZiDLI2PJbJZpAAaOft1ZopezaazLpWc4yijU0pjK0WjVUvQg3NXGQ2QAZL7fAKNbmTkmwJa8j/2OgAJ3VEhCBwKDwvlIkZYS1DS9rjPTW96FMW3AI1TVMkYL3wtgxMhpFu0q86XIKzEEyCqffeH16l4ZPEqLVZJNPGa+z5ly1SB3XBnwCkBRyK/AgAFB/+8oGWjxoJ8o/BEySTxqP6FLWhB0TfhP0W172HJ3XdAy3WZ7aFEJl3cOBfqvI4pOkzzgslUfngL2xbpmTca6vig3cPVXJX4gtyQC66JCGUkszao/VMKxYW9aOHwvDPTgPVJmAcF/4+vI30Y17A2aBvFC6Ebn59WClYY+Txz/H59wlOxjyTVIK1UxrqDYm 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)(39860400002)(136003)(376002)(396003)(451199021)(36840700001)(40470700004)(46966006)(2906002)(8936002)(8676002)(7416002)(86362001)(4326008)(6916009)(70586007)(70206006)(316002)(478600001)(41300700001)(54906003)(5660300002)(82740400003)(82310400005)(83380400001)(6666004)(7696005)(36860700001)(66574015)(426003)(2616005)(47076005)(336012)(36756003)(40460700003)(7636003)(356005)(186003)(1076003)(26005)(40480700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 11:12:52.6057 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c43d76d3-cb3d-40c2-7697-08db724874e5 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: CY4PEPF0000EDD2.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5764 Received-SPF: softfail client-ip=2a01:111:f400:7e89::60f; envelope-from=avihaih@nvidia.com; helo=NAM10-MW2-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1687346039468100001 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. Signed-off-by: Avihai Horon Reviewed-by: C=C3=A9dric Le Goater Tested-by: YangHang Liu Acked-by: Alex Williamson --- 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 devic= es opt-in to pre-copy support by reporting the VFIO_MIGRATION_PRE_COPY flag in the VFIO_DEVICE_FEATURE_MIGRATION ioctl. =20 +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 s= tream +and recommends that the initial bytes are sent and loaded in the destinati= on +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 pl= anned to be added later on. @@ -45,6 +52,9 @@ VFIO implements the device hooks for the iterative approa= ch as follows: * A ``save_live_iterate`` function that reads the VFIO device's data from = the vendor driver during iterative pre-copy phase. =20 +* 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 prese= nt. =20 * 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 1db901c194..3dc5f2104c 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; =20 typedef struct VFIOAddressSpace { diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index d8f6a22ae1..acbf0bb7ab 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) =20 /* * This is an arbitrary size based on migration of mlx5 devices, where typ= ically @@ -384,6 +387,7 @@ static void vfio_save_cleanup(void *opaque) migration->data_buffer =3D NULL; migration->precopy_init_size =3D 0; migration->precopy_dirty_size =3D 0; + migration->initial_data_sent =3D false; vfio_migration_cleanup(vbasedev); trace_vfio_save_cleanup(vbasedev->name); } @@ -457,10 +461,17 @@ static int vfio_save_iterate(QEMUFile *f, void *opaqu= e) if (data_size < 0) { return data_size; } - qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); =20 vfio_update_estimated_pending_data(migration, data_size); =20 + 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 =3D 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); =20 @@ -579,6 +590,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 a= ck " + "is not used", vbasedev->name); + return -EINVAL; + } + + ret =3D qemu_loadvm_approve_switchover(); + if (ret) { + error_report( + "%s: qemu_loadvm_approve_switchover failed, err=3D%d (= %s)", + vbasedev->name, ret, strerror(-ret)); + } + + return ret; + } default: error_report("%s: Unknown tag 0x%"PRIx64, vbasedev->name, data= ); return -EINVAL; @@ -593,6 +622,13 @@ static int vfio_load_state(QEMUFile *f, void *opaque, = int version_id) return ret; } =20 +static bool vfio_switchover_ack_needed(void *opaque) +{ + VFIODevice *vbasedev =3D opaque; + + return vfio_precopy_supported(vbasedev); +} + static const SaveVMHandlers savevm_vfio_handlers =3D { .save_setup =3D vfio_save_setup, .save_cleanup =3D vfio_save_cleanup, @@ -605,6 +641,7 @@ static const SaveVMHandlers savevm_vfio_handlers =3D { .load_setup =3D vfio_load_setup, .load_cleanup =3D vfio_load_cleanup, .load_state =3D vfio_load_state, + .switchover_ack_needed =3D vfio_switchover_ack_needed, }; =20 /* ---------------------------------------------------------------------- = */ --=20 2.26.3