RE: [PATCH 10/13] vfio: Make vfio_device_open() exclusive between group path and device cdev path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From: Tian, Kevin <kevin.tian@xxxxxxxxx>
> Sent: Thursday, January 19, 2023 5:55 PM
> 
> > From: Liu, Yi L <yi.l.liu@xxxxxxxxx>
> > Sent: Tuesday, January 17, 2023 9:50 PM
> >
> > @@ -17,7 +17,11 @@ struct vfio_device;
> >  struct vfio_container;
> >
> >  struct vfio_device_file {
> > +	/* static fields, init per allocation */
> >  	struct vfio_device *device;
> > +	bool single_open;
> 
> I wonder whether the readability is better by renaming this
> to 'cdev', e.g.:
> 
> 	/*
> 	 * Device cdev path cannot support multiple device open since
> 	 * it doesn't have a secure way for it. So a second device
> 	 * open attempt should be failed if the caller is from a cdev
> 	 * path or the device has already been opened by a cdev path.
> 	 */
> 	if (device->open_count != 0 &&
> 	    (df->cdev || device->single_open))
> 		return -EINVAL;
> 
> 	/*
> 	 * group path supports multiple device open, while cdev doesn't.
> 	 * So use vfio_device_group_close() for !singel_open case.
> 	 */
> 	if (!df->cdev)
> 		vfio_device_group_close(df);
> 
> because from device file p.o.v we just want to differentiate cdev
> vs. group interface. With this change we even don't need the
> comment for the last condition check.
> 
> it's fine to have device->single_open as it's kind of a status bit
> set in the cdev path to prevent more opens on this device.

Ok. 

Regards,
Yi Liu




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux