diff mbox

[RFC,2/3,V8] qapi,nmi: add inject-nmi qmp command

Message ID 4DAE7AFA.6030703@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lai Jiangshan April 20, 2011, 6:19 a.m. UTC
inject-nmi command injects an NMI on all CPUs of guest.
It is only supported for x86 guest currently, it will
returns "Unsupported" error for non-x86 guest.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 qapi-schema.json |   12 ++++++++++++
 qmp.c            |   17 +++++++++++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/qapi-schema.json b/qapi-schema.json
index de6c9a3..6a94d78 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1498,3 +1498,15 @@ 
 # Since: 0.14.0
 ##
 { 'option': 'vnc', 'data': 'VncConfig', 'implicit': 'address' }
+
+##
+# @inject-nmi:
+#
+# Inject an NMI on the guest.
+#
+# Returns: Nothing on success.
+#          If the guest(non-x86) does not support NMI injection, Unsupported
+#
+# Since: 0.15.0
+##
+{ 'command': 'inject-nmi' }
diff --git a/qmp.c b/qmp.c
index 9fdde8f..dac411a 100644
--- a/qmp.c
+++ b/qmp.c
@@ -379,3 +379,20 @@  StatusInfo *qmp_query_status(Error **errp)
 
     return info;
 }
+
+#if defined(TARGET_I386)
+void qmp_inject_nmi(Error **errp)
+{
+    CPUState *env;
+
+    for (env = first_cpu; env != NULL; env = env->next_cpu) {
+        cpu_interrupt(env, CPU_INTERRUPT_NMI);
+    }
+}
+#else
+void qmp_inject_nmi(Error **errp)
+{
+    error_set(errp, QERR_UNSUPPORTED,
+              "Injecting NMI is unsupported for the non-x86 guest");
+}
+#endif