mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
vfio: Make VFIOIOMMUClass::setup() 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:
parent
b77548355a
commit
35b25cf40e
3 changed files with 11 additions and 13 deletions
|
@ -507,7 +507,7 @@ static void vfio_get_iommu_info_migration(VFIOContainer *container,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vfio_legacy_setup(VFIOContainerBase *bcontainer, Error **errp)
|
static bool vfio_legacy_setup(VFIOContainerBase *bcontainer, Error **errp)
|
||||||
{
|
{
|
||||||
VFIOContainer *container = container_of(bcontainer, VFIOContainer,
|
VFIOContainer *container = container_of(bcontainer, VFIOContainer,
|
||||||
bcontainer);
|
bcontainer);
|
||||||
|
@ -517,7 +517,7 @@ static int vfio_legacy_setup(VFIOContainerBase *bcontainer, Error **errp)
|
||||||
ret = vfio_get_iommu_info(container, &info);
|
ret = vfio_get_iommu_info(container, &info);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
error_setg_errno(errp, -ret, "Failed to get VFIO IOMMU info");
|
error_setg_errno(errp, -ret, "Failed to get VFIO IOMMU info");
|
||||||
return ret;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->flags & VFIO_IOMMU_INFO_PGSIZES) {
|
if (info->flags & VFIO_IOMMU_INFO_PGSIZES) {
|
||||||
|
@ -533,7 +533,7 @@ static int vfio_legacy_setup(VFIOContainerBase *bcontainer, Error **errp)
|
||||||
vfio_get_info_iova_range(info, bcontainer);
|
vfio_get_info_iova_range(info, bcontainer);
|
||||||
|
|
||||||
vfio_get_iommu_info_migration(container, info);
|
vfio_get_iommu_info_migration(container, info);
|
||||||
return 0;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
||||||
|
@ -635,8 +635,8 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
||||||
|
|
||||||
assert(bcontainer->ops->setup);
|
assert(bcontainer->ops->setup);
|
||||||
|
|
||||||
ret = bcontainer->ops->setup(bcontainer, errp);
|
if (!bcontainer->ops->setup(bcontainer, errp)) {
|
||||||
if (ret) {
|
ret = -EINVAL;
|
||||||
goto enable_discards_exit;
|
goto enable_discards_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -458,7 +458,7 @@ static void vfio_spapr_container_release(VFIOContainerBase *bcontainer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vfio_spapr_container_setup(VFIOContainerBase *bcontainer,
|
static bool vfio_spapr_container_setup(VFIOContainerBase *bcontainer,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
VFIOContainer *container = container_of(bcontainer, VFIOContainer,
|
VFIOContainer *container = container_of(bcontainer, VFIOContainer,
|
||||||
|
@ -480,7 +480,7 @@ static int vfio_spapr_container_setup(VFIOContainerBase *bcontainer,
|
||||||
ret = ioctl(fd, VFIO_IOMMU_ENABLE);
|
ret = ioctl(fd, VFIO_IOMMU_ENABLE);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
error_setg_errno(errp, errno, "failed to enable container");
|
error_setg_errno(errp, errno, "failed to enable container");
|
||||||
return -errno;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
scontainer->prereg_listener = vfio_prereg_listener;
|
scontainer->prereg_listener = vfio_prereg_listener;
|
||||||
|
@ -488,7 +488,6 @@ static int vfio_spapr_container_setup(VFIOContainerBase *bcontainer,
|
||||||
memory_listener_register(&scontainer->prereg_listener,
|
memory_listener_register(&scontainer->prereg_listener,
|
||||||
&address_space_memory);
|
&address_space_memory);
|
||||||
if (bcontainer->error) {
|
if (bcontainer->error) {
|
||||||
ret = -1;
|
|
||||||
error_propagate_prepend(errp, bcontainer->error,
|
error_propagate_prepend(errp, bcontainer->error,
|
||||||
"RAM memory listener initialization failed: ");
|
"RAM memory listener initialization failed: ");
|
||||||
goto listener_unregister_exit;
|
goto listener_unregister_exit;
|
||||||
|
@ -500,7 +499,6 @@ static int vfio_spapr_container_setup(VFIOContainerBase *bcontainer,
|
||||||
if (ret) {
|
if (ret) {
|
||||||
error_setg_errno(errp, errno,
|
error_setg_errno(errp, errno,
|
||||||
"VFIO_IOMMU_SPAPR_TCE_GET_INFO failed");
|
"VFIO_IOMMU_SPAPR_TCE_GET_INFO failed");
|
||||||
ret = -errno;
|
|
||||||
goto listener_unregister_exit;
|
goto listener_unregister_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,13 +525,13 @@ static int vfio_spapr_container_setup(VFIOContainerBase *bcontainer,
|
||||||
0x1000);
|
0x1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return true;
|
||||||
|
|
||||||
listener_unregister_exit:
|
listener_unregister_exit:
|
||||||
if (v2) {
|
if (v2) {
|
||||||
memory_listener_unregister(&scontainer->prereg_listener);
|
memory_listener_unregister(&scontainer->prereg_listener);
|
||||||
}
|
}
|
||||||
return ret;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vfio_iommu_spapr_class_init(ObjectClass *klass, void *data)
|
static void vfio_iommu_spapr_class_init(ObjectClass *klass, void *data)
|
||||||
|
|
|
@ -110,7 +110,7 @@ struct VFIOIOMMUClass {
|
||||||
InterfaceClass parent_class;
|
InterfaceClass parent_class;
|
||||||
|
|
||||||
/* basic feature */
|
/* basic feature */
|
||||||
int (*setup)(VFIOContainerBase *bcontainer, Error **errp);
|
bool (*setup)(VFIOContainerBase *bcontainer, Error **errp);
|
||||||
int (*dma_map)(const VFIOContainerBase *bcontainer,
|
int (*dma_map)(const VFIOContainerBase *bcontainer,
|
||||||
hwaddr iova, ram_addr_t size,
|
hwaddr iova, ram_addr_t size,
|
||||||
void *vaddr, bool readonly);
|
void *vaddr, bool readonly);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue