@@ -958,3 +958,36 @@ int vfio_container_ioctl(AddressSpace *as, int32_t groupid,
return vfio_container_do_ioctl(as, groupid, req, param);
}
+
+struct vfio_dev_property *vfio_get_dev_property(int device, const char *name,
+ unsigned int type)
+{
+ unsigned int length = 0;
+ struct vfio_dev_property *property = NULL;
+ int ret;
+
+ length = strlen(name) + 1;
+
+ while (1) {
+ unsigned int argsz = sizeof(struct vfio_dev_property) + length;
+ property = realloc(property, argsz);
+ property->argsz = argsz;
+ property->type = type;
+ strcpy((char *) property->data, name);
+
+ ret = ioctl(device, VFIO_DEVICE_GET_DEV_PROPERTY, property);
+
+ if (length < property->length) {
+ length = property->length;
+ } else {
+ break;
+ }
+ }
+
+ if (ret) {
+ g_free(property);
+ property = NULL;
+ }
+
+ return property;
+}
@@ -149,6 +149,8 @@ VFIOGroup *vfio_get_group(int groupid, AddressSpace *as);
void vfio_put_group(VFIOGroup *group);
int vfio_get_device(VFIOGroup *group, const char *name,
VFIODevice *vbasedev);
+struct vfio_dev_property *vfio_get_dev_property(int device, const char *name,
+ unsigned int type);
extern const MemoryRegionOps vfio_region_ops;
extern const MemoryListener vfio_memory_listener;
Add a function to handle ioctl VFIO_DEVICE_GET_DEV_PROPERTY to retrieve properties from a VFIO device. Signed-off-by: Baptiste Reynal <b.reynal@virtualopensystems.com> --- hw/vfio/common.c | 33 +++++++++++++++++++++++++++++++++ include/hw/vfio/vfio-common.h | 2 ++ 2 files changed, 35 insertions(+)