[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [RFC PATCH v4 20/24] vfio/iommufd: Implement the iommufd backend
From: |
Duan, Zhenzhong |
Subject: |
RE: [RFC PATCH v4 20/24] vfio/iommufd: Implement the iommufd backend |
Date: |
Fri, 14 Jul 2023 09:35:36 +0000 |
>-----Original Message-----
>From: Joel Granados <j.granados@samsung.com>
>Sent: Friday, July 14, 2023 5:23 PM
>Subject: Re: [RFC PATCH v4 20/24] vfio/iommufd: Implement the iommufd
>backend
>
>On Wed, Jul 12, 2023 at 03:25:24PM +0800, Zhenzhong Duan wrote:
>> From: Yi Liu <yi.l.liu@intel.com>
...
>> +static int vfio_get_devicefd(const char *sysfs_path, Error **errp)
>> +{
>> + long int ret = -ENOTTY;
>> + char *path, *vfio_dev_path = NULL, *vfio_path = NULL;
>> + DIR *dir = NULL;
>> + struct dirent *dent;
>> + gchar *contents;
>> + struct stat st;
>> + gsize length;
>> + int major, minor;
>> + dev_t vfio_devt;
>> +
>> + path = g_strdup_printf("%s/vfio-dev", sysfs_path);
>> + if (stat(path, &st) < 0) {
>> + error_setg_errno(errp, errno, "no such host device");
>> + goto out_free_path;
>> + }
>> +
>> + dir = opendir(path);
>> + if (!dir) {
>> + error_setg_errno(errp, errno, "couldn't open dirrectory %s", path);
>> + goto out_free_path;
>> + }
>> +
>> + while ((dent = readdir(dir))) {
>> + if (!strncmp(dent->d_name, "vfio", 4)) {
>> + vfio_dev_path = g_strdup_printf("%s/%s/dev", path,
>> dent->d_name);
>> + break;
>> + }
>> + }
>> +
>> + if (!vfio_dev_path) {
>> + error_setg(errp, "failed to find vfio-dev/vfioX/dev");
>> + goto out_free_path;
>> + }
>> +
>> + if (!g_file_get_contents(vfio_dev_path, &contents, &length, NULL)) {
>> + error_setg(errp, "failed to load \"%s\"", vfio_dev_path);
>> + goto out_free_dev_path;
>> + }
>> +
>> + if (sscanf(contents, "%d:%d", &major, &minor) != 2) {
>> + error_setg(errp, "failed to get major:mino for \"%s\"",
>> vfio_dev_path);
>Very small nit: Should be "minor" here.
Good catch, will fix.
Thanks
Zhenzhong
- [RFC PATCH v4 15/24] vfio/container-base: Introduce [attach/detach]_device container callbacks, (continued)
- [RFC PATCH v4 15/24] vfio/container-base: Introduce [attach/detach]_device container callbacks, Zhenzhong Duan, 2023/07/12
- [RFC PATCH v4 14/24] vfio/ccw: Use vfio_[attach/detach]_device, Zhenzhong Duan, 2023/07/12
- [RFC PATCH v4 17/24] Add iommufd configure option, Zhenzhong Duan, 2023/07/12
- [RFC PATCH v4 13/24] vfio/ap: Use vfio_[attach/detach]_device, Zhenzhong Duan, 2023/07/12
- [RFC PATCH v4 18/24] backends/iommufd: Introduce the iommufd object, Zhenzhong Duan, 2023/07/12
- [RFC PATCH v4 16/24] vfio/as: Simplify vfio_viommu_preset(), Zhenzhong Duan, 2023/07/12
- [RFC PATCH v4 19/24] util/char_dev: Add open_cdev(), Zhenzhong Duan, 2023/07/12
- [RFC PATCH v4 22/24] vfio/pci: Adapt vfio pci hot reset support with iommufd BE, Zhenzhong Duan, 2023/07/12
- [RFC PATCH v4 20/24] vfio/iommufd: Implement the iommufd backend, Zhenzhong Duan, 2023/07/12
- [RFC PATCH v4 21/24] vfio/as: Add vfio device iterator callback for iommufd, Zhenzhong Duan, 2023/07/12
- [RFC PATCH v4 24/24] vfio/iommufd: Make vfio cdev pre-openable by passing a file handle, Zhenzhong Duan, 2023/07/12
- [RFC PATCH v4 23/24] vfio/as: Allow the selection of a given iommu backend, Zhenzhong Duan, 2023/07/12