vfio: Make VFIOIOMMUClass::add_window() and its wrapper return bool

Make VFIOIOMMUClass::add_window() and its wrapper function
vfio_container_add_section_window() return bool.

This is to follow the coding standand to return bool if 'Error **'
is used to pass error.

Suggested-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
Zhenzhong Duan 2024-05-07 14:42:46 +08:00 committed by Cédric Le Goater
parent 35b25cf40e
commit 33e4c22fd1
4 changed files with 19 additions and 19 deletions

View File

@ -588,7 +588,7 @@ static void vfio_listener_region_add(MemoryListener *listener,
return; return;
} }
if (vfio_container_add_section_window(bcontainer, section, &err)) { if (!vfio_container_add_section_window(bcontainer, section, &err)) {
goto fail; goto fail;
} }

View File

@ -31,12 +31,12 @@ int vfio_container_dma_unmap(VFIOContainerBase *bcontainer,
return bcontainer->ops->dma_unmap(bcontainer, iova, size, iotlb); return bcontainer->ops->dma_unmap(bcontainer, iova, size, iotlb);
} }
int vfio_container_add_section_window(VFIOContainerBase *bcontainer, bool vfio_container_add_section_window(VFIOContainerBase *bcontainer,
MemoryRegionSection *section, MemoryRegionSection *section,
Error **errp) Error **errp)
{ {
if (!bcontainer->ops->add_window) { if (!bcontainer->ops->add_window) {
return 0; return true;
} }
return bcontainer->ops->add_window(bcontainer, section, errp); return bcontainer->ops->add_window(bcontainer, section, errp);

View File

@ -323,7 +323,7 @@ static int vfio_spapr_create_window(VFIOContainer *container,
return 0; return 0;
} }
static int static bool
vfio_spapr_container_add_section_window(VFIOContainerBase *bcontainer, vfio_spapr_container_add_section_window(VFIOContainerBase *bcontainer,
MemoryRegionSection *section, MemoryRegionSection *section,
Error **errp) Error **errp)
@ -351,13 +351,13 @@ vfio_spapr_container_add_section_window(VFIOContainerBase *bcontainer,
error_setg(errp, "Container %p can't map guest IOVA region" error_setg(errp, "Container %p can't map guest IOVA region"
" 0x%"HWADDR_PRIx"..0x%"HWADDR_PRIx, container, " 0x%"HWADDR_PRIx"..0x%"HWADDR_PRIx, container,
iova, end); iova, end);
return -EINVAL; return false;
} }
return 0; return true;
} }
if (container->iommu_type != VFIO_SPAPR_TCE_v2_IOMMU) { if (container->iommu_type != VFIO_SPAPR_TCE_v2_IOMMU) {
return 0; return true;
} }
/* For now intersections are not allowed, we may relax this later */ /* For now intersections are not allowed, we may relax this later */
@ -373,14 +373,14 @@ vfio_spapr_container_add_section_window(VFIOContainerBase *bcontainer,
section->offset_within_address_space + section->offset_within_address_space +
int128_get64(section->size) - 1, int128_get64(section->size) - 1,
hostwin->min_iova, hostwin->max_iova); hostwin->min_iova, hostwin->max_iova);
return -EINVAL; return false;
} }
} }
ret = vfio_spapr_create_window(container, section, &pgsize); ret = vfio_spapr_create_window(container, section, &pgsize);
if (ret) { if (ret) {
error_setg_errno(errp, -ret, "Failed to create SPAPR window"); error_setg_errno(errp, -ret, "Failed to create SPAPR window");
return ret; return false;
} }
vfio_host_win_add(scontainer, section->offset_within_address_space, vfio_host_win_add(scontainer, section->offset_within_address_space,
@ -406,14 +406,14 @@ vfio_spapr_container_add_section_window(VFIOContainerBase *bcontainer,
"vfio: failed GROUP_SET_SPAPR_TCE for " "vfio: failed GROUP_SET_SPAPR_TCE for "
"KVM VFIO device %d and group fd %d", "KVM VFIO device %d and group fd %d",
param.tablefd, param.groupfd); param.tablefd, param.groupfd);
return -errno; return false;
} }
trace_vfio_spapr_group_attach(param.groupfd, param.tablefd); trace_vfio_spapr_group_attach(param.groupfd, param.tablefd);
} }
} }
} }
#endif #endif
return 0; return true;
} }
static void static void

View File

@ -76,7 +76,7 @@ int vfio_container_dma_map(VFIOContainerBase *bcontainer,
int vfio_container_dma_unmap(VFIOContainerBase *bcontainer, int vfio_container_dma_unmap(VFIOContainerBase *bcontainer,
hwaddr iova, ram_addr_t size, hwaddr iova, ram_addr_t size,
IOMMUTLBEntry *iotlb); IOMMUTLBEntry *iotlb);
int vfio_container_add_section_window(VFIOContainerBase *bcontainer, bool vfio_container_add_section_window(VFIOContainerBase *bcontainer,
MemoryRegionSection *section, MemoryRegionSection *section,
Error **errp); Error **errp);
void vfio_container_del_section_window(VFIOContainerBase *bcontainer, void vfio_container_del_section_window(VFIOContainerBase *bcontainer,
@ -156,7 +156,7 @@ struct VFIOIOMMUClass {
int (*pci_hot_reset)(VFIODevice *vbasedev, bool single); int (*pci_hot_reset)(VFIODevice *vbasedev, bool single);
/* SPAPR specific */ /* SPAPR specific */
int (*add_window)(VFIOContainerBase *bcontainer, bool (*add_window)(VFIOContainerBase *bcontainer,
MemoryRegionSection *section, MemoryRegionSection *section,
Error **errp); Error **errp);
void (*del_window)(VFIOContainerBase *bcontainer, void (*del_window)(VFIOContainerBase *bcontainer,