@@ -737,19 +737,20 @@ The values that can be specified here depend on the machine type, but are
the same that can be specified in the @code{-boot} command line option.
ETEXI
-#if defined(TARGET_I386)
{
- .name = "nmi",
- .args_type = "cpu_index:i",
- .params = "cpu",
- .help = "inject an NMI on the given CPU",
- .mhandler.cmd = do_inject_nmi,
+ .name = "inject-nmi",
+ .args_type = "",
+ .params = "",
+ .help = "Inject an NMI on guest.\n"
+ "Returns \"Unsupported\" error when the guest does"
+ "not support NMI injection",
+ .user_print = monitor_user_noop,
+ .mhandler.cmd_new = do_inject_nmi,
},
-#endif
STEXI
-@item nmi @var{cpu}
-@findex nmi
-Inject an NMI on the given CPU (x86 only).
+@item inject-nmi
+@findex inject-nmi
+Inject an NMI on the guest (x86 only).
ETEXI
{
@@ -2544,16 +2544,22 @@ static void do_wav_capture(Monitor *mon, const QDict *qdict)
#endif
#if defined(TARGET_I386)
-static void do_inject_nmi(Monitor *mon, const QDict *qdict)
+static int do_inject_nmi(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
CPUState *env;
- int cpu_index = qdict_get_int(qdict, "cpu_index");
- for (env = first_cpu; env != NULL; env = env->next_cpu)
- if (env->cpu_index == cpu_index) {
- cpu_interrupt(env, CPU_INTERRUPT_NMI);
- break;
- }
+ for (env = first_cpu; env != NULL; env = env->next_cpu) {
+ cpu_interrupt(env, CPU_INTERRUPT_NMI);
+ }
+
+ return 0;
+}
+#else
+static int do_inject_nmi(Monitor *mon, const QDict *qdict, QObject **ret_data)
+{
+ qerror_report(QERR_UNSUPPORTED,
+ "Injecting NMI is unsupported for the non-x86 guest");
+ return -1;
}
#endif
@@ -430,6 +430,35 @@ Example:
EQMP
{
+ .name = "inject-nmi",
+ .args_type = "",
+ .params = "",
+ .help = "Inject an NMI on guest.\n"
+ "Returns \"Unsupported\" error when the guest does"
+ "not support NMI injection",
+ .user_print = monitor_user_noop,
+ .mhandler.cmd_new = do_inject_nmi,
+ },
+
+SQMP
+inject-nmi
+----------
+
+Inject an NMI on guest.
+
+Arguments: None.
+
+Example:
+
+-> { "execute": "inject-nmi" }
+<- { "return": {} }
+
+Note: inject-nmi is only supported for x86 guest currently, it will
+ returns "Unsupported" error for non-x86 guest.
+
+EQMP
+
+ {
.name = "migrate",
.args_type = "detach:-d,blk:-b,inc:-i,uri:s",
.params = "[-d] [-b] [-i] uri",
Make we can inject NMI via qemu-monitor-protocol. We use "inject-nmi" for the command name, the meaning is clearer. The behavior is cheanged to "injecting NMI to all CPU" which simulates the Real hardware NMI button. The command "inject-nmi" is only supported for x86 guest currently, it will returns "Unsupported" error for non-x86 guest. This error and this behavior are described in the comments. Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> --- hmp-commands.hx | 21 +++++++++++---------- monitor.c | 20 +++++++++++++------- qmp-commands.hx | 29 +++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 17 deletions(-)