From nobody Tue Feb 10 06:07:45 2026 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651870541; cv=none; d=zohomail.com; s=zohoarc; b=PZnpoA7ocF+7wgBjXJ2M/niBVDEUGJhvdBN7xGHOUeDTlPWDgua1A9X7ps1Wx/BgUxlvSDk9GXprjRC1bOcdSfjaDzigWt5UEjYo/93d852rvCrcEnOWQ5XVb+NCr3AxN/QcFp+MSXJvbTuFyWFYCEa+f1nvPRKAjcKMQaGvDlk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651870541; 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=zS1lsXsoLJY5e0iorj0DJL7ygNnl8UUIdx8c49eSXcY=; b=fPCNDSGBxIjnGKRlNya8xLXdZDwLnGViH4A307ELaUV+bls4n7PhEmfGuoejiHPwalG2Lh34L5st+7X/Auwwpq4PQR9w157DBPmMELNOLSa1+I7nihIZW+Hd/ORSSHKvMkyoNPVxnFp4qLumin+KRS9UiXxutsRiVwAGugYASE8= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651870541857657.5449418573204; Fri, 6 May 2022 13:55:41 -0700 (PDT) Received: from localhost ([::1]:36692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nn4zE-0006sM-9w for importer@patchew.org; Fri, 06 May 2022 16:55:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nn4t3-0004dC-Ao for qemu-devel@nongnu.org; Fri, 06 May 2022 16:49:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59767) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nn4t1-0005vn-8h for qemu-devel@nongnu.org; Fri, 06 May 2022 16:49:17 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-172-LhRp8q8fM2K2nGBY5LmMrw-1; Fri, 06 May 2022 16:49:13 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 43AB1398CA6A; Fri, 6 May 2022 20:49:13 +0000 (UTC) Received: from [172.30.41.16] (unknown [10.2.16.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id E079D14E0B70; Fri, 6 May 2022 20:49:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651870154; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zS1lsXsoLJY5e0iorj0DJL7ygNnl8UUIdx8c49eSXcY=; b=guV8rtfErAzFySFlBoiVF1DsKnaQxgk6dXYwCgei9a4FgKu8LPqDNDB0ySaXf/uZwvSwGR Csq9bCFXaSB1A9dc2/FgQhC+5NI7TfPPt0ADxPYN43bk81c1upoFAVrkcsNqwt0n+/LYj+ cQPr1NifUWHrskiv3HbWNhiQcei4jmI= X-MC-Unique: LhRp8q8fM2K2nGBY5LmMrw-1 Subject: [PULL 10/11] vfio/pci: Use vbasedev local variable in vfio_realize() From: Alex Williamson To: qemu-devel@nongnu.org Cc: Eric Auger , Yi Liu Date: Fri, 06 May 2022 14:49:12 -0600 Message-ID: <165187014792.4166595.9539353046382635608.stgit@omen> In-Reply-To: <165186988363.4166595.3147442303200167674.stgit@omen> References: <165186988363.4166595.3147442303200167674.stgit@omen> User-Agent: StGit/1.0-8-g6af9-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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 client-ip=170.10.133.124; envelope-from=alex.williamson@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651870542273100001 From: Eric Auger Using a VFIODevice handle local variable to improve the code readability. no functional change intended Signed-off-by: Eric Auger Signed-off-by: Yi Liu Link: https://lore.kernel.org/r/20220502094223.36384-3-yi.l.liu@intel.com Signed-off-by: Alex Williamson --- hw/vfio/pci.c | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index cb912bd3f4b2..939dcc3d4a9e 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2846,6 +2846,7 @@ static void vfio_unregister_req_notifier(VFIOPCIDevic= e *vdev) static void vfio_realize(PCIDevice *pdev, Error **errp) { VFIOPCIDevice *vdev =3D VFIO_PCI(pdev); + VFIODevice *vbasedev =3D &vdev->vbasedev; VFIODevice *vbasedev_iter; VFIOGroup *group; char *tmp, *subsys, group_path[PATH_MAX], *group_name; @@ -2856,7 +2857,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) int i, ret; bool is_mdev; =20 - if (!vdev->vbasedev.sysfsdev) { + if (!vbasedev->sysfsdev) { if (!(~vdev->host.domain || ~vdev->host.bus || ~vdev->host.slot || ~vdev->host.function)) { error_setg(errp, "No provided host device"); @@ -2864,24 +2865,24 @@ static void vfio_realize(PCIDevice *pdev, Error **e= rrp) "or -device vfio-pci,sysfsdev=3DPATH_TO_DEVI= CE\n"); return; } - vdev->vbasedev.sysfsdev =3D + vbasedev->sysfsdev =3D g_strdup_printf("/sys/bus/pci/devices/%04x:%02x:%02x.%01x", vdev->host.domain, vdev->host.bus, vdev->host.slot, vdev->host.function); } =20 - if (stat(vdev->vbasedev.sysfsdev, &st) < 0) { + if (stat(vbasedev->sysfsdev, &st) < 0) { error_setg_errno(errp, errno, "no such host device"); - error_prepend(errp, VFIO_MSG_PREFIX, vdev->vbasedev.sysfsdev); + error_prepend(errp, VFIO_MSG_PREFIX, vbasedev->sysfsdev); return; } =20 - vdev->vbasedev.name =3D g_path_get_basename(vdev->vbasedev.sysfsdev); - vdev->vbasedev.ops =3D &vfio_pci_ops; - vdev->vbasedev.type =3D VFIO_DEVICE_TYPE_PCI; - vdev->vbasedev.dev =3D DEVICE(vdev); + vbasedev->name =3D g_path_get_basename(vbasedev->sysfsdev); + vbasedev->ops =3D &vfio_pci_ops; + vbasedev->type =3D VFIO_DEVICE_TYPE_PCI; + vbasedev->dev =3D DEVICE(vdev); =20 - tmp =3D g_strdup_printf("%s/iommu_group", vdev->vbasedev.sysfsdev); + tmp =3D g_strdup_printf("%s/iommu_group", vbasedev->sysfsdev); len =3D readlink(tmp, group_path, sizeof(group_path)); g_free(tmp); =20 @@ -2899,7 +2900,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) goto error; } =20 - trace_vfio_realize(vdev->vbasedev.name, groupid); + trace_vfio_realize(vbasedev->name, groupid); =20 group =3D vfio_get_group(groupid, pci_device_iommu_address_space(pdev)= , errp); if (!group) { @@ -2907,7 +2908,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) } =20 QLIST_FOREACH(vbasedev_iter, &group->device_list, next) { - if (strcmp(vbasedev_iter->name, vdev->vbasedev.name) =3D=3D 0) { + if (strcmp(vbasedev_iter->name, vbasedev->name) =3D=3D 0) { error_setg(errp, "device is already attached"); vfio_put_group(group); goto error; @@ -2920,22 +2921,22 @@ static void vfio_realize(PCIDevice *pdev, Error **e= rrp) * stays in sync with the active working set of the guest driver. Pre= vent * the x-balloon-allowed option unless this is minimally an mdev devic= e. */ - tmp =3D g_strdup_printf("%s/subsystem", vdev->vbasedev.sysfsdev); + tmp =3D g_strdup_printf("%s/subsystem", vbasedev->sysfsdev); subsys =3D realpath(tmp, NULL); g_free(tmp); is_mdev =3D subsys && (strcmp(subsys, "/sys/bus/mdev") =3D=3D 0); free(subsys); =20 - trace_vfio_mdev(vdev->vbasedev.name, is_mdev); + trace_vfio_mdev(vbasedev->name, is_mdev); =20 - if (vdev->vbasedev.ram_block_discard_allowed && !is_mdev) { + if (vbasedev->ram_block_discard_allowed && !is_mdev) { error_setg(errp, "x-balloon-allowed only potentially compatible " "with mdev devices"); vfio_put_group(group); goto error; } =20 - ret =3D vfio_get_device(group, vdev->vbasedev.name, &vdev->vbasedev, e= rrp); + ret =3D vfio_get_device(group, vbasedev->name, vbasedev, errp); if (ret) { vfio_put_group(group); goto error; @@ -2948,7 +2949,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) } =20 /* Get a copy of config space */ - ret =3D pread(vdev->vbasedev.fd, vdev->pdev.config, + ret =3D pread(vbasedev->fd, vdev->pdev.config, MIN(pci_config_size(&vdev->pdev), vdev->config_size), vdev->config_offset); if (ret < (int)MIN(pci_config_size(&vdev->pdev), vdev->config_size)) { @@ -2976,7 +2977,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) goto error; } vfio_add_emulated_word(vdev, PCI_VENDOR_ID, vdev->vendor_id, ~0); - trace_vfio_pci_emulated_vendor_id(vdev->vbasedev.name, vdev->vendo= r_id); + trace_vfio_pci_emulated_vendor_id(vbasedev->name, vdev->vendor_id); } else { vdev->vendor_id =3D pci_get_word(pdev->config + PCI_VENDOR_ID); } @@ -2987,7 +2988,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) goto error; } vfio_add_emulated_word(vdev, PCI_DEVICE_ID, vdev->device_id, ~0); - trace_vfio_pci_emulated_device_id(vdev->vbasedev.name, vdev->devic= e_id); + trace_vfio_pci_emulated_device_id(vbasedev->name, vdev->device_id); } else { vdev->device_id =3D pci_get_word(pdev->config + PCI_DEVICE_ID); } @@ -2999,7 +3000,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) } vfio_add_emulated_word(vdev, PCI_SUBSYSTEM_VENDOR_ID, vdev->sub_vendor_id, ~0); - trace_vfio_pci_emulated_sub_vendor_id(vdev->vbasedev.name, + trace_vfio_pci_emulated_sub_vendor_id(vbasedev->name, vdev->sub_vendor_id); } =20 @@ -3009,7 +3010,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) goto error; } vfio_add_emulated_word(vdev, PCI_SUBSYSTEM_ID, vdev->sub_device_id= , ~0); - trace_vfio_pci_emulated_sub_device_id(vdev->vbasedev.name, + trace_vfio_pci_emulated_sub_device_id(vbasedev->name, vdev->sub_device_id); } =20 @@ -3068,7 +3069,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) goto out_teardown; } =20 - ret =3D vfio_get_dev_region_info(&vdev->vbasedev, + ret =3D vfio_get_dev_region_info(vbasedev, VFIO_REGION_TYPE_PCI_VENDOR_TYPE | PCI_VENDOR_ID_I= NTEL, VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION, &opregion); if (ret) { @@ -3144,9 +3145,9 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) } =20 if (!pdev->failover_pair_id) { - ret =3D vfio_migration_probe(&vdev->vbasedev, errp); + ret =3D vfio_migration_probe(vbasedev, errp); if (ret) { - error_report("%s: Migration disabled", vdev->vbasedev.name); + error_report("%s: Migration disabled", vbasedev->name); } } =20 @@ -3163,7 +3164,7 @@ out_teardown: vfio_teardown_msi(vdev); vfio_bars_exit(vdev); error: - error_prepend(errp, VFIO_MSG_PREFIX, vdev->vbasedev.name); + error_prepend(errp, VFIO_MSG_PREFIX, vbasedev->name); } =20 static void vfio_instance_finalize(Object *obj)