On Fri, Oct 17, 2025 at 5:07 PM Vipin Sharma vipinsh@google.com wrote:
static int vfio_pci_liveupdate_retrieve(struct liveupdate_file_handler *handler, u64 data, struct file **file) {
...
filep = anon_inode_getfile_fmode("[vfio-cdev]", &vfio_device_fops, df,O_RDWR, FMODE_PREAD | FMODE_PWRITE);
It's a little weird that we have to use an anonymous inode when restoring cdev file descriptors. Do we care not about the association between VFIO cdev files and their inodes?
If we wanted to have the cdev inode we could have the user pass a file path to ioctl(LIVEUPDATE_SESSION_RESTORE_FD)? File handlers can use that to find the inode to use when creating a struct file. This would avoid the anonymous inode and also ensure that restoring the fd obeys the same filesystem permissions as opening a new fd (I think?).
Pasha this would be a uAPI change to LUO. What do you think?
Sami, Jason, what are you planning to do for iommufd?
if (IS_ERR(filep)) {err = PTR_ERR(filep);goto err_anon_inode;}/* Paired with the put in vfio_device_fops_release() */if (!vfio_device_try_get_registration(device)) {err = -ENODEV;goto err_get_registration;}put_device(&device->device);/** Use the pseudo fs inode on the device to link all mmaps* to the same address space, allowing us to unmap all vmas* associated to this device using unmap_mapping_range().*/filep->f_mapping = device->inode->i_mapping;
Most of this code already exists in vfio_device_fops_cdev_open(). I'll work on sharing the code in the next version.