All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org>
To: kvm@vger.kernel.org
Cc: Suzuki K Poulose <Suzuki.Poulose@arm.com>,
	Steven Price <steven.price@arm.com>,
	Will Deacon <will@kernel.org>,
	Julien Thierry <julien.thierry.kdev@gmail.com>,
	"Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org>
Subject: [RFC PATCH kvmtool 02/10] vfio: Rename some functions
Date: Sun, 25 May 2025 13:19:08 +0530	[thread overview]
Message-ID: <20250525074917.150332-2-aneesh.kumar@kernel.org> (raw)
In-Reply-To: <20250525074917.150332-1-aneesh.kumar@kernel.org>

We will add iommufd support in later patches. Rename the old vfio
method as legacy vfio.

Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
---
 vfio/core.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/vfio/core.c b/vfio/core.c
index c6b305c30cf7..424dc4ed3aef 100644
--- a/vfio/core.c
+++ b/vfio/core.c
@@ -282,7 +282,7 @@ void vfio_unmap_region(struct kvm *kvm, struct vfio_region *region)
 	}
 }
 
-static int vfio_configure_device(struct kvm *kvm, struct vfio_device *vdev)
+static int legacy_vfio_configure_device(struct kvm *kvm, struct vfio_device *vdev)
 {
 	int ret;
 	struct vfio_group *group = vdev->group;
@@ -340,12 +340,12 @@ err_close_device:
 	return ret;
 }
 
-static int vfio_configure_devices(struct kvm *kvm)
+static int legacy_vfio_configure_devices(struct kvm *kvm)
 {
 	int i, ret;
 
 	for (i = 0; i < kvm->cfg.num_vfio_devices; ++i) {
-		ret = vfio_configure_device(kvm, &vfio_devices[i]);
+		ret = legacy_vfio_configure_device(kvm, &vfio_devices[i]);
 		if (ret)
 			return ret;
 	}
@@ -429,7 +429,7 @@ static int vfio_configure_reserved_regions(struct kvm *kvm,
 	return ret;
 }
 
-static int vfio_configure_groups(struct kvm *kvm)
+static int legacy_vfio_configure_groups(struct kvm *kvm)
 {
 	int ret;
 	struct vfio_group *group;
@@ -454,7 +454,7 @@ static int vfio_configure_groups(struct kvm *kvm)
 	return 0;
 }
 
-static struct vfio_group *vfio_group_create(struct kvm *kvm, unsigned long id)
+static struct vfio_group *legacy_vfio_group_create(struct kvm *kvm, unsigned long id)
 {
 	int ret;
 	struct vfio_group *group;
@@ -512,10 +512,11 @@ static void vfio_group_exit(struct kvm *kvm, struct vfio_group *group)
 	if (--group->refs != 0)
 		return;
 
-	ioctl(group->fd, VFIO_GROUP_UNSET_CONTAINER);
-
 	list_del(&group->list);
-	close(group->fd);
+	if (group->fd != -1) {
+		ioctl(group->fd, VFIO_GROUP_UNSET_CONTAINER);
+		close(group->fd);
+	}
 	free(group);
 }
 
@@ -559,14 +560,14 @@ vfio_group_get_for_dev(struct kvm *kvm, struct vfio_device *vdev)
 		}
 	}
 
-	group = vfio_group_create(kvm, group_id);
+	group = legacy_vfio_group_create(kvm, group_id);
 
 out_close:
 	close(dirfd);
 	return group;
 }
 
-static int vfio_device_init(struct kvm *kvm, struct vfio_device *vdev)
+static int legacy_vfio_device_init(struct kvm *kvm, struct vfio_device *vdev)
 {
 	int ret;
 	char dev_path[PATH_MAX];
@@ -610,7 +611,7 @@ static void vfio_device_exit(struct kvm *kvm, struct vfio_device *vdev)
 	free(vdev->sysfs_path);
 }
 
-static int vfio_container_init(struct kvm *kvm)
+static int legacy_vfio_container_init(struct kvm *kvm)
 {
 	int api, i, ret, iommu_type;;
 
@@ -638,7 +639,7 @@ static int vfio_container_init(struct kvm *kvm)
 	for (i = 0; i < kvm->cfg.num_vfio_devices; ++i) {
 		vfio_devices[i].params = &kvm->cfg.vfio_devices[i];
 
-		ret = vfio_device_init(kvm, &vfio_devices[i]);
+		ret = legacy_vfio_device_init(kvm, &vfio_devices[i]);
 		if (ret)
 			return ret;
 	}
@@ -678,15 +679,15 @@ static int vfio__init(struct kvm *kvm)
 	}
 	kvm_vfio_device = device.fd;
 
