* [PATCH v3 0/4] Fix error handling for callers of load_image_targphys, get_image_size, event_notifier_init, msix_init
@ 2026-03-18 14:14 Trieu Huynh
2026-03-18 14:14 ` [PATCH v3 1/4] hw/core/loader: fix error handling for load_image_targphys callers Trieu Huynh
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Trieu Huynh @ 2026-03-18 14:14 UTC (permalink / raw)
To: qemu-devel; +Cc: Trieu Huynh
Changes in v3:
- Patch 1: For next-cube, use a local Error* instead of &error_fatal
so that load failures are reported only when !qtest_enabled(),
matching the existing guard. Distinguishes "file not found" (error
set) from "file too short" (no error, size < 8) in next-cube.
(pointed out by Peter Maydell)
- Patch 2: Drop leon3.c change: warning is meaningless for baremetal
programs where no BIOS is expected, and error handling already
exists downstream. (pointed out by Clément Chigot)
- Patch 3: No code changes. Add Reviewed-by tags.
- Patch 4: Replace error_propagate() with conditional errp passing:
(s->msix == ON_OFF_AUTO_ON ? errp : NULL), avoiding the need for
a local error variable. (pointed out by Akihiko Odaki)
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/413
Trieu Huynh (4):
hw/core/loader: fix error handling for load_image_targphys callers
hw/core/loader: fix error handling for get_image_size callers
util/event_notifier: fix error handling for event_notifier_init
callers
hw/pci/msix: fix error handling for msix_init callers
hw/alpha/dp264.c | 2 +-
hw/hppa/machine.c | 2 +-
hw/hyperv/hyperv.c | 4 ++--
hw/hyperv/vmbus.c | 4 ++--
hw/ipmi/ipmi_bmc_sim.c | 2 ++
hw/m68k/next-cube.c | 11 +++++++++--
hw/m68k/q800.c | 2 +-
hw/m68k/virt.c | 2 +-
hw/microblaze/boot.c | 3 ++-
hw/net/igbvf.c | 2 +-
hw/net/rocker/rocker.c | 2 +-
hw/pci/msix.c | 2 +-
hw/remote/proxy.c | 15 +++++++++++++--
hw/scsi/megasas.c | 16 +++++++++++-----
hw/usb/hcd-xhci-pci.c | 16 +++++++++++-----
hw/vfio/ap.c | 2 +-
hw/vfio/ccw.c | 2 +-
hw/vfio/pci-quirks.c | 2 +-
hw/vfio/pci.c | 2 +-
hw/virtio/vhost-vdpa.c | 4 ++--
20 files changed, 65 insertions(+), 32 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v3 1/4] hw/core/loader: fix error handling for load_image_targphys callers
2026-03-18 14:14 [PATCH v3 0/4] Fix error handling for callers of load_image_targphys, get_image_size, event_notifier_init, msix_init Trieu Huynh
@ 2026-03-18 14:14 ` Trieu Huynh
2026-03-19 17:54 ` Peter Maydell
2026-03-18 14:14 ` [PATCH v3 2/4] hw/core/loader: fix error handling for get_image_size callers Trieu Huynh
` (3 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Trieu Huynh @ 2026-03-18 14:14 UTC (permalink / raw)
To: qemu-devel
Cc: Trieu Huynh, Richard Henderson, Helge Deller, Thomas Huth,
Laurent Vivier, Edgar E. Iglesias
Use QEMU's Error API to handle load_image_targphys() failures
consistently across callers.
- Use &error_fatal for callers that previously passed NULL, ensuring
the process exits early on failure instead of continuing in an invalid
state.
- No functional changes.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/413
Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
hw/alpha/dp264.c | 2 +-
hw/hppa/machine.c | 2 +-
hw/m68k/next-cube.c | 11 +++++++++--
hw/m68k/q800.c | 2 +-
hw/m68k/virt.c | 2 +-
hw/microblaze/boot.c | 3 ++-
6 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c
index 98219f0456..2ab3c14747 100644
--- a/hw/alpha/dp264.c
+++ b/hw/alpha/dp264.c
@@ -190,7 +190,7 @@ static void clipper_init(MachineState *machine)
/* Put the initrd image as high in memory as possible. */
initrd_base = (ram_size - initrd_size) & TARGET_PAGE_MASK;
load_image_targphys(initrd_filename, initrd_base,
- ram_size - initrd_base, NULL);
+ ram_size - initrd_base, &error_fatal);
address_space_stq_le(&address_space_memory, param_offset + 0x100,
initrd_base + 0xfffffc0000000000ULL,
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index ec63dc1297..99a4c22c73 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -507,7 +507,7 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
}
load_image_targphys(initrd_filename, initrd_base, initrd_size,
- NULL);
+ &error_fatal);
cpu[0]->env.initrd_base = initrd_base;
cpu[0]->env.initrd_end = initrd_base + initrd_size;
}
diff --git a/hw/m68k/next-cube.c b/hw/m68k/next-cube.c
index 26177c7b86..4bfe5bcf56 100644
--- a/hw/m68k/next-cube.c
+++ b/hw/m68k/next-cube.c
@@ -1326,9 +1326,16 @@ static void next_cube_init(MachineState *machine)
memory_region_init_alias(&m->rom2, NULL, "next.rom2", &m->rom, 0x0,
0x20000);
memory_region_add_subregion(sysmem, 0x0, &m->rom2);
- if (load_image_targphys(bios_name, 0x01000000, 0x20000, NULL) < 8) {
+ Error *local_err = NULL;
+ if (load_image_targphys(bios_name, 0x01000000, 0x20000, &local_err) < 8) {
if (!qtest_enabled()) {
- error_report("Failed to load firmware '%s'.", bios_name);
+ if (local_err) {
+ error_report_err(local_err);
+ } else {
+ error_report("Firmware image '%s' is too short.", bios_name);
+ }
+ } else {
+ error_free(local_err);
}
} else {
uint8_t *ptr;
diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
index ded531394e..c0d78eb7d7 100644
--- a/hw/m68k/q800.c
+++ b/hw/m68k/q800.c
@@ -633,7 +633,7 @@ static void q800_machine_init(MachineState *machine)
initrd_base = (ram_size - initrd_size) & TARGET_PAGE_MASK;
load_image_targphys(initrd_filename, initrd_base,
- ram_size - initrd_base, NULL);
+ ram_size - initrd_base, &error_fatal);
BOOTINFO2(param_ptr, BI_RAMDISK, initrd_base,
initrd_size);
} else {
diff --git a/hw/m68k/virt.c b/hw/m68k/virt.c
index e67900c727..ffe6e23415 100644
--- a/hw/m68k/virt.c
+++ b/hw/m68k/virt.c
@@ -292,7 +292,7 @@ static void virt_init(MachineState *machine)
initrd_base = (ram_size - initrd_size) & TARGET_PAGE_MASK;
load_image_targphys(initrd_filename, initrd_base,
- ram_size - initrd_base, NULL);
+ ram_size - initrd_base, &error_fatal);
BOOTINFO2(param_ptr, BI_RAMDISK, initrd_base,
initrd_size);
} else {
diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c
index a6f9ebab90..4ad5ffd34b 100644
--- a/hw/microblaze/boot.c
+++ b/hw/microblaze/boot.c
@@ -38,6 +38,7 @@
#include "hw/core/loader.h"
#include "elf.h"
#include "qemu/cutils.h"
+#include "qapi/error.h"
#include "boot.h"
@@ -171,7 +172,7 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, bool is_little_endian,
/* Not an ELF image nor an u-boot image, try a RAW image. */
if (kernel_size < 0) {
kernel_size = load_image_targphys(kernel_filename, ddr_base,
- ramsize, NULL);
+ ramsize, &error_fatal);
boot_info.bootstrap_pc = ddr_base;
high = (ddr_base + kernel_size + 3) & ~3;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v3 2/4] hw/core/loader: fix error handling for get_image_size callers
2026-03-18 14:14 [PATCH v3 0/4] Fix error handling for callers of load_image_targphys, get_image_size, event_notifier_init, msix_init Trieu Huynh
2026-03-18 14:14 ` [PATCH v3 1/4] hw/core/loader: fix error handling for load_image_targphys callers Trieu Huynh
@ 2026-03-18 14:14 ` Trieu Huynh
2026-03-19 18:04 ` Peter Maydell
2026-03-18 14:14 ` [PATCH v3 3/4] util/event_notifier: fix error handling for event_notifier_init callers Trieu Huynh
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Trieu Huynh @ 2026-03-18 14:14 UTC (permalink / raw)
To: qemu-devel; +Cc: Trieu Huynh, Corey Minyard
Check the return value of get_image_size() and report failures
for non-mandatory file such as FRU image.
- Use ret < 0 to detect failures in getting image size.
- No functional changes.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/413
Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
hw/ipmi/ipmi_bmc_sim.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
index 012e2ee4fe..fd875491f5 100644
--- a/hw/ipmi/ipmi_bmc_sim.c
+++ b/hw/ipmi/ipmi_bmc_sim.c
@@ -2561,6 +2561,8 @@ static void ipmi_fru_init(IPMIFru *fru)
g_free(fru->data);
fru->data = NULL;
}
+ } else {
+ error_report("Could not get file size '%s'", fru->filename);
}
out:
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v3 3/4] util/event_notifier: fix error handling for event_notifier_init callers
2026-03-18 14:14 [PATCH v3 0/4] Fix error handling for callers of load_image_targphys, get_image_size, event_notifier_init, msix_init Trieu Huynh
2026-03-18 14:14 ` [PATCH v3 1/4] hw/core/loader: fix error handling for load_image_targphys callers Trieu Huynh
2026-03-18 14:14 ` [PATCH v3 2/4] hw/core/loader: fix error handling for get_image_size callers Trieu Huynh
@ 2026-03-18 14:14 ` Trieu Huynh
2026-03-18 14:14 ` [PATCH v3 4/4] hw/pci/msix: fix error handling for msix_init callers Trieu Huynh
2026-03-24 14:41 ` [PATCH v3 0/4] Fix error handling for callers of load_image_targphys, get_image_size, event_notifier_init, msix_init Philippe Mathieu-Daudé
4 siblings, 0 replies; 11+ messages in thread
From: Trieu Huynh @ 2026-03-18 14:14 UTC (permalink / raw)
To: qemu-devel
Cc: Trieu Huynh, Anthony Krowiak, Jagannathan Raman,
Maciej S . Szmigiero, Matthew Rosato, Elena Ufimtseva,
Halil Pasic, Jason Herne, Cornelia Huck, Eric Farman,
Alex Williamson, Cédric Le Goater, Michael S. Tsirkin,
Stefano Garzarella, open list:vfio-ap
Check return value of event_notifier_init() and return early on
failure instead of continuing with invalid state.
- Use ret < 0 to handle negative return value.
- No functional changes.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/413
Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
Acked-by: Anthony Krowiak <akrowiak@linux.ibm.com>
Reviewed-by: Jagannathan Raman <jag.raman@oracle.com>
Reviewed-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com> # for the Hyper-V part
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
---
hw/hyperv/hyperv.c | 4 ++--
hw/hyperv/vmbus.c | 4 ++--
hw/remote/proxy.c | 15 +++++++++++++--
hw/vfio/ap.c | 2 +-
hw/vfio/ccw.c | 2 +-
hw/vfio/pci-quirks.c | 2 +-
hw/vfio/pci.c | 2 +-
hw/virtio/vhost-vdpa.c | 4 ++--
8 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c
index 27e323a819..aa278b179e 100644
--- a/hw/hyperv/hyperv.c
+++ b/hw/hyperv/hyperv.c
@@ -439,7 +439,7 @@ HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint,
sint_route->staged_msg->cb_data = cb_data;
r = event_notifier_init(ack_notifier, false);
- if (r) {
+ if (r < 0) {
goto cleanup_err_sint;
}
event_notifier_set_handler(ack_notifier, sint_ack_handler);
@@ -453,7 +453,7 @@ HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint,
/* We need to setup a GSI for this SintRoute */
r = event_notifier_init(&sint_route->sint_set_notifier, false);
- if (r) {
+ if (r < 0) {
goto cleanup_err_sint;
}
diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c
index 64abe4c4c1..5388f4277f 100644
--- a/hw/hyperv/vmbus.c
+++ b/hw/hyperv/vmbus.c
@@ -1432,7 +1432,7 @@ static void open_channel(VMBusChannel *chan)
goto put_gpadl;
}
- if (event_notifier_init(&chan->notifier, 0)) {
+ if (event_notifier_init(&chan->notifier, 0) < 0) {
goto put_gpadl;
}
@@ -2450,7 +2450,7 @@ static void vmbus_realize(BusState *bus, Error **errp)
}
ret = event_notifier_init(&vmbus->notifier, 0);
- if (ret != 0) {
+ if (ret < 0) {
error_setg(errp, "event notifier failed to init with %d", ret);
goto remove_msg_handler;
}
diff --git a/hw/remote/proxy.c b/hw/remote/proxy.c
index 5081d67e7f..e91566509f 100644
--- a/hw/remote/proxy.c
+++ b/hw/remote/proxy.c
@@ -52,9 +52,20 @@ static void setup_irqfd(PCIProxyDev *dev)
PCIDevice *pci_dev = PCI_DEVICE(dev);
MPQemuMsg msg;
Error *local_err = NULL;
+ int ret = 0;
- event_notifier_init(&dev->intr, 0);
- event_notifier_init(&dev->resample, 0);
+ ret = event_notifier_init(&dev->intr, 0);
+ if (ret < 0) {
+ error_report("Failed to init intr notifier: %s", strerror(-ret));
+ return;
+ }
+
+ ret = event_notifier_init(&dev->resample, 0);
+ if (ret < 0) {
+ error_report("Failed to init resample notifier: %s", strerror(-ret));
+ event_notifier_cleanup(&dev->intr);
+ return;
+ }
memset(&msg, 0, sizeof(MPQemuMsg));
msg.cmd = MPQEMU_CMD_SET_IRQFD;
diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
index e58a0169af..5c8f305653 100644
--- a/hw/vfio/ap.c
+++ b/hw/vfio/ap.c
@@ -180,7 +180,7 @@ static bool vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,
return false;
}
- if (event_notifier_init(notifier, 0)) {
+ if (event_notifier_init(notifier, 0) < 0) {
error_setg_errno(errp, errno,
"vfio: Unable to init event notifier for irq (%d)",
irq);
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index 2251facb35..ce9c014e6a 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -418,7 +418,7 @@ static bool vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,
return false;
}
- if (event_notifier_init(notifier, 0)) {
+ if (event_notifier_init(notifier, 0) < 0) {
error_setg_errno(errp, errno,
"vfio: Unable to init event notifier for irq (%d)",
irq);
diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
index 7b907b9360..66e02b15a4 100644
--- a/hw/vfio/pci-quirks.c
+++ b/hw/vfio/pci-quirks.c
@@ -318,7 +318,7 @@ static VFIOIOEventFD *vfio_ioeventfd_init(VFIOPCIDevice *vdev,
ioeventfd = g_malloc0(sizeof(*ioeventfd));
- if (event_notifier_init(&ioeventfd->e, 0)) {
+ if (event_notifier_init(&ioeventfd->e, 0) < 0) {
g_free(ioeventfd);
return NULL;
}
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 94c174a773..1945751ffd 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -70,7 +70,7 @@ static bool vfio_notifier_init(VFIOPCIDevice *vdev, EventNotifier *e,
}
ret = event_notifier_init(e, 0);
- if (ret) {
+ if (ret < 0) {
error_setg_errno(errp, -ret, "vfio_notifier_init %s failed", name);
return false;
}
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 2f8f11df86..9c7634e243 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -1075,13 +1075,13 @@ static int vhost_vdpa_svq_set_fds(struct vhost_dev *dev,
int r;
r = event_notifier_init(&svq->hdev_kick, 0);
- if (r != 0) {
+ if (r < 0) {
error_setg_errno(errp, -r, "Couldn't create kick event notifier");
goto err_init_hdev_kick;
}
r = event_notifier_init(&svq->hdev_call, 0);
- if (r != 0) {
+ if (r < 0) {
error_setg_errno(errp, -r, "Couldn't create call event notifier");
goto err_init_hdev_call;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v3 4/4] hw/pci/msix: fix error handling for msix_init callers
2026-03-18 14:14 [PATCH v3 0/4] Fix error handling for callers of load_image_targphys, get_image_size, event_notifier_init, msix_init Trieu Huynh
` (2 preceding siblings ...)
2026-03-18 14:14 ` [PATCH v3 3/4] util/event_notifier: fix error handling for event_notifier_init callers Trieu Huynh
@ 2026-03-18 14:14 ` Trieu Huynh
2026-03-19 18:02 ` Peter Maydell
2026-03-24 14:41 ` [PATCH v3 0/4] Fix error handling for callers of load_image_targphys, get_image_size, event_notifier_init, msix_init Philippe Mathieu-Daudé
4 siblings, 1 reply; 11+ messages in thread
From: Trieu Huynh @ 2026-03-18 14:14 UTC (permalink / raw)
To: qemu-devel
Cc: Trieu Huynh, Akihiko Odaki, Sriram Yagnaraman, Jason Wang,
Jiri Pirko, Michael S. Tsirkin, Marcel Apfelbaum, Paolo Bonzini,
Fam Zheng, open list:megasas
Check return value of msix_init() and return early on
failure instead of continuing with invalid state.
- Use ret < 0 to handle negative return value.
- Use errp parameter to handle failure instead of NULL.
- No functional changes.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/413
Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
hw/net/igbvf.c | 2 +-
hw/net/rocker/rocker.c | 2 +-
hw/pci/msix.c | 2 +-
hw/scsi/megasas.c | 16 +++++++++++-----
hw/usb/hcd-xhci-pci.c | 16 +++++++++++-----
5 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/hw/net/igbvf.c b/hw/net/igbvf.c
index 48d56e43ac..9a165c7063 100644
--- a/hw/net/igbvf.c
+++ b/hw/net/igbvf.c
@@ -260,7 +260,7 @@ static void igbvf_pci_realize(PCIDevice *dev, Error **errp)
ret = msix_init(dev, IGBVF_MSIX_VEC_NUM, &s->msix, IGBVF_MSIX_BAR_IDX, 0,
&s->msix, IGBVF_MSIX_BAR_IDX, 0x2000, 0x70, errp);
- if (ret) {
+ if (ret < 0) {
return;
}
diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
index 4a7056bd45..910dce901b 100644
--- a/hw/net/rocker/rocker.c
+++ b/hw/net/rocker/rocker.c
@@ -1228,7 +1228,7 @@ static int rocker_msix_init(Rocker *r, Error **errp)
&r->msix_bar,
ROCKER_PCI_MSIX_BAR_IDX, ROCKER_PCI_MSIX_PBA_OFFSET,
0, errp);
- if (err) {
+ if (err < 0) {
return err;
}
diff --git a/hw/pci/msix.c b/hw/pci/msix.c
index b35476d057..1b23eaf100 100644
--- a/hw/pci/msix.c
+++ b/hw/pci/msix.c
@@ -432,7 +432,7 @@ int msix_init_exclusive_bar(PCIDevice *dev, uint32_t nentries,
0, &dev->msix_exclusive_bar,
bar_nr, bar_pba_offset,
0, errp);
- if (ret) {
+ if (ret < 0) {
return ret;
}
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index f62e420a91..a29742d449 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -2380,11 +2380,17 @@ static void megasas_scsi_realize(PCIDevice *dev, Error **errp)
memory_region_init_io(&s->queue_io, OBJECT(s), &megasas_queue_ops, s,
"megasas-queue", 0x40000);
- if (megasas_use_msix(s) &&
- msix_init(dev, 15, &s->mmio_io, b->mmio_bar, 0x2000,
- &s->mmio_io, b->mmio_bar, 0x3800, 0x68, NULL)) {
- /* TODO: check msix_init's error, and should fail on msix=on */
- s->msix = ON_OFF_AUTO_OFF;
+ if (megasas_use_msix(s)) {
+ ret = msix_init(dev, 15, &s->mmio_io, b->mmio_bar, 0x2000,
+ &s->mmio_io, b->mmio_bar, 0x3800, 0x68,
+ s->msix == ON_OFF_AUTO_ON ? errp : NULL);
+
+ if (ret < 0) {
+ if (s->msix == ON_OFF_AUTO_ON) {
+ return;
+ }
+ s->msix = ON_OFF_AUTO_OFF;
+ }
}
if (pci_is_express(dev)) {
diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c
index aa570506fc..c5446a4a5e 100644
--- a/hw/usb/hcd-xhci-pci.c
+++ b/hw/usb/hcd-xhci-pci.c
@@ -173,11 +173,17 @@ static void usb_xhci_pci_realize(struct PCIDevice *dev, Error **errp)
}
if (s->msix != ON_OFF_AUTO_OFF) {
- /* TODO check for errors, and should fail when msix=on */
- msix_init(dev, s->xhci.numintrs,
- &s->xhci.mem, 0, OFF_MSIX_TABLE,
- &s->xhci.mem, 0, OFF_MSIX_PBA,
- 0x90, NULL);
+ ret = msix_init(dev, s->xhci.numintrs,
+ &s->xhci.mem, 0, OFF_MSIX_TABLE,
+ &s->xhci.mem, 0, OFF_MSIX_PBA,
+ 0x90, s->msix == ON_OFF_AUTO_ON ? errp : NULL);
+
+ if (ret < 0) {
+ if (s->msix == ON_OFF_AUTO_ON) {
+ return;
+ }
+ s->msix = ON_OFF_AUTO_OFF;
+ }
}
s->xhci.as = pci_get_address_space(dev);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v3 1/4] hw/core/loader: fix error handling for load_image_targphys callers
2026-03-18 14:14 ` [PATCH v3 1/4] hw/core/loader: fix error handling for load_image_targphys callers Trieu Huynh
@ 2026-03-19 17:54 ` Peter Maydell
0 siblings, 0 replies; 11+ messages in thread
From: Peter Maydell @ 2026-03-19 17:54 UTC (permalink / raw)
To: Trieu Huynh
Cc: qemu-devel, Richard Henderson, Helge Deller, Thomas Huth,
Laurent Vivier, Edgar E. Iglesias
On Wed, 18 Mar 2026 at 14:15, Trieu Huynh <vikingtc4@gmail.com> wrote:
>
> Use QEMU's Error API to handle load_image_targphys() failures
> consistently across callers.
>
> - Use &error_fatal for callers that previously passed NULL, ensuring
> the process exits early on failure instead of continuing in an invalid
> state.
> - No functional changes.
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/413
> Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
> ---
> hw/alpha/dp264.c | 2 +-
> hw/hppa/machine.c | 2 +-
> hw/m68k/next-cube.c | 11 +++++++++--
> hw/m68k/q800.c | 2 +-
> hw/m68k/virt.c | 2 +-
> hw/microblaze/boot.c | 3 ++-
> 6 files changed, 15 insertions(+), 7 deletions(-)
> diff --git a/hw/m68k/next-cube.c b/hw/m68k/next-cube.c
> index 26177c7b86..4bfe5bcf56 100644
> --- a/hw/m68k/next-cube.c
> +++ b/hw/m68k/next-cube.c
> @@ -1326,9 +1326,16 @@ static void next_cube_init(MachineState *machine)
> memory_region_init_alias(&m->rom2, NULL, "next.rom2", &m->rom, 0x0,
> 0x20000);
> memory_region_add_subregion(sysmem, 0x0, &m->rom2);
> - if (load_image_targphys(bios_name, 0x01000000, 0x20000, NULL) < 8) {
> + Error *local_err = NULL;
> + if (load_image_targphys(bios_name, 0x01000000, 0x20000, &local_err) < 8) {
> if (!qtest_enabled()) {
> - error_report("Failed to load firmware '%s'.", bios_name);
> + if (local_err) {
> + error_report_err(local_err);
> + } else {
> + error_report("Firmware image '%s' is too short.", bios_name);
> + }
> + } else {
> + error_free(local_err);
> }
> } else {
> uint8_t *ptr;
This changes the error message with no firmware from:
qemu-system-m68k: Failed to load firmware 'Rev_2.5_v66.bin'.
to:
qemu-system-m68k: Could not open 'Rev_2.5_v66.bin': No such file or directory
We lose the mention that this is the firmware blob,
but gain the more specific error message. That's OK,
I guess.
Both before and afterwards, once we've printed the message
we go ahead and run the machine, which immediately takes a
double mmu fault and aborts. No change with this patch,
so no problem.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
-- PMM
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3 4/4] hw/pci/msix: fix error handling for msix_init callers
2026-03-18 14:14 ` [PATCH v3 4/4] hw/pci/msix: fix error handling for msix_init callers Trieu Huynh
@ 2026-03-19 18:02 ` Peter Maydell
0 siblings, 0 replies; 11+ messages in thread
From: Peter Maydell @ 2026-03-19 18:02 UTC (permalink / raw)
To: Trieu Huynh
Cc: qemu-devel, Akihiko Odaki, Sriram Yagnaraman, Jason Wang,
Jiri Pirko, Michael S. Tsirkin, Marcel Apfelbaum, Paolo Bonzini,
Fam Zheng, open list:megasas
On Wed, 18 Mar 2026 at 14:16, Trieu Huynh <vikingtc4@gmail.com> wrote:
>
> Check return value of msix_init() and return early on
> failure instead of continuing with invalid state.
> - Use ret < 0 to handle negative return value.
> - Use errp parameter to handle failure instead of NULL.
> - No functional changes.
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/413
> Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
> ---
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3 2/4] hw/core/loader: fix error handling for get_image_size callers
2026-03-18 14:14 ` [PATCH v3 2/4] hw/core/loader: fix error handling for get_image_size callers Trieu Huynh
@ 2026-03-19 18:04 ` Peter Maydell
2026-03-19 18:29 ` Corey Minyard
0 siblings, 1 reply; 11+ messages in thread
From: Peter Maydell @ 2026-03-19 18:04 UTC (permalink / raw)
To: Trieu Huynh; +Cc: qemu-devel, Corey Minyard
On Wed, 18 Mar 2026 at 14:15, Trieu Huynh <vikingtc4@gmail.com> wrote:
>
> Check the return value of get_image_size() and report failures
> for non-mandatory file such as FRU image.
>
> - Use ret < 0 to detect failures in getting image size.
> - No functional changes.
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/413
> Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
> ---
> hw/ipmi/ipmi_bmc_sim.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
> index 012e2ee4fe..fd875491f5 100644
> --- a/hw/ipmi/ipmi_bmc_sim.c
> +++ b/hw/ipmi/ipmi_bmc_sim.c
> @@ -2561,6 +2561,8 @@ static void ipmi_fru_init(IPMIFru *fru)
> g_free(fru->data);
> fru->data = NULL;
> }
> + } else {
> + error_report("Could not get file size '%s'", fru->filename);
> }
>
> out:
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3 2/4] hw/core/loader: fix error handling for get_image_size callers
2026-03-19 18:04 ` Peter Maydell
@ 2026-03-19 18:29 ` Corey Minyard
2026-03-24 14:44 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 11+ messages in thread
From: Corey Minyard @ 2026-03-19 18:29 UTC (permalink / raw)
To: Peter Maydell; +Cc: Trieu Huynh, qemu-devel, Corey Minyard
On Thu, Mar 19, 2026 at 06:04:33PM +0000, Peter Maydell wrote:
> On Wed, 18 Mar 2026 at 14:15, Trieu Huynh <vikingtc4@gmail.com> wrote:
> >
> > Check the return value of get_image_size() and report failures
> > for non-mandatory file such as FRU image.
Yes, this makes sense. You want to do this through my tree, or do you
have another way you want to get it in?
-corey
> >
> > - Use ret < 0 to detect failures in getting image size.
> > - No functional changes.
> >
> > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/413
> > Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
> > ---
> > hw/ipmi/ipmi_bmc_sim.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
> > index 012e2ee4fe..fd875491f5 100644
> > --- a/hw/ipmi/ipmi_bmc_sim.c
> > +++ b/hw/ipmi/ipmi_bmc_sim.c
> > @@ -2561,6 +2561,8 @@ static void ipmi_fru_init(IPMIFru *fru)
> > g_free(fru->data);
> > fru->data = NULL;
> > }
> > + } else {
> > + error_report("Could not get file size '%s'", fru->filename);
> > }
> >
> > out:
>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>
> thanks
> -- PMM
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3 0/4] Fix error handling for callers of load_image_targphys, get_image_size, event_notifier_init, msix_init
2026-03-18 14:14 [PATCH v3 0/4] Fix error handling for callers of load_image_targphys, get_image_size, event_notifier_init, msix_init Trieu Huynh
` (3 preceding siblings ...)
2026-03-18 14:14 ` [PATCH v3 4/4] hw/pci/msix: fix error handling for msix_init callers Trieu Huynh
@ 2026-03-24 14:41 ` Philippe Mathieu-Daudé
4 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-24 14:41 UTC (permalink / raw)
To: Trieu Huynh, qemu-devel
On 18/3/26 15:14, Trieu Huynh wrote:
> Trieu Huynh (4):
> hw/core/loader: fix error handling for load_image_targphys callers
> hw/core/loader: fix error handling for get_image_size callers
> util/event_notifier: fix error handling for event_notifier_init
> callers
> hw/pci/msix: fix error handling for msix_init callers
Merged as commits b06bb02721a98d5b42...08324de90d1036326f, thanks.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3 2/4] hw/core/loader: fix error handling for get_image_size callers
2026-03-19 18:29 ` Corey Minyard
@ 2026-03-24 14:44 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-24 14:44 UTC (permalink / raw)
To: corey, Peter Maydell; +Cc: Trieu Huynh, qemu-devel, Corey Minyard
On 19/3/26 19:29, Corey Minyard wrote:
> On Thu, Mar 19, 2026 at 06:04:33PM +0000, Peter Maydell wrote:
>> On Wed, 18 Mar 2026 at 14:15, Trieu Huynh <vikingtc4@gmail.com> wrote:
>>>
>>> Check the return value of get_image_size() and report failures
>>> for non-mandatory file such as FRU image.
>
> Yes, this makes sense. You want to do this through my tree, or do you
> have another way you want to get it in?
Merged via hw-misc tree, thanks!
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-03-24 14:45 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-18 14:14 [PATCH v3 0/4] Fix error handling for callers of load_image_targphys, get_image_size, event_notifier_init, msix_init Trieu Huynh
2026-03-18 14:14 ` [PATCH v3 1/4] hw/core/loader: fix error handling for load_image_targphys callers Trieu Huynh
2026-03-19 17:54 ` Peter Maydell
2026-03-18 14:14 ` [PATCH v3 2/4] hw/core/loader: fix error handling for get_image_size callers Trieu Huynh
2026-03-19 18:04 ` Peter Maydell
2026-03-19 18:29 ` Corey Minyard
2026-03-24 14:44 ` Philippe Mathieu-Daudé
2026-03-18 14:14 ` [PATCH v3 3/4] util/event_notifier: fix error handling for event_notifier_init callers Trieu Huynh
2026-03-18 14:14 ` [PATCH v3 4/4] hw/pci/msix: fix error handling for msix_init callers Trieu Huynh
2026-03-19 18:02 ` Peter Maydell
2026-03-24 14:41 ` [PATCH v3 0/4] Fix error handling for callers of load_image_targphys, get_image_size, event_notifier_init, msix_init Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox