From: Zhenzhong Duan <zhenzhong.duan@intel.com>
To: qemu-devel@nongnu.org
Cc: alex.williamson@redhat.com, clg@redhat.com,
eric.auger@redhat.com, chao.p.peng@intel.com,
Zhenzhong Duan <zhenzhong.duan@intel.com>,
Nicholas Piggin <npiggin@gmail.com>,
Daniel Henrique Barboza <danielhb413@gmail.com>,
David Gibson <david@gibson.dropbear.id.au>,
Harsh Prateek Bora <harshpb@linux.ibm.com>,
qemu-ppc@nongnu.org (open list:sPAPR (pseries))
Subject: [PATCH v2 04/11] vfio: Make VFIOIOMMUClass::setup() return bool
Date: Tue, 7 May 2024 14:42:45 +0800 [thread overview]
Message-ID: <20240507064252.457884-5-zhenzhong.duan@intel.com> (raw)
In-Reply-To: <20240507064252.457884-1-zhenzhong.duan@intel.com>
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>
---
include/hw/vfio/vfio-container-base.h | 2 +-
hw/vfio/container.c | 10 +++++-----
hw/vfio/spapr.c | 12 +++++-------
3 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-container-base.h
index c839cfd9cb..68539e3bed 100644
--- a/include/hw/vfio/vfio-container-base.h
+++ b/include/hw/vfio/vfio-container-base.h
@@ -111,7 +111,7 @@ struct VFIOIOMMUClass {
InterfaceClass parent_class;
/* basic feature */
- int (*setup)(VFIOContainerBase *bcontainer, Error **errp);
+ bool (*setup)(VFIOContainerBase *bcontainer, Error **errp);
int (*dma_map)(const VFIOContainerBase *bcontainer,
hwaddr iova, ram_addr_t size,
void *vaddr, bool readonly);
diff --git a/hw/vfio/container.c b/hw/vfio/container.c
index ea3b145913..85a8a369dc 100644
--- a/hw/vfio/container.c
+++ b/hw/vfio/container.c
@@ -505,7 +505,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,
bcontainer);
@@ -515,7 +515,7 @@ static int vfio_legacy_setup(VFIOContainerBase *bcontainer, Error **errp)
ret = vfio_get_iommu_info(container, &info);
if (ret) {
error_setg_errno(errp, -ret, "Failed to get VFIO IOMMU info");
- return ret;
+ return false;
}
if (info->flags & VFIO_IOMMU_INFO_PGSIZES) {
@@ -531,7 +531,7 @@ static int vfio_legacy_setup(VFIOContainerBase *bcontainer, Error **errp)
vfio_get_info_iova_range(info, bcontainer);
vfio_get_iommu_info_migration(container, info);
- return 0;
+ return true;
}
static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
@@ -633,8 +633,8 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
assert(bcontainer->ops->setup);
- ret = bcontainer->ops->setup(bcontainer, errp);
- if (ret) {
+ if (!bcontainer->ops->setup(bcontainer, errp)) {
+ ret = -EINVAL;
goto enable_discards_exit;
}
diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c
index 0d949bb728..148b257c9c 100644
--- a/hw/vfio/spapr.c
+++ b/hw/vfio/spapr.c
@@ -458,8 +458,8 @@ static void vfio_spapr_container_release(VFIOContainerBase *bcontainer)
}
}
-static int vfio_spapr_container_setup(VFIOContainerBase *bcontainer,
- Error **errp)
+static bool vfio_spapr_container_setup(VFIOContainerBase *bcontainer,
+ Error **errp)
{
VFIOContainer *container = container_of(bcontainer, VFIOContainer,
bcontainer);
@@ -480,7 +480,7 @@ static int vfio_spapr_container_setup(VFIOContainerBase *bcontainer,
ret = ioctl(fd, VFIO_IOMMU_ENABLE);
if (ret) {
error_setg_errno(errp, errno, "failed to enable container");
- return -errno;
+ return false;
}
} else {
scontainer->prereg_listener = vfio_prereg_listener;
@@ -488,7 +488,6 @@ static int vfio_spapr_container_setup(VFIOContainerBase *bcontainer,
memory_listener_register(&scontainer->prereg_listener,
&address_space_memory);
if (bcontainer->error) {
- ret = -1;
error_propagate_prepend(errp, bcontainer->error,
"RAM memory listener initialization failed: ");
goto listener_unregister_exit;
@@ -500,7 +499,6 @@ static int vfio_spapr_container_setup(VFIOContainerBase *bcontainer,
if (ret) {
error_setg_errno(errp, errno,
"VFIO_IOMMU_SPAPR_TCE_GET_INFO failed");
- ret = -errno;
goto listener_unregister_exit;
}
@@ -527,13 +525,13 @@ static int vfio_spapr_container_setup(VFIOContainerBase *bcontainer,
0x1000);
}
- return 0;
+ return true;
listener_unregister_exit:
if (v2) {
memory_listener_unregister(&scontainer->prereg_listener);
}
- return ret;
+ return false;
}
static void vfio_iommu_spapr_class_init(ObjectClass *klass, void *data)
--
2.34.1
next prev parent reply other threads:[~2024-05-07 6:46 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-07 6:42 [PATCH v2 00/11] VFIO: misc cleanups Zhenzhong Duan
2024-05-07 6:42 ` [PATCH v2 01/11] vfio/pci: Use g_autofree in vfio_realize Zhenzhong Duan
2024-05-14 15:45 ` Cédric Le Goater
2024-05-07 6:42 ` [PATCH v2 02/11] vfio/pci: Use g_autofree in iommufd_cdev_get_info_iova_range() Zhenzhong Duan
2024-05-14 15:45 ` Cédric Le Goater
2024-05-07 6:42 ` [PATCH v2 03/11] vfio: Make VFIOIOMMUClass::attach_device() and its wrapper return bool Zhenzhong Duan
2024-05-07 7:27 ` Cédric Le Goater
2024-05-07 7:34 ` Duan, Zhenzhong
2024-05-15 16:28 ` Cédric Le Goater
2024-05-07 6:42 ` Zhenzhong Duan [this message]
2024-05-07 6:42 ` [PATCH v2 05/11] vfio: Make VFIOIOMMUClass::add_window() " Zhenzhong Duan
2024-05-07 6:42 ` [PATCH v2 06/11] vfio/container: Make vfio_connect_container() " Zhenzhong Duan
2024-05-14 16:00 ` Cédric Le Goater
2024-05-07 6:42 ` [PATCH v2 07/11] vfio/container: Make vfio_set_iommu() " Zhenzhong Duan
2024-05-14 16:00 ` Cédric Le Goater
2024-05-07 6:42 ` [PATCH v2 08/11] vfio/container: Make vfio_get_device() " Zhenzhong Duan
2024-05-14 16:01 ` Cédric Le Goater
2024-05-07 6:42 ` [PATCH v2 09/11] vfio/iommufd: Make iommufd_cdev_*() " Zhenzhong Duan
2024-05-14 16:02 ` Cédric Le Goater
2024-05-07 6:42 ` [PATCH v2 10/11] vfio/cpr: Make vfio_cpr_register_container() " Zhenzhong Duan
2024-05-14 16:02 ` Cédric Le Goater
2024-05-07 6:42 ` [PATCH v2 11/11] backends/iommufd: Make iommufd_backend_*() " Zhenzhong Duan
2024-05-14 16:03 ` Cédric Le Goater
2024-05-14 3:46 ` [PATCH v2 00/11] VFIO: misc cleanups Duan, Zhenzhong
2024-05-16 16:30 ` Cédric Le Goater
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240507064252.457884-5-zhenzhong.duan@intel.com \
--to=zhenzhong.duan@intel.com \
--cc=alex.williamson@redhat.com \
--cc=chao.p.peng@intel.com \
--cc=clg@redhat.com \
--cc=danielhb413@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=eric.auger@redhat.com \
--cc=harshpb@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).