From nobody Mon Nov 25 10:31:31 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=1715246225; cv=pass; d=zohomail.com; s=zohoarc; b=lYGGXT6bNvludxMWP9O9u4vDNW+6GuzbvT0QmEI+QV9RJ/zOir674L0JeSrkMVCytnzhNv1vJhsdAUJTMJe9eIzmFvT2lW6qjBSVTZ6kFu/oVbjfdMEWMxxfncd/SFh/PdnhTDwVNveVzK63YLdXidoJ7elODW3Hrfl7j+WX3uQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715246225; 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=v0yPHHloLUKIK3bsg7eDBRSATaUMxTXGbX6fYXMt5fE=; b=fiNNbYivGNz/RCaCNO/j004s9vAxDqSVwstS40CMlWjgmcJvnBh2v6g3B2+l6mhkAsikfQTmvxo4yG4t+ItZLV020FsMZL80z7fr+jDXuBjzRpBlXSXBX3gAQ3825gfGB6TQwjaT+SdDgKXHdPdo0L1KH7Zizv16CHtqNROez6E= 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 1715246225678414.12010488189946; Thu, 9 May 2024 02:17:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4zsE-0007kS-68; Thu, 09 May 2024 05:15:34 -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 1s4zs4-0007jZ-OY for qemu-devel@nongnu.org; Thu, 09 May 2024 05:15:24 -0400 Received: from mail-mw2nam10on2084.outbound.protection.outlook.com ([40.107.94.84] 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 1s4zs0-0005mZ-BT for qemu-devel@nongnu.org; Thu, 09 May 2024 05:15:24 -0400 Received: from MN2PR20CA0037.namprd20.prod.outlook.com (2603:10b6:208:235::6) by MW4PR12MB7237.namprd12.prod.outlook.com (2603:10b6:303:22a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.35; Thu, 9 May 2024 09:10:14 +0000 Received: from BL6PEPF0002256E.namprd02.prod.outlook.com (2603:10b6:208:235:cafe::e9) by MN2PR20CA0037.outlook.office365.com (2603:10b6:208:235::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.45 via Frontend Transport; Thu, 9 May 2024 09:10:14 +0000 Received: from mail.nvidia.com (216.228.117.160) by BL6PEPF0002256E.mail.protection.outlook.com (10.167.249.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.18 via Frontend Transport; Thu, 9 May 2024 09:10:13 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 9 May 2024 02:10:02 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 9 May 2024 02:10:01 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Thu, 9 May 2024 02:09:58 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E9olfczyYCOP95g2hlYy/8wVwwgepR9t7C19Ymrik/9O6tmY+M3lcQf48n8MFBtbAcF7dLq8RWc7GBYhsbWW48lhMjOb96oo83C2s26GFhZknjZiTE/X2+RtX6deKTPj0L9iz1+zeA2LbCCesKxPB4T/AwMOEg6VNvcHnE/0wyrO351nz5r9xf4SJYFOuLsby9l4LKU0dVKetYJ4nAgi9aByKaZoajeX6JS04/wntFo5wA0K2gaZJ3Sib2sg/lPEeBMRnhL9+tv6MKXIHZuqH4Rh+3BvQnXYzvTnii7lYccLfhTLN6PJHnNn0WWaKIZC2Bxn1NHgcTsSo0skFZ6rTw== 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=v0yPHHloLUKIK3bsg7eDBRSATaUMxTXGbX6fYXMt5fE=; b=QMRmnjbe9EP9Xz1VaUsC7+SPGZpH4er6g4NQk8aptSIgU97l9hrvPWV58hCtNpzTwiC3BYBxpFGm4FcDm/f89p40MzWxMCVHWDRhrwJBDz4Liwe0RYV2b8GRNCeBvpcvW3/YluhYsLWairGVvxLjcwvpZtEtvbDapwdftaikByqDAs3LlEoFhrC2LgaRQk2S9euAcFygsZh21pQ/87aepzNg95y2Bub/rKgBeNIVF8dlNNhOYC60Prsbw6iBCT3CWdbBtDyGgwmCxQkRbx7mRpfxZfsBooDq40WWfEMfs20de8/fri5aF5xXGqix7i/Oz4Guk9fgnbjeh+nPUmsIsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (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=v0yPHHloLUKIK3bsg7eDBRSATaUMxTXGbX6fYXMt5fE=; b=TlGiLYVPqWsE/ki5cgHJMm//2KIFY9FYBuodxZE5OfH7DwKIUEyr2gaotzLfCaIoy+oRchEqniBB8+vYClv2A6DO90/+8vlDVc6ZpnIm1UlJ50TArxhqRsr2e4gm68xxfF6qqpLjYdOkMNTQ9tyndEp4oRft59+779oGDhWMuGrCBkjAirTOLWw/LCje5CpPUnp41gM/DMJ0t7ezULIsKzqq4BeWQDvB+MDyFn73vOkXKEkAriUVZ49yiLYMe6vYUwGX14yVnK9gLrLZLqHgMJ9wCGEbY1eY7y0UAD3dIgEs1de5sOBvjGTVudLJzTEqY2U6fEDWJawt4plwpSTAtg== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Markus Armbruster , Michael Roth , Eric Blake , Peter Xu , Fabiano Rosas , Joao Martins , Maor Gottlieb , Avihai Horon Subject: [PATCH v2 1/3] qapi/vfio: Add VFIO migration QAPI event Date: Thu, 9 May 2024 12:09:52 +0300 Message-ID: <20240509090954.16447-2-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240509090954.16447-1-avihaih@nvidia.com> References: <20240509090954.16447-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: BL6PEPF0002256E:EE_|MW4PR12MB7237:EE_ X-MS-Office365-Filtering-Correlation-Id: 13609ea6-9b89-4bcc-154d-08dc7007d606 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?5Gc2poBx2x7CuwVVgONTk+VS+ySqSl5RwBFUcn/AQ2lytN46dAK+qDLwtqyD?= =?us-ascii?Q?BVAudAL2EIqL8KQ+KmF3HlfaPIPyfYokw1E6om+4294knijMYB6YEzQjGmE2?= =?us-ascii?Q?2Z3aWD0BomvqC6QTyLbbdzzsqnIc0/SptFVQu7C5ep+zfvBChE4kPqgB2k/C?= =?us-ascii?Q?6ShvjAK2T777kB20PXttEClexZZkpx8b3Kuo6Lz47wbuoAWCNqfKOwKmxfP1?= =?us-ascii?Q?g+oW0pnUunWLjD0cuXv+o4Mzhu8cRkzwk3nj1vtMbyVNiGdwCYwdGFtlJ36x?= =?us-ascii?Q?aRfPa6Owl9kw2F9K/QiUnQEL4Qk1KWk08aSDkNdsNxh9EdgN830ZxbSCLdpd?= =?us-ascii?Q?QFYw9C5DWdztfENe030livhqnkmWK9WYAHWuSqw9WBJmQsPVhudepQwRt6pa?= =?us-ascii?Q?EPr5PuPn0TsTYAk7uMTUosD+sLL5h+nEVbUXdxt3j4gqFV9Axin9l0Uq/6TM?= =?us-ascii?Q?I7q1tfF2oHy6idldc1hKSHCmNvUevv+IEN4nq6SxadaDYDYN+l/GIOTkc27y?= =?us-ascii?Q?8/WAlTf+189gb9HuckINPHDVHsJUa8cpkRvMFuO8RPzo0tHZD9+rDkycMZS5?= =?us-ascii?Q?wR2btsogm7sGA7kvfm5hT/frlFw8I90104TOlVFUM3GnA++l24r7kXeCKs19?= =?us-ascii?Q?MSYIrDf+6z+ttNvayTgrYOJHJ+uvbd1CWJEPu06AftTGmEqF/a0n3wqozgRe?= =?us-ascii?Q?vQh35mr31mR2s57CxzjyMrv+Nmymne0MG8C8KFR5cxdeIRK+xqKLQqt4ij+9?= =?us-ascii?Q?PR0eTyzy7zdddydhPlqd3xMRZDawCVcJapnM7r7B5T4LTHIz9RvTpHooPJ95?= =?us-ascii?Q?bVb4LpzmPqQzwhASdLnB1d52bXLK54NkMIbWvK80ubbLp58bAwQ8BHh4zULg?= =?us-ascii?Q?M9/oCDlpCkU1kN7VbXKejPI2Swfs2qUP4R1nlOr7c8IwUNSeBtQxJ5kicMna?= =?us-ascii?Q?mHrgSjwarBMy7k7jwBBtPJwOF0QH7FfVdtg6wjrcvsBhcXKd+yh8HIyE8S/j?= =?us-ascii?Q?pzN5JzKNOwjm05fpjDAXatP6aOj+nNGs+HpylaFm4I9ZqHo+sdAXJEk5uFmO?= =?us-ascii?Q?iAiBRnB89gH/xltBa486sW+7jZNuMWD/i+rPjTz1pKG0he34E0dIyLkAb5R/?= =?us-ascii?Q?iLnAHUG1U3JPMRpG1ojwtSL57HpVZ130slxs9WLsI2HpNIZe1uV+LHvtWMKw?= =?us-ascii?Q?c5hLQWE+MpCSDYVrBefQttB67bs/po5ay94l9xoDGuAmf/MCDww8ZkTpcpmS?= =?us-ascii?Q?HJBA6yDP9w6vHzVvlZBK2Dl4wERScKAxQMZ6Z42ntLu5jFKYxAP31UB0+JZQ?= =?us-ascii?Q?fkz0406xSoMR+ZKBflBEr7aeh1WQ/2/aLP2WhXksP210FDaA/99eVOYYZs+M?= =?us-ascii?Q?Yh415iOYe6ZKyJwRvnNAWlEqanNJ?= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(376005)(1800799015)(36860700004)(82310400017); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2024 09:10:13.5541 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 13609ea6-9b89-4bcc-154d-08dc7007d606 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0002256E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7237 Received-SPF: softfail client-ip=40.107.94.84; envelope-from=avihaih@nvidia.com; helo=NAM10-MW2-obe.outbound.protection.outlook.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.582, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, 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: 1715246227284100002 Content-Type: text/plain; charset="utf-8" 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 84391777db..b5f1de459e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2160,6 +2160,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:31:31 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=1715245889; cv=pass; d=zohomail.com; s=zohoarc; b=GQq3b2zu067Krb3aZF07FBXG7mswI0ABaPKAhW6rvwsbaSHbhFDIWsFbuzYzXBMwo2DwK+Wr37YSni38bUrTX02W+veW6yLi3ySJzLpHRcZTsVNoGO/ZcKVJhW5OiZ7AvSl4NTF6JaeDL1SY8uNESmYnrhyDDQVbIkVbjLmDuT8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715245889; 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=kDXPi1eKaN76rgzC+w4BLL1j0SEwquiNwP6LCfrF4Ss=; b=QqTZl/Y1usubIVv24rn5hnuvkhsA0+dUvgfXkq8pnk/UL2+v9i2jILh8eGgSJFezQdhfUqN/wFw9yCCGQkZ45a7+MPs2UJg4oQ2YVoXiAefRolB6vwURqBHZsTeyUbx7AD23gTb7Sftn0CfNlXzmpTGMVZmcebWpTU0HZ2HeWbw= 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 1715245889064556.79752828135; Thu, 9 May 2024 02:11:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4znR-0004o6-Kk; Thu, 09 May 2024 05:10:37 -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 1s4znQ-0004nd-3t for qemu-devel@nongnu.org; Thu, 09 May 2024 05:10:36 -0400 Received: from mail-mw2nam12on20601.outbound.protection.outlook.com ([2a01:111:f403:200a::601] 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 1s4znN-0003T5-GV for qemu-devel@nongnu.org; Thu, 09 May 2024 05:10:35 -0400 Received: from SJ0PR03CA0216.namprd03.prod.outlook.com (2603:10b6:a03:39f::11) by DM4PR12MB6325.namprd12.prod.outlook.com (2603:10b6:8:a4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.46; Thu, 9 May 2024 09:10:25 +0000 Received: from CO1PEPF000042AE.namprd03.prod.outlook.com (2603:10b6:a03:39f:cafe::e8) by SJ0PR03CA0216.outlook.office365.com (2603:10b6:a03:39f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.45 via Frontend Transport; Thu, 9 May 2024 09:10:24 +0000 Received: from mail.nvidia.com (216.228.117.161) by CO1PEPF000042AE.mail.protection.outlook.com (10.167.243.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.18 via Frontend Transport; Thu, 9 May 2024 09:10:24 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 9 May 2024 02:10:05 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 9 May 2024 02:10:05 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Thu, 9 May 2024 02:10:02 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CESMs1JkvJ15BtB/SGdEAbaX6MtTqdH9dhB+OwOhh+x2bI8IWs+49EO5IQ8xUOWIaXa91FQSIAyNx8pZ/SaBGulhOet2aBGOFvojJJyX8uZk60JtKLYFyyM9/DPfpd7hKOcvK7bPN234Ch3Kb59CekZWOxHb0MAbPqpxmRxes90xbXf2PRlsUBmYwnq+LyMJBQwyEo8IAyS+V612Fjbqa50Pf1Hy82hBGyMO8uVbSdyt9wAVy6Ush+NJkJdtdJtMP9qsRyWoISHyB5p9HdsCL0mMZLImUa4Kmm6xv651A5JNsUB3HI+nd3AewsBW9axUrzPIhtkKJfL57/0WwmtwKw== 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=kDXPi1eKaN76rgzC+w4BLL1j0SEwquiNwP6LCfrF4Ss=; b=I7sR/oJIP2UeHtZDrhe1PAK4vc5g/1bCok6PjtGS7uZX2K6cByLvwiEiqaJtnaOfrnHQgNtkuMZrrQ0LIHNpWieMylTwmGPhyRP+cCiP9A8WjuJG/KQz/GqgYts71CXjFJbwpLwzq3grusmKaVaZawo/NythnquLWJQuqk5k01kW44c/Fa6D/YAEAIEdbAK5xtKmQXNgzin1YDwBoAEQtLEcvbdXHDPSUJK36hZjeKJYimn/qaWf3GRzmrtRcETSK4hq9M8Gsto5DoVDeFuMJhk1JUKs7Gb03RmNAAF1uBeM0D5qHQln/6cy9pWweZ/Rebb/BLF3glKloY8SRhJxoA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (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=kDXPi1eKaN76rgzC+w4BLL1j0SEwquiNwP6LCfrF4Ss=; b=T8+EbUNEpOIzhTnz5NW4ObYyqshl2IPI61eC01kX08ujAtHuh+gTluCIGG4uem2h48BwrC8A+kgKK8p5gbzVP7dgUDG6FBHrF8YJggxyRjf77C1D+2kW6u2Wt4j2xtQfwNXORcg7UMQzKe8LmnAX8LxTwOJfXFevEntfUi6lXQjH3vwENDjL7ESEqO2nDUQVKe/c7jyJbImKZZlFtfQr1HD1HuM5WnevXPxWCHa17wF/Txcwu3XPzqoOMPQThfUgt9g6xSMN1YDOJwFNcUw6pVvQRt/AomXqpoMbSiU+wYqiHc612IYq5lKZR3xJcfAtHEK4caIen6iJtF5ZoBmm9w== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Markus Armbruster , Michael Roth , Eric Blake , Peter Xu , Fabiano Rosas , Joao Martins , Maor Gottlieb , Avihai Horon Subject: [PATCH v2 2/3] vfio/migration: Emit VFIO migration QAPI event Date: Thu, 9 May 2024 12:09:53 +0300 Message-ID: <20240509090954.16447-3-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240509090954.16447-1-avihaih@nvidia.com> References: <20240509090954.16447-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: CO1PEPF000042AE:EE_|DM4PR12MB6325:EE_ X-MS-Office365-Filtering-Correlation-Id: 4d6251c3-fb0b-4f10-0c2a-08dc7007dc71 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|376005|82310400017|36860700004|1800799015; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?dzzOCja6BMwakU7hXPVpEBJRO8f+e5mbRs5pI5BIZ3E37Z8W3ifKk6O1odk/?= =?us-ascii?Q?29IUZ/d7+/MUeIAMUQZdnW2CTdLDAZs7i/gmz3aYcY4QDjzyrrNTjo++mgZP?= =?us-ascii?Q?l6KerkRy3OnUbkPWCGQ0s1lWsdW936hUR9/LE33qYsttCt+zAGb5g7uzaz7N?= =?us-ascii?Q?QyKtyyvq5N7QvtUk0y04tOTdZdfs800c4GuWy/3OcqfRpF8SEbNWx2i1jEju?= =?us-ascii?Q?OgyNc4dsvpx9PRQBbG503GuI9+KbHnYzYi3UEEvD/+aqTGkWrF/YZ+Qaowdh?= =?us-ascii?Q?4JAtzu4rdX6aBxbl1PZVCrf61HDPs7gIL2gkUigDQNI1u5e2EubEXhyzC++y?= =?us-ascii?Q?N8NwgExggnXONPTftqmCCW5AHEk5QdBebQSnl67vetPeOmLy03H4Pq3Obcog?= =?us-ascii?Q?ZBO/AZqpvYRy16qoAUsVrYMrk9F38DTGc3uYpQOlqZ1+IqBGmUVSIGR7MJJp?= =?us-ascii?Q?Epa2EnrcvGJyHxw/ZWi4jBYIS5UTGgr7uDBnwO0IAMzG9p2IMOxdJiyZrJcw?= =?us-ascii?Q?aYaNJALycK/o24MEE0Qa2IcfBklIT6KFfMafgR75Ecdj+Pjha/XfMu5pcm4v?= =?us-ascii?Q?zLSjxgeGiCEBDpV8cGwFpZ9hZR55Qx244Qsf+1Q7dygpYuejnsg1Vfl0ADfL?= =?us-ascii?Q?cSFgjHYN7UqMNhq5Q4bIDYzMoYj5k6kllEvR2+SKyoe2cxndcxbUpoapj8WV?= =?us-ascii?Q?z+UN0YsOFF+N5C9oEi3dzqeQkUMg5vHgHuUXtcQDSvIJwLyWP4M4/04gMSMc?= =?us-ascii?Q?659eAWrJv7vn2Ro4xv5ufVxyqLB+v6456puB9xMAwQXLr3lgCdU57RPvLHmf?= =?us-ascii?Q?SX9OcJ+IUWtGhJ93Gxn0IYsbrULcQVda8iOKH5qrA89hEMuATxPhyghXoF5s?= =?us-ascii?Q?H4x3EgXtghPLWftvE49rnQBsh51I5f5eJF2EBI3FpyQwt9GgI3zkBNcWI89G?= =?us-ascii?Q?9HX9HTfFE6on1ArImnGkbrs3oR6tKQ7RbEEsCLzrUzCNzyB/kBa6a3/dOQ/6?= =?us-ascii?Q?6sJpCGQ+dbYdg3SrA13TTTVBEW3lEDT+m22QsWdoRvH4KOXEAOKb0t1q6oZV?= =?us-ascii?Q?Zqy3J4qAR6RU0fDBY09KbKgzavP3zAsvOQPAgiizMsfSXeaJdY9+DlmxyYvK?= =?us-ascii?Q?AqNuf6R0dXMZXw9ouObjnLXkey2cIXr8EpWs4Wj2zisO7Sspnvj7WAbWmoUk?= =?us-ascii?Q?oWXe08Aq/H491fLS0slye1jYHggyNx2TYLDXUVkX/Au2Hp3sgjXKUvoDEo5z?= =?us-ascii?Q?16qxJhgRbRpy8CeVwSWkE8sv7GQ3Ls5mbpB3PUS42Z7ou+ukooVJXKsgAIo/?= =?us-ascii?Q?yx7S6tTRHYd3aolnTD4oPExeDjLdWNVn3fp2noOODKcRSgGaJdtfOBHPVabV?= =?us-ascii?Q?87/yZT+1G4D/9TM3rPh0zbncATXI?= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230031)(376005)(82310400017)(36860700004)(1800799015); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2024 09:10:24.3683 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d6251c3-fb0b-4f10-0c2a-08dc7007dc71 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042AE.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6325 Received-SPF: softfail client-ip=2a01:111:f403:200a::601; envelope-from=avihaih@nvidia.com; helo=NAM12-MW2-obe.outbound.protection.outlook.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.582, 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: 1715245889829100001 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 --- include/hw/vfio/vfio-common.h | 1 + hw/vfio/migration.c | 56 +++++++++++++++++++++++++++++++++-- hw/vfio/pci.c | 2 ++ 3 files changed, 56 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..5a359c4c78 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,55 @@ 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; + } + + obj =3D vbasedev->ops->vfio_get_object(vbasedev); + 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 set_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 +175,12 @@ static int vfio_migration_set_state(VFIODevice *vbase= dev, goto reset_device; } =20 - migration->device_state =3D recover_state; + set_state(vbasedev, recover_state); =20 return ret; } =20 - migration->device_state =3D new_state; + set_state(vbasedev, new_state); if (mig_state->data_fd !=3D -1) { if (migration->data_fd !=3D -1) { /* @@ -156,7 +206,7 @@ reset_device: strerror(errno)); } =20 - migration->device_state =3D VFIO_DEVICE_STATE_RUNNING; + set_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:31:31 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=1715245889; cv=pass; d=zohomail.com; s=zohoarc; b=SpwHQdh7/a2Z2fVuDIiKCj5rO1cRewTRvztl4U/uZ7XkRchZb6O4TzmqohSRpvvkgVombMB5+FJpey30HGMPESOG4wkwceHbsIuTb+ZUkJgGNuBL+PIke0dZCs/PhTV0s4ECzSUbFWmmiMkUCDzigmQPVIxTK1017VMNbZadabE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715245889; 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=5lWyV9quOOxfAeWLQKjuqBfvQRwQ9aN5eUYcsXLYsjY=; b=h4HeEouAS/wAIqBpwWF8k51Z3KGC4I7hY5zevFdwPNIdbaB1U7d9psPD0l1l9OSbhq9UVx36QAH/pa4Q9Men5NUNNSicpwZxcgyQEo0dOUOm4zCzFQNr/9PskRDxGTs92s04sa7HL5ghjc5Wo7/bdWPuqE0G3jiG3t7GW92EMXA= 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 1715245889155232.07791239504536; Thu, 9 May 2024 02:11:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4znT-0004oW-PY; Thu, 09 May 2024 05:10:39 -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 1s4znS-0004o9-7F for qemu-devel@nongnu.org; Thu, 09 May 2024 05:10:38 -0400 Received: from mail-bn1nam02on20601.outbound.protection.outlook.com ([2a01:111:f403:2407::601] helo=NAM02-BN1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s4znM-0003T4-PR for qemu-devel@nongnu.org; Thu, 09 May 2024 05:10:37 -0400 Received: from BL1PR13CA0143.namprd13.prod.outlook.com (2603:10b6:208:2bb::28) by SN7PR12MB7021.namprd12.prod.outlook.com (2603:10b6:806:262::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.47; Thu, 9 May 2024 09:10:28 +0000 Received: from BL6PEPF00022573.namprd02.prod.outlook.com (2603:10b6:208:2bb:cafe::f3) by BL1PR13CA0143.outlook.office365.com (2603:10b6:208:2bb::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.43 via Frontend Transport; Thu, 9 May 2024 09:10:28 +0000 Received: from mail.nvidia.com (216.228.117.160) by BL6PEPF00022573.mail.protection.outlook.com (10.167.249.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.18 via Frontend Transport; Thu, 9 May 2024 09:10:28 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 9 May 2024 02:10:09 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 9 May 2024 02:10:08 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Thu, 9 May 2024 02:10:05 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mdaySpgfM8n/vem47ABvCq8sBwiU47Lf1ksQ/Qt/Z8TggYumdNlYteQoXi4tQEzOGIM7CJ+Mfujjc6y8Kt88cVLJ26AoEIi0pEq1eD8zvdRocT7SgR7WZwVurNzATHN+boFEvDjMWEsHwUdsrcp+hgrJut/82Rp0AD0ykTrAukK9PninXdAXLT4j0TG+2mA+/+vT6pA5ut23f7SIpKEuP0BepIphbpuCY1z4QSuuY/lgWCZeQYe9SMTrjiJbZUFJavr0Teh5IqaUrgeGYiEve66eI0/DPtZlNEtSyx/CwTFJM9qmCgEdiT4R6V31QAFIWF3oJasxy7X49aVpyGsCzQ== 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=5lWyV9quOOxfAeWLQKjuqBfvQRwQ9aN5eUYcsXLYsjY=; b=MkG+Nld3bVvTCxETiN/4JZuj29++B5CJGVEBf7gcuhSP9CcKeAjI+N2J5dtit/nAap2/FgqTCcRc1D2iMfMZ3JG4HbxcQScdCPUCKZ3L0kXuy4VuyAHOxXgj6YNDMF/H54LvTlZQaEFOnYNo16fmRI9/oCg7iJc3JHjI+UDbkSZh3mSypf6+IOWruSi/se71OUD4FylQL1AgmaHy6QBWH5gi/+QXJjFvKqNSXRbWSdI51L2cPdJGNjcBcCNm5DwfGzySIoZ0j7mFSOEepy8KJgTR+VvJ+K5rAlgu/k0AJhcI7nPOJrulOWEmnVEOoYUURm5NmH+bzYd6wsrkvkzhSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (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=5lWyV9quOOxfAeWLQKjuqBfvQRwQ9aN5eUYcsXLYsjY=; b=nvpD710oqYo86fdZ8LIZVZrBd45Q4FctltSLq5ZMFHnE2QYE51IoSOFDRKXXaTanAqtBVA/fT/rMS4u9hetB8YFidaGQLr3QqzKq3dZRn2ws0Raodihh/XbBMPA4XUd6txV7gWGE87uiTB7Oy2g5cQTNiFiEdsXWlD0zRsM7Q2cW27119bHGGXfQT3pNAmdbQm9CeKuK5HOLVgAal74fOxgMq7SzJKKdySCZo7Krn3Hp40uZGKYosAONp5HCP8Dy/SKUZqGZ2WRM8x0e+iKk8eTX1ClDIpX10TzeTktXzS040efZMBCHtX/AncOP0LVdfi5v9uEMlGMX/pJpJKwL3w== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Markus Armbruster , Michael Roth , Eric Blake , Peter Xu , Fabiano Rosas , Joao Martins , Maor Gottlieb , Avihai Horon Subject: [PATCH v2 3/3] vfio/migration: Don't emit STOP_COPY VFIO migration QAPI event twice Date: Thu, 9 May 2024 12:09:54 +0300 Message-ID: <20240509090954.16447-4-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20240509090954.16447-1-avihaih@nvidia.com> References: <20240509090954.16447-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: BL6PEPF00022573:EE_|SN7PR12MB7021:EE_ X-MS-Office365-Filtering-Correlation-Id: 535c83ff-2185-424a-f053-08dc7007dea0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|36860700004|376005|1800799015|82310400017; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?NvohWKiYDR00GrllSuiXfK4OQw0wLXoMuWQlc9a/s4gy5hhclWxWm6K7Gxl8?= =?us-ascii?Q?h1P4k84qjlR4fwFLNiyr7SN8ThqhnMcr96FEkGdlnlfUcDxu2xeza5MXC5Wa?= =?us-ascii?Q?XBR6mAeOKm2K7zKywLewvrbFP6/4fH+VZOUtqVUgWa3h780wy+OZ0o0DGFP7?= =?us-ascii?Q?t801fW2zOGRFraRrlu3wtNpZUQctHxki+62e7w8ogbtdAstn2rkNLktJHBmI?= =?us-ascii?Q?8q8xaQIDTsCfCcuD0YqHm/POYBJmkCFXdGoFTwl/xjShWa2eCQwBDxWU9SUV?= =?us-ascii?Q?zCnzJHyYfdQnHCwQAi2Vy36cPDZyq57DUXnL/ivh4rAXEO6TSTROeMxaf21e?= =?us-ascii?Q?2uRdhgYbj72O/snac0ckXIBhsFkWnk75yyzbbVd4UhFsRdMsZg5aJbuZ/7Rg?= =?us-ascii?Q?6Qgt/KeInPebXNIunDDgacG67L3DKeNWmZ+KWMMl0MKmL1r2vm7EpNn48riO?= =?us-ascii?Q?wfXwuniyhSrYroyiVWZ+BdEDIgVs9ygRzXOdTgGQELI+TANpZe4tf0FGe4wX?= =?us-ascii?Q?d7BScj7CWEhEnDkKXJo17XzxP1iZs7CHKScvERkshgwN0b377z32xA6Yt7H7?= =?us-ascii?Q?fudIGw6GDrx6nOLk4MQiH2eh1Yfj+4UaPuDzJnVcDEDSX8Y+LDwz1RZZawEN?= =?us-ascii?Q?pPtj8U4PNj+LwLjEtPq3N4QFKdPKKscaRzptPLQRLCp2tZFDWLMY/7WJolaE?= =?us-ascii?Q?MI8SSyTZ5xeeiHGlgRJEFwj8NCblMIfn2iRwKOQAuZFCShbmi+kaKWpa69/i?= =?us-ascii?Q?QnbW+R3hpOvIodn+5G4PeIo7r9NP856o6NF/K+fTEDFpxylWTOxjT1zNsQnm?= =?us-ascii?Q?QwZV2q7/uR6chRJegHwxHNuGAX1TlsGY5b+vcsFj5gfvhlQIXLlfTVRxk2nB?= =?us-ascii?Q?2/cvZxfDckqU8CqcEY/FChBWf5nAt8quQkrzsORqIIgg2mOYqY5mtUqIeiK2?= =?us-ascii?Q?o5GbQqNydkZMzDj+Wlf4kNYXkYZffBq10nVjf0590vzr9/Wgl9o1UYvaO5ap?= =?us-ascii?Q?LYS1vAA8lzxqD4tOTf9LAquuyQivfiWUBAoTLhTmRpz894rRwErKmKj3ob3B?= =?us-ascii?Q?MTporCB6dtiGMK+SQb9DcXRFHxo2SKR4AoCSya/cWVIFiHkERCNIDD3jzTeU?= =?us-ascii?Q?dShobfA15NKhSDyy5msmITDiX1HbZYW2L9sNOnayVgYXwljn4Viq+DIZS12t?= =?us-ascii?Q?zx/RpoyF50bpioPOjFMxR6PB/nt7vceYJnWHV6sccAiC7vWKKmCMoZkcbvnG?= =?us-ascii?Q?4dnT93TpOZPw85FSElYc+HtM1ooLQoDQdzzD/hCL64TCAzx27Q24Mok+UfeL?= =?us-ascii?Q?uuk/MGodOtxFyv8iBgtlyhjbiBjfAgL6EtWi8E+9fNWq29zJ4wuAV/gIcYZV?= =?us-ascii?Q?6rM3eTTF1UeV2G/USHTqPV/xHfgc?= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(36860700004)(376005)(1800799015)(82310400017); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2024 09:10:28.0064 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 535c83ff-2185-424a-f053-08dc7007dea0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF00022573.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7021 Received-SPF: softfail client-ip=2a01:111:f403:2407::601; envelope-from=avihaih@nvidia.com; helo=NAM02-BN1-obe.outbound.protection.outlook.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.582, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=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: 1715245889834100002 Content-Type: text/plain; charset="utf-8" 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 5a359c4c78..14ef9c924e 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -143,6 +143,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