These routines are VFIODevice related. Move their definitions into "device.c".
Signed-off-by: Cédric Le Goater <c...@redhat.com> --- hw/vfio/common.c | 37 ------------------------------------- hw/vfio/device.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index df9585d1a471f893da072068f6056bbc6731d448..ed2f2ed8839caaf40fabb0cbbcaa1df2c5b70d67 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -1287,40 +1287,3 @@ const MemoryListener vfio_memory_listener = { .log_global_stop = vfio_listener_log_global_stop, .log_sync = vfio_listener_log_sync, }; - -bool vfio_attach_device(char *name, VFIODevice *vbasedev, - AddressSpace *as, Error **errp) -{ - const VFIOIOMMUClass *ops = - VFIO_IOMMU_CLASS(object_class_by_name(TYPE_VFIO_IOMMU_LEGACY)); - HostIOMMUDevice *hiod = NULL; - - if (vbasedev->iommufd) { - ops = VFIO_IOMMU_CLASS(object_class_by_name(TYPE_VFIO_IOMMU_IOMMUFD)); - } - - assert(ops); - - - if (!vbasedev->mdev) { - hiod = HOST_IOMMU_DEVICE(object_new(ops->hiod_typename)); - vbasedev->hiod = hiod; - } - - if (!ops->attach_device(name, vbasedev, as, errp)) { - object_unref(hiod); - vbasedev->hiod = NULL; - return false; - } - - return true; -} - -void vfio_detach_device(VFIODevice *vbasedev) -{ - if (!vbasedev->bcontainer) { - return; - } - object_unref(vbasedev->hiod); - VFIO_IOMMU_GET_CLASS(vbasedev->bcontainer)->detach_device(vbasedev); -} diff --git a/hw/vfio/device.c b/hw/vfio/device.c index 2e0ddec942690514e692b2380a909f15ece430f5..e6a1bbcda2297f9e6272fff9b1c228b6772457ce 100644 --- a/hw/vfio/device.c +++ b/hw/vfio/device.c @@ -332,3 +332,40 @@ VFIODevice *vfio_get_vfio_device(Object *obj) return NULL; } } + +bool vfio_attach_device(char *name, VFIODevice *vbasedev, + AddressSpace *as, Error **errp) +{ + const VFIOIOMMUClass *ops = + VFIO_IOMMU_CLASS(object_class_by_name(TYPE_VFIO_IOMMU_LEGACY)); + HostIOMMUDevice *hiod = NULL; + + if (vbasedev->iommufd) { + ops = VFIO_IOMMU_CLASS(object_class_by_name(TYPE_VFIO_IOMMU_IOMMUFD)); + } + + assert(ops); + + + if (!vbasedev->mdev) { + hiod = HOST_IOMMU_DEVICE(object_new(ops->hiod_typename)); + vbasedev->hiod = hiod; + } + + if (!ops->attach_device(name, vbasedev, as, errp)) { + object_unref(hiod); + vbasedev->hiod = NULL; + return false; + } + + return true; +} + +void vfio_detach_device(VFIODevice *vbasedev) +{ + if (!vbasedev->bcontainer) { + return; + } + object_unref(vbasedev->hiod); + VFIO_IOMMU_GET_CLASS(vbasedev->bcontainer)->detach_device(vbasedev); +} -- 2.48.1