From patchwork Thu Feb 9 19:20:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13135002 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 36422C636D3 for ; Thu, 9 Feb 2023 19:24:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQCUK-0004Jl-Ca; Thu, 09 Feb 2023 14:21:44 -0500 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 1pQCUI-0004J6-A3 for qemu-devel@nongnu.org; Thu, 09 Feb 2023 14:21:42 -0500 Received: from mail-dm6nam11on20631.outbound.protection.outlook.com ([2a01:111:f400:7eaa::631] 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 1pQCUF-0005VY-6Q for qemu-devel@nongnu.org; Thu, 09 Feb 2023 14:21:42 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UWvfQQ+etvIwK1WMpJWSKEBPEUeRK3N2MPhwwl897fqgHHncVRxtA6EzavszFY2+10iJeXJltUeqAe2wSJ/qvOoJhonMVR9fuxVnlejt6h02SWr2XobWnMRHqnu/hzVvp83DgmgdvGaaWWad7r+oUy06beVtiPR0L6sd51yXNmuFI/IWW1zsBrFRp1kj0HfTUL4Qv54MgHpoly9K2Ct96R0l3z+JbDIWJqFjiYhZWMgZF0i3WuzjQsNKNoeqM13TgS70Ex7Els2+tVfPJ1zdoucrh4DK2WvS81HmkSgIIDrWm6veuGcZYP0S/EigEvTZo9yvIpcLZ1/fzzW20hutMA== 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=nz993PSvdRIFg4eQdv70qzKwZWfhajud32Wmyakv3d0=; b=AagiU8N8/6bvT6/cptdXZmgo6QpnmR9zm27ekNhnDFpxOIq6d19MuPQAkXrduIVgWpFvHOsh0AjhVFmD0OD7C326R/+FVyYzmrFRXnQ+kJ2WyAqmh7usCCvoXGqYA/ua1jJW1y4Z6V6rOreBhBRaXOl65SJbp5ixFrljTj4dBuXrMBT6GA7cTbETCXv9r7KWQu+Vg3WICIaoTqQnRAmb8hQVBazb6i7lsFk0x6lqW7CAU+IMaAWNg2Qz2sThIeM/WX02nC7aqV9cuMG2Yxe6ZbaMbXYa7YNv8CfVompHW/DaBT32HLvi+pYnVXQICh+27hijUZcrnCeUnd1XbiDkeg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nz993PSvdRIFg4eQdv70qzKwZWfhajud32Wmyakv3d0=; b=gm/z8qRo6MnuSpIV1g6S5MmnEFordHu0D5HkPKKhCrd+3WkB/5Of5D5JQFCL5VVeA61Kw7xlFQ56l4yd21u/05dJV7Nxik468zllNwKiBdmL51jw3PX2+1nVTIsZSPdRvD6KYtahXKs0wvireVory6b7moOqR397mDJaqNW6pBgsc+fFc6C3u+FXsVa3wk4Zvxx539FIuO3q+jFBreaZ6TZfwbbaTHZNXJFFGFrOuE1D3NQ5R45dB217CBUGti+MJWDKWcynipaFmiSWGwAhtKFBOpjq06sVrquOh1R8Er02TskpedGNeGDeMYsZ0cFffiNXLPBqn/sNNsJ4OpvVEQ== Received: from BN9PR03CA0267.namprd03.prod.outlook.com (2603:10b6:408:ff::32) by BL1PR12MB5730.namprd12.prod.outlook.com (2603:10b6:208:385::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.35; Thu, 9 Feb 2023 19:21:35 +0000 Received: from BN8NAM11FT017.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ff:cafe::9e) by BN9PR03CA0267.outlook.office365.com (2603:10b6:408:ff::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.19 via Frontend Transport; Thu, 9 Feb 2023 19:21:35 +0000 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 (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 Received: from mail.nvidia.com (216.228.118.232) by BN8NAM11FT017.mail.protection.outlook.com (10.13.177.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.19 via Frontend Transport; Thu, 9 Feb 2023 19:21:35 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 9 Feb 2023 11:21:18 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 9 Feb 2023 11:21:17 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Thu, 9 Feb 2023 11:21:13 -0800 From: Avihai Horon To: CC: Alex Williamson , Juan Quintela , "Dr. David Alan Gilbert" , "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Vladimir Sementsov-Ogievskiy , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v10 07/12] vfio/migration: Move migration v1 logic to vfio_migration_init() Date: Thu, 9 Feb 2023 21:20:38 +0200 Message-ID: <20230209192043.14885-8-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230209192043.14885-1-avihaih@nvidia.com> References: <20230209192043.14885-1-avihaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT017:EE_|BL1PR12MB5730:EE_ X-MS-Office365-Filtering-Correlation-Id: 286a2443-0acf-414e-385e-08db0ad2dc56 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hpUKNayXIZrwj/LBVhvDOracqTNsyEBIfFNNyF9iA5NQiVTkzKZ/cRHcEblVCvG9hrZt1sXqcREY9dr+MQos1rf3BjOHHiwBgtBq4U2a0ErUFpROIw26RjMvbmREaVciwgqqmqe04oxPWNv5M+JZSQVSClHJPxeyoTxpgoe9jmBQqrrsiXuu6FYQcFiZXRjWodAWl8BvxaKxOKkxotB6cJBASi264c5SByclCEeqkLgxYhcNplIxI9BfE0a7cnS0MskW5pjjR4wGzoxOfJT0oljA8tvi9CuySQqMND5PNSBS/dsMYMHTAbxGU1DGhy1Lnlk5xfbQyJTP0bpTX/6Thn9ViKkDKljGthLq0Z0PqXN1ol8qN5iR1PyMKXqixQSFGJYohxaEWmy3u/Wa7Q0c15IjnDvTyPnboHj+sjnqIEb2goIGVhsEV6UzxeCGm8YLBBFab7L7mQEO5ZsynVMrfSCemsPQDxiWvswEE+rnXdy74sanBcuVY6jwZzRo6nlRKHrZNDdfJEDX/2ORPJIMLwg9YVqNsoe6J9Vcvhx9oOkApQFtv64caRE0ZisTQNm+WI1D8nDZyFoAD1GtCQ382TvqhVD4xH6XjJoqrbF65j6FXPm9WhxlDd8jqcBS7+TyZPgMKVZ8n/oPZftaV0l2achMmXc7ViDVXz7LBTwv6+13rSx5ulDQWtmfzULy816JuQYT0z4nTKPzDhZx0UIxVw== 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:(13230025)(4636009)(376002)(346002)(136003)(39860400002)(396003)(451199018)(36840700001)(40470700004)(46966006)(82310400005)(83380400001)(66574015)(426003)(36756003)(47076005)(5660300002)(2906002)(7416002)(7696005)(186003)(41300700001)(40460700003)(8936002)(26005)(6666004)(316002)(478600001)(86362001)(70586007)(7636003)(82740400003)(2616005)(6916009)(1076003)(40480700001)(336012)(356005)(70206006)(54906003)(4326008)(8676002)(36860700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 19:21:35.7230 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 286a2443-0acf-414e-385e-08db0ad2dc56 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: BN8NAM11FT017.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5730 Received-SPF: softfail client-ip=2a01:111:f400:7eaa::631; envelope-from=avihaih@nvidia.com; helo=NAM11-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Move vfio_dev_get_region_info() logic from vfio_migration_probe() to vfio_migration_init(). This logic is specific to v1 protocol and moving it will make it easier to add the v2 protocol implementation later. No functional changes intended. Signed-off-by: Avihai Horon Reviewed-by: Cédric Le Goater --- hw/vfio/migration.c | 30 +++++++++++++++--------------- hw/vfio/trace-events | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 5dafa0a558..ca64551cc9 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -789,14 +789,14 @@ static void vfio_migration_exit(VFIODevice *vbasedev) vbasedev->migration = NULL; } -static int vfio_migration_init(VFIODevice *vbasedev, - struct vfio_region_info *info) +static int vfio_migration_init(VFIODevice *vbasedev) { int ret; Object *obj; VFIOMigration *migration; char id[256] = ""; g_autofree char *path = NULL, *oid = NULL; + struct vfio_region_info *info; if (!vbasedev->ops->vfio_get_object) { return -EINVAL; @@ -807,6 +807,14 @@ static int vfio_migration_init(VFIODevice *vbasedev, return -EINVAL; } + ret = vfio_get_dev_region_info(vbasedev, + VFIO_REGION_TYPE_MIGRATION_DEPRECATED, + VFIO_REGION_SUBTYPE_MIGRATION_DEPRECATED, + &info); + if (ret) { + return ret; + } + vbasedev->migration = g_new0(VFIOMigration, 1); vbasedev->migration->device_state = VFIO_DEVICE_STATE_V1_RUNNING; vbasedev->migration->vm_running = runstate_is_running(); @@ -826,6 +834,8 @@ static int vfio_migration_init(VFIODevice *vbasedev, goto err; } + g_free(info); + migration = vbasedev->migration; migration->vbasedev = vbasedev; @@ -848,6 +858,7 @@ static int vfio_migration_init(VFIODevice *vbasedev, return 0; err: + g_free(info); vfio_migration_exit(vbasedev); return ret; } @@ -861,22 +872,13 @@ int64_t vfio_mig_bytes_transferred(void) int vfio_migration_probe(VFIODevice *vbasedev, Error **errp) { - struct vfio_region_info *info = NULL; int ret = -ENOTSUP; if (!vbasedev->enable_migration) { goto add_blocker; } - ret = vfio_get_dev_region_info(vbasedev, - VFIO_REGION_TYPE_MIGRATION_DEPRECATED, - VFIO_REGION_SUBTYPE_MIGRATION_DEPRECATED, - &info); - if (ret) { - goto add_blocker; - } - - ret = vfio_migration_init(vbasedev, info); + ret = vfio_migration_init(vbasedev); if (ret) { goto add_blocker; } @@ -886,14 +888,12 @@ int vfio_migration_probe(VFIODevice *vbasedev, Error **errp) return ret; } - trace_vfio_migration_probe(vbasedev->name, info->index); - g_free(info); + trace_vfio_migration_probe(vbasedev->name); return 0; add_blocker: error_setg(&vbasedev->migration_blocker, "VFIO device doesn't support migration"); - g_free(info); ret = migrate_add_blocker(vbasedev->migration_blocker, errp); if (ret < 0) { diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 52de1c84f8..8badd76034 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -148,7 +148,7 @@ vfio_display_edid_update(uint32_t prefx, uint32_t prefy) "%ux%u" vfio_display_edid_write_error(void) "" # migration.c -vfio_migration_probe(const char *name, uint32_t index) " (%s) Region %d" +vfio_migration_probe(const char *name) " (%s)" vfio_migration_set_state(const char *name, uint32_t state) " (%s) state %d" vfio_vmstate_change(const char *name, int running, const char *reason, uint32_t dev_state) " (%s) running %d reason %s device state %d" vfio_migration_state_notifier(const char *name, const char *state) " (%s) state %s"