From nobody Fri May 17 09:01:47 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=1684338870; cv=pass; d=zohomail.com; s=zohoarc; b=JqFAMqUm2mt1NSrisksWllo6Znb1lZmvZ3EVjKDPeOH0WUfzT60KfjdA2Z635yYtZB+hY1UClLXQg3zSUAcijHo8eWfR+Flm2wmRfhROmgZbN9adk51VFFD4b/BSBy0Ifmo+G4bCkgHtis3stJ5se3cnaokFJCL2RCJn63bk5ww= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684338870; 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=K4tRTe7RYY+7uBlRj7TjNitjXQVqgxEd/OzzPd7HgqY=; b=XGlW7ARxZ/+wROFN0NBcuH7vi0ZCHy3WXFsFW10GdW4BruHqQRdzmUvBzLJrzh00dquugH8o+/RG07UpW9e6ff77n9rqQuCIcRk14GSGyhjXCsWaR8DMgijz+hs0UK7+/r7t3Lrh8q27I4fMzT3wKXF80tt/2KbJbuG19uob6Ws= 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 1684338870912571.029175742836; Wed, 17 May 2023 08:54:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzJSP-0003Jk-Kl; Wed, 17 May 2023 11:52:53 -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 1pzJSM-0003Hy-I3 for qemu-devel@nongnu.org; Wed, 17 May 2023 11:52:50 -0400 Received: from mail-mw2nam10on20630.outbound.protection.outlook.com ([2a01:111:f400:7e89::630] 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 1pzJSH-0005uI-E5 for qemu-devel@nongnu.org; Wed, 17 May 2023 11:52:47 -0400 Received: from BN9PR03CA0975.namprd03.prod.outlook.com (2603:10b6:408:109::20) by CH3PR12MB8482.namprd12.prod.outlook.com (2603:10b6:610:15b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.33; Wed, 17 May 2023 15:52:40 +0000 Received: from BN8NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:408:109:cafe::2) by BN9PR03CA0975.outlook.office365.com (2603:10b6:408:109::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.33 via Frontend Transport; Wed, 17 May 2023 15:52:40 +0000 Received: from mail.nvidia.com (216.228.118.233) by BN8NAM11FT010.mail.protection.outlook.com (10.13.177.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.18 via Frontend Transport; Wed, 17 May 2023 15:52:40 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 17 May 2023 08:52:30 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 17 May 2023 08:52:30 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 17 May 2023 08:52:25 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uxtxs5tF7MMfJ+HrP+bCQEGRNp3JUIpITaAs1vBFzBhToE7S1QTC8omg31uTGfl/gVMhgr2XEVOi06jOS6Tgvvaw3euRXZ1CnKXuaN6zkKX+K0kbHTq5skjm60+Mpo9urs7PuFcfjoTEP5FuYY5D3IwDCGgJWSd8IDT2D0A58c7OZQ4O5r6tMcCxasjygLHA/rG/DNZXKs45XGUMqFfupajzvsV/v0kR+AxUpLejsYM6nNwIioo6tdQ+XCgRFJDHasP/IW///6MVHYUtJ0PDg0AIsA77SfGzOjqZ5vlyKsnAMtXbr+1amaV2XKqdg1d5TnaJT0KHJ50OgDBWiQnlvw== 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=K4tRTe7RYY+7uBlRj7TjNitjXQVqgxEd/OzzPd7HgqY=; b=JtB6dTUlD4ov9ZQgEr763xtWEqyFUmAqeoPC7hGTMkUUAkxq12CggrlnYVP6ZdUFCTwUoc5s2SvrBER700iPqX366bD/Sujb0jmtVN4kAEx7yoX4LpgcXcDc33KbEhFPnWrc5aBXTK05Qf2lHx9eHdos5DqzWFZB+h8R898wl0ZR82gRaxK7Qa4Mia+wFd0pggLPGEV8u4qosY4QYOi4gLQBMjXN1dvTp7BUkJVirXUDknFMxCWlBIvk00itsmwsqrADQdpwZ15f+UC5nAUjVxn2vMUUtwHRNlFnK+AFM0fLPRJcp5k5armBcEA+sJDI0FuoAxWncFDDwZhRph2ayA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none 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=K4tRTe7RYY+7uBlRj7TjNitjXQVqgxEd/OzzPd7HgqY=; b=sDGL6+uLHDrKjCojIoOquEnqGxfwidkNWEIup064iQwgBoAu51yuWofIXibD7psWQlTlA2c241XFIz4adXDUhKyp8DGKLVbv25gTHHMA4H1vluqebrqAIlszY4jyt4OpmNKdD6LZ1WY7Nl5XlwelydBrvtLMpB6gEV4tFPmKxJAYSrhJvdOZbsLZQ7qfn+EZGPfrxEueHpvpO05VGIuQhmkv+7JEeQUo5a86RAfSw/zs0pHD2CwwPEbv7wFm8TvpihWjhByPNk6bKuEOlP9LP02kb/4iue7Y3uOsTv3WMWUZ2r4c7S4cKQCaf0zh55Z7chC/CTMd9IwilIy3v3N/Yw== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Juan Quintela , Peter Xu , Leonardo Bras , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v2 1/7] migration: Add precopy initial data capability Date: Wed, 17 May 2023 18:52:13 +0300 Message-ID: <20230517155219.10691-2-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230517155219.10691-1-avihaih@nvidia.com> References: <20230517155219.10691-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT010:EE_|CH3PR12MB8482:EE_ X-MS-Office365-Filtering-Correlation-Id: b99d900c-19be-41ab-a48f-08db56eebec8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hIA6DjKVc47VRUC0sr3BES74hmNSF4TWWTSkCmAr7ftoo/5IrCm58NxIusxL8vULNY0iMr/wxfP2PQPMI0rNjLh0sjslOGNxPWqZwU5u+7s5eWcRVACfttvtrofYOxELqwU4cMUU9Xe9G1oIfI3PgecIXFmEHLwdN9SmJl4dx3Sx0PQb3h+tOYSSNL02WfAsSglCrG7wWiHJQ/LHrnfLBXtd9NKQE91FtpInXnI0M2FJpLoP9jcgKRd/Pcvg84rox63oM4E/J0w/5wx3TgGEaJtP6KCXOsmURP6v+9NW1QvtAVdsIxDvw9PB3rj3TZjkrwZcCjJxxmmsHc1PvwNVVE4r92hjVi8S3/uAx4KeqP7I7vTfJ+coxjEo7Vk8grpB8a2ymVzqqHnQCXokK0Su8n73itxrZhphPPxwUtz531RpU20RN4LF6gPmBJqhjBnjZLxXr5VidgNbHIB55NDkLC3+cIq15ar01FkotMMAZTKC33feb93M/sD2Uv1uhbKw6xzHpUB/wt3SsXHQltIXF9ijBnkKDnlftRm3cqPOqiqVhXOuW4GEbLkoe29ECW637kMWWWZ7Y79pzknoEC8IJLkdmGcYiZeUr5jh3KD4cq5+hh1lK/3WiAtEP7L33Gftyx9yoDqH0OTQ8S+XBjMF3/jic3rM/LYX8CeWuS1NwM1lVzrVLu2mM8Zi6EEi0Dwh38ucjsrNXmPCmqX4XY95mjxQygtXAkytAr6B6NBv8SphTtiaQ51w2HviNkrfKpnY X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(136003)(346002)(376002)(396003)(451199021)(40470700004)(46966006)(36840700001)(7696005)(36756003)(6666004)(2616005)(40480700001)(83380400001)(47076005)(1076003)(36860700001)(26005)(186003)(40460700003)(336012)(426003)(5660300002)(82310400005)(7416002)(7636003)(356005)(82740400003)(54906003)(86362001)(41300700001)(316002)(70206006)(70586007)(8676002)(6916009)(8936002)(478600001)(2906002)(4326008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 15:52:40.4207 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b99d900c-19be-41ab-a48f-08db56eebec8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8482 Received-SPF: softfail client-ip=2a01:111:f400:7e89::630; 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: 1684338872040100001 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 migration users. 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 "precopy initial data" that allows the source to send initial precopy data and the destination to ACK that this data has been loaded. Migration will not attempt to stop the source VM and complete the migration until this ACK is received. This will allow migration users to send initial precopy data which can be used to reduce downtime (e.g., by pre-allocating resources), while making sure that the source will stop the VM and complete the migration only after this initial precopy data is sent and loaded in the destination 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 --- qapi/migration.json | 9 ++++++++- migration/options.h | 1 + migration/options.c | 21 +++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/qapi/migration.json b/qapi/migration.json index 179af0c4d8..a6c1942064 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -487,6 +487,13 @@ # and should not affect the correctness of postcopy migration. # (since 7.1) # +# @precopy-initial-data: If enabled, migration will not attempt to +# stop source VM and complete the migration until an ACK is +# received from the destination that initial precopy data has been +# loaded. This can improve downtime if there are migration users +# that support precopy initial data. '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 +509,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', 'precopy-initial-data'] } =20 ## # @MigrationCapabilityStatus: diff --git a/migration/options.h b/migration/options.h index 5cca3326d6..bba70a33bf 100644 --- a/migration/options.h +++ b/migration/options.h @@ -44,6 +44,7 @@ bool migrate_pause_before_switchover(void); bool migrate_postcopy_blocktime(void); bool migrate_postcopy_preempt(void); bool migrate_postcopy_ram(void); +bool migrate_precopy_initial_data(void); bool migrate_rdma_pin_all(void); bool migrate_release_ram(void); bool migrate_return_path(void); diff --git a/migration/options.c b/migration/options.c index c2a278ee2d..0a31921a7a 100644 --- a/migration/options.c +++ b/migration/options.c @@ -184,6 +184,8 @@ Property migration_properties[] =3D { DEFINE_PROP_MIG_CAP("x-zero-copy-send", MIGRATION_CAPABILITY_ZERO_COPY_SEND), #endif + DEFINE_PROP_MIG_CAP("x-precopy-initial-data", + MIGRATION_CAPABILITY_PRECOPY_INITIAL_DATA), =20 DEFINE_PROP_END_OF_LIST(), }; @@ -286,6 +288,13 @@ bool migrate_postcopy_ram(void) return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_RAM]; } =20 +bool migrate_precopy_initial_data(void) +{ + MigrationState *s =3D migrate_get_current(); + + return s->capabilities[MIGRATION_CAPABILITY_PRECOPY_INITIAL_DATA]; +} + bool migrate_rdma_pin_all(void) { MigrationState *s =3D migrate_get_current(); @@ -546,6 +555,18 @@ bool migrate_caps_check(bool *old_caps, bool *new_caps= , Error **errp) } } =20 + if (new_caps[MIGRATION_CAPABILITY_PRECOPY_INITIAL_DATA]) { + if (!new_caps[MIGRATION_CAPABILITY_RETURN_PATH]) { + error_setg(errp, "Capability 'precopy-initial-data' requires " + "capability 'return-path'"); + return false; + } + + /* Disable this capability until it's implemented */ + error_setg(errp, "'precopy-initial-data' is not implemented yet"); + return false; + } + return true; } =20 --=20 2.26.3 From nobody Fri May 17 09:01:47 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=1684338830; cv=pass; d=zohomail.com; s=zohoarc; b=AdDK/vjJST5l14+9SCB4Uk6kPwUCj3djVsWY37pEKF457Vi9fNvgFAipQ2opIc70Vl2xQPXf2P1nEae+FsvgUxZfxH0Ad6avFtA3qEOUN4qzJ4GvwZMrHSekMPuwJkS3rV3VlPnEuCwP/GZu1KdDzM+eszD34d5HTHcY7dQ732g= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684338830; 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=D3eNmstU6+dZUNsKAOcuJIoMMbPJZdRDquef+y7SsbE=; b=HYzTk4UpPcfc344sbN85tk0MauwNAaBiR6hUB+8WqanBNFr0TcqQJB8ckvtQv8yyHtY0TvWHOPf0a1p92sLj0pG2PN5fHG9ofMUIN6Byvrxqknu2GrtJ6tKrtVOKr+gzZB8VLcoA2Av9mk4W+7bP4da0hvkRgmI/RFV5QxTtf7k= 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 1684338830773298.31025128029626; Wed, 17 May 2023 08:53:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzJSS-0003MI-BD; Wed, 17 May 2023 11:52:57 -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 1pzJSQ-0003Kx-MG for qemu-devel@nongnu.org; Wed, 17 May 2023 11:52:55 -0400 Received: from mail-mw2nam04on2060b.outbound.protection.outlook.com ([2a01:111:f400:7e8c::60b] helo=NAM04-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzJSN-0005v3-8m for qemu-devel@nongnu.org; Wed, 17 May 2023 11:52:54 -0400 Received: from DM6PR13CA0043.namprd13.prod.outlook.com (2603:10b6:5:134::20) by SA3PR12MB8809.namprd12.prod.outlook.com (2603:10b6:806:31f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.33; Wed, 17 May 2023 15:52:46 +0000 Received: from DM6NAM11FT067.eop-nam11.prod.protection.outlook.com (2603:10b6:5:134:cafe::a7) by DM6PR13CA0043.outlook.office365.com (2603:10b6:5:134::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.14 via Frontend Transport; Wed, 17 May 2023 15:52:46 +0000 Received: from mail.nvidia.com (216.228.118.232) by DM6NAM11FT067.mail.protection.outlook.com (10.13.172.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.18 via Frontend Transport; Wed, 17 May 2023 15:52:46 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 17 May 2023 08:52:36 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 17 May 2023 08:52:35 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 17 May 2023 08:52:30 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=leLzj+4q142aFzt678Gw+QcTFsrnKPFmYpjRt18wy4LS400CwcMKgREn0D9TZd33yEXJGCyUN316M5H4Igk4ACmysndTbxsB27zDil/UKNSLp67833LCP6NCz4BBIayqnzDof+Uqb86BRUnEZptL9XPump6bKvYvJZ3s96WGf20XLhcgmc60VreLuDt9Q/cYsxdln+KuVMjdnqVu1qBvjuCGkehkx0njGUOOkEXSwxNFMAfrj8tGqwcYmCy0fuyvHF7UlC8gNNbuVNUZk0GQGDNQq9X16FS10z9ay3VwBiFV+9uRkJvCSbVc0z6qElQ6UPDVz73YrE0iT8dfSMGdXA== 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=D3eNmstU6+dZUNsKAOcuJIoMMbPJZdRDquef+y7SsbE=; b=iN3CNqpxpivtktgSzZvWQNL0Ey1PZUoVSDt8zrBY/c4er074iPcWXHpUBvaTJZ1E1NpFjEX50k+dhRgF6Hh0DxeRbQbDLPOlxUALGc4ihtpUkFDgYa+HhPFwIJKCbWS4JOrW8WWgdd0OyK/HaMG5l/Oiwhvsmq0LJY7c6orQF2E9T5h4om/YCU9MlAolT7FQuN+/zYtHMKEG0tKqZBPskNsmG9pgNTtTALPz/G4WBMQq7V1bn/yuU/Uf2wV1fBE6cDSmf4pzAQDgHpNpZBer2+WJDWBzoPF9lOr+JkmWvVOr3x9pRQojC/b9p8paZJhkI97TtYMG5P6jF7e+0gJ00w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none 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=D3eNmstU6+dZUNsKAOcuJIoMMbPJZdRDquef+y7SsbE=; b=pD0F1ZxHoTqyCb70HW0RVP5P6Tpe2+118RPb1RtRnv2XpdIS6hc7noWISsX4Z9Z4D8fkEe36/dJUcON7wdEhBcq34maP6gxy/gxoscl57tJDscfB5IGU6I0LdGotFNCepmqt5HbDjGVRY20vnCRAPVMqOmEtEdxSPanuQglBI7LimM7pwgxNs+dksBwwmLpw0TSnm5gmEtuF2VKFk/MlUPk321k6KKUHHgIKaiR5FLdiqcXPMz9V51R7FTykkZIpO4yMVprBYgO0mLi26YzpY7mtK1/CX0YtU0G1EtH1tZ+LQUQmiYQwfXjHbUYYi+6aX//9E4uv2+wkm28dBgOvRQ== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Juan Quintela , Peter Xu , Leonardo Bras , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v2 2/7] migration: Implement precopy initial data logic Date: Wed, 17 May 2023 18:52:14 +0300 Message-ID: <20230517155219.10691-3-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230517155219.10691-1-avihaih@nvidia.com> References: <20230517155219.10691-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT067:EE_|SA3PR12MB8809:EE_ X-MS-Office365-Filtering-Correlation-Id: be9ff45f-8954-4856-82e5-08db56eec239 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E1o4LOFR8ez0Jm+yvK/wUZ2sN73yEPX+717+6ywxnJFmMwAQBdKeZrklMw+uiKvVHQz5Jm6mwJhGBYg2Tq5GbzKhuX9h19GBO8aD48QkkzwAWBepsM+bTykXYBRvz93qpMf3Uw8TrQe/fpUBlwI/n3C3OGwGopEVna4jKgD0eUGIEFsiD1NuU8C44wz3kiWUvPN7z1rWE7XBh0hBXjzhrG1zcra0RGCk2jAmARwm/XWwcPAd9GunWuLd3Y4yd7kgz9u+lEQbXTimYP3eNPUFFlns2UsWKsvfvPokuf6QCw0eqICTPJaUf09Y2qlhMSmhZxHPObyDZEKg76V3glU0TjrxNJeaAFP06NVVuM/n/yMpnkQZf9tC1F4HkUOcfmT80IUeLR9wsZZBgWjtZsapgeg0hj3E+c5KmBd8KvuTQCnTLJDZ6UISvlsY6vJ+f/NC0JWqklUqkbCmGZFechpMphCN3yKwSdepr0aPvV1XPnDzOypJJH4j5e5UGbLndQq6H7h0RaRmRlZ4H5sIJra3QAz2G2dPD01+Tqzs4BXlJVSCM+hRQ5Xo3z38wHvOf6EJz2iP0Q9f7UO1hkXmR9B4ZmR5PzuF2Qofh0YgjlnjWnbFbXfsLh6AksNsmfw8Dx4/9c8/HdZsZHDx+SPyFegLt0cxbUnrRSr8M9N56Gz/HMVEDgrnu3h82pBIEW43KpKQc9FwcfT2YOo5wkIYf8FXUpGkGI5LOwQlqnDNm1Y8Ti0= X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(346002)(376002)(396003)(39860400002)(136003)(451199021)(36840700001)(40470700004)(46966006)(316002)(70586007)(6916009)(54906003)(41300700001)(70206006)(4326008)(40480700001)(26005)(1076003)(478600001)(6666004)(7696005)(8936002)(5660300002)(8676002)(7416002)(82310400005)(40460700003)(86362001)(36860700001)(186003)(47076005)(83380400001)(7636003)(82740400003)(356005)(2616005)(30864003)(426003)(2906002)(36756003)(336012); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 15:52:46.2405 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be9ff45f-8954-4856-82e5-08db56eec239 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT067.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB8809 Received-SPF: softfail client-ip=2a01:111:f400:7e8c::60b; envelope-from=avihaih@nvidia.com; helo=NAM04-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: 1684338831845100003 Content-Type: text/plain; charset="utf-8" Implement precopy initial data logic. This allows migration users in the source to send precopy initial data and the destination to ACK when this data is loaded. Migration will not attempt to stop the source VM and complete the migration until this ACK is received. To achieve this, a new SaveVMHandlers handler initial_data_advise() and a new return path mesage MIG_RP_MSG_INITIAL_DATA_LOADED_ACK are added. The initial_data_advise() handler is called during migration setup both in the source and the destination to advise the migration user that precopy initial data is used, and its return value indicates whether precopy initial data is supported by it. When precopy initial data of all the migration users is loaded in the destination, the MIG_RP_MSG_INITIAL_DATA_LOADED_ACK return path message is sent to the source to notify it. Signed-off-by: Avihai Horon --- include/migration/register.h | 6 ++++ migration/migration.h | 14 ++++++++ migration/savevm.h | 2 ++ migration/migration.c | 40 ++++++++++++++++++++-- migration/savevm.c | 65 ++++++++++++++++++++++++++++++++++++ migration/trace-events | 4 +++ 6 files changed, 129 insertions(+), 2 deletions(-) diff --git a/include/migration/register.h b/include/migration/register.h index a8dfd8fefd..3ac443a55f 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -71,6 +71,12 @@ typedef struct SaveVMHandlers { int (*load_cleanup)(void *opaque); /* Called when postcopy migration wants to resume from failure */ int (*resume_prepare)(MigrationState *s, void *opaque); + + /* + * Advises that precopy initial data was requested. Returns true if it= 's + * supported or false otherwise. Called both in src and dest. + */ + bool (*initial_data_advise)(void *opaque); } SaveVMHandlers; =20 int register_savevm_live(const char *idstr, diff --git a/migration/migration.h b/migration/migration.h index 7721c7658b..cc4e817939 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -202,6 +202,13 @@ struct MigrationIncomingState { * contains valid information. */ QemuMutex page_request_mutex; + + /* + * Number of migration users that are waiting for their initial data t= o be + * loaded. When this reaches zero an ACK is sent to source. No lock is + * needed as this field is updated serially. + */ + unsigned int initial_data_pending_num; }; =20 MigrationIncomingState *migration_incoming_get_current(void); @@ -430,6 +437,12 @@ struct MigrationState { =20 /* QEMU_VM_VMDESCRIPTION content filled for all non-iterable devices. = */ JSONWriter *vmdesc; + + /* + * Indicates whether an ACK that precopy initial data was loaded in + * destination has been received. + */ + bool initial_data_loaded_acked; }; =20 void migrate_set_state(int *state, int old_state, int new_state); @@ -470,6 +483,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_initial_data_loaded_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..e1d8a2b3b2 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -32,6 +32,7 @@ bool qemu_savevm_state_blocked(Error **errp); void qemu_savevm_non_migratable_list(strList **reasons); void qemu_savevm_state_setup(QEMUFile *f); +void qemu_savevm_state_initial_data_advise(MigrationState *ms); bool qemu_savevm_state_guest_unplug_pending(void); int qemu_savevm_state_resume_prepare(MigrationState *s); void qemu_savevm_state_header(QEMUFile *f); @@ -65,6 +66,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_notify_initial_data_loaded(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 00d8ba8da0..fdb8592e64 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_INITIAL_DATA_LOADED_ACK, /* Tell source initial data is loa= ded */ =20 MIG_RP_MSG_MAX }; @@ -780,6 +781,12 @@ bool migration_has_all_channels(void) return true; } =20 +int migrate_send_rp_initial_data_loaded_ack(MigrationIncomingState *mis) +{ + return migrate_send_rp_message(mis, MIG_RP_MSG_INITIAL_DATA_LOADED_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 @@ -1425,6 +1432,7 @@ void migrate_init(MigrationState *s) s->vm_was_running =3D false; s->iteration_initial_bytes =3D 0; s->threshold_size =3D 0; + s->initial_data_loaded_acked =3D false; } =20 int migrate_add_blocker_internal(Error *reason, Error **errp) @@ -1741,6 +1749,9 @@ 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_INITIAL_DATA_LOADED_ACK] =3D { .len =3D 0, + .name =3D + "INITIAL_DATA_LOADED_ACK"= }, [MIG_RP_MSG_MAX] =3D { .len =3D -1, .name =3D "MAX" }, }; =20 @@ -1979,6 +1990,11 @@ retry: } break; =20 + case MIG_RP_MSG_INITIAL_DATA_LOADED_ACK: + ms->initial_data_loaded_acked =3D true; + trace_source_return_path_thread_initial_data_loaded_ack(); + break; + default: break; } @@ -2727,6 +2743,20 @@ static void migration_update_counters(MigrationState= *s, bandwidth, s->threshold_size); } =20 +static bool initial_data_loaded_acked(MigrationState *s) +{ + if (!migrate_precopy_initial_data()) { + return true; + } + + /* No reason to wait for precopy initial data loaded ACK if VM is stop= ped */ + if (!runstate_is_running()) { + return true; + } + + return s->initial_data_loaded_acked; +} + /* Migration thread iteration status */ typedef enum { MIG_ITERATE_RESUME, /* Resume current iteration */ @@ -2742,6 +2772,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 initial_data_loaded =3D initial_data_loaded_acked(s); =20 qemu_savevm_state_pending_estimate(&must_precopy, &can_postcopy); uint64_t pending_size =3D must_precopy + can_postcopy; @@ -2754,7 +2785,8 @@ static MigIterateState migration_iteration_run(Migrat= ionState *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) && + initial_data_loaded) { trace_migration_thread_low_pending(pending_size); migration_completion(s); return MIG_ITERATE_BREAK; @@ -2762,7 +2794,7 @@ static MigIterateState migration_iteration_run(Migrat= ionState *s) =20 /* Still a significant amount to transfer */ if (!in_postcopy && must_precopy <=3D s->threshold_size && - qatomic_read(&s->start_postcopy)) { + initial_data_loaded && qatomic_read(&s->start_postcopy)) { if (postcopy_start(s)) { error_report("%s: postcopy failed to start", __func__); } @@ -2986,6 +3018,10 @@ static void *migration_thread(void *opaque) =20 qemu_savevm_state_setup(s->to_dst_file); =20 + if (migrate_precopy_initial_data()) { + qemu_savevm_state_initial_data_advise(s); + } + qemu_savevm_wait_unplug(s, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_ACTIVE); =20 diff --git a/migration/savevm.c b/migration/savevm.c index e33788343a..c713ace891 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1233,6 +1233,32 @@ bool qemu_savevm_state_guest_unplug_pending(void) return false; } =20 +void qemu_savevm_state_initial_data_advise(MigrationState *ms) +{ + SaveStateEntry *se; + unsigned int supported_num =3D 0; + + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + if (!se->ops || !se->ops->initial_data_advise) { + continue; + } + + if (se->ops->initial_data_advise(se->opaque)) { + supported_num++; + } + } + + if (!supported_num) { + /* + * There are no migration users that support precopy initial data.= Set + * initial data loaded acked to true so migration can be completed. + */ + ms->initial_data_loaded_acked =3D true; + } + + trace_savevm_state_initial_data_advise(supported_num); +} + void qemu_savevm_state_setup(QEMUFile *f) { MigrationState *ms =3D migrate_get_current(); @@ -2586,6 +2612,23 @@ static int qemu_loadvm_state_header(QEMUFile *f) return 0; } =20 +static void qemu_loadvm_state_initial_data_advise(MigrationIncomingState *= mis) +{ + SaveStateEntry *se; + + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + if (!se->ops || !se->ops->initial_data_advise) { + continue; + } + + if (se->ops->initial_data_advise(se->opaque)) { + mis->initial_data_pending_num++; + } + } + + trace_loadvm_state_initial_data_advise(mis->initial_data_pending_num); +} + static int qemu_loadvm_state_setup(QEMUFile *f) { SaveStateEntry *se; @@ -2789,6 +2832,10 @@ int qemu_loadvm_state(QEMUFile *f) return -EINVAL; } =20 + if (migrate_precopy_initial_data()) { + qemu_loadvm_state_initial_data_advise(mis); + } + cpu_synchronize_all_pre_loadvm(); =20 ret =3D qemu_loadvm_state_main(f, mis); @@ -2862,6 +2909,24 @@ int qemu_load_device_state(QEMUFile *f) return 0; } =20 +int qemu_loadvm_notify_initial_data_loaded(void) +{ + MigrationIncomingState *mis =3D migration_incoming_get_current(); + + if (!mis->initial_data_pending_num) { + return -EINVAL; + } + + mis->initial_data_pending_num--; + trace_loadvm_notify_initial_data_loaded(mis->initial_data_pending_num); + + if (mis->initial_data_pending_num) { + return 0; + } + + return migrate_send_rp_initial_data_loaded_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 f39818c329..807083c0a1 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_initial_data_advise(unsigned int initial_data_pending_num) "I= nitial data 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_notify_initial_data_loaded(unsigned int initial_data_pending_num) "= Initial data pending num=3D%u" postcopy_ram_listen_thread_exit(void) "" postcopy_ram_listen_thread_start(void) "" qemu_savevm_send_postcopy_advise(void) "" @@ -39,6 +41,7 @@ savevm_send_postcopy_resume(void) "" savevm_send_colo_enable(void) "" savevm_send_recv_bitmap(char *name) "%s" savevm_state_setup(void) "" +savevm_state_initial_data_advise(unsigned int initial_data_supported_num) = "Initial data supported num=3D%u" savevm_state_resume_prepare(void) "" savevm_state_header(void) "" savevm_state_iterate(void) "" @@ -180,6 +183,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_initial_data_loaded_ack(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 Fri May 17 09:01:47 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=1684338805; cv=pass; d=zohomail.com; s=zohoarc; b=JhYFIr2IolFzkNVYp/wAAg5VA62MWGXrVxvBcbj4cRrFErovOSuscNtDks8RUtgt0KVrNYAH+ql4j5ZakXVFd3kuFmMjv9DizAhvvmXf91aMKTiO0B67PFzjo6xi7bgTjCQj3oHnVBpffuQBrJDy9ojJO4SFzYPSq6oGVZUAxMk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684338805; 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=qwg/xFQs5M2jSep5gzsnhFAF7zskD7cQHJBRmmfUmBs=; b=S4/aYax1g9PPMod1Zzh17FjzePW7xkTuEcFttYY4KBzEURCyU5wAltuxX/aV1Y9n5/bj8CgryAw+/anFEvwtDU+HdxGC7Jh2+UvuOQLvesmKwbc7LgMrX6DPeM9eyTqQi8lJ0hffsLfLV9aTLgBF7IUQeYj2xFEgQQCTYBbu+KA= 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 1684338805402989.8527361248318; Wed, 17 May 2023 08:53:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzJSV-0003Ot-Ad; Wed, 17 May 2023 11:52:59 -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 1pzJSS-0003M1-2h for qemu-devel@nongnu.org; Wed, 17 May 2023 11:52:56 -0400 Received: from mail-mw2nam10on20602.outbound.protection.outlook.com ([2a01:111:f400:7e89::602] 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 1pzJSQ-0005wE-6T for qemu-devel@nongnu.org; Wed, 17 May 2023 11:52:55 -0400 Received: from BN0PR03CA0046.namprd03.prod.outlook.com (2603:10b6:408:e7::21) by PH7PR12MB6491.namprd12.prod.outlook.com (2603:10b6:510:1f4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Wed, 17 May 2023 15:52:50 +0000 Received: from BN8NAM11FT062.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e7:cafe::ee) by BN0PR03CA0046.outlook.office365.com (2603:10b6:408:e7::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.18 via Frontend Transport; Wed, 17 May 2023 15:52:50 +0000 Received: from mail.nvidia.com (216.228.118.233) by BN8NAM11FT062.mail.protection.outlook.com (10.13.177.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.18 via Frontend Transport; Wed, 17 May 2023 15:52:49 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 17 May 2023 08:52:41 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 17 May 2023 08:52:40 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 17 May 2023 08:52:36 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ROAJv+Wc5LOUlCZ01AR0rxYFGFTewAsb34YT92vpNMATiadJ2MJ+vRsbqtKjPlcYYPEoMHZqeeSFuJZoayXHWihtpTmEClgSBVdVsFkaWMQUiSy0JPGFSS/pOPmaO0LKtLpYviBI7UYOc1w7D8syz0HdfcLx4Yb0CZQHxP2fkzo7CDSeMABo7WIk4VKlCofhCZBfXqQljYduuKww1reqcrBfe1e293WCcS6UFgoob37O9mLJb2FrSJsd9ZOTYTdfaj6Y3bzbO7bhd2BDhK5JRLC4nBsDEbizG11a/swgNN6gu180+u4pn6d/4siXX8XmpoYP2gCRU/hjzWg/vdpbNw== 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=qwg/xFQs5M2jSep5gzsnhFAF7zskD7cQHJBRmmfUmBs=; b=KrNF/21ZWt9GloN2pq7Z0nPWK5ARjorS0uXx5tMs7kdVHbr/5/Wu5yE8/V7hAY/AbI/eoXdy866xPTzmq3VkTYTMFg7x2fJffYdr2wOuLNdocjxfOB31WQE1MjiIYPT5fg0qV8jyJT1jKvUIe5Y/ONc5KoRCEeMlL84AEpZ5ZGSW95bSr6nyGRAJIhwd9RK7b0gXJkCmzM4gkH/siXYKGLyZTaGhG3MbEEwxP85plW8Um/MM1bZo4DPx6+E8brZTOWX2ehvDoewEboPCC0AfNmWRY35+Jv3p9soqvMWvndFnC0qDVDGsXqM4NskYHrzS5rj8dQ3c4PA9SP3GYFQGOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none 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=qwg/xFQs5M2jSep5gzsnhFAF7zskD7cQHJBRmmfUmBs=; b=j0wD5JqvmGvJt6/Sqyo92aR4JNBJDYEpLywBV/SKASyP3TNGNgb2qI8+eWDWidlSinCO3do1fKcO0Zv7vEauD9clQeSIQxANwETCda4ijzm3yVvKzKKoNiVWFjo/E33AbT+iUUo/c85FMMZtvlTp3REVzUOf7NcNOsXX6b0MQNkoJRxNTYPONOoJEE51BhWjcoPlYCA9adlPS/cVMe1MTsyV6K5xyfsOBuo/R2xpvn37W6swqrxAwVUEZgNnZLsnUggoMAMhEw20lamPutzNHspAdG+ZKiI0s0nUXUPeSF60yi4twPBtVYV3YPSjzuXWNLZc9uTJ2WgKFxF3xe5t5g== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Juan Quintela , Peter Xu , Leonardo Bras , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v2 3/7] migration: Enable precopy initial data capability Date: Wed, 17 May 2023 18:52:15 +0300 Message-ID: <20230517155219.10691-4-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230517155219.10691-1-avihaih@nvidia.com> References: <20230517155219.10691-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT062:EE_|PH7PR12MB6491:EE_ X-MS-Office365-Filtering-Correlation-Id: 7fd3a2ff-4480-4c17-b90c-08db56eec46c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: irNmAnpQaGpp74fMTKw/3GGxvYXhhdCGyL6BYbEPW3/f1bgIcsLJUSpGjnkPlNRb4qONXsCBdZZDadPStGr8gFWUNUfq1dp4hp7Q+kuvlomTwm6gdF6i+pCDs00SNyQD8WNaB1e7rY8tcOf4k+nYxxAUk/WJFXtads16mTjd4iB/pAtf4mZevFZq9HUIZ/Ple203RltmAIATrYvISirSgU1sg9S08Zq9Mdy2C5aXuJ076RyDsX/IYtuA907lbfD6/gcPbKRJ+a4gjB0q6fvrwwnh2I3u1azvngJH9fywkniVbXtq+Qzb7ZZogjgI975tUpl7j0fh4xispKFR3cjlkHtfjWu5h7lK59vFhLTY2MVpEVpkmFZ6mf2Ilpe1e3ZlY+TY45QfwkmAXHkBCtNCQnnpZLNVdVjyAtdMAFsou7R3btThnJ95/SKuWR5l2/TOQud4n+DRDlarHwuj7cuyEIJvNMFDwXWwztC+zC4DS7SOqXkUY6SbrTIaQToSsnx8fqObmV7Tmc4RhS4jQrPH8WbtvxmrAp6mg/xixNQ6XFp3lTbsjNTIsVdxYpcuzKpBK5GCNvSmwVJVZn5hiqIhyK/RosgatsFct0fyaeYbIMyo3D0aOKIeRdnpCS/JVCV392l62/Gv0UBjy89xxwIX+bgOtBFIexyyxo9dP/OlFR9VouJS1D3ILXZzXoFaBH8k+Xue6bM9SdUyEe2BkUjDAdogDE56q9fKYq1DLQc3+/QaPe3va8X2KstpdhsG4ieK X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(376002)(136003)(346002)(39860400002)(396003)(451199021)(40470700004)(46966006)(36840700001)(70586007)(70206006)(478600001)(54906003)(6916009)(4326008)(316002)(7696005)(6666004)(41300700001)(5660300002)(40460700003)(186003)(1076003)(26005)(8676002)(8936002)(7416002)(40480700001)(4744005)(2616005)(47076005)(2906002)(336012)(36756003)(83380400001)(426003)(36860700001)(82740400003)(82310400005)(356005)(7636003)(86362001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 15:52:49.8690 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7fd3a2ff-4480-4c17-b90c-08db56eec46c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT062.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6491 Received-SPF: softfail client-ip=2a01:111:f400:7e89::602; 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: 1684338805753100002 Content-Type: text/plain; charset="utf-8" Now that precopy initial data logic has been implemented, enable the capability. Signed-off-by: Avihai Horon Reviewed-by: Juan Quintela Reviewed-by: Peter Xu --- migration/options.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/migration/options.c b/migration/options.c index 0a31921a7a..3449ce4f14 100644 --- a/migration/options.c +++ b/migration/options.c @@ -561,10 +561,6 @@ bool migrate_caps_check(bool *old_caps, bool *new_caps= , Error **errp) "capability 'return-path'"); return false; } - - /* Disable this capability until it's implemented */ - error_setg(errp, "'precopy-initial-data' is not implemented yet"); - return false; } =20 return true; --=20 2.26.3 From nobody Fri May 17 09:01:47 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=1684338873; cv=pass; d=zohomail.com; s=zohoarc; b=nHPpuBq1gNva4pUXA3DgME3pgUOsxQx7APRQiS/X9Pm7dO3vaGVXRddXPlwwOabG/dkRmfawXIRRf9rg9hi9O9lYjibL7tIw9IdJuVufer/iRS3r8PQ+/fnvA0N4HiizSOq1aGp7zySs94lpMkVOpR0FcHITQecSVPVHvHwOrXw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684338873; 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=vfXTcAeyPGQONDNtgZUGShfRWn5SXn5THvzuYjSEQi8=; b=bR8Kn8sGcD87vYfpKhSQTmpplg8gWhBDFNR+6vM04djzq0vCvQUdQw347xrZi9EQLYzXS7mZh/HLM6W9WNyXsuHsFXA2htHELiv+2HOLAmNNUg1Fz1yS3mOS+kKt+mlRKemJgR9av9uEy880Qf6FtIozBTwTkL0iHs3uaDjZsg0= 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 1684338873142631.6998168269562; Wed, 17 May 2023 08:54:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzJTA-0003vp-7O; Wed, 17 May 2023 11:53: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 1pzJSd-0003Rp-T5 for qemu-devel@nongnu.org; Wed, 17 May 2023 11:53:11 -0400 Received: from mail-mw2nam12on2060b.outbound.protection.outlook.com ([2a01:111:f400:fe5a::60b] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzJSc-0005zL-6C for qemu-devel@nongnu.org; Wed, 17 May 2023 11:53:07 -0400 Received: from DM6PR01CA0007.prod.exchangelabs.com (2603:10b6:5:296::12) by CO6PR12MB5459.namprd12.prod.outlook.com (2603:10b6:303:13b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.33; Wed, 17 May 2023 15:53:02 +0000 Received: from DM6NAM11FT110.eop-nam11.prod.protection.outlook.com (2603:10b6:5:296:cafe::47) by DM6PR01CA0007.outlook.office365.com (2603:10b6:5:296::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17 via Frontend Transport; Wed, 17 May 2023 15:53:02 +0000 Received: from mail.nvidia.com (216.228.118.232) by DM6NAM11FT110.mail.protection.outlook.com (10.13.173.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.18 via Frontend Transport; Wed, 17 May 2023 15:53:01 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 17 May 2023 08:52:46 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 17 May 2023 08:52:46 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 17 May 2023 08:52:41 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oKcG8EVszFmg/YmLirbblsL2nxD0l4hP1i7NukNj1Ls7dk+6hOBh8YJVmEqHcKrtflqTf+zb6PfJaa9KymNLs1GShIIdbBpgG6RvCcaOSjG/L3Uv6qHL+0SMzkK6jlQcSoYEN0pqonavPN9Evj2N1+4KNBGhAK5oebx1xU72v66E7dNKAdPEQ1bhnvudWhq6MUHIf37P+SwRKMQqoqbfBoA01uykRW8106k1wF5POCYNFSrKbOujMZXWf1NYuznzw01xWldjx6G4lyGySw+Ek2rgpZJyxm6rTVy+IqsnJ4rNJaY+8oqq0voWmq8wJfI2fByaQQ0SMlKnwLlB64hPcg== 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=vfXTcAeyPGQONDNtgZUGShfRWn5SXn5THvzuYjSEQi8=; b=YtpdC0zOVwquwK04C6KJvrcxTBkW18/ZNtyYMLKxYierHnILp0DxmdTQJPPg0a3GFGUCom1fS1Fh9bM91cPw9eYp8a3zx8y/XP/DfACwFBHLlejMm4hf7/anv3RUDPbH5dEFImPjBGFb6hsGHW7BRd562+ZQk3XYaOTAKg742JeA8zECU1YIskp0hvrCvJ+4xsCRaGmXsh05jzIinpzBo6MOv4QRv2Fa5JS0snWGKZJQl0zZEKgK0wxvGxZwuE6G7Y9+rGtlxtkBU8DdBuewr4KJCJsvd0ul5yR2emoixdMm0QtanA0QgEHrMeHxfQmbKbau1fD3cqcDhkP407FL+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none 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=vfXTcAeyPGQONDNtgZUGShfRWn5SXn5THvzuYjSEQi8=; b=DY2d0e0p/HSVcfXeq/uX/0CZ8xkSjvM4fKcfJiXatTtrP8pE958wuxdh0tONSma3K0U00wMs/VAtyagz7bjelbKiQFEAUxheDNbxsL30fi4H6H9SCK8lKrt+mOajLAtLEvG9WG8nZ6ePnlnUa+ZUEgKoFPAtDF2fNk6LqSCWSYwODU0GDUbziIYzDXFtJcGeenvRn/n6Fkq/TlKcCBTT5Z+SWpjL3POXM0ue0UF7nIHKrYZolqm7ftXL3+qcDJF9FhMUp2g2w6PMVWvVm8xo4NUhism4Iz4mRBZNmJLrf+EpN2PA04kjiX/XTcsiCf10nCT5d0WWVuWwMrRFs5lJcQ== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Juan Quintela , Peter Xu , Leonardo Bras , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v2 4/7] tests: Add migration precopy initial data capability test Date: Wed, 17 May 2023 18:52:16 +0300 Message-ID: <20230517155219.10691-5-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230517155219.10691-1-avihaih@nvidia.com> References: <20230517155219.10691-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT110:EE_|CO6PR12MB5459:EE_ X-MS-Office365-Filtering-Correlation-Id: 64e7af20-ad32-4bd6-ca48-08db56eecb86 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Sc9CA8orF3mm4IdoVPHQjywYW9htXow0r9/Lq19TfhGVs/EFF/EHw4a0FjNtNV3hB9wCjX4K9fenTldY4lHibq1LucGKoTf2KY3B0Rf8Y/oFSCAjDyyzJMf7wfgRpLrz8v+UeXXtOOY9rhto/rXmLvAsAHtt/yhdL8a4HhdgYMWbZi3A5blDlrDzdqE5FTi1dJY2CigPHQTUGjaxE3hnMFUYcw+Oq1pQ6JAgvZcXoHPabpOv71BtyYQMMAHBQcyJS9RXU82BCCwzztRRX0SFsAzH0pCyuqqpYaj/JAhUuHlWy0+Da5CBqlJOH4ZRk1NbYqf/uPDbcq1YVCQGXl0rIL993ZOzYD0pKcagYevSMzNvaDAkpAV2zSnLVola+pJSLFDVu77NDc0C6i1owLhVW/X6eWIPX3HlTFTKy0jNynGwHkdSTUcxpcl1cMDxKTai0+72rl/kz62VKZysPx+caxozEVjUAzEHNCmJHediecb3JrHmG7h3Ht2gS2YA1yA1gYrHUoCjuzrnuehXfxlxJ05nEkuDbSfDP2ii57bHvwewC+cO4AQk3lewgR7awQSbqYLJq6VmNc0J3/fRgvOLXNypaGIc7Qox7ovOg31JgyfWaqKnde8C9QTVXew3Q6YIEhpOJzuq8thmq7ADibARiX+vxFhy9C/o/MdXux5dIKc21PUgC4bHFoajoBCTWHqKoPpz1Zd2aQl2cWWvlY5EM0F5OYCtIwHzZUxy0HIg3US+k3d/N7QuoUkcSsWIncKj X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(376002)(346002)(136003)(396003)(39860400002)(451199021)(46966006)(40470700004)(36840700001)(478600001)(86362001)(7696005)(47076005)(40460700003)(6666004)(40480700001)(82740400003)(2616005)(70586007)(316002)(70206006)(6916009)(7636003)(356005)(36756003)(4326008)(7416002)(36860700001)(5660300002)(2906002)(82310400005)(426003)(336012)(41300700001)(8936002)(8676002)(1076003)(26005)(186003)(54906003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 15:53:01.8464 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 64e7af20-ad32-4bd6-ca48-08db56eecb86 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT110.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR12MB5459 Received-SPF: softfail client-ip=2a01:111:f400:fe5a::60b; envelope-from=avihaih@nvidia.com; helo=NAM12-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: 1684338874051100003 Content-Type: text/plain; charset="utf-8" Add migration precopy initial data capability test. The test runs without migration users that support this capability, but is still useful to make sure it didn't break anything. Signed-off-by: Avihai Horon Reviewed-by: Juan Quintela Reviewed-by: Peter Xu --- tests/qtest/migration-test.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index b99b49a314..3b3c806104 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1648,6 +1648,28 @@ static void test_precopy_tcp_plain(void) test_precopy_common(&args); } =20 +static void *test_migrate_initial_data_start(QTestState *from, QTestState = *to) +{ + + migrate_set_capability(from, "return-path", true); + migrate_set_capability(to, "return-path", true); + + migrate_set_capability(from, "precopy-initial-data", true); + migrate_set_capability(to, "precopy-initial-data", true); + + return NULL; +} + +static void test_precopy_tcp_initial_data(void) +{ + MigrateCommon args =3D { + .listen_uri =3D "tcp:127.0.0.1:0", + .start_hook =3D test_migrate_initial_data_start, + }; + + test_precopy_common(&args); +} + #ifdef CONFIG_GNUTLS static void test_precopy_tcp_tls_psk_match(void) { @@ -2695,6 +2717,10 @@ int main(int argc, char **argv) #endif /* CONFIG_GNUTLS */ =20 qtest_add_func("/migration/precopy/tcp/plain", test_precopy_tcp_plain); + + qtest_add_func("/migration/precopy/tcp/plain/precopy-initial-data", + test_precopy_tcp_initial_data); + #ifdef CONFIG_GNUTLS qtest_add_func("/migration/precopy/tcp/tls/psk/match", test_precopy_tcp_tls_psk_match); --=20 2.26.3 From nobody Fri May 17 09:01:47 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=1684338819; cv=pass; d=zohomail.com; s=zohoarc; b=T6/7zM9T3NG5nreZCsmIIrWeZQma3xu/uvsZLPC66b9PCQmX8KUHwMXpUgm8BvHZXxV3LfxyksW1NpdkGpaWSgFNVrg9kBY+e/McgOVi2cTzgHfLDZO315Zd5DKSqNF4NWv9TRUumoEkeQP201MSIGbfWqCz/ZAz+cnbZ0HEC7k= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684338819; 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=h68j4Dm1Q/+H4wT8g4CxjcyAuM4Dnwee3te5mdFcdNY=; b=UtUX1wdCxC/qSNqbvvVSCx8VCAFa5ZASX1MAvmEbSyupryu976wVAmmOOjjHAiKX4Zd2boviV02EIwSXOxVwquMuaWH99EfaT8KfxsfLCtwybs0bjyvHTcJkYT2hsRI2ijr+D5/Ki8YAllfvyL7kHJBnyb6NvWPDzTwrsoPvxwA= 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 1684338819335898.124209112681; Wed, 17 May 2023 08:53:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzJT3-0003j9-OX; Wed, 17 May 2023 11:53:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzJSc-0003Ro-DZ for qemu-devel@nongnu.org; Wed, 17 May 2023 11:53:11 -0400 Received: from mail-bn8nam11on20600.outbound.protection.outlook.com ([2a01:111:f400:7eae::600] helo=NAM11-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 1pzJSa-0005z9-Hz for qemu-devel@nongnu.org; Wed, 17 May 2023 11:53:06 -0400 Received: from BN9P223CA0023.NAMP223.PROD.OUTLOOK.COM (2603:10b6:408:10b::28) by CH2PR12MB5019.namprd12.prod.outlook.com (2603:10b6:610:6a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.33; Wed, 17 May 2023 15:53:01 +0000 Received: from BN8NAM11FT084.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10b:cafe::3a) by BN9P223CA0023.outlook.office365.com (2603:10b6:408:10b::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17 via Frontend Transport; Wed, 17 May 2023 15:53:00 +0000 Received: from mail.nvidia.com (216.228.118.233) by BN8NAM11FT084.mail.protection.outlook.com (10.13.176.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.15 via Frontend Transport; Wed, 17 May 2023 15:53:00 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 17 May 2023 08:52:52 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 17 May 2023 08:52:51 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 17 May 2023 08:52:46 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nMlWqNhnmfUQ53BthkmHmGeLFFxYtBRsqFgt83GGkRL6aH0YfR41xMNMnElw+P3jUKQa00I8axu1UWOrmtlSSZpc4wl7RyHpmKoT70Ct+wTmOEbZW/hIksTu+fSPdhHt4HGbw776B753irHsGGerBOcjzRL4fnIWxoYeYj47NNiofg6I9d1DuwMyXIziLyl9OxIoiJvZ+cLYVBcrRu01PRv/UFBQULkPnsJVoAzANZs8HsBSGy4h6vTCrZmyh/F4FAAoGqkvN/K7z1f8WoCOPnPJfK590iNIsUB4KTzFFwjRWhhdwLqMxpBiEgkymvb6lL3AxVSV3AC9051NTSES2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=h68j4Dm1Q/+H4wT8g4CxjcyAuM4Dnwee3te5mdFcdNY=; b=L0e4rIkydafEhV7NI9eZy4XolITJfgV9bfbyS6x4l+FX1WPbEpYS0zNgOMdBadtVpFvFBaJQ8F8jPbJmfjqRfD029bJ3qEo+zPHF4psiiDpiGE9fcz8XS7A0qfesv0POs6WJ6njaTwzp7LlCS4qb+gL1jbO8Zl2trTREZZU5dqktnvP5ZmXlPU3GrcrWffUhKMSfoKERWi/ZV77vIdExH7j5mMXpv096vXSXwigbypBt2KnBQLpw/78IiVn/CYL5iOGuN3C6UfThzw9j/geWxklS9rElgZbOWv2t5o2zmPtnA3AyfXqK472lKOyPbUn1knK35InUylLM1m9WhCyC8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=h68j4Dm1Q/+H4wT8g4CxjcyAuM4Dnwee3te5mdFcdNY=; b=L7x3TtdJN6v7yRvMnSTRS4Yg6jM+3t3nzF8W0WVXBll8JJ20+TzHsJ2pA6o913smDXLU1MYKcCW3dTb/cjkAsYoZ7eNcvgqxDhOtGvqJotMKayiQg0CBbjMmxqIliyfEQXXw9f6tvSiSbopoof2j5HtHgZhG8FXxLaRJBDbUe6BwO4dsG100B4aWRdaTUGeVdfsm18qQRUX8xkspF8XdslF1qVzthXPkZ8dECOnIXGvR6KiRRzlbMpWDYZaw/efcDZgms0oDDWbUmFF7GBjypKlnMH9u06HI7V0Kw75Br6HPSruDt9N5TjU/3ufJ9j4pqGLkXAdL6Si1xQRBw00BBA== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Juan Quintela , Peter Xu , Leonardo Bras , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v2 5/7] vfio/migration: Refactor vfio_save_block() to return saved data size Date: Wed, 17 May 2023 18:52:17 +0300 Message-ID: <20230517155219.10691-6-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230517155219.10691-1-avihaih@nvidia.com> References: <20230517155219.10691-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT084:EE_|CH2PR12MB5019:EE_ X-MS-Office365-Filtering-Correlation-Id: c9043374-d4fc-4bc0-c6c6-08db56eecacf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KCeJPF+23reuPStsyMwkyTdvnuPDIYAajc8WXU4zrZhYqO/aqBJYnoxcQNFPmEe9b4YyOsaZMGQocMS+1EZXNkCi3sc7w79DIvANolHoO/83urVK9eYnQVrmQAZx9unj2XZ3lZ1xp963hNDv1+v7lglyxvxwc2dH4T06GA3rSWE/OkRcsGy4xXxHc+76G6QztELEIo+Bqv19XciDy51UJ575DPdRKGlGocV6Bh7UeonwH016mvE96hKs5MbqosO3kdvF+ps6S6Y1cNJnbzod/kDFkXu1e8iYj6k2Ti5X/AA7WN/qgP8YowfJsPiho9/1bU8OdPMn+qFjIFEHiv8XB0db+dR2rGXHcAQTKXRW3QM94aM3lWoEanN3sWaItMxkG6izI20Kw8AvVEWTKV9TRffAOu/xOrgvCgJqqYB7i80n+yewBZ86KErEshJYYaHpNve/QrsUUw0hl7d47pAdHvkl/F8xYlbTIHUIr9+MaJycQXCD8qp2UtUeAd+rfqSGTKI1hpO+DOQ+0q77lc0it9lh9ljrGrPdC9Sb+SfHi7xocPftlSrW7fIoXvCoR18aueZ4wfrLJ8QVaJBMpV1q/rw9F0AR6iZwuoi18r74bmvQxCki/nu98EHQSV2beAA2OqBon8whlrv+XOQWPzbP3TUtgpYiZ5rRg1zTJTl6DSyDDuLPEvL+2Y5gV+ofU6B5S4wfqi94g35bhdipQmD8Ti9XGUufvE7PCiTk20Bl1MclarOkps1fNOX38JQwAFfC X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(136003)(396003)(346002)(376002)(39860400002)(451199021)(46966006)(36840700001)(40470700004)(6916009)(4326008)(36756003)(2906002)(7416002)(426003)(336012)(8676002)(5660300002)(8936002)(40460700003)(41300700001)(40480700001)(86362001)(70206006)(54906003)(70586007)(478600001)(7696005)(316002)(6666004)(83380400001)(186003)(82740400003)(7636003)(1076003)(36860700001)(356005)(82310400005)(66574015)(2616005)(47076005)(26005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 15:53:00.6001 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c9043374-d4fc-4bc0-c6c6-08db56eecacf X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT084.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB5019 Received-SPF: softfail client-ip=2a01:111:f400:7eae::600; envelope-from=avihaih@nvidia.com; helo=NAM11-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: 1684338819895100001 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 --- 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 Fri May 17 09:01:47 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=1684338860; cv=pass; d=zohomail.com; s=zohoarc; b=aIZjSgB37DSp0RB+f+8aFMqcW/4LIejzOKQdYV9CmPj5VGpi99Ke4rdFvdlA0qL8tYOCBvwJ5cthV1iHSTfvzFSh+/z2mu8deGN26tfmdi2O1RpVjPWVhr3x1Qh1meqjhmvXjpHvZd5te9eTjxhRBn4sozXskm05rfI2J9nHrh8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684338860; 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=C8fT2CMTGijbdIH36E4TTqDbCEQambl3Q1TGZJk7C6A=; b=ROhJGQwYA5ZAISXnDzIG3SM/YGjtah5jKDrwtUXifCsPzcBrvByu1NY26m+z+NlIL3bmzuv8TT1NSy6nRBxBe5Y6XtUXbNBbmC+c1KOb+yOUKF58uA6nPl1lN6Hw8xNFlaTNUR0UFp3ofjmd1CDfD8ftsdtivMo5BIFNQBzwpxw= 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 1684338860546307.0172174984474; Wed, 17 May 2023 08:54:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzJTJ-0004Uu-LH; Wed, 17 May 2023 11:53:49 -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 1pzJSs-0003bF-B6 for qemu-devel@nongnu.org; Wed, 17 May 2023 11:53:26 -0400 Received: from mail-mw2nam12on20604.outbound.protection.outlook.com ([2a01:111:f400:fe5a::604] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzJSo-000604-3t for qemu-devel@nongnu.org; Wed, 17 May 2023 11:53:21 -0400 Received: from DM6PR10CA0025.namprd10.prod.outlook.com (2603:10b6:5:60::38) by SA0PR12MB4576.namprd12.prod.outlook.com (2603:10b6:806:93::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.30; Wed, 17 May 2023 15:53:10 +0000 Received: from DM6NAM11FT104.eop-nam11.prod.protection.outlook.com (2603:10b6:5:60:cafe::b7) by DM6PR10CA0025.outlook.office365.com (2603:10b6:5:60::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.18 via Frontend Transport; Wed, 17 May 2023 15:53:10 +0000 Received: from mail.nvidia.com (216.228.118.232) by DM6NAM11FT104.mail.protection.outlook.com (10.13.173.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.18 via Frontend Transport; Wed, 17 May 2023 15:53:10 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 17 May 2023 08:52:58 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 17 May 2023 08:52:57 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 17 May 2023 08:52:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kVi9mZw78J4Ecc7xr835Rs269BY1AZsvUokx5SbqrBLcuoCNnV2fVMXLQMF3fw84Rstv4IKFzTw4ihCKZ9YrcBk1Ybs7OkBe0ySSITsk+d2aYt46vptSC55KauRQpLiMaOtRqZraLKznB3geOeei9dYk7rmoc+tfOuSV5fGrvPL/AU9gF2wmnCgiZePSIyxRXLhvO01YXkX1nUf9XRuyaNvYa58bUt/fNO7McCod/JtbJyfrv8KTclleIGCChinKwRslQW6mscJjqSXtPY/pstLUeEbtE8QU6U8mhx4HNd5XNXukFycJVEOAPu9Kt5zBgfKuv4DvdUtv3tlZI+qkNA== 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=C8fT2CMTGijbdIH36E4TTqDbCEQambl3Q1TGZJk7C6A=; b=QDk0KIyMumsVjmbbRiorMC5on/PyWZhpllNfnMNe/LUfKA0nuAg5UlHdiWRB4IKE4/wGNTQRlZPBhcBEmD54D5tMB/lR42FgwGaKW/qkMkB+Gi1uOxbW43tOqxjKhlJ4wMNO2XBn6MIoWLX7ttX4nlegOZs1vzny6Ws3HTgKt666sBmNBf7GlemI6KNQWVoIMnR1C+1rWSM4easHclPvuziY7LvMPriRVgaejx3V81dZO5/xpKzlGq6acsTSC4KzIz43n+ca9rGo0PSP41kElZXYvaXbVCccnk84ux3qz9kTljEM1eSh3ZcH3uftWZn8ChyZQKAq9o4/JXFxbCeO6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none 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=C8fT2CMTGijbdIH36E4TTqDbCEQambl3Q1TGZJk7C6A=; b=EJOdqp2BXp8ZbO4jLgKzMDNCFstmkpVHyzbpEazgKESaL+ve7CUS4R0QIjnoX23R9VfnjC8/rxTRpJD58FTALOO2gbhktS2phTI0cdk9c4V4HBCrELnP8aVOzGVsbu8Dc8C6rK7PJRThG8Nla51OE4JP+7WIGQjkBrB+jq+Pk+OHf25buV1N4bxW+riYJcOGHfpcAcIxHgUYfhYFWczlAdGeJooV7Egpcddjr+WkKvv2Imm1FIQkYbjybN4k566D/jr+R3msKzoSYUh5IqBhSM3dFm+LfCOlfWQX2zhFdHTdzfBomtuBbSSGE7lqs3PkQOshjGIQEoPc4iO5hx6BwA== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Juan Quintela , Peter Xu , Leonardo Bras , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v2 6/7] vfio/migration: Add VFIO migration pre-copy support Date: Wed, 17 May 2023 18:52:18 +0300 Message-ID: <20230517155219.10691-7-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230517155219.10691-1-avihaih@nvidia.com> References: <20230517155219.10691-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT104:EE_|SA0PR12MB4576:EE_ X-MS-Office365-Filtering-Correlation-Id: e22fcc48-c1a8-4d6d-ae95-08db56eed0a4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +2CUqHqAix2UpAbYTmvor3A4NQiHN1G1XZa2PfOPF1/eypQIH6RLVUWYOPAarjKq36wMGF+/FhvgT4iMTJyvOwS1wrXueoY7RRuKfLIsWxS116ij5qAZXEMbTV+YyyF8175PU2LZc2cFwqEv9jmRDKi2KA3iI1xX0LvOacXC/wNe61qEuRfx50lxbXEtDWC2mwD2vP41rrOPYsqC2q7PZu/nW/Zclrm9olI84UEVA415LZTbz0kmQ1RzxwqkRQ+3Jgekb9KgLpCRe4z3evK2gBi2Gi/8PHzjBIe1U4KkiEsT5ZolfOMORtcTRucVm2J7xyVCWuG6gwy2wB41HHbl5+Ro+dDmcXj1S7vlssixmSFeeYHBvLohWHsS0SCJvPFNF9XOhMNu05MDYWPVVgQGuKRT8KUEXGL4ImaFfoiISBwrf/e9+O/kBJ93i1XW/1eZ9YBlEbSpBq6f5YVON28oY/ODB06uvRrvjBzBUG7j4td1UsZG5cICcuaW50DM7GHpTZbmjOmY6AlsgvgsA6y5XNfwBqIomNTmvPHtc8LPnj8ybL5mRGVIEjGm6cWtSOLGfISM658Vke+k/cnYY6VQUFwsEfs8ILZapv5U4naW8arnN5U8Qjk/BgeHbwih4PfcY4WHx+7gdsZSr5VmRddPpH/UH5F1NQELImucp1HspvWtVgU3+T2Z8IhJ1fk2d7NQUwAGqT8mhW65vpMGPnRa5+xElfwy0xpNK4/e49ixYUnUlsEXUYQH38ZFxqLH1mbwJHyLYUFk5NE9CAXn716bLnMYOY+woE9L1RWnbMF033U= X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(136003)(396003)(39860400002)(376002)(346002)(451199021)(36840700001)(40470700004)(46966006)(6666004)(83380400001)(2906002)(30864003)(966005)(7696005)(82310400005)(47076005)(36756003)(336012)(426003)(2616005)(186003)(5660300002)(82740400003)(7416002)(8676002)(26005)(1076003)(54906003)(8936002)(86362001)(41300700001)(40460700003)(7636003)(36860700001)(70586007)(478600001)(6916009)(70206006)(356005)(4326008)(316002)(40480700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 15:53:10.4465 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e22fcc48-c1a8-4d6d-ae95-08db56eed0a4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT104.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4576 Received-SPF: softfail client-ip=2a01:111:f400:fe5a::604; envelope-from=avihaih@nvidia.com; helo=NAM12-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: 1684338862030100003 Content-Type: text/plain; charset="utf-8" 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 here [1]. In addition, add a new VFIO device property x-allow-pre-copy to keep migration compatibility to/from older QEMU versions that don't have VFIO pre-copy support. [1] https://lore.kernel.org/kvm/20221206083438.37807-3-yishaih@nvidia.com/ Signed-off-by: Avihai Horon --- docs/devel/vfio-migration.rst | 35 +++++--- include/hw/vfio/vfio-common.h | 4 + hw/core/machine.c | 1 + hw/vfio/common.c | 6 +- hw/vfio/migration.c | 163 ++++++++++++++++++++++++++++++++-- hw/vfio/pci.c | 2 + hw/vfio/trace-events | 4 +- 7 files changed, 193 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 eed244f25f..5ce7a01d56 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -66,6 +66,9 @@ typedef struct VFIOMigration { int data_fd; void *data_buffer; size_t data_buffer_size; + uint64_t precopy_init_size; + uint64_t precopy_dirty_size; + uint64_t mig_flags; } VFIOMigration; =20 typedef struct VFIOAddressSpace { @@ -143,6 +146,7 @@ typedef struct VFIODevice { VFIOMigration *migration; Error *migration_blocker; OnOffAuto pre_copy_dirty_page_tracking; + bool allow_pre_copy; bool dirty_pages_supported; bool dirty_tracking; } VFIODevice; diff --git a/hw/core/machine.c b/hw/core/machine.c index 47a34841a5..cde449a6c9 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -41,6 +41,7 @@ =20 GlobalProperty hw_compat_8_0[] =3D { { "migration", "multifd-flush-after-each-section", "on"}, + { "vfio-pci", "x-allow-pre-copy", "false" }, }; const size_t hw_compat_8_0_len =3D G_N_ELEMENTS(hw_compat_8_0); =20 diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 78358ede27..b73086e17a 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -492,7 +492,8 @@ static bool vfio_devices_all_dirty_tracking(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 235978fd68..418efed019 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,22 @@ 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), + }; + + 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 +267,11 @@ 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 */ + if (errno =3D=3D ENOMSG) { + return 0; + } + return -errno; } if (data_size =3D=3D 0) { @@ -265,6 +288,39 @@ 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 vbasedev->allow_pre_copy && + migration->mig_flags & VFIO_MIGRATION_PRE_COPY; +} + /* ---------------------------------------------------------------------- = */ =20 static int vfio_save_setup(QEMUFile *f, void *opaque) @@ -285,6 +341,31 @@ static int vfio_save_setup(QEMUFile *f, void *opaque) return -ENOMEM; } =20 + if (vfio_precopy_supported(vbasedev)) { + int ret; + + migration->precopy_init_size =3D 0; + migration->precopy_dirty_size =3D 0; + + 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); @@ -303,22 +384,36 @@ static void vfio_save_cleanup(void *opaque) 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 +423,49 @@ 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) { + migration->precopy_init_size =3D 0; + migration->precopy_dirty_size =3D 0; + 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); + + /* + * 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 +474,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 +593,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 +609,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 /* @@ -603,6 +747,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 diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index bf27a39905..72f30ce09f 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3335,6 +3335,8 @@ static Property vfio_pci_dev_properties[] =3D { DEFINE_PROP_ON_OFF_AUTO("x-pre-copy-dirty-page-tracking", VFIOPCIDevic= e, vbasedev.pre_copy_dirty_page_tracking, ON_OFF_AUTO_ON), + DEFINE_PROP_BOOL("x-allow-pre-copy", VFIOPCIDevice, + vbasedev.allow_pre_copy, true), DEFINE_PROP_ON_OFF_AUTO("display", VFIOPCIDevice, display, ON_OFF_AUTO_OFF), DEFINE_PROP_UINT32("xres", VFIOPCIDevice, display_xres, 0), diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 646e42fd27..fd6893cb43 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) " (%s)" 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 Fri May 17 09:01:47 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=1684338881; cv=pass; d=zohomail.com; s=zohoarc; b=inUy6RozDGIDmF2I7GRP4lqj+/AVK1sc+l3gnaP13pNJEHz4HrBg7jzHzRxMU/x/6VLA/6kNMj2H/W3nYzCWf5Xy73LNMdxEKGKfaV4u5wLRKEYHOZXOcub89G90/uynOnxf8RXkvTq36AB7gtytu2Bp4vRa/udaJqYuhjGPqIM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684338881; 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=kNySRFimy5WXY/34yt3k3o7IrVL7nFHurF4v6aKSt5E=; b=LDQxuZ0AimJd7lKfyYWX5Mz0WI9W5uEcIcWn0GtcgqPylCae+EdddXRvmcUVmyks3fGnuf2vqTopxsFHNzc+ZwaPsClfIUi5vNQzF15EcQYgBbpHm5Eg0Fx/LUUttqZZAue+z7/tUtad9u8XQx+S3IhSurwKOddu6RLY2rl9QCE= 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 1684338881920552.1259648211827; Wed, 17 May 2023 08:54:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzJTC-00045T-Cp; Wed, 17 May 2023 11:53:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzJSy-0003j8-86 for qemu-devel@nongnu.org; Wed, 17 May 2023 11:53:31 -0400 Received: from mail-mw2nam12on20629.outbound.protection.outlook.com ([2a01:111:f400:fe5a::629] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzJSu-00060y-3E for qemu-devel@nongnu.org; Wed, 17 May 2023 11:53:27 -0400 Received: from BN0PR07CA0006.namprd07.prod.outlook.com (2603:10b6:408:141::23) by MW4PR12MB7383.namprd12.prod.outlook.com (2603:10b6:303:219::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.33; Wed, 17 May 2023 15:53:17 +0000 Received: from BN8NAM11FT037.eop-nam11.prod.protection.outlook.com (2603:10b6:408:141:cafe::b1) by BN0PR07CA0006.outlook.office365.com (2603:10b6:408:141::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17 via Frontend Transport; Wed, 17 May 2023 15:53:17 +0000 Received: from mail.nvidia.com (216.228.118.233) by BN8NAM11FT037.mail.protection.outlook.com (10.13.177.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.18 via Frontend Transport; Wed, 17 May 2023 15:53:17 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 17 May 2023 08:53:03 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 17 May 2023 08:53:02 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 17 May 2023 08:52:58 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lJ3rqPWtMyrbLSOYEcose+P8u6DIlQRoXm3p/C6aFOkfkmOshN7isvL36a0+BkSZvyn8zDTrrzFIEEfKwsqsIzuyec93XU2cCB8ekehwQnxFdTb01x9OKRUwV2V9tsh5Iraxqp3YhJY1gQA9XVbgwqaQXHjlsY1aaQeabMtMEyyrWekzdomTS1EGMj7Eif7wsuzkeAcgrcaEHwKgj/4KSFuWKvrJmk90g84MxA1AF/EaZ488SYqisJBoMNkZtE1bMNAeChA4DjKFhDAtU/jjVdUlhm8/Ku0DnJSTTrkY6OgCgQz/2kfTs52OkkQh0/cJY6JGA7OL0DyrgWETktwOlw== 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=kNySRFimy5WXY/34yt3k3o7IrVL7nFHurF4v6aKSt5E=; b=H8Kht51PmatZQNU2yt7teM9ah6n3L54Vh5ggX/nw86VHsg8YjCes9eeY7FdLVhxC7h2v2ynUICmMQ9ijpJ/dH8z6O/kdtmHDBiYaRO8ooWDY39f/RTG3vZouVGTv6TQs5HCyDpih2jrxoAmtFHUDhL46OLA/01UommefrtXXeDQupoHLfy80DW0Z6euAR7W8gh49j5WSsA6q4++SBkgToFKszTJZoKmoS4kZ1jzy3djkQeJZHKfY21Pw6Ra81SF0rChoKPbTjgXg7HQX86hziHWgLfs+HPXHMS1ffTu7gP+k4KArDdEGPSEx23zhxHCHl0oQ6/faerllhMaJKbo3yQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none 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=kNySRFimy5WXY/34yt3k3o7IrVL7nFHurF4v6aKSt5E=; b=W/N92qpji3txbBW/uAlYsdHfig8+SI0vcOpz1Bkggp4zvG20UzWF4bOUQ6ZPBCBSX4aPhsJa7lL+dsMRn4YNPjkhVEvK2FrkTrnF3TWut5/IE6C/QbeGtCmTDGvrGscVXLxb8BVli0mhL/1HUSXjzTkzrHt45NpJ1fWNsd3gHysalvLR+cYs7g/vWiooeAvNpXOyN0QKhcey5+DyPob29MXZ2oQxfElcLms7mCOWXfFNvd/Pg5JnfhySQ/xHZ1PEO245gKKhEduq0TQggtQpCs6RVyyun9qCPQ6uzHwkfsRoAygapagc+zkyRmqGa31Vdqy95agdrhndQILlOoTDmg== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Juan Quintela , Peter Xu , Leonardo Bras , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v2 7/7] vfio/migration: Add support for precopy initial data capability Date: Wed, 17 May 2023 18:52:19 +0300 Message-ID: <20230517155219.10691-8-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230517155219.10691-1-avihaih@nvidia.com> References: <20230517155219.10691-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT037:EE_|MW4PR12MB7383:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e55b3be-46ac-418c-7e01-08db56eed4d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6vJYvXvecfkZZa2WrkLIaWnSJqeeMiiQDtuxOxrMFnmxAI685HrVUVcbvqReFE0OEKcY068PaizIv32kugNy7V5qHY003JWgpeIs/1Mdv61waH/OqAwo/Oi+Z4Cxfrmo7YY8DSNOPsdpwJm5AYIOsUjSflqmhailIwq39jxr492mLf5FcoLpupy+3rJhlTDXD6K86qdUS9/lxGqGDaHS2fCat/t8m0I2/KkaX5TZMI5PSSjU3aAKamCbS3ALzov+4TWjNJg1OEJk+Rf8bJH5/5fjAzKDKWWvkXr1VWAOOWgjsBPE6UPObSfyuN7LseV6/y1zT5wj+/kJZhPgWWeIangOjU6ikxnksHGA2zn19HdGetRIXCjL0eF63oufAKQtyt1lBxCj+7FJBl7Q/Gt+LdPuJ7EhndJDp2yRlyC5F2Ix/+iUWO8+Xtic5/91z7A3gvcTssJZ1oO6xZjJKBiqHgcUx0fmhinjiJcSvxVzZUyKOnytykEl48AVm5E7/mxWfbSkNCr7ZcN86vS2j8PgWdM7iNsk9kqUoSJ2n69kdNnKbfE7Q0WJIHl+pP7/oF4+01WLk/dLZjrmFJFeaePlb87P6WqsZmyaxN3d4xQuVaRbCW7ACPa06K+6BZpwmz5eo6g5BDSmpLs5Kour//dQcanht7l2nvYXvi6vQbxtse1LjD1b7V2GeU8832MptJN2iM8bIHhqhC+ORJvWXuafoYdsrCSjWdVZX09F1HYvgPcN6iJo+EE9z5QM1YMXHn/b X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(136003)(346002)(39860400002)(396003)(376002)(451199021)(46966006)(40470700004)(36840700001)(83380400001)(26005)(40480700001)(1076003)(36756003)(7696005)(186003)(6666004)(36860700001)(47076005)(2616005)(478600001)(336012)(426003)(40460700003)(82740400003)(82310400005)(4326008)(2906002)(316002)(70586007)(70206006)(6916009)(54906003)(8936002)(7416002)(8676002)(86362001)(41300700001)(5660300002)(356005)(7636003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 15:53:17.4148 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e55b3be-46ac-418c-7e01-08db56eed4d5 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT037.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7383 Received-SPF: softfail client-ip=2a01:111:f400:fe5a::629; envelope-from=avihaih@nvidia.com; helo=NAM12-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: 1684338884104100007 Content-Type: text/plain; charset="utf-8" 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 precopy initial data capability to make sure a VFIO device's initial bytes are sent and loaded in the destination before the source stops the VM and attempts to complete the migration. This can significantly reduce migration downtime for some devices. As precopy support and precopy initial data support come together in VFIO migration, use x-allow-pre-copy device property to control usage of this feature as well. Signed-off-by: Avihai Horon --- docs/devel/vfio-migration.rst | 10 +++++++++ include/hw/vfio/vfio-common.h | 2 ++ hw/vfio/migration.c | 42 ++++++++++++++++++++++++++++++++++- 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/docs/devel/vfio-migration.rst b/docs/devel/vfio-migration.rst index e896b2a673..aebf63b02b 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 "precopy-initial-data" 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 +* An ``initial_data_advise`` function that advises the VFIO device to use + "precopy-initial-data" migration capability if supported. + * 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 5ce7a01d56..698b2b8cc5 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -69,6 +69,8 @@ typedef struct VFIOMigration { uint64_t precopy_init_size; uint64_t precopy_dirty_size; uint64_t mig_flags; + bool initial_data_active; + bool initial_data_sent; } VFIOMigration; =20 typedef struct VFIOAddressSpace { diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 418efed019..5d98c4cd94 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -18,6 +18,7 @@ #include "sysemu/runstate.h" #include "hw/vfio/vfio-common.h" #include "migration/migration.h" +#include "migration/savevm.h" #include "migration/vmstate.h" #include "migration/qemu-file.h" #include "migration/register.h" @@ -45,6 +46,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 @@ -380,6 +382,8 @@ static void vfio_save_cleanup(void *opaque) =20 g_free(migration->data_buffer); migration->data_buffer =3D NULL; + migration->initial_data_sent =3D false; + migration->initial_data_active =3D false; vfio_migration_cleanup(vbasedev); trace_vfio_save_cleanup(vbasedev->name); } @@ -455,10 +459,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 (migration->initial_data_active && !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); =20 /* @@ -576,6 +587,24 @@ static int vfio_load_state(QEMUFile *f, void *opaque, = int version_id) } break; } + case VFIO_MIG_FLAG_DEV_INIT_DATA_SENT: + { + if (!vbasedev->migration->initial_data_active) { + error_report("%s: Received INIT_DATA_SENT but initial data= is " + "not active", + vbasedev->name); + return -EINVAL; + } + + ret =3D qemu_loadvm_notify_initial_data_loaded(); + if (ret) { + error_report("%s: qemu_loadvm_notify_initial_data_loaded " + "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; @@ -590,6 +619,16 @@ static int vfio_load_state(QEMUFile *f, void *opaque, = int version_id) return ret; } =20 +static bool vfio_initial_data_advise(void *opaque) +{ + VFIODevice *vbasedev =3D opaque; + VFIOMigration *migration =3D vbasedev->migration; + + migration->initial_data_active =3D vfio_precopy_supported(vbasedev); + + return migration->initial_data_active; +} + static const SaveVMHandlers savevm_vfio_handlers =3D { .save_setup =3D vfio_save_setup, .save_cleanup =3D vfio_save_cleanup, @@ -602,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, + .initial_data_advise =3D vfio_initial_data_advise, }; =20 /* ---------------------------------------------------------------------- = */ --=20 2.26.3