Use first_cpu directly instead of going through monitor_get_cpu_index(), as this is HMP-territory. QMP doesn't have a `cpu` command, we should add arguments instead when needed.
Update the inject-nmi doc to accurately describe per-architecture NMI delivery. Signed-off-by: Marc-André Lureau <[email protected]> --- qapi/machine.json | 5 +++-- system/cpus.c | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/qapi/machine.json b/qapi/machine.json index 685e4e29b87..03461f5f723 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -432,8 +432,9 @@ ## # @inject-nmi: # -# Injects a Non-Maskable Interrupt into the default CPU (x86/s390) or -# all CPUs (ppc64). The command fails when the guest doesn't support +# Injects a Non-Maskable Interrupt into the virtual machine. The NMI +# is delivered to all vCPUs (x86, hppa, ppc64) or to the first vCPU +# (s390). The command fails when the guest doesn't support # injecting. # # Since: 0.14 diff --git a/system/cpus.c b/system/cpus.c index bded87feb1c..0089eef9b1c 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -913,6 +913,9 @@ exit: void qmp_inject_nmi(Error **errp) { - nmi_monitor_handle(monitor_get_cpu_index(monitor_cur()), errp); + int cpu_index = UNASSIGNED_CPU_INDEX; + if (first_cpu) { + cpu_index = first_cpu->cpu_index; + } + nmi_monitor_handle(cpu_index, errp); } - -- 2.54.0
