On 2023/1/9 12:17, Tian, Kevin wrote:
From: Liu, Yi L <yi.l.liu@xxxxxxxxx>
Sent: Friday, January 6, 2023 11:05 PM
Probably kvm needs to put back the VFIO file reference when its own
struct file closes, not when when the kvm->users_count reaches 0.
yes. Seems no need to hold device file reference until las kvm->user_count.
At least no such need per my understanding.
looks just replacing .destroy() with .release() in kvm_vfio_ops...
yeah, this seems to be the easiest way. Let kvm_vfio_ops implement the
.release() op. Other kvm_devices won't be affected.
/*
* Destroy is responsible for freeing dev.
*
* Destroy may be called before or after destructors are called
* on emulated I/O regions, depending on whether a reference is
* held by a vcpu or other kvm component that gets destroyed
* after the emulated I/O.
*/
void (*destroy)(struct kvm_device *dev);
/*
* Release is an alternative method to free the device. It is
* called when the device file descriptor is closed. Once
* release is called, the destroy method will not be called
* anymore as the device is removed from the device list of
* the VM. kvm->lock is held.
*/
void (*release)(struct kvm_device *dev);
--
Regards,
Yi Liu