mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-09-09 08:17:53 -06:00
backends/iommufd: Implement HostIOMMUDeviceClass::get_cap() handler
Suggested-by: Cédric Le Goater <clg@redhat.com> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
ed92ed2d48
commit
63c6e83ec2
1 changed files with 23 additions and 0 deletions
|
@ -230,6 +230,28 @@ bool iommufd_backend_get_device_info(IOMMUFDBackend *be, uint32_t devid,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int hiod_iommufd_get_cap(HostIOMMUDevice *hiod, int cap, Error **errp)
|
||||||
|
{
|
||||||
|
HostIOMMUDeviceCaps *caps = &hiod->caps;
|
||||||
|
|
||||||
|
switch (cap) {
|
||||||
|
case HOST_IOMMU_DEVICE_CAP_IOMMU_TYPE:
|
||||||
|
return caps->type;
|
||||||
|
case HOST_IOMMU_DEVICE_CAP_AW_BITS:
|
||||||
|
return caps->aw_bits;
|
||||||
|
default:
|
||||||
|
error_setg(errp, "%s: unsupported capability %x", hiod->name, cap);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void hiod_iommufd_class_init(ObjectClass *oc, void *data)
|
||||||
|
{
|
||||||
|
HostIOMMUDeviceClass *hioc = HOST_IOMMU_DEVICE_CLASS(oc);
|
||||||
|
|
||||||
|
hioc->get_cap = hiod_iommufd_get_cap;
|
||||||
|
};
|
||||||
|
|
||||||
static const TypeInfo types[] = {
|
static const TypeInfo types[] = {
|
||||||
{
|
{
|
||||||
.name = TYPE_IOMMUFD_BACKEND,
|
.name = TYPE_IOMMUFD_BACKEND,
|
||||||
|
@ -246,6 +268,7 @@ static const TypeInfo types[] = {
|
||||||
}, {
|
}, {
|
||||||
.name = TYPE_HOST_IOMMU_DEVICE_IOMMUFD,
|
.name = TYPE_HOST_IOMMU_DEVICE_IOMMUFD,
|
||||||
.parent = TYPE_HOST_IOMMU_DEVICE,
|
.parent = TYPE_HOST_IOMMU_DEVICE,
|
||||||
|
.class_init = hiod_iommufd_class_init,
|
||||||
.abstract = true,
|
.abstract = true,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue