aboutsummaryrefslogtreecommitdiff
path: root/hw/vfio/common.c
diff options
context:
space:
mode:
authorYi Liu <yi.l.liu@intel.com>2023-11-21 16:44:03 +0800
committerCédric Le Goater <clg@redhat.com>2023-12-19 19:03:38 +0100
commit5ee3dc7af7859e7b8aa34c10c21778101c15e812 (patch)
treeaec5bf93cff00ca176ccb23ec8d0e6224eeb9480 /hw/vfio/common.c
parent1eae5b7bd3ddd03b5591e9122b011c6520064a5a (diff)
downloadqemu-5ee3dc7af7859e7b8aa34c10c21778101c15e812.zip
qemu-5ee3dc7af7859e7b8aa34c10c21778101c15e812.tar.gz
qemu-5ee3dc7af7859e7b8aa34c10c21778101c15e812.tar.bz2
vfio/iommufd: Implement the iommufd backend
The iommufd backend is implemented based on the new /dev/iommu user API. This backend obviously depends on CONFIG_IOMMUFD. So far, the iommufd backend doesn't support dirty page sync yet. Co-authored-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> Tested-by: Eric Auger <eric.auger@redhat.com> Tested-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Cédric Le Goater <clg@redhat.com>
Diffstat (limited to 'hw/vfio/common.c')
-rw-r--r--hw/vfio/common.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 934f4f5..6569732 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
+#include CONFIG_DEVICES /* CONFIG_IOMMUFD */
#include <sys/ioctl.h>
#ifdef CONFIG_KVM
#include <linux/kvm.h>
@@ -1503,6 +1504,11 @@ int vfio_attach_device(char *name, VFIODevice *vbasedev,
{
const VFIOIOMMUOps *ops = &vfio_legacy_ops;
+#ifdef CONFIG_IOMMUFD
+ if (vbasedev->iommufd) {
+ ops = &vfio_iommufd_ops;
+ }
+#endif
return ops->attach_device(name, vbasedev, as, errp);
}