hw/core/loader: Pass errp to load_image_targphys_as()

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.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Vishal Chourasia <vishalc@linux.ibm.com>
Message-ID: <20251024130556.1942835-12-vishalc@linux.ibm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
Vishal Chourasia
2025-10-28 08:19:18 +01:00
committed by Philippe Mathieu-Daudé
parent beded5ebd0
commit 1b5eafee86
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -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;
}
}
+2 -2
View File
@@ -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;
}