From nobody Mon Nov 25 10:26:43 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=1715779403; cv=pass; d=zohomail.com; s=zohoarc; b=a3rV/EyJMp82xt6AH0oDFoD2QGKczBoge+XKTOHgD9zaXvsKhta+7kuErCEogKqt9SPrtugU8CPNidlqRWTCO+6KudBmHVHUSMwt6nuu6J06sZn4B2GzDGaIfk2hGlOmvMtlT6V7Hnt+KUyByRkUyueV/BJq0b8hs7WgWfLlgJU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715779403; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SmWO0AxSzPSaSe9bmaQhyDXGyhc+LqakSOpDXCeOnD8=; b=CyGWwIxvfee5S/xUE/MnHK0WexHwwraNRbZV4Gk/CnS+ASGH+rEuw2AnaYdzKhTGyy7SfXBJNBDFyxNcRTFFmU3mNwaDXjpENUWVisvNwHbrcA3MuKrUImIB/PekEv92ff+3ny7Cb+Cp2mVacblZqSCRGctafTGglJrfeRmtCws= 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 1715779403759496.4649459665145; Wed, 15 May 2024 06:23:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s7EaS-0001KT-4w; Wed, 15 May 2024 09:22:28 -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 1s7EaP-0001KA-2B for qemu-devel@nongnu.org; Wed, 15 May 2024 09:22:26 -0400 Received: from mail-bn8nam12on20600.outbound.protection.outlook.com ([2a01:111:f403:2418::600] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s7EaJ-0007Gf-HB for qemu-devel@nongnu.org; Wed, 15 May 2024 09:22:24 -0400 Received: from BL0PR02CA0074.namprd02.prod.outlook.com (2603:10b6:208:51::15) by SN7PR12MB7787.namprd12.prod.outlook.com (2603:10b6:806:347::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Wed, 15 May 2024 13:22:14 +0000 Received: from MN1PEPF0000F0E5.namprd04.prod.outlook.com (2603:10b6:208:51:cafe::95) by BL0PR02CA0074.outlook.office365.com (2603:10b6:208:51::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55 via Frontend Transport; Wed, 15 May 2024 13:22:14 +0000 Received: from mail.nvidia.com (216.228.118.232) by MN1PEPF0000F0E5.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.21 via Frontend Transport; Wed, 15 May 2024 13:22:14 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) 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.1544.4; Wed, 15 May 2024 06:21:45 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 15 May 2024 06:21:44 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 15 May 2024 06:21:42 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MgvBCfs3Re7EbQ6ie+YlXs1oje4xofncRYNGfGSRv30cKzflEpeCiRzRYOXRrEI07RV9k2Nlsft8lO28Ra9FiPMZaybnlsadFVNzUWHEsiVXdPYTOvg6x9MGFg+bo5uAPkgsM5glNB0kv8vLxF5d379/ojL49RhlRkI/sHPJxA784/3Bs8pScsJHDTRlhQev4rLZlwtx+aUB8dzU1uE/MxmDEwpcRBAEspzZkU0Dx78XedrHEd3BqC7Q77MuUHvgJ0EbQWDDiEbpvWMrAwK5FKJi+O8HHCnyvnHO/F5Wm/Yn/zqWi2LL1sYDDjlVBNFHdTUZkmWMmgUShiuUIKtOmQ== 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=SmWO0AxSzPSaSe9bmaQhyDXGyhc+LqakSOpDXCeOnD8=; b=NpMPH3CttKPpE4zlsiQKLGRL5pLr8pXTq9dS8rxGW/Jwz9DVP7fuh+yXb+43lWF4ufICFGK/iSoRMESTGSmwnn6AWx+AZC5U5dlaL6Df/LumTfdM7YGK0bDcDysR0c0yzof2u2TgtrsoNEQ6ppXD/TxAmQtmWsG5v6Smw/fjxRYskQiIe0oGKXNqwERWpBIzBQLGlQLns/QoI2NfxVOgpH57TCR4PhSLM2rK1kxqvxh1p3+LYFY5/mRdFvDEmL0I+IIzk8hB3TAwEweAyWADq/E9Dxg2/Y0q++EJOTXHoqS8HM8bRnYvaoqdhVuunRNdMG7NEEcEtZuvKevagAGvXw== 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 (0) 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=SmWO0AxSzPSaSe9bmaQhyDXGyhc+LqakSOpDXCeOnD8=; b=l17m4B6VnNs83rse4fwXp+ExAWt0SFNooZ6vbRcPSndMWIYmiGnOry55i35tSgQheqSDP2EmtN2i2WwzLIww0oUcRhiulxQLL2BJ349V/Svnm2PWjKyiSYZvrOCv04C3dSncO9cWgeyHAaTJ+IySn2ejy4f7c9hb3l+6j8YYYIG4h2M27pF9Ze3J7/cGfBRaIGvD8riG1++7UInEJ/UoQ6CzKDkBAPVA/9LcB1IhvceOQRiT1Ewf00TXv7YN1ZJDbcSsXyqNHyUZAPz4sgo59WSTtDc13XqWbLXXRQ77MO5X/0d7jydSZkbKvPqVzWDr2Bzd0GqrlhmokInW8PhwNw== 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?= , Markus Armbruster , Michael Roth , Eric Blake , Peter Xu , Fabiano Rosas , Joao Martins , Maor Gottlieb , Avihai Horon Subject: [PATCH v3 1/4] qapi/vfio: Add VFIO migration QAPI event Date: Wed, 15 May 2024 16:21:35 +0300 Message-ID: <20240515132138.4560-2-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240515132138.4560-1-avihaih@nvidia.com> References: <20240515132138.4560-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E5:EE_|SN7PR12MB7787:EE_ X-MS-Office365-Filtering-Correlation-Id: 47a930e1-ec12-4ce1-e717-08dc74e2090e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|36860700004|376005|82310400017|1800799015; X-Microsoft-Antispam-Message-Info: =?utf-8?B?ZjREczI0cUlyWEloLzFRd2w2MFRrSmxuZkxzS0FJeTh2d3NUNG9tQUFUSzQz?= =?utf-8?B?UjRkMUl6VkwwVTJYRDdWQlNTbUZDV1hGZi9QVHdXcG95NUxHbjAwcFFrWDJq?= =?utf-8?B?ZWRwTVN1Tktnb1QwdTR3NitySkFLWGNiMmJXL1BkRzJKVi8zMmh1STd5S083?= =?utf-8?B?ek5UMFRLeXJWZG4xc3phdTYyNk14OVBDWWJEKzNYSHZNeFZta25GRENIZ1hn?= =?utf-8?B?RW5Jc1p0d0NRYThZekxUVzNKRWxCK1BaWVB6M2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U2hQRWpqMnRlNG83ZGtHNU9RcFArd3M0UWpjRHBK?= =?utf-8?B?OEdtbEhHd09RKzVjbnpnelJxeTZrYWI3cGJObitBYUNZK1JxbGtmQWhzN3E0?= =?utf-8?B?UjFQL1FqdXpGQUQ0bHFiWFhURFNoM0JhYzQ3VzdBYUt3T09wZjRQYmQremFW?= =?utf-8?B?M0ZKb3RHaGZtM2piRFBRMkpTTFRVaWtEMTBEbERBdzk1dlp6N2FVUXRGdDdZ?= =?utf-8?B?V0tOMFkwRnJCNWR6WURGTVpxR3kyUFJkalhXbzkyR0JBUDFhQ1YxcWJ4eVlH?= =?utf-8?B?ZDNNckhtWTdxQlZZMXVoK1Z1QklGamRvT04yb2dGVkdSRUZCeEdqUG1sOVNV?= =?utf-8?B?d2lNempxU2hPUis1T1pveUgrRDVIdW5aR2lGMC8rbUJVa2ZDVGlUbzZjM2pO?= =?utf-8?B?dDZEaEplVjI2Z21IelBkQ3JkMWJmSE5YcXh6MlExSm5WWGF4dU56WS9mNGhJ?= =?utf-8?B?bHU3OTR4TGYrTjFQbHNZZzNKSUgzQUZXL240K3Q1MVkwZXlBekRjR2JqdHFt?= =?utf-8?B?eFJMTUVCa3ZBaENkRVU2anR1ejUwemdRK3FPNmFJQzZCVHRVM2F3RHVhWEM4?= =?utf-8?B?OHQzb25MeVozSWhWbEhpRU5wa2pka0dtY3MxNFliZ3NieTEzTktsbUpSWVB0?= =?utf-8?B?aVZ4dXd6WWNOYkgwSFpZWDBkSERFS0hkUnkvcmowayt4VDdnTCtFVElJdllY?= =?utf-8?Q?IXoLBh4wPf1bW?= 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:(13230031)(36860700004)(376005)(82310400017)(1800799015); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2024 13:22:14.1295 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 47a930e1-ec12-4ce1-e717-08dc74e2090e 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: MN1PEPF0000F0E5.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7787 Received-SPF: softfail client-ip=2a01:111:f403:2418::600; envelope-from=avihaih@nvidia.com; helo=NAM12-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.935, 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 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: 1715779404681100009 Add a new QAPI event for VFIO migration. This event will be emitted when a VFIO device changes its migration state, for example, during migration or when stopping/starting the guest. This event can be used by management applications to get updates on the current state of the VFIO device for their own purposes. Note that this new event is introduced since VFIO devices have a unique set of migration states which cannot be described as accurately by other existing events such as run state or migration status. Signed-off-by: Avihai Horon Reviewed-by: C=C3=A9dric Le Goater --- MAINTAINERS | 1 + qapi/qapi-schema.json | 1 + qapi/vfio.json | 67 +++++++++++++++++++++++++++++++++++++++++++ qapi/meson.build | 1 + 4 files changed, 70 insertions(+) create mode 100644 qapi/vfio.json diff --git a/MAINTAINERS b/MAINTAINERS index 1b79767d61..448dc951c5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2164,6 +2164,7 @@ F: hw/vfio/* F: include/hw/vfio/ F: docs/igd-assign.txt F: docs/devel/migration/vfio.rst +F: qapi/vfio.json =20 vfio-ccw M: Eric Farman diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json index 5e33da7228..b1581988e4 100644 --- a/qapi/qapi-schema.json +++ b/qapi/qapi-schema.json @@ -78,5 +78,6 @@ { 'include': 'pci.json' } { 'include': 'stats.json' } { 'include': 'virtio.json' } +{ 'include': 'vfio.json' } { 'include': 'cryptodev.json' } { 'include': 'cxl.json' } diff --git a/qapi/vfio.json b/qapi/vfio.json new file mode 100644 index 0000000000..a0e5013188 --- /dev/null +++ b/qapi/vfio.json @@ -0,0 +1,67 @@ +# -*- Mode: Python -*- +# vim: filetype=3Dpython +# + +## +# =3D VFIO devices +## + +## +# @VfioMigrationState: +# +# An enumeration of the VFIO device migration states. +# +# @stop: The device is stopped. +# +# @running: The device is running. +# +# @stop-copy: The device is stopped and its internal state is available +# for reading. +# +# @resuming: The device is stopped and its internal state is available +# for writing. +# +# @running-p2p: The device is running in the P2P quiescent state. +# +# @pre-copy: The device is running, tracking its internal state and its +# internal state is available for reading. +# +# @pre-copy-p2p: The device is running in the P2P quiescent state, +# tracking its internal state and its internal state is available +# for reading. +# +# Since: 9.1 +## +{ 'enum': 'VfioMigrationState', + 'data': [ 'stop', 'running', 'stop-copy', 'resuming', 'running-p2p', + 'pre-copy', 'pre-copy-p2p' ], + 'prefix': 'QAPI_VFIO_MIGRATION_STATE' } + +## +# @VFIO_MIGRATION: +# +# This event is emitted when a VFIO device migration state is changed. +# +# @device-id: The device's id, if it has one. +# +# @qom-path: The device's QOM path. +# +# @device-state: The new changed device migration state. +# +# Since: 9.1 +# +# Example: +# +# <- { "timestamp": { "seconds": 1713771323, "microseconds": 212268 }, +# "event": "VFIO_MIGRATION", +# "data": { +# "device-id": "vfio_dev1", +# "qom-path": "/machine/peripheral/vfio_dev1", +# "device-state": "stop" } } +## +{ 'event': 'VFIO_MIGRATION', + 'data': { + 'device-id': 'str', + 'qom-path': 'str', + 'device-state': 'VfioMigrationState' + } } diff --git a/qapi/meson.build b/qapi/meson.build index c92af6e063..e7bc54e5d0 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -52,6 +52,7 @@ qapi_all_modules =3D [ 'stats', 'trace', 'transaction', + 'vfio', 'virtio', 'yank', ] --=20 2.26.3 From nobody Mon Nov 25 10:26:43 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=1715779403; cv=pass; d=zohomail.com; s=zohoarc; b=NURRWwxUvIPv6IfF7jV8uti464LZ1jYWeaJ/jYs06gZMtydvJF4sBHdlEorCQuHWS9YDYPeG1PRqsY70v8U4lu9B3bS5851TQzt6fQ9vntj5UQHLs2zIUpV0XCUNOFcIQWxYPtPRLu/sEGTsLp7sZxaQ/gKEW5Jm/QQoW/4ssbs= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715779403; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vGSveI8gWjWqlXHzIK8RnyyI8vYTqlSU2h79zeFC/wo=; b=ab9UwRuQSPLMxc3FZ7DwMKx4rvl91UKOSY9vxyeNG0wsFah2e0K0Vb1ryHHG0Om0CeCFtkefbbUs1CEdbWGAFwBGluKc8jJOzBlwcoAipda+/Ts0znXW5b3Q6UcYuAnTpJ7NsutRH39wwkNgYDNo0vVjj1E7NGzFPmoah+wyLZA= 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 1715779403668157.02469349508362; Wed, 15 May 2024 06:23:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s7EaK-0001JG-RS; Wed, 15 May 2024 09:22:20 -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 1s7EaH-0001Ij-VL for qemu-devel@nongnu.org; Wed, 15 May 2024 09:22:18 -0400 Received: from mail-dm6nam11on20600.outbound.protection.outlook.com ([2a01:111:f403:2415::600] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s7Ea8-0007FI-Ay for qemu-devel@nongnu.org; Wed, 15 May 2024 09:22:17 -0400 Received: from CH5PR03CA0002.namprd03.prod.outlook.com (2603:10b6:610:1f1::14) by IA0PR12MB7626.namprd12.prod.outlook.com (2603:10b6:208:438::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Wed, 15 May 2024 13:22:00 +0000 Received: from CH1PEPF0000A349.namprd04.prod.outlook.com (2603:10b6:610:1f1:cafe::af) by CH5PR03CA0002.outlook.office365.com (2603:10b6:610:1f1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.28 via Frontend Transport; Wed, 15 May 2024 13:22:00 +0000 Received: from mail.nvidia.com (216.228.118.233) by CH1PEPF0000A349.mail.protection.outlook.com (10.167.244.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.21 via Frontend Transport; Wed, 15 May 2024 13:22:00 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) 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.1544.4; Wed, 15 May 2024 06:21:48 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 15 May 2024 06:21:48 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 15 May 2024 06:21:45 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K4Q3thHFGN9cPgMtJtky74RITzbdZte0Bo7IRdOCbWDGY//vRHK3NK72Im0R+hEo5Bu8NhEwOFG01TF/zbTrXhQ6CPgzqSZ2jSyAJqTM5qX1zqYewJu1XX8RFSrMXjSQGIjfW57DUX7yKjgRR5owy2U4bpUXdC9UhRzO+brbagHyF0zQ8ZevSEBwW3uYeUY1ppUwODc1lV1hIRzoDiVFnYiL/Pi4DmUha6ci2Sbfqdh4VzV88+Ph94ebdj9irz/e1IOZ19T33fo08BfXOJ4+aGUo/UmadEZ5ZuvzfuWOIZv+YDJtP+rjtjQKyCotShNkL6j5pXEPPHVxtNqKWNN8SA== 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=vGSveI8gWjWqlXHzIK8RnyyI8vYTqlSU2h79zeFC/wo=; b=lpdeSwqNqRbvPmqYZRKbUmXyEZWTay2YPzfd8k6QKhmzIN3v53enh4QvLgsieuP2Sy5kRMXfDRMBEtsOmmhSZycWrCyK9OED8Ky6DH6n/d0FnZ/XY1OIrhp/csIbijBLPNAKocQdKIYuZSXWzr7hY0zG2n6hWkRpWvhmL5hzJHYaT1qE+53y0ukyEGhuq1lNteyEJatAW029Gn14numzA8maq066UGmnhbwqoBkKJgyTk0ONUMR8A9Bmz6nlyL4oAQRH2NL1HNIKjzZEGIP/GT6uJPeWJjlYMwqRFhduMerpugJvyJf/QkibK3thrrkAEwW70HIq0IOxk27V5qh5ZA== 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 (0) 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=vGSveI8gWjWqlXHzIK8RnyyI8vYTqlSU2h79zeFC/wo=; b=rTvGIsAKlY316XfB9uuubehI9gpVb3FtCw5CYFZRiWWbwaQDVYSbSwV8rSBdUV0bQors8wOG/ku8lC0fZOhXbnalbRGNXbMpX+tor+CRAzrHzn5UczgprBWk2QtPDnPHghEarPqbMKvH7DwqqRyA10SLTGjpItZsUdI0yADmdOCPQW41AMlYQ03nwoNc3MkxV4xvpiaTp+RkNxN4My5mhG1fXDKMrvSXPNuPpfw3g6rkTDjjgrJ4nz4bqkvinl436FQFEWam9bzsuZniGQfMnLfnlfLsJkUzajf/OiQZ+Djf3nXha2IH0TMzcGgBX0WW6Z8JtahQK8S8TqEhWqoFHQ== 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?= , Markus Armbruster , Michael Roth , Eric Blake , Peter Xu , Fabiano Rosas , Joao Martins , Maor Gottlieb , Avihai Horon Subject: [PATCH v3 2/4] vfio/migration: Emit VFIO migration QAPI event Date: Wed, 15 May 2024 16:21:36 +0300 Message-ID: <20240515132138.4560-3-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240515132138.4560-1-avihaih@nvidia.com> References: <20240515132138.4560-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A349:EE_|IA0PR12MB7626:EE_ X-MS-Office365-Filtering-Correlation-Id: a83355ab-396a-447c-6cc2-08dc74e200ed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|376005|1800799015|36860700004|82310400017; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?g2Cc0Jh7hDLxV3cg4yRnfdG6afj0wCq5UMf3dugfwyvvIDAiebVQTmVW8PK2?= =?us-ascii?Q?i6ak7lVB4jN6KC/+hVpphdbw7WYiVZHPX1rFd+V60sANXWxGWunuudA4nWv0?= =?us-ascii?Q?Kai/AsEMSdaUO8eAbPEmVbTTmDpHzg+6ZIN8MdfRzj9X2/W5npnhzg0KJUdI?= =?us-ascii?Q?jMYdgFLMoDDhP7djOuu26W16bWBIbjC13EslZ94p19WzpdKQodPyVQE4D/Ys?= =?us-ascii?Q?Ad5WMdycVpAoMpDqT8hslo5E6QnxLh2eLaUl1pFKIEyCG8cDWF535JuR4wRm?= =?us-ascii?Q?mkj+MmLVKNiJ4+5a5/CSmltLjRpri1+nDYK2kZHZipADtmONt+j0G5VxKGf0?= =?us-ascii?Q?mJOReNIdIdE88+UznsbANWpy97SG6Zy4Q8velz8MGeNADNEy9tfNijQCUhXy?= =?us-ascii?Q?z9m4JS6re6sL0uza7t0Wf/qdDPoRaN7G4LeXnAjvrtLnJ6VxYfhVRfUbAe8s?= =?us-ascii?Q?MEHJQwckOFORAnIjVucyZW3L5LmggCVgQQKC8DL/Fpwq61+1iW1U5rLRrnYx?= =?us-ascii?Q?LmFMq4RGaB6kpQGc41/THnCLgQLZbFX8hlXImTpYAFwvFiTglV0xKWYjLQlu?= =?us-ascii?Q?srgxQR1v2901NzUJz8mMF6pT8LG6yGA/SVUcuqHE1VhEUv8wWhQdaAv3EisT?= =?us-ascii?Q?oVbf4PptUSpH4rJR/HbAMgloEKD+Gtn/PoA9ULp3jqL76HelKU0HB+kKpNdq?= =?us-ascii?Q?zW3ntsK4rfsQolvtc2yZ6Z9FeMBLJZSF7T5jPuE1jOOzvWDtXBUgTlPHRNlQ?= =?us-ascii?Q?FVSOD26Y0lgWxXlLGIrtLA0HSo/lnrc5+OLwI3z2hsN/crelcOLN2wMd2Z4Q?= =?us-ascii?Q?kbOyrv5Mzjhpy0GVe/K0N2/7/DMkjYVxV+g63tigMMXBMBKgG+zCLsYV6tzy?= =?us-ascii?Q?suBitRqZhQMa7PKBI2mosZCrlJ9gc3Qv2tRqQSj2nXADYXtX3JJ/4otFo1OJ?= =?us-ascii?Q?tKlf4BQ//AJa1OHD3s5LJU3SkXjOR3W34L9VQqqTGiuyfRlMe3BSSyiqwZHU?= =?us-ascii?Q?1Lgj0yWbs15B3Tl6CZ8FxrUikEjsAimcbqEHYuU1QMxlbZ+mTzezLLf2lPzd?= =?us-ascii?Q?1ZkjomdAKyCDE7YpzuxxddUgGijXAgT7hcOc2/ZGeGRmtIIbVJv1xHCfy8UP?= =?us-ascii?Q?SExom7PUHREAfYCOSoaZJwvTGaWRdjkpLgZM4OEkM0bTAptieArRGI+j2zIG?= =?us-ascii?Q?Ix6RBFtuJP0amW92XsovDdeE5BWD0oPoC7UOsixdfdOCjjjzlhmUwvphQwWt?= =?us-ascii?Q?qHz/1p8WcSkvdYrSx9RvSxD3XTODIUMrJdpTM/+/UN9Vx3RmKRL2pxlN/RNp?= =?us-ascii?Q?+xOoqzqeuXeYD//yRyJIQyzQ8MZrmro+UOaasdJxmRB7g/xyQOMDjV0810w8?= =?us-ascii?Q?FSAJ/dzUSAP3ONtArwDLmbEeVb4B?= 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:(13230031)(376005)(1800799015)(36860700004)(82310400017); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2024 13:22:00.5352 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a83355ab-396a-447c-6cc2-08dc74e200ed 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: CH1PEPF0000A349.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7626 Received-SPF: softfail client-ip=2a01:111:f403:2415::600; envelope-from=avihaih@nvidia.com; helo=NAM11-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.935, 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 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: 1715779404676100008 Content-Type: text/plain; charset="utf-8" Emit VFIO migration QAPI event when a VFIO device changes its migration state. This can be used by management applications to get updates on the current state of the VFIO device for their own purposes. A new per VFIO device capability, "migration-events", is added so events can be enabled only for the required devices. It is disabled by default. Signed-off-by: Avihai Horon Reviewed-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-common.h | 1 + hw/vfio/migration.c | 59 +++++++++++++++++++++++++++++++++-- hw/vfio/pci.c | 2 ++ 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index b9da6c08ef..3ec5f2425e 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -115,6 +115,7 @@ typedef struct VFIODevice { bool no_mmap; bool ram_block_discard_allowed; OnOffAuto enable_migration; + bool migration_events; VFIODeviceOps *ops; unsigned int num_irqs; unsigned int num_regions; diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 06ae40969b..2e1a8f6031 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -24,6 +24,7 @@ #include "migration/register.h" #include "migration/blocker.h" #include "qapi/error.h" +#include "qapi/qapi-events-vfio.h" #include "exec/ramlist.h" #include "exec/ram_addr.h" #include "pci.h" @@ -80,6 +81,58 @@ static const char *mig_state_to_str(enum vfio_device_mig= _state state) } } =20 +static VfioMigrationState +mig_state_to_qapi_state(enum vfio_device_mig_state state) +{ + switch (state) { + case VFIO_DEVICE_STATE_STOP: + return QAPI_VFIO_MIGRATION_STATE_STOP; + case VFIO_DEVICE_STATE_RUNNING: + return QAPI_VFIO_MIGRATION_STATE_RUNNING; + case VFIO_DEVICE_STATE_STOP_COPY: + return QAPI_VFIO_MIGRATION_STATE_STOP_COPY; + case VFIO_DEVICE_STATE_RESUMING: + return QAPI_VFIO_MIGRATION_STATE_RESUMING; + case VFIO_DEVICE_STATE_RUNNING_P2P: + return QAPI_VFIO_MIGRATION_STATE_RUNNING_P2P; + case VFIO_DEVICE_STATE_PRE_COPY: + return QAPI_VFIO_MIGRATION_STATE_PRE_COPY; + case VFIO_DEVICE_STATE_PRE_COPY_P2P: + return QAPI_VFIO_MIGRATION_STATE_PRE_COPY_P2P; + default: + g_assert_not_reached(); + } +} + +static void vfio_migration_send_event(VFIODevice *vbasedev) +{ + VFIOMigration *migration =3D vbasedev->migration; + DeviceState *dev =3D vbasedev->dev; + g_autofree char *qom_path =3D NULL; + Object *obj; + + if (!vbasedev->migration_events) { + return; + } + + g_assert(vbasedev->ops->vfio_get_object); + obj =3D vbasedev->ops->vfio_get_object(vbasedev); + g_assert(obj); + qom_path =3D object_get_canonical_path(obj); + + qapi_event_send_vfio_migration( + dev->id, qom_path, mig_state_to_qapi_state(migration->device_state= )); +} + +static void vfio_migration_set_device_state(VFIODevice *vbasedev, + enum vfio_device_mig_state sta= te) +{ + VFIOMigration *migration =3D vbasedev->migration; + + migration->device_state =3D state; + vfio_migration_send_event(vbasedev); +} + static int vfio_migration_set_state(VFIODevice *vbasedev, enum vfio_device_mig_state new_state, enum vfio_device_mig_state recover_sta= te) @@ -125,12 +178,12 @@ static int vfio_migration_set_state(VFIODevice *vbase= dev, goto reset_device; } =20 - migration->device_state =3D recover_state; + vfio_migration_set_device_state(vbasedev, recover_state); =20 return ret; } =20 - migration->device_state =3D new_state; + vfio_migration_set_device_state(vbasedev, new_state); if (mig_state->data_fd !=3D -1) { if (migration->data_fd !=3D -1) { /* @@ -156,7 +209,7 @@ reset_device: strerror(errno)); } =20 - migration->device_state =3D VFIO_DEVICE_STATE_RUNNING; + vfio_migration_set_device_state(vbasedev, VFIO_DEVICE_STATE_RUNNING); =20 return ret; } diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 64780d1b79..8840602c50 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3362,6 +3362,8 @@ static Property vfio_pci_dev_properties[] =3D { VFIO_FEATURE_ENABLE_IGD_OPREGION_BIT, false), DEFINE_PROP_ON_OFF_AUTO("enable-migration", VFIOPCIDevice, vbasedev.enable_migration, ON_OFF_AUTO_AUTO), + DEFINE_PROP_BOOL("migration-events", VFIOPCIDevice, + vbasedev.migration_events, false), DEFINE_PROP_BOOL("x-no-mmap", VFIOPCIDevice, vbasedev.no_mmap, false), DEFINE_PROP_BOOL("x-balloon-allowed", VFIOPCIDevice, vbasedev.ram_block_discard_allowed, false), --=20 2.26.3 From nobody Mon Nov 25 10:26:43 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=1715779421; cv=pass; d=zohomail.com; s=zohoarc; b=ZRNg0Zzn3d3jNs9og55r2SyHE4VZgSACkI5lGH0h+X0Re8bBSWqg6e3qZKH7Q17fHXFJ6Iz+d5nxs3GwF3FVOtFRrquMNGKdKY21kaDbM9tB86H+U6GuZsgi47CGRctmgAnspES+qvClRtaHxP6AcSCVndC232zr838HkNpZEnc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715779421; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5akPpisdGNxEHRO1SLzA54myalXy/FoOcXu+Y3TWzks=; b=BQxV36RAUSyJqB9x+1+smFWsYe2+9bI/Qdg6wyisJyZSGWzeGyh3CvJbHj4bdF9a4sYDkILjDeG6wqu40gxoUQaqx1n0wdZ3LrxV4B2x500aAApUlIWSEEIh1dh6QFqLCagygxOt1Iqunk1GGeMTcumO9vu5+TDrtOFzVoRudcg= 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 1715779421424840.5160036792056; Wed, 15 May 2024 06:23:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s7EaU-0001L9-RN; Wed, 15 May 2024 09:22:30 -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 1s7EaS-0001KW-4f for qemu-devel@nongnu.org; Wed, 15 May 2024 09:22:28 -0400 Received: from mail-sn1nam02on20601.outbound.protection.outlook.com ([2a01:111:f400:7ea9::601] helo=NAM02-SN1-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 1s7EaQ-0007HO-2s for qemu-devel@nongnu.org; Wed, 15 May 2024 09:22:27 -0400 Received: from BL1PR13CA0444.namprd13.prod.outlook.com (2603:10b6:208:2c3::29) by LV8PR12MB9229.namprd12.prod.outlook.com (2603:10b6:408:191::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.28; Wed, 15 May 2024 13:22:19 +0000 Received: from MN1PEPF0000F0DE.namprd04.prod.outlook.com (2603:10b6:208:2c3:cafe::55) by BL1PR13CA0444.outlook.office365.com (2603:10b6:208:2c3::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.27 via Frontend Transport; Wed, 15 May 2024 13:22:19 +0000 Received: from mail.nvidia.com (216.228.118.232) by MN1PEPF0000F0DE.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.21 via Frontend Transport; Wed, 15 May 2024 13:22:18 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) 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.1544.4; Wed, 15 May 2024 06:21:51 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 15 May 2024 06:21:51 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 15 May 2024 06:21:48 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KwhmoTD2lEu9LnDgj6sNtDIxSEf7l9ICZm0XXUgVDDbVwWhS6U4saycinxMWIZZtY9q/7Ca93aO0lzmdwKvI3c5yAayGCmdEhK2gP2OM0ZqWGloK+gJLliX6ZXpkYs83MmzL27veLKdroddIklFf4eKB+Izb1DD2X7UIJ1aoZZtWl3JSHgqhkty8O1jMbRLicyFO+7XZOwdNjv2tIhLBW64mEnNbcjzFMrX3frJlRz4Kaq4cmgk96u7/vt0Gn7WpFHGQZFyFxQqAL2EIj7PfFHc0+i+6xMAiyvtTYNzu+D1XzFDbo29VKII/DhTrpmLYG8U7gWwlMKxpm2Du29SkAw== 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=5akPpisdGNxEHRO1SLzA54myalXy/FoOcXu+Y3TWzks=; b=Z2eBTTthcSxlNDPSM0YUdZ4fIXm1g3ExrLoIdF8wt4+JYrpm8TkqGYPXXumZZCTX8LFmyrWe+XX9GKg+jpsopJ21Babx0JB/oRG3DSEfz5/4h9jlv59S2RtkI6ZCrFr7vJ3HpHDmX4mnw+zL9rM0LlLLQCaFHOYdcHknHlx1nGCpZPT2c9z+I3GUIz26jYLC60xpLxtphm1bVn4muQN7xT3tOAX4wrYa46auvSjTFeP1pn3aY/tRFnvW8pwUjly7OF8cfpvKyZlVkws4wtTTfxX2+2rpH7z+oQuTa53Pi0qZjWYgZ1EypPAIp/iZKG91y4sQ0k1nITITw6Qa1Oz6AQ== 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 (0) 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=5akPpisdGNxEHRO1SLzA54myalXy/FoOcXu+Y3TWzks=; b=jmh8pI3ypQKhIgzKoN0Cy+aHUZwPc+SertVCgkTn4G1VOnSbEUmksssqXEBUwCglyixmNY2n2tBe8XfOI2co1zIyNm6LLsEHp82gbLa2oyI/h6dy6w3GwHJ1INNXppOnEoXmrf7NopTVf5xP1dKWL/bFmBbkE0v2+3buo4aoBFdpDX1Iz6KiPECm7MW1nDVorNTz24jm6qWdMurOn4W9EXf7xeEXPQkrJhUi4KM2cVACEx/en3YLOJpGzds+txLtn13g/USoAh61gylfT6ygkeR8r9s6WvwP6mTb3WIMGa57JK5K16m8g1P2SvdBIirU+vRCUwBf/L/PuUl6OdZvxg== 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?= , Markus Armbruster , Michael Roth , Eric Blake , Peter Xu , Fabiano Rosas , Joao Martins , Maor Gottlieb , Avihai Horon Subject: [PATCH v3 3/4] vfio/migration: Don't emit STOP_COPY VFIO migration QAPI event twice Date: Wed, 15 May 2024 16:21:37 +0300 Message-ID: <20240515132138.4560-4-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240515132138.4560-1-avihaih@nvidia.com> References: <20240515132138.4560-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0DE:EE_|LV8PR12MB9229:EE_ X-MS-Office365-Filtering-Correlation-Id: 3fb27b94-d10e-4f8b-64da-08dc74e20ba4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|82310400017|376005|36860700004|1800799015; X-Microsoft-Antispam-Message-Info: =?utf-8?B?VW9ibUFqTDA0ZVR4YXFKczdYYkxCa1lEMEpsVEhvTkJFdTkyY1RiM2Q4eXp4?= =?utf-8?B?M04vWWlVMGxWZGw0TUtpMmVsMUgyKzFRZUg4eHlWS0lWNmFXT3dCeDQ0cjRl?= =?utf-8?B?L3l2SGlwcmo3NHlBNDVzd3VDOXI1TkpYQnRUeUdQWmhKQ2htT3pXM3g1SFZM?= =?utf-8?B?WVBXQ3N2WkFLa1RxMzJaSnZjaFgrcjZka0lzS1BKYWI3cDgwZkQxeEVabnc3?= =?utf-8?B?Y0k1czVES1pLTkJxUjFNQlQzbERtRlRybTBWODY5bzFpN3E2c0tjUXFES0ZB?= =?utf-8?B?dk9EdEZuZmQ0VmFkSFNuZnkwNG9QT3A1S3ZUcTJKbXhudWlmR0ErVnZnWDdh?= =?utf-8?B?S25Vdl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8?B?UXpCQUxhS2c4d3VRZm01VkQzSmt2YnYvWEhGUlIydWYzYXdKbTVVQ0xoakh2?= =?utf-8?B?LzdHdE5XNlJPbXRmalNVcHNIZC9ZSWJmUUNqOXBQRytiVVp2QldtWWlsUlNv?= =?utf-8?B?LzNNak1GTkJNSW0xc3FadXV3UElXZFJuZW1PQ3VWRG8vL3lzMVNDUXc4TlhT?= =?utf-8?B?eXo4TjlTTGFzMGVaU2xZR0hOTWQ5Y0pRZjNTUnRFTWVUL3RqaG10S3RublZC?= =?utf-8?B?TSs2Qk41b3FoRTJDTnV0RnRkNlJPQ09CVUd0RFViMFQyakhMcE9qOGp0RnVC?= =?utf-8?B?Q09tNU82YnBnM0o2NzVtQnp6YU0reUFxRlZRQ2JSMWRNTWFPRUovNE9rSTMz?= =?utf-8?B?MnRDZU54TU1zVC9VVkk5THc2bWNHdkRiTzI0cHMwdHhzVjJQR1J1UnVTUmZS?= =?utf-8?B?MFNLdWZQcEFWWFRhNUp0Uk14aWtlQ0p3REhta0FPYnRyMDcwRUpQdEt5UU9E?= =?utf-8?B?aUZoNEdUYm56dTFmUHNKa2ZNZDIzMk5uR2RRRXo0ckdCTWVTMEhDd3pFMmFt?= =?utf-8?B?SDd5WDROOFZZTFRzNjhPQ0pRcUNJdkpCaGRLVkJzNjlCVU50cklDalZFOWVI?= =?utf-8?Q?3yoVnKs9WoaS3?= 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:(13230031)(82310400017)(376005)(36860700004)(1800799015); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2024 13:22:18.4646 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3fb27b94-d10e-4f8b-64da-08dc74e20ba4 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: MN1PEPF0000F0DE.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9229 Received-SPF: softfail client-ip=2a01:111:f400:7ea9::601; envelope-from=avihaih@nvidia.com; helo=NAM02-SN1-obe.outbound.protection.outlook.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.935, 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 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: 1715779422766100006 When migrating a VFIO device that supports pre-copy, it is transitioned to STOP_COPY twice: once in vfio_vmstate_change() and second time in vfio_save_complete_precopy(). The second transition is harmless, as it's a STOP_COPY->STOP_COPY no-op transition. However, with the newly added VFIO migration QAPI event, the STOP_COPY event is undesirably emitted twice. Prevent this by returning early in vfio_migration_set_state() if new_state is the same as current device state. Note that the STOP_COPY transition in vfio_save_complete_precopy() is essential for VFIO devices that don't support pre-copy, for migrating an already stopped guest and for snapshots. Signed-off-by: Avihai Horon Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/migration.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 2e1a8f6031..f2b7a3067b 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -146,6 +146,10 @@ static int vfio_migration_set_state(VFIODevice *vbased= ev, (struct vfio_device_feature_mig_state *)feature->data; int ret; =20 + if (new_state =3D=3D migration->device_state) { + return 0; + } + feature->argsz =3D sizeof(buf); feature->flags =3D VFIO_DEVICE_FEATURE_SET | VFIO_DEVICE_FEATURE_MIG_DEVICE_STATE; --=20 2.26.3 From nobody Mon Nov 25 10:26:43 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=1715779421; cv=pass; d=zohomail.com; s=zohoarc; b=k97mHWcRubUHIk3ZYif5gbflarBbzLxhX4C4iEL8NfwZKHKtAz/QYtUFImb/JxvVkPFnbFl7gYXIiETxbeyxAn2CTBgl62XCfEjgBcWVjtRxD5fqbTG7syhV69F+zXB7X01rRftmFvwj4pmViu3wteCWcAKGOLJYGsxQGEBoqYM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715779421; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ysncH/GXbkCkfqKlt0YJah71gRqhJesgEfziDyTDuLI=; b=nxATvGKho8LNs/2FNVdGx+JQdGizzTkAhtzYZodjFBiD2Z7seQqhtxXtW0Qmf04RQbp0fHhBL4cHIyzrdHllO4GlhXSlxX1p46cYxsBCPAjCJ8TSvCnb8BftYh0sBQX64ZzvnVcHS/M9gHKFn3hxnehSAyEOZGHlUo4O7O8Cya4= 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 1715779421601324.9848734720937; Wed, 15 May 2024 06:23:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s7EaI-0001It-KC; Wed, 15 May 2024 09:22:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s7EaH-0001Ib-3b for qemu-devel@nongnu.org; Wed, 15 May 2024 09:22:17 -0400 Received: from mail-bn8nam12on20600.outbound.protection.outlook.com ([2a01:111:f403:2418::600] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s7EaB-0007Fu-B9 for qemu-devel@nongnu.org; Wed, 15 May 2024 09:22:15 -0400 Received: from CH2PR07CA0066.namprd07.prod.outlook.com (2603:10b6:610:5b::40) by SA0PR12MB7479.namprd12.prod.outlook.com (2603:10b6:806:24b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.28; Wed, 15 May 2024 13:22:04 +0000 Received: from CH1PEPF0000A34B.namprd04.prod.outlook.com (2603:10b6:610:5b:cafe::5b) by CH2PR07CA0066.outlook.office365.com (2603:10b6:610:5b::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34 via Frontend Transport; Wed, 15 May 2024 13:22:04 +0000 Received: from mail.nvidia.com (216.228.118.233) by CH1PEPF0000A34B.mail.protection.outlook.com (10.167.244.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.21 via Frontend Transport; Wed, 15 May 2024 13:22:04 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) 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.1544.4; Wed, 15 May 2024 06:21:54 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 15 May 2024 06:21:54 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 15 May 2024 06:21:51 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L8IY5wFAeA4xV6Dyzx7NwV5bY1ze7oBjIWiF21nfpBzBLi5ag2R81Vx0DaF+rROcvnLwUtBZjQLH5QCin0z83XCFu4gvIS2/VMsp42jqsmd6BecxYBllMYyPQub/p3Ucb9dQZznqFrc2hOhOaU6Po+98KOS/Ozryn6iktfCT4hubT5c6SskEeic/gL9hbDCAz/Ys37KJFODq48QZgLd+g+7SmaKi4YMJHcNh5AlP7zIKfq5qr9C+NNAo/UOqhwj4EW5XV+hfJbG6M3nyzuYx8cjRhn9OUHbxubg1e1g7h3yPptoFHCo3Es04YjemQPM5RN/jODnq6EMPHByD7hRelg== 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=ysncH/GXbkCkfqKlt0YJah71gRqhJesgEfziDyTDuLI=; b=iJ1irTOKOJiWzsiT4ADdtSiu12SKg3WW/BA6JGdlQ8tbZddawGJ9s5nmGvNQGPlSHsRxZbinRw/Df6x6Z7Tv5HCv5llxINdzxofXr5rhCrtQFkmAvEl/uf1kziv1zETyDXJWJv5IcSmlqa4pGjUN86sMrlYcdFJ26kE66V2h3lh42mH/3fqd4H8poyCmK+ubNvsTdHLFZkhg91k3SkbQupZC0OTDzm+xp961/9S5Cd5TisZpf/XmrUf9/bclPtKpOQ9+xrtutd2lQaCgPyhL+c7tBcySRZHc08lAu9E80sriAe/i7aU3YZKJd346Tzm27YswvaSS4dWEJRTlZO/9lA== 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 (0) 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=ysncH/GXbkCkfqKlt0YJah71gRqhJesgEfziDyTDuLI=; b=nSeaI6UsSJzbrV4jv42mhDUBt/gtRufiB8zDElDhKEHrZRTgpX2WGScYz2PlY8XD1nF/V2ojIyCNs8Wvcs8u4fh9L25Catus7w8Nf5C2+NzZ9jmA8riINs522GN6sTu56EyQEsMTp/8lzGrX9riTciahvBbtyI52oe0Gt+2PnmaZrwPSWE/lWqgWCGmORdZhzHUSw5HpAHbA/EdsXVzjE2ROHZdzWAcpMiiOKHJQK1yruzjW7nYm+jBnl+H8UpIdriGD10L+dfe9Xb38V/nNJCtD9iK0j5T6kYLl4/O0waPVI2jWKYimC0SNEfAvIs2jITz0v2BqsYQT8Tp4ScTXEw== 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?= , Markus Armbruster , Michael Roth , Eric Blake , Peter Xu , Fabiano Rosas , Joao Martins , Maor Gottlieb , Avihai Horon Subject: [PATCH v3 4/4] vfio/migration: Enhance VFIO migration state tracing Date: Wed, 15 May 2024 16:21:38 +0300 Message-ID: <20240515132138.4560-5-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240515132138.4560-1-avihaih@nvidia.com> References: <20240515132138.4560-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A34B:EE_|SA0PR12MB7479:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ad208f3-f970-45fe-92f4-08dc74e20328 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|82310400017|376005|36860700004|1800799015; X-Microsoft-Antispam-Message-Info: =?utf-8?B?MVFvamN6SnRXY2RkdmRidy9WcWdRZjkzbFl5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8?B?QjVqUHZGR2lyZGdUODBCbjZwajNxU21RSnBqK2pNSk9RM1I1cnR1c2dkM20w?= =?utf-8?Q?IJu7NiCzh6Wjd?= 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:(13230031)(82310400017)(376005)(36860700004)(1800799015); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2024 13:22:04.2470 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ad208f3-f970-45fe-92f4-08dc74e20328 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: CH1PEPF0000A34B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB7479 Received-SPF: softfail client-ip=2a01:111:f403:2418::600; envelope-from=avihaih@nvidia.com; helo=NAM12-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.935, 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 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: 1715779422760100005 Move trace_vfio_migration_set_state() to the top of the function, add recover_state to it, and add a new trace event to vfio_migration_set_device_state(). This improves tracing of device state changes as state changes are now also logged when vfio_migration_set_state() fails (covering recover state and device reset transitions) and in no-op state transitions to the same state. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Avihai Horon Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/migration.c | 8 ++++++-- hw/vfio/trace-events | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index f2b7a3067b..7f0d76ab50 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -129,6 +129,9 @@ static void vfio_migration_set_device_state(VFIODevice = *vbasedev, { VFIOMigration *migration =3D vbasedev->migration; =20 + trace_vfio_migration_set_device_state(vbasedev->name, + mig_state_to_str(state)); + migration->device_state =3D state; vfio_migration_send_event(vbasedev); } @@ -146,6 +149,9 @@ static int vfio_migration_set_state(VFIODevice *vbasede= v, (struct vfio_device_feature_mig_state *)feature->data; int ret; =20 + trace_vfio_migration_set_state(vbasedev->name, mig_state_to_str(new_st= ate), + mig_state_to_str(recover_state)); + if (new_state =3D=3D migration->device_state) { return 0; } @@ -203,8 +209,6 @@ static int vfio_migration_set_state(VFIODevice *vbasede= v, migration->data_fd =3D mig_state->data_fd; } =20 - trace_vfio_migration_set_state(vbasedev->name, mig_state_to_str(new_st= ate)); - return 0; =20 reset_device: diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index f0474b244b..64161bf6f4 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -152,7 +152,8 @@ vfio_load_device_config_state(const char *name) " (%s)" vfio_load_state(const char *name, uint64_t data) " (%s) data 0x%"PRIx64 vfio_load_state_device_data(const char *name, uint64_t data_size, int ret)= " (%s) size 0x%"PRIx64" ret %d" vfio_migration_realize(const char *name) " (%s)" -vfio_migration_set_state(const char *name, const char *state) " (%s) state= %s" +vfio_migration_set_device_state(const char *name, const char *state) " (%s= ) state %s" +vfio_migration_set_state(const char *name, const char *new_state, const ch= ar *recover_state) " (%s) new state %s, recover state %s" vfio_migration_state_notifier(const char *name, int state) " (%s) state %d" vfio_save_block(const char *name, int data_size) " (%s) data_size %d" vfio_save_cleanup(const char *name) " (%s)" --=20 2.26.3