From: Zhenzhong Duan Date: Wed, 5 Jun 2024 08:30:35 +0000 (+0800) Subject: vfio/container: Implement HostIOMMUDeviceClass::get_cap() handler X-Git-Tag: v9.1.0-rc0~59^2~33 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ed92ed2d486e5fddacb1e611c57e976eb160d0a5;p=thirdparty%2Fqemu.git vfio/container: Implement HostIOMMUDeviceClass::get_cap() handler Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: Eric Auger Reviewed-by: Michael S. Tsirkin --- diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 2f62c132144..99beeba422e 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -1147,11 +1147,26 @@ static bool hiod_legacy_vfio_realize(HostIOMMUDevice *hiod, void *opaque, return true; } +static int hiod_legacy_vfio_get_cap(HostIOMMUDevice *hiod, int cap, + Error **errp) +{ + HostIOMMUDeviceCaps *caps = &hiod->caps; + + switch (cap) { + 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_legacy_vfio_class_init(ObjectClass *oc, void *data) { HostIOMMUDeviceClass *hioc = HOST_IOMMU_DEVICE_CLASS(oc); hioc->realize = hiod_legacy_vfio_realize; + hioc->get_cap = hiod_legacy_vfio_get_cap; }; static const TypeInfo types[] = {