Re: [PATCH v2] vfio/pci: print vfio-device syspath to fdinfo

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

 



On Thu, Jul 24, 2025 at 04:29:53PM -0700, Alex Mastro wrote:
> Print the PCI device syspath to a vfio device's fdinfo. This enables tools
> to query which device is associated with a given vfio device fd.
> 
> This results in output like below:
> 
> $ cat /proc/"$SOME_PID"/fdinfo/"$VFIO_FD" | grep vfio
> vfio-device-syspath: /sys/devices/pci0000:e0/0000:e0:01.1/0000:e1:00.0/0000:e2:05.0/0000:e8:00.0
> 
> Signed-off-by: Alex Mastro <amastro@xxxxxx>
> ---
> Based on the feedback received from Jason G. and Alex W. in v1, print
> the PCI device syspath to fdinfo instead of the BDF. This provides a
> more specific waypoint for user space to query for any other relevant
> information about the device.
> 
> There was discussion about removing vfio_device_ops callbacks, and
> relying on just dev_name() in vfio_main.c, but since the concept of PCI
> syspath is implementation-specific, I think we need to keep some form
> of callback.

??

> +static void vfio_pci_core_show_fdinfo(struct vfio_device *core_vdev, struct seq_file *m)
> +{
> +	char *path;
> +	struct vfio_pci_core_device *vdev =
> +		container_of(core_vdev, struct vfio_pci_core_device, vdev);
> +
> +	path = kobject_get_path(&vdev->pdev->dev.kobj, GFP_KERNEL);
                                 ^^^^^^^^^^^^^

vdev->pdev == core_vdev->dev 

int vfio_pci_core_init_dev(struct vfio_device *core_vdev)
{
	vdev->pdev = to_pci_dev(core_vdev->dev);

It is the right thing to just make this generic and use
core_dev->dev.kobj

Every vfio parent device has a sysfs path.

Jason




[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