qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@redhat.com>
To: Amit Machhiwal <amachhiw@linux.ibm.com>,
	qemu-ppc@nongnu.org, Nicholas Piggin <npiggin@gmail.com>,
	Harsh Prateek Bora <harshpb@linux.ibm.com>
Cc: qemu-devel@nongnu.org, Vaibhav Jain <vaibhav@linux.ibm.com>,
	Shivaprasad G Bhat <sbhat@linux.ibm.com>,
	Daniel Henrique Barboza <danielhb413@gmail.com>,
	Alex Williamson <alex.williamson@redhat.com>
Subject: Re: [PATCH v3 1/2] vfio/spapr: Enhance error handling in vfio_spapr_create_window()
Date: Tue, 8 Apr 2025 14:50:18 +0200	[thread overview]
Message-ID: <8a689ae0-c7fd-40a4-a524-7048d4e5f709@redhat.com> (raw)
In-Reply-To: <20250408124042.2695955-2-amachhiw@linux.ibm.com>

On 4/8/25 14:40, Amit Machhiwal wrote:
> Introduce an Error ** parameter to vfio_spapr_create_window() to enable
> structured error reporting. This allows the function to propagate
> detailed errors back to callers.
> 
> Suggested-by: Cédric Le Goater <clg@redhat.com>
> Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com>
> --->   hw/vfio/spapr.c | 33 ++++++++++++++++-----------------
>   1 file changed, 16 insertions(+), 17 deletions(-)
> 
> diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c
> index 1a5d1611f2cd..dd9207679dbe 100644
> --- a/hw/vfio/spapr.c
> +++ b/hw/vfio/spapr.c
> @@ -230,9 +230,9 @@ static int vfio_spapr_remove_window(VFIOContainer *container,
>       return 0;
>   }
>   
> -static int vfio_spapr_create_window(VFIOContainer *container,
> +static bool vfio_spapr_create_window(VFIOContainer *container,
>                                       MemoryRegionSection *section,
> -                                    hwaddr *pgsize)
> +                                    hwaddr *pgsize, Error **errp)
>   {
>       int ret = 0;
>       VFIOContainerBase *bcontainer = &container->bcontainer;
> @@ -252,11 +252,11 @@ static int vfio_spapr_create_window(VFIOContainer *container,
>       pgmask = bcontainer->pgsizes & (pagesize | (pagesize - 1));
>       pagesize = pgmask ? (1ULL << (63 - clz64(pgmask))) : 0;
>       if (!pagesize) {
> -        error_report("Host doesn't support page size 0x%"PRIx64
> -                     ", the supported mask is 0x%lx",
> -                     memory_region_iommu_get_min_page_size(iommu_mr),
> -                     bcontainer->pgsizes);
> -        return -EINVAL;
> +        error_setg_errno(errp, EINVAL, "Host doesn't support page size 0x%"PRIx64
> +                         ", the supported mask is 0x%lx",
> +                         memory_region_iommu_get_min_page_size(iommu_mr),
> +                         bcontainer->pgsizes);
> +        return false;
>       }
>   
>       /*
> @@ -302,17 +302,17 @@ static int vfio_spapr_create_window(VFIOContainer *container,
>           }
>       }
>       if (ret) {
> -        error_report("Failed to create a window, ret = %d (%m)", ret);
> -        return -errno;
> +        error_setg_errno(errp, errno, "Failed to create a window, ret = %d", ret);
> +        return false;
>       }
>   
>       if (create.start_addr != section->offset_within_address_space) {
>           vfio_spapr_remove_window(container, create.start_addr);
>   
> -        error_report("Host doesn't support DMA window at %"HWADDR_PRIx", must be %"PRIx64,
> -                     section->offset_within_address_space,
> -                     (uint64_t)create.start_addr);
> -        return -EINVAL;
> +        error_setg_errno(errp, EINVAL, "Host doesn't support DMA window at %"HWADDR_PRIx
> +                         ", must be %"PRIx64, section->offset_within_address_space,
> +                         (uint64_t)create.start_addr);
> +        return false;
>       }
>       trace_vfio_spapr_create_window(create.page_shift,
>                                      create.levels,
> @@ -320,7 +320,7 @@ static int vfio_spapr_create_window(VFIOContainer *container,
>                                      create.start_addr);
>       *pgsize = pagesize;
>   
> -    return 0;
> +    return true;
>   }
>   
>   static bool
> @@ -377,9 +377,8 @@ vfio_spapr_container_add_section_window(VFIOContainerBase *bcontainer,
>           }
>       }
>   
> -    ret = vfio_spapr_create_window(container, section, &pgsize);
> -    if (ret) {
> -        error_setg_errno(errp, -ret, "Failed to create SPAPR window");
> +    ret = vfio_spapr_create_window(container, section, &pgsize, errp);
> +    if (!ret) {
>           return false;
>       }
>   

ret is not needed. Minor.


Reviewed-by: Cédric Le Goater <clg@redhat.com>

Thanks,

C.




  reply	other threads:[~2025-04-08 12:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-08 12:40 [PATCH v3 0/2] vfio/spapr: Fix L2 crash with PCI device passthrough Amit Machhiwal
2025-04-08 12:40 ` [PATCH v3 1/2] vfio/spapr: Enhance error handling in vfio_spapr_create_window() Amit Machhiwal
2025-04-08 12:50   ` Cédric Le Goater [this message]
2025-04-08 12:40 ` [PATCH v3 2/2] vfio/spapr: Fix L2 crash with PCI device passthrough and memory > 128G Amit Machhiwal
2025-04-08 12:50   ` Cédric Le Goater
2025-04-09 10:00 ` [PATCH v3 0/2] vfio/spapr: Fix L2 crash with PCI device passthrough 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=8a689ae0-c7fd-40a4-a524-7048d4e5f709@redhat.com \
    --to=clg@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=amachhiw@linux.ibm.com \
    --cc=danielhb413@gmail.com \
    --cc=harshpb@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=sbhat@linux.ibm.com \
    --cc=vaibhav@linux.ibm.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).