From: "Cédric Le Goater" <clg@redhat.com>
To: Mark Cave-Ayland <mark.caveayland@nutanix.com>,
npiggin@gmail.com, danielhb413@gmail.com, harshpb@linux.ibm.com,
mjrosato@linux.ibm.com, farman@linux.ibm.com,
pasic@linux.ibm.com, borntraeger@linux.ibm.com, thuth@redhat.com,
richard.henderson@linaro.org, david@redhat.com,
iii@linux.ibm.com, john.levon@nutanix.com,
thanos.makatos@nutanix.com, alex.williamson@redhat.com,
steven.sistare@oracle.com, tomitamoeko@gmail.com,
qemu-ppc@nongnu.org, qemu-s390x@nongnu.org,
qemu-devel@nongnu.org
Subject: Re: [PATCH 04/22] hw/vfio/container.c: use QOM casts where appropriate
Date: Mon, 11 Aug 2025 14:19:52 +0200 [thread overview]
Message-ID: <cf0a4fb8-de01-45df-b828-150b7ff64f86@redhat.com> (raw)
In-Reply-To: <20250715093110.107317-5-mark.caveayland@nutanix.com>
On 7/15/25 11:25, Mark Cave-Ayland wrote:
> Use QOM casts to convert between VFIOContainer and VFIOContainerBase instead
> of accessing bcontainer directly.
>
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Thanks,
C.
> ---
> hw/vfio/container.c | 31 +++++++++++++------------------
> 1 file changed, 13 insertions(+), 18 deletions(-)
>
> diff --git a/hw/vfio/container.c b/hw/vfio/container.c
> index 3e13feaa74..f4337741b3 100644
> --- a/hw/vfio/container.c
> +++ b/hw/vfio/container.c
> @@ -71,7 +71,7 @@ static int vfio_dma_unmap_bitmap(const VFIOContainer *container,
> hwaddr iova, ram_addr_t size,
> IOMMUTLBEntry *iotlb)
> {
> - const VFIOContainerBase *bcontainer = &container->bcontainer;
> + const VFIOContainerBase *bcontainer = VFIO_IOMMU(container);
> struct vfio_iommu_type1_dma_unmap *unmap;
> struct vfio_bitmap *bitmap;
> VFIOBitmap vbmap;
> @@ -124,8 +124,7 @@ static int vfio_legacy_dma_unmap_one(const VFIOContainerBase *bcontainer,
> hwaddr iova, ram_addr_t size,
> IOMMUTLBEntry *iotlb)
> {
> - const VFIOContainer *container = container_of(bcontainer, VFIOContainer,
> - bcontainer);
> + const VFIOContainer *container = VFIO_IOMMU_LEGACY(bcontainer);
> struct vfio_iommu_type1_dma_unmap unmap = {
> .argsz = sizeof(unmap),
> .flags = 0,
> @@ -213,8 +212,7 @@ static int vfio_legacy_dma_map(const VFIOContainerBase *bcontainer, hwaddr iova,
> ram_addr_t size, void *vaddr, bool readonly,
> MemoryRegion *mr)
> {
> - const VFIOContainer *container = container_of(bcontainer, VFIOContainer,
> - bcontainer);
> + const VFIOContainer *container = VFIO_IOMMU_LEGACY(bcontainer);
> struct vfio_iommu_type1_dma_map map = {
> .argsz = sizeof(map),
> .flags = VFIO_DMA_MAP_FLAG_READ,
> @@ -246,8 +244,7 @@ static int
> vfio_legacy_set_dirty_page_tracking(const VFIOContainerBase *bcontainer,
> bool start, Error **errp)
> {
> - const VFIOContainer *container = container_of(bcontainer, VFIOContainer,
> - bcontainer);
> + const VFIOContainer *container = VFIO_IOMMU_LEGACY(bcontainer);
> int ret;
> struct vfio_iommu_type1_dirty_bitmap dirty = {
> .argsz = sizeof(dirty),
> @@ -272,8 +269,7 @@ vfio_legacy_set_dirty_page_tracking(const VFIOContainerBase *bcontainer,
> static int vfio_legacy_query_dirty_bitmap(const VFIOContainerBase *bcontainer,
> VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp)
> {
> - const VFIOContainer *container = container_of(bcontainer, VFIOContainer,
> - bcontainer);
> + const VFIOContainer *container = VFIO_IOMMU_LEGACY(bcontainer);
> struct vfio_iommu_type1_dirty_bitmap *dbitmap;
> struct vfio_iommu_type1_dirty_bitmap_get *range;
> int ret;
> @@ -495,7 +491,7 @@ static void vfio_get_iommu_info_migration(VFIOContainer *container,
> {
> struct vfio_info_cap_header *hdr;
> struct vfio_iommu_type1_info_cap_migration *cap_mig;
> - VFIOContainerBase *bcontainer = &container->bcontainer;
> + VFIOContainerBase *bcontainer = VFIO_IOMMU(container);
>
> hdr = vfio_get_iommu_info_cap(info, VFIO_IOMMU_TYPE1_INFO_CAP_MIGRATION);
> if (!hdr) {
> @@ -518,8 +514,7 @@ static void vfio_get_iommu_info_migration(VFIOContainer *container,
>
> static bool vfio_legacy_setup(VFIOContainerBase *bcontainer, Error **errp)
> {
> - VFIOContainer *container = container_of(bcontainer, VFIOContainer,
> - bcontainer);
> + VFIOContainer *container = VFIO_IOMMU_LEGACY(bcontainer);
> g_autofree struct vfio_iommu_type1_info *info = NULL;
> int ret;
>
> @@ -634,7 +629,7 @@ static bool vfio_container_connect(VFIOGroup *group, AddressSpace *as,
>
> if (!cpr_is_incoming()) {
> QLIST_FOREACH(bcontainer, &space->containers, next) {
> - container = container_of(bcontainer, VFIOContainer, bcontainer);
> + container = VFIO_IOMMU_LEGACY(bcontainer);
> if (!ioctl(group->fd, VFIO_GROUP_SET_CONTAINER, &container->fd)) {
> return vfio_container_group_add(container, group, errp);
> }
> @@ -652,7 +647,7 @@ static bool vfio_container_connect(VFIOGroup *group, AddressSpace *as,
> * create the container struct and group list.
> */
> QLIST_FOREACH(bcontainer, &space->containers, next) {
> - container = container_of(bcontainer, VFIOContainer, bcontainer);
> + container = VFIO_IOMMU_LEGACY(bcontainer);
>
> if (vfio_cpr_container_match(container, group, fd)) {
> return vfio_container_group_add(container, group, errp);
> @@ -672,7 +667,7 @@ static bool vfio_container_connect(VFIOGroup *group, AddressSpace *as,
> goto fail;
> }
> new_container = true;
> - bcontainer = &container->bcontainer;
> + bcontainer = VFIO_IOMMU(container);
>
> if (!vfio_legacy_cpr_register_container(container, errp)) {
> goto fail;
> @@ -735,7 +730,7 @@ fail:
> static void vfio_container_disconnect(VFIOGroup *group)
> {
> VFIOContainer *container = group->container;
> - VFIOContainerBase *bcontainer = &container->bcontainer;
> + VFIOContainerBase *bcontainer = VFIO_IOMMU(container);
> VFIOIOMMUClass *vioc = VFIO_IOMMU_GET_CLASS(bcontainer);
>
> QLIST_REMOVE(group, container_next);
> @@ -781,7 +776,7 @@ static VFIOGroup *vfio_group_get(int groupid, AddressSpace *as, Error **errp)
> QLIST_FOREACH(group, &vfio_group_list, next) {
> if (group->groupid == groupid) {
> /* Found it. Now is it already in the right context? */
> - if (group->container->bcontainer.space->as == as) {
> + if (VFIO_IOMMU(group->container)->space->as == as) {
> return group;
> } else {
> error_setg(errp, "group %d used in multiple address spaces",
> @@ -895,7 +890,7 @@ static bool vfio_device_get(VFIOGroup *group, const char *name,
> }
> }
>
> - vfio_device_prepare(vbasedev, &group->container->bcontainer, info);
> + vfio_device_prepare(vbasedev, VFIO_IOMMU(group->container), info);
>
> vbasedev->fd = fd;
> vbasedev->group = group;
next prev parent reply other threads:[~2025-08-11 12:20 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-15 9:25 [PATCH 00/22] vfio: improve use of QOM and coding guidelines Mark Cave-Ayland
2025-07-15 9:25 ` [PATCH 01/22] vfio/vfio-container-base.h: update VFIOContainerBase declaration Mark Cave-Ayland
2025-08-11 11:45 ` Cédric Le Goater
2025-08-11 11:56 ` Cédric Le Goater
2025-08-29 11:10 ` Mark Cave-Ayland
2025-07-15 9:25 ` [PATCH 02/22] vfio/vfio-container.h: update VFIOContainer declaration Mark Cave-Ayland
2025-07-15 9:39 ` Philippe Mathieu-Daudé
2025-08-11 11:45 ` Cédric Le Goater
2025-07-15 9:25 ` [PATCH 03/22] hw/vfio/cpr-legacy.c: use QOM casts where appropriate Mark Cave-Ayland
2025-07-15 12:36 ` Steven Sistare
2025-08-11 11:45 ` Cédric Le Goater
2025-07-15 9:25 ` [PATCH 04/22] hw/vfio/container.c: " Mark Cave-Ayland
2025-08-11 12:19 ` Cédric Le Goater [this message]
2025-07-15 9:25 ` [PATCH 05/22] ppc/spapr_pci_vfio.c: " Mark Cave-Ayland
2025-07-16 7:58 ` Harsh Prateek Bora
2025-08-11 12:19 ` Cédric Le Goater
2025-07-15 9:25 ` [PATCH 06/22] vfio/spapr.c: " Mark Cave-Ayland
2025-07-16 8:01 ` Harsh Prateek Bora
2025-08-11 12:20 ` Cédric Le Goater
2025-07-15 9:25 ` [PATCH 07/22] vfio/vfio-container.h: rename VFIOContainer bcontainer field to parent_obj Mark Cave-Ayland
2025-07-15 9:39 ` Philippe Mathieu-Daudé
2025-08-11 12:23 ` Cédric Le Goater
2025-07-15 9:25 ` [PATCH 08/22] vfio-user/container.h: update VFIOUserContainer declaration Mark Cave-Ayland
2025-07-15 9:39 ` Philippe Mathieu-Daudé
2025-07-15 12:57 ` John Levon
2025-08-11 12:23 ` Cédric Le Goater
2025-07-15 9:25 ` [PATCH 09/22] vfio/container.c: use QOM casts where appropriate Mark Cave-Ayland
2025-07-15 14:13 ` John Levon
2025-08-28 15:14 ` Mark Cave-Ayland
2025-08-28 15:25 ` John Levon
2025-08-11 12:23 ` Cédric Le Goater
2025-07-15 9:25 ` [PATCH 10/22] vfio-user/container.h: rename VFIOUserContainer bcontainer field to parent_obj Mark Cave-Ayland
2025-07-15 9:41 ` Philippe Mathieu-Daudé
2025-07-15 14:13 ` John Levon
2025-08-11 12:23 ` Cédric Le Goater
2025-07-15 9:25 ` [PATCH 11/22] vfio-user/pci.c: update VFIOUserPCIDevice declaration Mark Cave-Ayland
2025-07-15 9:42 ` Philippe Mathieu-Daudé
2025-07-15 9:43 ` Philippe Mathieu-Daudé
2025-07-15 13:35 ` BALATON Zoltan
2025-07-15 14:15 ` John Levon
2025-08-11 12:24 ` Cédric Le Goater
2025-07-15 9:25 ` [PATCH 12/22] vfio-user/pci.c: use QOM casts where appropriate Mark Cave-Ayland
2025-07-15 14:15 ` John Levon
2025-07-15 9:25 ` [PATCH 13/22] vfio-user/pci.c: rename VFIOUserPCIDevice device field to parent_obj Mark Cave-Ayland
2025-07-15 9:42 ` Philippe Mathieu-Daudé
2025-07-15 14:15 ` John Levon
2025-08-11 12:25 ` Cédric Le Goater
2025-07-15 9:25 ` [PATCH 14/22] vfio/pci.h: update VFIOPCIDevice declaration Mark Cave-Ayland
2025-07-15 9:44 ` Philippe Mathieu-Daudé
2025-08-11 12:25 ` Cédric Le Goater
2025-07-15 9:25 ` [PATCH 15/22] vfio/pci.h: use QOM casts where appropriate Mark Cave-Ayland
2025-07-15 9:25 ` [PATCH 16/22] vfio/pci.c: " Mark Cave-Ayland
2025-07-15 13:38 ` BALATON Zoltan
2025-08-11 12:45 ` Cédric Le Goater
2025-08-29 11:13 ` Mark Cave-Ayland
2025-08-29 11:07 ` Mark Cave-Ayland
2025-08-29 14:31 ` BALATON Zoltan
2025-09-01 10:24 ` Cédric Le Goater
2025-07-15 9:25 ` [PATCH 17/22] vfio/pci-quirks.c: " Mark Cave-Ayland
2025-07-15 9:25 ` [PATCH 18/22] vfio/cpr.c: " Mark Cave-Ayland
2025-07-15 12:36 ` Steven Sistare
2025-07-15 9:25 ` [PATCH 19/22] vfio/igd.c: " Mark Cave-Ayland
2025-07-18 15:26 ` Tomita Moeko
2025-07-15 9:26 ` [PATCH 20/22] vfio-user/pci.c: " Mark Cave-Ayland
2025-07-15 14:17 ` John Levon
2025-07-15 9:26 ` [PATCH 21/22] s390x/s390-pci-vfio.c: " Mark Cave-Ayland
2025-07-15 13:29 ` Eric Farman
2025-07-15 14:19 ` Matthew Rosato
2025-07-15 9:26 ` [PATCH 22/22] vfio/pci.h: rename VFIOPCIDevice pdev field to parent_obj Mark Cave-Ayland
2025-07-15 9:44 ` Philippe Mathieu-Daudé
2025-07-15 12:36 ` Steven Sistare
2025-08-11 12:46 ` Cédric Le Goater
2025-07-15 14:31 ` [PATCH 00/22] vfio: improve use of QOM and coding guidelines 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=cf0a4fb8-de01-45df-b828-150b7ff64f86@redhat.com \
--to=clg@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=borntraeger@linux.ibm.com \
--cc=danielhb413@gmail.com \
--cc=david@redhat.com \
--cc=farman@linux.ibm.com \
--cc=harshpb@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=john.levon@nutanix.com \
--cc=mark.caveayland@nutanix.com \
--cc=mjrosato@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=pasic@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=steven.sistare@oracle.com \
--cc=thanos.makatos@nutanix.com \
--cc=thuth@redhat.com \
--cc=tomitamoeko@gmail.com \
/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 NNTP newsgroup(s).