qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vishal Chourasia <vishalc@linux.ibm.com>
To: Alistair Francis <alistair23@gmail.com>
Cc: adityag@linux.ibm.com, harshpb@linux.ibm.com,
	milesg@linux.ibm.com, npiggin@gmail.com,
	peter.maydell@linaro.org, qemu-devel@nongnu.org,
	qemu-ppc@nongnu.org, berrange@redhat.com, alistair@alistair23.me,
	alex.bennee@linaro.org
Subject: Re: [PATCH 3/5] hw/core: Pass errp to load_image_targphys_as()
Date: Fri, 17 Oct 2025 10:22:18 +0530	[thread overview]
Message-ID: <3099333d-f5c2-40d5-8d87-314c90cd2647@linux.ibm.com> (raw)
In-Reply-To: <CAKmqyKME2SWuE0LjcgcxuR=vLLnKfqUkB2DsvuTxVgX9QrxTDQ@mail.gmail.com>

Thanks Alistair for the review.

On 17/10/25 04:29, Alistair Francis wrote:
> On Fri, Oct 17, 2025 at 3:41 AM Vishal Chourasia <vishalc@linux.ibm.com> wrote:
>> Pass errp to load_image_targphys_as() in generic-loader and
>> guest-loader to capture detailed error information from the
>> loader functions.
>>
>> Use error_prepend() instead of error_setg() to preserve the
>> underlying error details while adding context about which image
>> failed to load.
>>
>> Signed-off-by: Vishal Chourasia <vishalc@linux.ibm.com>
> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

I have one more change to be added to this patch.

diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c
index 433efb7387..c69c857ed4 100644
--- a/hw/core/generic-loader.c
+++ b/hw/core/generic-loader.c
@@ -155,7 +155,12 @@ static void generic_loader_realize(DeviceState 
*dev, Error **errp)
          }

          if (size < 0) {
-            error_prepend(errp, "Cannot load specified image %s: ", 
s->file);
+            const char *msg = "Cannot load specified image %s: ";
+            if (*errp) {
+                error_prepend(errp, msg, s->file);
+            } else {
+                error_setg(errp, msg, s->file);
+            }
              return;
          }
      }

Similar change has to be done in guest-loader.c
I will include it in v4.

>
> Alistair
>
>> ---
>>   hw/core/generic-loader.c | 4 ++--
>>   hw/core/guest-loader.c   | 4 ++--
>>   2 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c
>> index 6689847c33..433efb7387 100644
>> --- a/hw/core/generic-loader.c
>> +++ b/hw/core/generic-loader.c
>> @@ -149,13 +149,13 @@ static void generic_loader_realize(DeviceState *dev, Error **errp)
>>           if (size < 0 || s->force_raw) {
>>               /* Default to the maximum size being the machine's ram size */
>>               size = load_image_targphys_as(s->file, s->addr,
>> -                    current_machine->ram_size, as, NULL);
>> +                    current_machine->ram_size, as, errp);
>>           } else {
>>               s->addr = entry;
>>           }
>>
>>           if (size < 0) {
>> -            error_setg(errp, "Cannot load specified image %s", s->file);
>> +            error_prepend(errp, "Cannot load specified image %s: ", s->file);
>>               return;
>>           }
>>       }
>> diff --git a/hw/core/guest-loader.c b/hw/core/guest-loader.c
>> index 59f325ad9c..618455e556 100644
>> --- a/hw/core/guest-loader.c
>> +++ b/hw/core/guest-loader.c
>> @@ -101,9 +101,9 @@ static void guest_loader_realize(DeviceState *dev, Error **errp)
>>
>>       /* Default to the maximum size being the machine's ram size */
>>       size = load_image_targphys_as(file, s->addr, current_machine->ram_size,
>> -                                  NULL, NULL);
>> +                                  NULL, errp);
>>       if (size < 0) {
>> -        error_setg(errp, "Cannot load specified image %s", file);
>> +        error_prepend(errp, "Cannot load specified image %s: ", file);
>>           return;
>>       }
>>
>> --
>> 2.51.0
>>
>>


  reply	other threads:[~2025-10-17  4:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-16 17:34 [PATCH v3 0/5] hw/core/loader: Add Error parameter for better error reporting Vishal Chourasia
2025-10-16 17:34 ` [PATCH 1/5] hw/core/loader: capture Error from load_image_targphys Vishal Chourasia
2025-10-16 22:58   ` Alistair Francis
2025-10-17  5:49     ` Vishal Chourasia
2025-10-16 17:34 ` [PATCH 2/5] hw/core/loader: Use qemu_open() instead of open() in get_image_size() Vishal Chourasia
2025-10-16 17:40   ` Daniel P. Berrangé
2025-10-16 17:35 ` [PATCH 3/5] hw/core: Pass errp to load_image_targphys_as() Vishal Chourasia
2025-10-16 22:59   ` Alistair Francis
2025-10-17  4:52     ` Vishal Chourasia [this message]
2025-10-16 17:35 ` [PATCH 4/5] hw/ppc/spapr: Rename resize_hpt_err to errp Vishal Chourasia
2025-10-16 17:35 ` [PATCH 5/5] hw/ppc: Pass errp to load_image_targphys() and report errors Vishal Chourasia
2025-10-16 19:27   ` BALATON Zoltan
2025-10-16 20:26     ` Vishal Chourasia
2025-10-17  6:08       ` Vishal Chourasia
2025-10-17  4:54   ` Aditya Gupta

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=3099333d-f5c2-40d5-8d87-314c90cd2647@linux.ibm.com \
    --to=vishalc@linux.ibm.com \
    --cc=adityag@linux.ibm.com \
    --cc=alex.bennee@linaro.org \
    --cc=alistair23@gmail.com \
    --cc=alistair@alistair23.me \
    --cc=berrange@redhat.com \
    --cc=harshpb@linux.ibm.com \
    --cc=milesg@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=peter.maydell@linaro.org \
    --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 NNTP newsgroup(s).