rust-vmm / vfio

14 stars 20 forks source link

vfio-ioctls: fix get_region_info VFIO_PCI_VGA_REGION_INDEX error #50

Closed Dummyc0m closed 3 weeks ago

Dummyc0m commented 2 months ago

vfio_pci driver returns num_regions of at least VFIO_PCI_NUM_REGIONS from VFIO_DEVICE_GET_INFO ioctl.

However, if the device does not support VGA, the VFIO_DEVICE_GET_REGION_INFO ioctl returns -EINVAL for VFIO_PCI_VGA_REGION_INDEX.

Currently, an error is logged for this case, but a device not supporting VGA is not an error, so this particular -EINVAL is intended and correct for devices without VGA regions.

Two fixes:

  1. make the ioctl wrappers return the actual errno errors, instead of the ioctl return values.
  2. ignore the EINVAL return for VFIO_PCI_VGA_REGION_INDEX
Dummyc0m commented 2 months ago

Tested by passing through an audio device, a GPU, and a USB controller with cloud-hypervisor --device.

Updated unit tests to include testing for VFIO_PCI_VGA_REGION_INDEX.

Dummyc0m commented 1 month ago

Ping on review?