-	ret = vfio_container_init(kvm);
+	ret = legacy_vfio_container_init(kvm);
 	if (ret)
 		return ret;
 
-	ret = vfio_configure_groups(kvm);
+	ret = legacy_vfio_configure_groups(kvm);
 	if (ret)
 		return ret;
 
-	ret = vfio_configure_devices(kvm);
+	ret = legacy_vfio_configure_devices(kvm);
 	if (ret)
 		return ret;
 
-- 
2.43.0


  reply	other threads:[~2025-05-25  7:49 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-25  7:49 [RFC PATCH kvmtool 01/10] vfio: Associate vm instance with vfio fd Aneesh Kumar K.V (Arm)
2025-05-25  7:49 ` Aneesh Kumar K.V (Arm) [this message]
2025-07-27 18:20   ` [RFC PATCH kvmtool 02/10] vfio: Rename some functions Mostafa Saleh
2025-07-29  4:53     ` Aneesh Kumar K.V
2025-05-25  7:49 ` [RFC PATCH kvmtool 03/10] vfio: Create new file legacy.c Aneesh Kumar K.V (Arm)
2025-07-27 18:23   ` Mostafa Saleh
2025-07-29  4:59     ` Aneesh Kumar K.V
2025-05-25  7:49 ` [RFC PATCH kvmtool 04/10] vfio: Update vfio header from linux kernel Aneesh Kumar K.V (Arm)
2025-07-27 18:23   ` Mostafa Saleh
2025-05-25  7:49 ` [RFC PATCH kvmtool 05/10] vfio: Add dma map/unmap handlers Aneesh Kumar K.V (Arm)
2025-07-27 18:25   ` Mostafa Saleh
2025-07-29  5:03     ` Aneesh Kumar K.V
2025-05-25  7:49 ` [RFC PATCH kvmtool 06/10] vfio/iommufd: Import iommufd header from kernel Aneesh Kumar K.V (Arm)
2025-07-27 18:25   ` Mostafa Saleh
2025-05-25  7:49 ` [RFC PATCH kvmtool 07/10] vfio/iommufd: Add basic iommufd support Aneesh Kumar K.V (Arm)
2025-07-27 18:31   ` Mostafa Saleh
2025-07-29  5:12     ` Aneesh Kumar K.V
2025-07-29  9:38       ` Mostafa Saleh
2025-05-25  7:49 ` [RFC PATCH kvmtool 08/10] vfio/iommufd: Move the hwpt allocation to helper Aneesh Kumar K.V (Arm)
2025-07-27 18:32   ` Mostafa Saleh
2025-07-29  5:14     ` Aneesh Kumar K.V
2025-07-29  9:43       ` Mostafa Saleh
2025-05-25  7:49 ` [RFC PATCH kvmtool 09/10] vfio/iommufd: Add viommu and vdevice objects Aneesh Kumar K.V (Arm)
2025-07-21 12:27   ` Will Deacon
2025-07-24 14:09     ` Aneesh Kumar K.V
2025-08-04 22:33       ` Suzuki K Poulose
2025-08-08 13:00         ` Will Deacon
2025-08-11  6:16           ` Aneesh Kumar K.V
2025-07-27 18:35   ` Mostafa Saleh
2025-07-29  5:19     ` Aneesh Kumar K.V
2025-07-29  9:41       ` Mostafa Saleh
2025-07-30  8:13         ` Aneesh Kumar K.V
2025-07-30 14:15           ` Mostafa Saleh
2025-07-31  4:39             ` Aneesh Kumar K.V
2025-08-04 15:07               ` Mostafa Saleh
2025-05-25  7:49 ` [RFC PATCH kvmtool 10/10] util/update_headers: Add vfio related header files to update list Aneesh Kumar K.V (Arm)
2025-07-27 18:35   ` Mostafa Saleh
2025-07-27 18:19 ` [RFC PATCH kvmtool 01/10] vfio: Associate vm instance with vfio fd Mostafa Saleh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250525074917.150332-2-aneesh.kumar@kernel.org \
    --to=aneesh.kumar@kernel.org \
    --cc=Suzuki.Poulose@arm.com \
    --cc=julien.thierry.kdev@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=steven.price@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.