mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 10:34:58 -06:00
vfio/container: Implement attach/detach_device
No functional change intended. Signed-off-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Yi Liu <yi.l.liu@intel.com> Signed-off-by: Yi Sun <yi.y.sun@linux.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>
This commit is contained in:
parent
f79baf8c95
commit
1eb31f13b2
2 changed files with 21 additions and 7 deletions
|
@ -1498,3 +1498,19 @@ retry:
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int vfio_attach_device(char *name, VFIODevice *vbasedev,
|
||||||
|
AddressSpace *as, Error **errp)
|
||||||
|
{
|
||||||
|
const VFIOIOMMUOps *ops = &vfio_legacy_ops;
|
||||||
|
|
||||||
|
return ops->attach_device(name, vbasedev, as, errp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void vfio_detach_device(VFIODevice *vbasedev)
|
||||||
|
{
|
||||||
|
if (!vbasedev->bcontainer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vbasedev->bcontainer->ops->detach_device(vbasedev);
|
||||||
|
}
|
||||||
|
|
|
@ -873,8 +873,8 @@ static int vfio_device_groupid(VFIODevice *vbasedev, Error **errp)
|
||||||
* @name and @vbasedev->name are likely to be different depending
|
* @name and @vbasedev->name are likely to be different depending
|
||||||
* on the type of the device, hence the need for passing @name
|
* on the type of the device, hence the need for passing @name
|
||||||
*/
|
*/
|
||||||
int vfio_attach_device(char *name, VFIODevice *vbasedev,
|
static int vfio_legacy_attach_device(const char *name, VFIODevice *vbasedev,
|
||||||
AddressSpace *as, Error **errp)
|
AddressSpace *as, Error **errp)
|
||||||
{
|
{
|
||||||
int groupid = vfio_device_groupid(vbasedev, errp);
|
int groupid = vfio_device_groupid(vbasedev, errp);
|
||||||
VFIODevice *vbasedev_iter;
|
VFIODevice *vbasedev_iter;
|
||||||
|
@ -914,14 +914,10 @@ int vfio_attach_device(char *name, VFIODevice *vbasedev,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vfio_detach_device(VFIODevice *vbasedev)
|
static void vfio_legacy_detach_device(VFIODevice *vbasedev)
|
||||||
{
|
{
|
||||||
VFIOGroup *group = vbasedev->group;
|
VFIOGroup *group = vbasedev->group;
|
||||||
|
|
||||||
if (!vbasedev->bcontainer) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QLIST_REMOVE(vbasedev, global_next);
|
QLIST_REMOVE(vbasedev, global_next);
|
||||||
QLIST_REMOVE(vbasedev, container_next);
|
QLIST_REMOVE(vbasedev, container_next);
|
||||||
vbasedev->bcontainer = NULL;
|
vbasedev->bcontainer = NULL;
|
||||||
|
@ -933,6 +929,8 @@ void vfio_detach_device(VFIODevice *vbasedev)
|
||||||
const VFIOIOMMUOps vfio_legacy_ops = {
|
const VFIOIOMMUOps vfio_legacy_ops = {
|
||||||
.dma_map = vfio_legacy_dma_map,
|
.dma_map = vfio_legacy_dma_map,
|
||||||
.dma_unmap = vfio_legacy_dma_unmap,
|
.dma_unmap = vfio_legacy_dma_unmap,
|
||||||
|
.attach_device = vfio_legacy_attach_device,
|
||||||
|
.detach_device = vfio_legacy_detach_device,
|
||||||
.set_dirty_page_tracking = vfio_legacy_set_dirty_page_tracking,
|
.set_dirty_page_tracking = vfio_legacy_set_dirty_page_tracking,
|
||||||
.query_dirty_bitmap = vfio_legacy_query_dirty_bitmap,
|
.query_dirty_bitmap = vfio_legacy_query_dirty_bitmap,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue