vfio/pci: Introduce vfio_[attach/detach]_device
commit5456b1867d10826e3857fda417b59a669fa5cce9
authorEric Auger <eric.auger@redhat.com>
Mon, 9 Oct 2023 09:09:09 +0000 (9 11:09 +0200)
committerCédric Le Goater <clg@redhat.com>
Wed, 18 Oct 2023 08:10:49 +0000 (18 10:10 +0200)
tree956dcf7e2a886e03fabea7e623c9b7253c722f53
parent5621c02d5adf3841884bb751ec8cf43d931aaa25
vfio/pci: Introduce vfio_[attach/detach]_device

We want the VFIO devices to be able to use two different
IOMMU backends, the legacy VFIO one and the new iommufd one.

Introduce vfio_[attach/detach]_device which aim at hiding the
underlying IOMMU backend (IOCTLs, datatypes, ...).

Once vfio_attach_device completes, the device is attached
to a security context and its fd can be used. Conversely
When vfio_detach_device completes, the device has been
detached from the security context.

At the moment only the implementation based on the legacy
container/group exists. Let's use it from the vfio-pci device.
Subsequent patches will handle other devices.

We also take benefit of this patch to properly free
vbasedev->name on failure.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
hw/vfio/common.c
hw/vfio/pci.c
hw/vfio/trace-events
include/hw/vfio/vfio-common.h