@samitouri / QOSamiQemu / commits / acfbe07619

hw/nmi: Remove unused @errp argument from raise_nmi()

Not a single handler update @errp. The single user is nmi_inject() filling with "machine does not provide NMIs". Remove the unused argument from the raise_nmi() callback, simplifying the methods in hw/core/nmi.c. Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20260812121232.71958-7-philmd@oss.qualcomm.com>

Philippe Mathieu-Daudé committed Aug 11, 2026 at 12:24 UTC acfbe07619b533238a376ee1dc4cdced56cb3a95
10 files changed +15 -36
hw/core/nmi.c
+6 -26
@@ -23,45 +23,25 @@
23 #include "hw/core/nmi.h"
24 #include "qapi/error.h"
25
26 -struct do_nmi_s {
27 - Error *err;
28 - bool handled;
29 -};
30 -
26 static int do_nmi(Object *o, void *opaque)
27 {
33 - struct do_nmi_s *ns = opaque;
28 + bool *handled = opaque;
29 NMIState *n = (NMIState *) object_dynamic_cast(o, TYPE_NMI);
30
31 if (n) {
37 - NMIClass *nc = NMI_GET_CLASS(n);
38 -
39 - ns->handled = true;
40 - nc->raise_nmi(n, &ns->err);
41 - if (ns->err) {
42 - return -1;
43 - }
32 + *handled = true;
33 + NMI_GET_CLASS(n)->raise_nmi(n);
34 }
35
36 return 0;
37 }
38
49 -static int nmi_children(Object *o, struct do_nmi_s *ns)
50 -{
51 - return object_child_foreach_recursive(o, do_nmi, ns);
52 -}
53 -
39 bool nmi_inject(Error **errp)
40 {
56 - struct do_nmi_s ns = {
57 - .err = NULL,
58 - .handled = false
59 - };
41 + bool handled = false;
42
61 - if (nmi_children(object_get_root(), &ns)) {
62 - error_propagate(errp, ns.err);
63 - return false;
64 - } else if (!ns.handled) {
43 + object_child_foreach_recursive(object_get_root(), do_nmi, &handled);
44 + if (!handled) {
45 error_setg(errp, "machine does not provide NMIs");
46 return false;
47 }
hw/hppa/machine.c
+1 -1
@@ -829,7 +829,7 @@ static void hppa_machine_reset(MachineState *ms, ResetType type)
829 cpu[0]->env.cmdline_or_bootorder = 'c';
830 }
831
832 -static void hppa_nmi(NMIState *ns, Error **errp)
832 +static void hppa_nmi(NMIState *ns)
833 {
834 CPUState *cs;
835
hw/i386/x86.c
+1 -1
@@ -147,7 +147,7 @@ static const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms)
147 return ms->possible_cpus;
148 }
149
150 -static void x86_nmi(NMIState *ns, Error **errp)
150 +static void x86_nmi(NMIState *ns)
151 {
152 /* cpu index isn't used */
153 CPUState *cs;
hw/intc/m68k_irqc.c
+1 -1
@@ -70,7 +70,7 @@ static void m68k_irqc_instance_init(Object *obj)
70 qdev_init_gpio_in(DEVICE(obj), m68k_set_irq, M68K_IRQC_LEVEL_NUM);
71 }
72
73 -static void m68k_nmi(NMIState *n, Error **errp)
73 +static void m68k_nmi(NMIState *n)
74 {
75 m68k_set_irq(n, M68K_IRQC_LEVEL_7, 1);
76 }
hw/m68k/q800-glue.c
+1 -1
@@ -159,7 +159,7 @@ static void glue_auxmode_set_irq(void *opaque, int irq, int level)
159 s->auxmode = level;
160 }
161
162 -static void glue_nmi(NMIState *n, Error **errp)
162 +static void glue_nmi(NMIState *n)
163 {
164 GLUEState *s = GLUE(n);
165
hw/misc/macio/gpio.c
+1 -1
@@ -188,7 +188,7 @@ static void macio_gpio_reset(DeviceState *dev)
188 macio_set_gpio(s, 1, true);
189 }
190
191 -static void macio_gpio_nmi(NMIState *n, Error **errp)
191 +static void macio_gpio_nmi(NMIState *n)
192 {
193 macio_set_gpio(MACIO_GPIO(n), 9, true);
194 macio_set_gpio(MACIO_GPIO(n), 9, false);
hw/ppc/pnv.c
+1 -1
@@ -3552,7 +3552,7 @@ static void pnv_cpu_do_nmi(PnvChip *chip, PowerPCCPU *cpu, void *opaque)
3552 async_run_on_cpu(CPU(cpu), pnv_cpu_do_nmi_on_cpu, RUN_ON_CPU_HOST_INT(0));
3553 }
3554
3555 -static void pnv_nmi(NMIState *ns, Error **errp)
3555 +static void pnv_nmi(NMIState *ns)
3556 {
3557 PnvMachineState *pnv = PNV_MACHINE(qdev_get_machine());
3558 int i;
hw/ppc/spapr.c
+1 -1
@@ -3550,7 +3550,7 @@ void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg)
3550 }
3551 }
3552
3553 -static void spapr_nmi(NMIState *ns, Error **errp)
3553 +static void spapr_nmi(NMIState *ns)
3554 {
3555 CPUState *cs;
3556
hw/s390x/s390-virtio-ccw.c
+1 -1
@@ -725,7 +725,7 @@ static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,
725 return NULL;
726 }
727
728 -static void s390_nmi(NMIState *ns, Error **errp)
728 +static void s390_nmi(NMIState *ns)
729 {
730 s390_cpu_restart(S390_CPU(first_cpu));
731 }
include/hw/core/nmi.h
+1 -2
@@ -40,12 +40,11 @@ struct NMIClass {
40 /**
41 * raise_nmi: Callback to handle NMI notifications.
42 * @ns: Class #NMIState state
43 - * @errp: pointer to error object
43 *
44 * Called by nmi_inject() to perform the machine-specific
45 * action when a NMI is requested.
46 */
48 - void (*raise_nmi)(NMIState *ns, Error **errp);
47 + void (*raise_nmi)(NMIState *ns);
48 };
49
50 /**