From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lai Jiangshan Subject: [PATCH 2/2 V9] qmp,inject-nmi: convert do_inject_nmi() to QObject Date: Thu, 28 Apr 2011 11:35:33 +0800 Message-ID: <4DB8E085.6000202@cn.fujitsu.com> References: <4D74A8C9.2020408@cn.fujitsu.com> <4D74A974.6090509@cn.fujitsu.com> <20110404105949.GA30324@redhat.com> <4D99BF99.1040305@redhat.com> <4D99C22C.4070401@codemonkey.ws> <20110406144723.45333682@doriath> <4D9CAAF9.7000509@codemonkey.ws> <20110406150818.56707b9b@doriath> <4DAE7AF4.3050508@cn.fujitsu.com> <4DAFA34A.3030701@cn.fujitsu.com> <20110426102641.71a60d81@doriath> <4DB6C8CB.7030706@codemonkey.ws> <4DB7775A.1010608@cn.fujitsu.com> <20110427113346.5bd7fcac@doriath> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Anthony Liguori , Lai Jiangshan , kvm@vger.kernel.org, qemu-devel@nongnu.org, Markus Armbruster , Avi Kivity To: Luiz Capitulino Return-path: Received: from cn.fujitsu.com ([222.73.24.84]:58437 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1756263Ab1D1Dcv (ORCPT ); Wed, 27 Apr 2011 23:32:51 -0400 In-Reply-To: <20110427113346.5bd7fcac@doriath> Sender: kvm-owner@vger.kernel.org List-ID: 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 --- hmp-commands.hx | 21 +++++++++++---------- monitor.c | 20 +++++++++++++------- qmp-commands.hx | 29 +++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 17 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 834e6a8..b511850 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -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 { diff --git a/monitor.c b/monitor.c index 5f3bc72..129eed1 100644 --- a/monitor.c +++ b/monitor.c @@ -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 diff --git a/qmp-commands.hx b/qmp-commands.hx index fbd98ee..e1b9b40 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -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", -- 1.7.4