From nobody Mon Sep 16 18:50:56 2024 Delivered-To: importer2@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+importer2=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=1673878422; cv=pass; d=zohomail.com; s=zohoarc; b=j4j2jZd6eCQRfw77T9QcdAWP5E6jqDq+X0rKY9BtvRJimtmNCN+hOvLmH4Xnrs2V+OMGnE9bBPSjtxGIY7Vr2wo89VLFXb4ZuGiuZ6VJC0OE1XPCNDUk05NF/WgaO3uQxbyn1KElnu5Lkur1dMVLGWTW5w3sBoYdoM95q1dyHyg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673878422; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+HKL4e9qjWn47bt8QpXMO38xpZA8acaFd0nAKqvDd68=; b=EZNKREDpKwMJiz5gU+0x63LpJYUXWJ8TkwjXn10MFd2klL70mJwjaQY6+T6wH69sMFn4YL5ELZRH6Dt08xJu+k+vX2w6UD4WtFy1FPjVc8Qd+7oaNVl645D70AE8uWF+bgfzCkszZco0WuSF+vSO+2sQDtZPaq9FkcRYjFVr+qo= 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+importer2=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 1673878422549330.4780318890296; Mon, 16 Jan 2023 06:13:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHQEK-0002kc-JB; Mon, 16 Jan 2023 09:12:56 -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 1pHQEH-0002hI-1C; Mon, 16 Jan 2023 09:12:53 -0500 Received: from mail-bn7nam10on2057.outbound.protection.outlook.com ([40.107.92.57] helo=NAM10-BN7-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 1pHQEF-0002Qa-6d; Mon, 16 Jan 2023 09:12:52 -0500 Received: from DM6PR07CA0047.namprd07.prod.outlook.com (2603:10b6:5:74::24) by DS0PR12MB6464.namprd12.prod.outlook.com (2603:10b6:8:c4::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Mon, 16 Jan 2023 14:12:47 +0000 Received: from DM6NAM11FT092.eop-nam11.prod.protection.outlook.com (2603:10b6:5:74:cafe::16) by DM6PR07CA0047.outlook.office365.com (2603:10b6:5:74::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.19 via Frontend Transport; Mon, 16 Jan 2023 14:12:47 +0000 Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT092.mail.protection.outlook.com (10.13.173.44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Mon, 16 Jan 2023 14:12:47 +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.986.36; Mon, 16 Jan 2023 06:12:35 -0800 Received: from rnnvmail201.nvidia.com (10.129.68.8) 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.986.36; Mon, 16 Jan 2023 06:12:34 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Mon, 16 Jan 2023 06:12:28 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VJY7wwUELBA+7f2Z0x6YjkSTRzsmAW3Jes2JpNnMFxtoMvSjZ1RZKvp3YjRS3e45vLwWqyVQCQtq55G97LrzvWphQZvw1VPXbNp0nQnfO6uK43FOC+1s/M46rWtXQ6Vrk1UC3lgzBVOSALUlgS4y9kbv5HG/XHn1DI+0vhLB9FUYIkDAkvlVlv+OzgVy1rF5+ZrjS3aw55lPjaUmB7JKVtU1btV4n2pBYUn86QaxoGp72D5QyVAyOlqOPHNH8/9y4+D8Uo60snOFd95Q0CsSR/77DfZK3rUCyUisjlqwdmOb/0KRN51cjpeb60Y0pYjlNQrQaNWSbn5VCf/eeW9ANQ== 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=+HKL4e9qjWn47bt8QpXMO38xpZA8acaFd0nAKqvDd68=; b=Wt6YUxqyuiRvHB46Ij9RuVgj0QjgybCtVjkfZmGlLC2Gq5jBYjuV0d7sswmfNa9alV5cwnae86KJppXT9/YW52PrVOKoTUBf9qldu99SRo6okjG4i2+yS2KTK8F2WaVLfVNXpZCzSWiiekDuwPE12dO+9MNTkkMniThzPDLK8wPfply2qc/wIRMDlU1kc3ckkZxNaIn2DYyM3aRao3mBe0kpO2pjMnKLlIuob6esr329Yjsm3HAh9A00KBL8Km2KuWW6t1p8BxoZujON7Unla0JpGIi0X+4uMMMQ+KJf9Dgw5cSPTM+PAZB1kpl/BvBGPPdTX2kEb8Bdawn5p550Ew== 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 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=+HKL4e9qjWn47bt8QpXMO38xpZA8acaFd0nAKqvDd68=; b=iOVQPm2X/1wv+ZNobCgPO5TiMrxqJKjLcLdCzTc5yVn8fh4Cs0gsj1bHpr/Bb6NcLNv9Oz/MZ/YUeBxjINCGToXuW8FU6HbGJMSKpIZRNC4GIZzXa26wc603nwKp3TmOFqhEi9nEE0uFmuQbiDsCNV9BnQjK9Kya3EYNuf9+2gL5tJTmoxU4aoiNL9iKq4JQ33zydpeAzr0Glz4xm51CvQ2N1TfiMqlGkBqN8G/Y5YB0PT/fqh80qxM550TVy92dY6w5GVlxg15F+Vu2J4x77bUwhBZ4Lsc6wQJAWApCSrX1UwIxXYNaNP8g+LiIrQ5hiWGJr1iJSmNTOEA7CBtJZw== 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+importer2=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 , 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 , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , , , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v8 07/13] vfio/migration: Move migration v1 logic to vfio_migration_init() Date: Mon, 16 Jan 2023 16:11:29 +0200 Message-ID: <20230116141135.12021-8-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230116141135.12021-1-avihaih@nvidia.com> References: <20230116141135.12021-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT092:EE_|DS0PR12MB6464:EE_ X-MS-Office365-Filtering-Correlation-Id: 3df364f7-75c1-44a0-59b7-08daf7cbbeb0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cqgtgDQzlIeZ4j983hlELLBJSkskRJJ6WHHo7WBDQA6NOCIJotGIkMjPuGv5Er/9fjUCGbLQRUUqUwHT6gxQ4YpJQlbGo/pILJ/r0+DvlrawouUV2C9YUV3HD7AQZMs5DLntwoxu3Zv7Z3+AwnwdPdv7NOtxG9Ngg5ydQyRLV4XGvnExwwTxtZGBW9uazcmQcF32tx0q5dFtXV1lMLfIY/g+IH/OwKVcNHoYcsbrl7uvRcMAzsL/iGOp6j8+lxHYl2upn4x8tFCkhkv2doUvCOiQGNIPiPsW/Uvh+j4TbaXLkZ+paYj9wJnnmRLA9Pkp8NTJ9ZE2sI4ZwhG7IIycDZTif9nyhcfGDHywDShXwCaQuEFgmM9eardwLYiTIlRMCAx9o6aS/XJdHSbEQkx9SbVjRY/bzRmt2j84t4A07YdtbAeBcGPaM8FJxbc2lCm2JGg0ppCMTPhOwM2y+4ej9YqM0T9s7uFAfvMwWaBIg3qnkXr5Pd/fSDhTxOD3n8Iw2RFLh6k60EVdR8okTbN4k4iyGv3PcBg/31oiNuWfihUPBPLl5N2E8QuujW9azbGGODV6KYVCUv3Zh0uiIZpo4tnuPAquooXgsxYOGariZ/YuyC6xN77E12Gewflc22Dw3m5dtqp94uZwUHnIVBIpiXMGtehsDBuiewxvVx7Bna7MdaEZlu0QlamDsmUXOMjFcA4JW7tYIewv4SyUsba0Fg== 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:(13230022)(4636009)(136003)(346002)(39860400002)(376002)(396003)(451199015)(36840700001)(40470700004)(46966006)(70206006)(82310400005)(2906002)(7416002)(5660300002)(36756003)(2616005)(70586007)(8676002)(1076003)(4326008)(54906003)(316002)(41300700001)(40480700001)(478600001)(66574015)(26005)(8936002)(336012)(186003)(6916009)(426003)(7696005)(86362001)(83380400001)(36860700001)(47076005)(356005)(7636003)(40460700003)(82740400003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2023 14:12:47.4434 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3df364f7-75c1-44a0-59b7-08daf7cbbeb0 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: DM6NAM11FT092.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6464 Received-SPF: softfail client-ip=40.107.92.57; envelope-from=avihaih@nvidia.com; helo=NAM10-BN7-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, 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: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1673878425724100001 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=C3=A9dric 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 552c2313b2..977da64411 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -788,14 +788,14 @@ static void vfio_migration_exit(VFIODevice *vbasedev) vbasedev->migration =3D NULL; } =20 -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] =3D ""; g_autofree char *path =3D NULL, *oid =3D NULL; + struct vfio_region_info *info; =20 if (!vbasedev->ops->vfio_get_object) { return -EINVAL; @@ -806,6 +806,14 @@ static int vfio_migration_init(VFIODevice *vbasedev, return -EINVAL; } =20 + ret =3D vfio_get_dev_region_info(vbasedev, + VFIO_REGION_TYPE_MIGRATION_DEPRECATED, + VFIO_REGION_SUBTYPE_MIGRATION_DEPRECATE= D, + &info); + if (ret) { + return ret; + } + vbasedev->migration =3D g_new0(VFIOMigration, 1); vbasedev->migration->device_state =3D VFIO_DEVICE_STATE_V1_RUNNING; vbasedev->migration->vm_running =3D runstate_is_running(); @@ -825,6 +833,8 @@ static int vfio_migration_init(VFIODevice *vbasedev, goto err; } =20 + g_free(info); + migration =3D vbasedev->migration; migration->vbasedev =3D vbasedev; =20 @@ -847,6 +857,7 @@ static int vfio_migration_init(VFIODevice *vbasedev, return 0; =20 err: + g_free(info); vfio_migration_exit(vbasedev); return ret; } @@ -860,34 +871,23 @@ int64_t vfio_mig_bytes_transferred(void) =20 int vfio_migration_probe(VFIODevice *vbasedev, Error **errp) { - struct vfio_region_info *info =3D NULL; int ret =3D -ENOTSUP; =20 if (!vbasedev->enable_migration) { goto add_blocker; } =20 - ret =3D vfio_get_dev_region_info(vbasedev, - VFIO_REGION_TYPE_MIGRATION_DEPRECATED, - VFIO_REGION_SUBTYPE_MIGRATION_DEPRECATE= D, - &info); - if (ret) { - goto add_blocker; - } - - ret =3D vfio_migration_init(vbasedev, info); + ret =3D vfio_migration_init(vbasedev); if (ret) { goto add_blocker; } =20 - trace_vfio_migration_probe(vbasedev->name, info->index); - g_free(info); + trace_vfio_migration_probe(vbasedev->name); return 0; =20 add_blocker: error_setg(&vbasedev->migration_blocker, "VFIO device doesn't support migration"); - g_free(info); =20 ret =3D migrate_add_blocker(vbasedev->migration_blocker, errp); if (ret < 0) { diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 73dffe9e00..b259dcc644 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) "" =20 # 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, uin= t32_t dev_state) " (%s) running %d reason %s device state %d" vfio_migration_state_notifier(const char *name, const char *state) " (%s) = state %s" --=20 2.26.3