From patchwork Mon Feb 6 12:31:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13129802 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 4384BC61DA4 for ; Mon, 6 Feb 2023 12:33:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pP0gH-0004fo-P9; Mon, 06 Feb 2023 07:33:09 -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 1pP0gF-0004TR-Lg; Mon, 06 Feb 2023 07:33:07 -0500 Received: from mail-dm6nam10on2062f.outbound.protection.outlook.com ([2a01:111:f400:7e88::62f] helo=NAM10-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 1pP0gC-0000aA-TO; Mon, 06 Feb 2023 07:33:07 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eofGbFbIrDphl4y21Sj+BugQq1W3I1gFxeu3j9zXQ24peUYRB8q3wyrBeOxOTsrM1TUbc0hO2GdQYerTMP+YvsdxKw+4w1Wrqz8lrViuxh0eUwEJrYUkBuyodNjrxOYE9wBAm1IYysDuvOJPU0GyOWrjk/lZbzRpZITyRbDw2QLvOu6H3yFiF0Kr9VY1lzno/lSH3/L5RWbfggCjRyloxpKhZyoh08MI/NFTkJim5Kd0zA5WcGPcqRM8CRWyu8V+0xeQ9CZ/Giac+ca+6CjkJTXOsiHFWUFn+iFMNutgae5WJMnnCA1h68M6LPP/nHvWF5gY48e2cHW6oLkBagDNwg== 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=ayqNT0fvE0eEMB7XqW9sOtF0qJNnTJnzrJE2c6uNQRo=; b=gw30PmbeADqh1/OD+oy23gPMdUgH4Mexyc5N0Kqlsc1VgQpWNETze3aIE5NhM5RhNp67X7cJMqoyhyHLNpxYTiktlO/cifY9sfv3fYOhOg1C3ahEPxvRhTsKN21F7tssFriziZs3b+qdsAfDHFyqgXsUDKDUh6hHbucnycRmyyed6SEbzHw7kerEKQifsIdQsq+dYdgHxnD149jBThLgyY6bpolmZ5DVF6TpwTZGaU+FzSXIOh4YVTlbiWYHSs5RfJypQsqVYGASEkunk/ajLlgAaAQffIrC0jvRTA42yvXaOlbcP+WVibyULfVczN60buOgXhy3rcXcjbMAayI2tg== 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 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=ayqNT0fvE0eEMB7XqW9sOtF0qJNnTJnzrJE2c6uNQRo=; b=A0Z4zRcRReafZH335r6k9V7Th72Wvm1fy8c9melpB0/3XDUidHNu3FBsm66sNn8VL0fItMzXSUQVvvANwJgRJGjetbeyMw7lKeE27rSR98m9dDMvwW2er8d+bBckTANZRtGPkQDCyAGAZ7pC1gyCjyeHY/4fW3WsklfK85LNICdX0jnCacHyHJ2GnybmCmKJydVs5p4FCx4DM+GglZbpj/P1SoTmSbSXu5er+IpdK0XHModZcQZVMq04l+SDeI/ZyG3/z6pRk+dquMlxYirgnrEYQpwHz17mqxnKkK0bk73v55irwRyOvitKJKEk2oN5qi/R8OEJTDwgE3qmjK1gyw== Received: from DM6PR07CA0038.namprd07.prod.outlook.com (2603:10b6:5:74::15) by BL1PR12MB5876.namprd12.prod.outlook.com (2603:10b6:208:398::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.29; Mon, 6 Feb 2023 12:32:59 +0000 Received: from DM6NAM11FT105.eop-nam11.prod.protection.outlook.com (2603:10b6:5:74:cafe::26) by DM6PR07CA0038.outlook.office365.com (2603:10b6:5:74::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Mon, 6 Feb 2023 12:32:59 +0000 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 (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 Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT105.mail.protection.outlook.com (10.13.173.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32 via Frontend Transport; Mon, 6 Feb 2023 12:32:59 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) 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.986.36; Mon, 6 Feb 2023 04:32:48 -0800 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 04:32:48 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Mon, 6 Feb 2023 04:32:40 -0800 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_Le_Goater?= , , , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v9 08/14] vfio/migration: Move migration v1 logic to vfio_migration_init() Date: Mon, 6 Feb 2023 14:31:31 +0200 Message-ID: <20230206123137.31149-9-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230206123137.31149-1-avihaih@nvidia.com> References: <20230206123137.31149-1-avihaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT105:EE_|BL1PR12MB5876:EE_ X-MS-Office365-Filtering-Correlation-Id: 5a8fc369-417b-4162-f48e-08db083e4812 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MwXWf0W9BuV9A9aDX0iCQxKZjWQVzcQj8yfIdTQq+dkko82HX4p17TiveEZUWgo3xM/nPRl8lb1NrMScdSgutS27CcPQE+5GXNAtlJPDce5T/4id9uA+20ijMSVr2VxCRVzRF/napppAwtXltsilVscoUVIiZtWIC6LpPU5CSCZnSpKl+xXeYzsgNVoW6vW1xeP+n44venCwQslCOlrhCGkprJRN36Ince8mxqsY3OfBlpWWSkApJaaM/DN/CATL855e8pdZ658rbkoakeNk0gTAulVacdlntYBCoBlfCuzz+fVhKCa1PhqP+grAjS+6p5tcEQApfqzD23C0UI6F/qfjbkefkZYO+7X/a5UjTpHV5Zkuvp/h91IZd5XHLERLKG+jpEsDz5msklARZNdKvRMJcf9WJVw6QZzKn3L18GJ5hb7Bk6nXu07ZthPTR/IqGog9i7VnFvJRLJTsSpWt+Zxtm9xpK9yJV7Xo5U6bTUGWZwMbIDyk0NOjL2HA6Y4yUHLt+kuIxIjtdEexjRPoQ8Td2kAUNV4ZX3K3dgi+UWVQwj/s2L7frBUMSfLcG9Jih3fXBEemISJKKOnZHdQPxFhUcW4YUb+caw7UPIQnB0REWKitZ6spf2WsnLIxK1JmGvbKpXVrdSquywiRIqz9/sj1juk4m9ZplY7L7zTvZmX/5xk7wJYqIUzCcaPNckzbkkiWx840p+VKdKCkojtqjA== 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:(13230025)(4636009)(376002)(346002)(396003)(39860400002)(136003)(451199018)(40470700004)(36840700001)(46966006)(336012)(4326008)(6916009)(2616005)(66574015)(478600001)(7416002)(70586007)(70206006)(83380400001)(426003)(2906002)(186003)(40460700003)(40480700001)(26005)(5660300002)(36756003)(8936002)(41300700001)(7696005)(356005)(82740400003)(7636003)(86362001)(54906003)(47076005)(6666004)(316002)(8676002)(1076003)(82310400005)(36860700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 12:32:59.1534 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5a8fc369-417b-4162-f48e-08db083e4812 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: DM6NAM11FT105.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5876 Received-SPF: softfail client-ip=2a01:111:f400:7e88::62f; envelope-from=avihaih@nvidia.com; helo=NAM10-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 8085a4ff44..55b43d24f6 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -788,14 +788,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; @@ -806,6 +806,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(); @@ -825,6 +833,8 @@ static int vfio_migration_init(VFIODevice *vbasedev, goto err; } + g_free(info); + migration = vbasedev->migration; migration->vbasedev = vbasedev; @@ -847,6 +857,7 @@ static int vfio_migration_init(VFIODevice *vbasedev, return 0; err: + g_free(info); vfio_migration_exit(vbasedev); return ret; } @@ -860,22 +871,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; } @@ -885,14 +887,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 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) "" # 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"