On 30/03/2017 14:47, Alexey Kardashevskiy wrote: > +static int spapr_tce_get_fd(IOMMUMemoryRegion *iommu) > +{ > + sPAPRTCETable *tcet = container_of(iommu, sPAPRTCETable, iommu); > + > + return tcet->fd; > +} > + > static int spapr_tce_table_post_load(void *opaque, int version_id) > { > sPAPRTCETable *tcet = SPAPR_TCE_TABLE(opaque); > @@ -266,7 +273,7 @@ static int spapr_tce_table_realize(DeviceState *dev) > memory_region_init(&tcet->root, tcetobj, tmp, UINT64_MAX); > > snprintf(tmp, sizeof(tmp), "tce-iommu-%x", tcet->liobn); > - memory_region_init_iommu_type(TYPE_IOMMU_MEMORY_REGION, > + memory_region_init_iommu_type(TYPE_SPAPR_IOMMU_MEMORY_REGION, > &tcet->iommu, tcetobj, &spapr_iommu_ops, > tmp, 0); > > @@ -634,9 +641,25 @@ static TypeInfo spapr_tce_table_info = { > .class_init = spapr_tce_table_class_init, > }; > > +static void spapr_iommu_memory_region_class_init(ObjectClass *k, void *data) > +{ > + sPAPRIOMMUMemoryRegionClass *smrc = SPAPR_IOMMU_MEMORY_REGION_CLASS(k); > + > + smrc->get_fd = spapr_tce_get_fd; > +} > +
You don't even need the virtual function. Rather, make spapr_tce_get_fd public and give it a sPAPRTCETable argument. Then vfio_spapr_notify_kvm can use SPAPR_IOMMU_MEMORY_REGION(iommumr). Paolo