On Fri, 2 Oct 2020 12:54:28 +0000 Thanos Makatos <thanos.maka...@nutanix.com> wrote:
> According to linux/include/uapi/linux/vfio.h, for a device to support > migration > it must provide a VFIO capability of type VFIO_REGION_INFO_CAP_TYPE and set > .type/.subtype to VFIO_REGION_TYPE_MIGRATION/VFIO_REGION_TYPE_MIGRATION. > > What confuses me is the following: > > "The structure vfio_device_migration_info is placed at the 0th offset of > the VFIO_REGION_SUBTYPE_MIGRATION region to get and set VFIO device related > migration information." > > Where do regions VFIO_REGION_TYPE_MIGRATION and VFIO_REGION_SUBTYPE_MIGRATION > live on the device's address space? Is just like any other region, except that > in the case of a PCI device it's index must be equal to, or larger than, > VFIO_PCI_NUM_REGIONS, and set arbitrarily by the device implementation? If > so, then I suppose this index must appear in struct > vfio_device_info.num_regions? Yes, the user gets a device fd via VFIO_GROUP_GET_DEVICE_FD, they then use the VFIO_DEVICE_GET_INFO ioctl to query the device type, number of IRQs and number of regions. For a vfio-pci device, some of the reported region indexes are used for a fixed purpose, these are where the VFIO_PCI_BAR0_REGION_INDEX conventions come into play. For region indexes beyond that fixed enum (VFIO_PCI_NUM_REGION), the user relies on the capability chain reported in the VFIO_DEVICE_GET_REGION_INFO ioctl to determine the purpose of the region. Userspace would walk the capability chain in that ioctl return buffer to find a VFIO_REGION_INFO_CAP_TYPE. This is what would identify the region as providing migration support. The vfio_device_migration_info structure is then accessible at the zero'th offset within that region, ie. vfio_region_info.offset within the vfio device fd. Thanks, Alex _______________________________________________ vfio-users mailing list vfio-users@redhat.com https://www.redhat.com/mailman/listinfo/vfio-users