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@xxxxxxxxxxxxxx> --- qapi-schema.json | 12 ++++++++++++ qmp.c | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 0 deletions(-) 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 -- 1.7.4 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html