common.c (dd7d3e35401f80ffef4e209fa9e27db9087501b0) common.c (fdaa774e67435a328c0e28006c4d749f2198294a)
1/*
2 * generic functions used by VFIO devices
3 *
4 * Copyright Red Hat, Inc. 2012
5 *
6 * Authors:
7 * Alex Williamson <alex.williamson@redhat.com>
8 *

--- 1489 unchanged lines hidden (view full) ---

1498 }
1499
1500 return info;
1501}
1502
1503int vfio_attach_device(char *name, VFIODevice *vbasedev,
1504 AddressSpace *as, Error **errp)
1505{
1/*
2 * generic functions used by VFIO devices
3 *
4 * Copyright Red Hat, Inc. 2012
5 *
6 * Authors:
7 * Alex Williamson <alex.williamson@redhat.com>
8 *

--- 1489 unchanged lines hidden (view full) ---

1498 }
1499
1500 return info;
1501}
1502
1503int vfio_attach_device(char *name, VFIODevice *vbasedev,
1504 AddressSpace *as, Error **errp)
1505{
1506 const VFIOIOMMUOps *ops = &vfio_legacy_ops;
1506 const VFIOIOMMUClass *ops = &vfio_legacy_ops;
1507
1508#ifdef CONFIG_IOMMUFD
1509 if (vbasedev->iommufd) {
1510 ops = &vfio_iommufd_ops;
1511 }
1512#endif
1513 return ops->attach_device(name, vbasedev, as, errp);
1514}
1515
1516void vfio_detach_device(VFIODevice *vbasedev)
1517{
1518 if (!vbasedev->bcontainer) {
1519 return;
1520 }
1521 vbasedev->bcontainer->ops->detach_device(vbasedev);
1522}
1507
1508#ifdef CONFIG_IOMMUFD
1509 if (vbasedev->iommufd) {
1510 ops = &vfio_iommufd_ops;
1511 }
1512#endif
1513 return ops->attach_device(name, vbasedev, as, errp);
1514}
1515
1516void vfio_detach_device(VFIODevice *vbasedev)
1517{
1518 if (!vbasedev->bcontainer) {
1519 return;
1520 }
1521 vbasedev->bcontainer->ops->detach_device(vbasedev);
1522}