From: Vishal Chourasia <vishalc@linux.ibm.com>
To: adityag@linux.ibm.com, harshpb@linux.ibm.com,
milesg@linux.ibm.com, npiggin@gmail.com,
peter.maydell@linaro.org, alistair23@gmail.com,
balaton@eik.bme.hu, qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
berrange@redhat.com
Cc: Vishal Chourasia <vishalc@linux.ibm.com>
Subject: [Patch v6 4/6] hw/core: Pass errp to load_image_targphys_as()
Date: Wed, 22 Oct 2025 18:55:07 +0530 [thread overview]
Message-ID: <20251022132507.1597232-10-vishalc@linux.ibm.com> (raw)
In-Reply-To: <20251022132507.1597232-2-vishalc@linux.ibm.com>
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>
---
hw/core/generic-loader.c | 7 ++++---
hw/core/guest-loader.c | 7 ++++---
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c
index 6689847c33..35d4e5f4ea 100644
--- a/hw/core/generic-loader.c
+++ b/hw/core/generic-loader.c
@@ -60,6 +60,7 @@ static void generic_loader_reset(void *opaque)
static void generic_loader_realize(DeviceState *dev, Error **errp)
{
+ ERRP_GUARD();
GenericLoaderState *s = GENERIC_LOADER(dev);
hwaddr entry;
ssize_t size = 0;
@@ -149,13 +150,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);
+ if (*errp) {
+ 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..dcbe8e4520 100644
--- a/hw/core/guest-loader.c
+++ b/hw/core/guest-loader.c
@@ -81,6 +81,7 @@ static void loader_insert_platform_data(GuestLoaderState *s, int size,
static void guest_loader_realize(DeviceState *dev, Error **errp)
{
+ ERRP_GUARD();
GuestLoaderState *s = GUEST_LOADER(dev);
char *file = s->kernel ? s->kernel : s->initrd;
int size = 0;
@@ -101,9 +102,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);
- if (size < 0) {
- error_setg(errp, "Cannot load specified image %s", file);
+ NULL, errp);
+ if (*errp) {
+ error_prepend(errp, "Cannot load specified image %s: ", file);
return;
}
--
2.51.0
next prev parent reply other threads:[~2025-10-22 13:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-22 13:24 [Patch v6 0/6] hw/core/loader: capture Error from load_image_targphys Vishal Chourasia
2025-10-22 13:25 ` [Patch v6 1/6] hw/core/loader: Use qemu_open() instead of open() in get_image_size() Vishal Chourasia
2025-10-22 13:25 ` [Patch v6 2/6] hw/core/loader: capture Error from load_image_targphys Vishal Chourasia
2025-10-22 13:25 ` [Patch v6 3/6] hw/core/loader: add check for zero size in load_image_targphys_as Vishal Chourasia
2025-10-22 13:25 ` Vishal Chourasia [this message]
2025-10-22 13:25 ` [Patch v6 5/6] hw/ppc/spapr: Rename resize_hpt_err to errp Vishal Chourasia
2025-10-22 13:25 ` [Patch v6 6/6] hw/ppc: Pass errp to load_image_targphys() and report errors Vishal Chourasia
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=20251022132507.1597232-10-vishalc@linux.ibm.com \
--to=vishalc@linux.ibm.com \
--cc=adityag@linux.ibm.com \
--cc=alistair23@gmail.com \
--cc=balaton@eik.bme.hu \
--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).