diff options
author | Zhenzhong Duan <zhenzhong.duan@intel.com> | 2024-06-05 16:30:36 +0800 |
---|---|---|
committer | Cédric Le Goater <clg@redhat.com> | 2024-06-24 23:15:30 +0200 |
commit | 63c6e83ec236f5de07444eac1d0bb747c506cc90 (patch) | |
tree | f73d8fd816db32be99bfe33c8512eb7a1e7f7c5f /backends | |
parent | ed92ed2d486e5fddacb1e611c57e976eb160d0a5 (diff) | |
download | qemu-63c6e83ec236f5de07444eac1d0bb747c506cc90.zip qemu-63c6e83ec236f5de07444eac1d0bb747c506cc90.tar.gz qemu-63c6e83ec236f5de07444eac1d0bb747c506cc90.tar.bz2 |
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>
Diffstat (limited to 'backends')
-rw-r--r-- | backends/iommufd.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/backends/iommufd.c b/backends/iommufd.c index c7e969d..84fefbc 100644 --- a/backends/iommufd.c +++ b/backends/iommufd.c @@ -230,6 +230,28 @@ bool iommufd_backend_get_device_info(IOMMUFDBackend *be, uint32_t devid, 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[] = { { .name = TYPE_IOMMUFD_BACKEND, @@ -246,6 +268,7 @@ static const TypeInfo types[] = { }, { .name = TYPE_HOST_IOMMU_DEVICE_IOMMUFD, .parent = TYPE_HOST_IOMMU_DEVICE, + .class_init = hiod_iommufd_class_init, .abstract = true, } }; |