From mboxrd@z Thu Jan 1 00:00:00 1970 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 B0E74C43219 for ; Thu, 3 Nov 2022 16:22:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oqcwb-0004bb-VX; Thu, 03 Nov 2022 12:19:54 -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 1oqcun-0000vr-SO; Thu, 03 Nov 2022 12:18:04 -0400 Received: from mail-bn1nam07on2040.outbound.protection.outlook.com ([40.107.212.40] 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 1oqcuk-00089U-PZ; Thu, 03 Nov 2022 12:18:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mGboQ+GP6ZoPVW2RDkDcG4+2FB0tbtkQcfmRi9ShrajyapYHqwBUPdQDEkKd/sNPhJjbNgqvinjIp8CN9R3Vkf5ikHJUAITMGvhADxeXfhljw16g8kcj6gRmhxG9nz2z7Ui9ScXxzhuKbu4QIC6uJRMndiosWqV9eUJcQywN2Q9kmLor7ma0PV+NkGku2xTWPc9R8rLRwpb/kk69odAnMARofWf9WLv3vZkgDiHvc9SzTjaDZuMXjlt0uadGfxHwSnoOjCUuyzyPNvvMFpM9aDtiXNAI2PW4Ugaj125HbKuMbYE4dR2IN8hIYfbtzjiosqmi1YAQ/O03OOBeEaUE2g== 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=bcyCzUTe4XhO9Hun42CZqHXJkbhMwsSgb0e/nr2mE3k=; b=glpYw59bTw2B1Rx2aT5wPtxuMtNoQg9UDiHFSEGmdrzd0smW0S/EY4BZMphAx6bwd7XcHYQcQV7wJwaF68MqkoXXboCKfibW6cD53CAjJwxQup6BtGe1jQHF0Js+ITmrRpEwFSj3/BdvumpAgzRvncZqAFWc5okxuREU2qs1yrdGvhqVP6Grhkh+Xd8DBuavUFnDPcENvx7CjWT6NLF7Bc5MKu/dU2j551DJaZT3UzTAZuuJxXdUv5Rf9JqaniBxH6mRJRsMo5BoboN0rqHv65vMGk6r/qzBDWuEWDtqjF7yreps6afYxkTGkDDjpDUpmZvPSIn0Y6GBNaFa75ZbNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bcyCzUTe4XhO9Hun42CZqHXJkbhMwsSgb0e/nr2mE3k=; b=b97wVkQtlEgetg7krEZ+pr4RCCx2qcqggXHMaG2FIkXrYwZbyw1HXJjJ7PtdYP5jLBjJExMunw0p8Y8dOCQDLZSW8bVUYvj7LMTMY6Ixy1O4t9K5SkdGcl3C3Ys+7Lwyc2n93t9JSQweuF7658V7bBwdPzDs+lAh7GnJbQbINJ9UgKxNJlHnW+CVuIqih+rs23f+DzqyulwpFv3nbaBRull9jNpO6MUfgWTQkRA9ui8nkUQhNgtc/zsx6vrV6zvuVuZcv07VB5bvwfjPXJPSQiPnyDx8ZmyEeEBOoxevz4lbg6yA+Gm+CgpDieNwWh++frBNoOuHZN4DbXo4B/kLtw== Received: from MW4PR04CA0150.namprd04.prod.outlook.com (2603:10b6:303:84::35) by PH8PR12MB7109.namprd12.prod.outlook.com (2603:10b6:510:22f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.16; Thu, 3 Nov 2022 16:17:53 +0000 Received: from CO1NAM11FT011.eop-nam11.prod.protection.outlook.com (2603:10b6:303:84:cafe::81) by MW4PR04CA0150.outlook.office365.com (2603:10b6:303:84::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.21 via Frontend Transport; Thu, 3 Nov 2022 16:17:53 +0000 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 (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 Received: from mail.nvidia.com (216.228.118.233) by CO1NAM11FT011.mail.protection.outlook.com (10.13.175.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.20 via Frontend Transport; Thu, 3 Nov 2022 16:17:53 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Thu, 3 Nov 2022 09:17:46 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Thu, 3 Nov 2022 09:17:45 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.29 via Frontend Transport; Thu, 3 Nov 2022 09:17:38 -0700 From: Avihai Horon To: CC: Alex Williamson , Halil Pasic , Christian Borntraeger , Eric Farman , Richard Henderson , David Hildenbrand , "Ilya Leoshkevich" , Thomas Huth , "Juan Quintela" , "Dr. David Alan Gilbert" , "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Stefan Hajnoczi , Fam Zheng , Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , , , Kunkun Jiang , "Zhang, Chen" , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Shay Drory , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v3 10/17] vfio/migration: Move migration v1 logic to vfio_migration_init() Date: Thu, 3 Nov 2022 18:16:13 +0200 Message-ID: <20221103161620.13120-11-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20221103161620.13120-1-avihaih@nvidia.com> References: <20221103161620.13120-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT011:EE_|PH8PR12MB7109:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e9d69ca-5d3f-4e2a-de89-08dabdb6f5cd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: faqFH/Hrc158Pt1JxWCLAQO6mri0c7c16rnx3EqkAlLXREHALWrlCtLGrSadBkqplgByZ1C5tN3djaUL+SI7Yjc1dFttSpWhai3EEORhvibZYISLc2odv91INRzC/oeLAHxODtXq3ckxpXhzbgWnm0NC/n2+sxedYzVGmzJ5cSkWM7s5t3hi8ghW6+a8vRayOWe3Ac1UvxTQIOauuhEMo8/nr5nexlUvVlBcV4PWeSoEOuL6KFE4rbQHbCXO8U8BpxeO6JFNWs95v3LwdDh+02hwDYRj3vWTerA88jj9HyXARllXKwScn1d6Jyo6/hUDfz1rFUpZhn3BmzhSg3ZzOL0wRLagL1Ysda5ldkqQDPDahK/Q+Wi4/+Q+u3tYJzFirLER6dO+c7cOTB9d9gzrIgeNyK4nno0FrrQ8e2aCYRvpFgLrJV0lvWjpFaQnOWzASoFbUxXDitExaeohcfqhttSVx/AHdIfwVvxcSvVA0fYuHw/6PYQ407lilthP29HVUYxKPsxYpblBtr4LKroA0fd+2cZQZCAH6KPcQ+IGtnXeDCiO7ORFSd5tL6W8vNxz9jA/eT+7jmCrPAFz7o1BovzTkgJ0q8zEa0B/prDCVV81O3Qgaaapp7cdq7+dYLO/9/17pG/dBnVyE2nOHKhqwm/lY7vPn4AWyN0GrUKKNiPqWzRyUy0916GlSuucAmTDqXsNbHy+RBIvPaywqUGzXcw/UeolU0AzOHnb71dRYabvxT0zOj3hdXvwyY9nmMfmM0v7E7TTRZTYp9eyLhw2zA== 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:(13230022)(4636009)(396003)(136003)(376002)(346002)(39860400002)(451199015)(36840700001)(40470700004)(46966006)(2906002)(336012)(83380400001)(86362001)(8676002)(36756003)(7696005)(40460700003)(4326008)(41300700001)(26005)(7636003)(82310400005)(54906003)(6666004)(82740400003)(36860700001)(6916009)(186003)(426003)(70206006)(47076005)(356005)(5660300002)(7416002)(70586007)(316002)(8936002)(2616005)(478600001)(40480700001)(1076003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2022 16:17:53.0860 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8e9d69ca-5d3f-4e2a-de89-08dabdb6f5cd 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: CO1NAM11FT011.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7109 Received-SPF: softfail client-ip=40.107.212.40; envelope-from=avihaih@nvidia.com; helo=NAM02-BN1-obe.outbound.protection.outlook.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.047, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Sender: "Qemu-devel" Errors-To: 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 --- 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 99ffb75782..0e3a950746 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -785,14 +785,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 = NULL; if (!vbasedev->ops->vfio_get_object) { return -EINVAL; @@ -803,6 +803,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(); @@ -822,6 +830,8 @@ static int vfio_migration_init(VFIODevice *vbasedev, goto err; } + g_free(info); + migration = vbasedev->migration; migration->vbasedev = vbasedev; @@ -844,6 +854,7 @@ static int vfio_migration_init(VFIODevice *vbasedev, return 0; err: + g_free(info); vfio_migration_exit(vbasedev); return ret; } @@ -857,34 +868,23 @@ 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); + ret = vfio_migration_init(vbasedev); if (ret) { goto add_blocker; } - ret = vfio_migration_init(vbasedev, info); - if (ret) { - goto add_blocker; - } - - 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 a21cbd2a56..27c059f96e 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" -- 2.21.3