diff mbox

[2/5] QMP: add inject-nmi qmp command

Message ID 1306943645-20313-3-git-send-email-lcapitulino@redhat.com
State New
Headers show

Commit Message

Luiz Capitulino June 1, 2011, 3:54 p.m. UTC
From: Lai Jiangshan <laijs@cn.fujitsu.com>

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: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c       |   17 +++++++++++++++++
 qmp-commands.hx |   27 +++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 0 deletions(-)

Comments

Blue Swirl June 4, 2011, 8:34 a.m. UTC | #1
On Wed, Jun 1, 2011 at 6:54 PM, Luiz Capitulino <lcapitulino@redhat.com> wrote:
> From: Lai Jiangshan <laijs@cn.fujitsu.com>
>
> 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.

Please rename the command to 'x-inject-nmi' to point out that it will
be replaced by a generic method later.

> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
>  monitor.c       |   17 +++++++++++++++++
>  qmp-commands.hx |   27 +++++++++++++++++++++++++++
>  2 files changed, 44 insertions(+), 0 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index f63cce0..81d3c9b 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -2555,6 +2555,23 @@ static void do_inject_nmi(Monitor *mon, const QDict *qdict)
>             break;
>         }
>  }
> +
> +static int do_inject_nmi_all(Monitor *mon, const QDict *qdict, QObject **ret_data)
> +{
> +    CPUState *env;
> +
> +    for (env = first_cpu; env != NULL; env = env->next_cpu) {
> +        cpu_interrupt(env, CPU_INTERRUPT_NMI);
> +    }
> +
> +    return 0;
> +}
> +#else
> +static int do_inject_nmi_all(Monitor *mon, const QDict *qdict, QObject **ret_data)
> +{
> +    qerror_report(QERR_UNSUPPORTED);
> +    return -1;
> +}
>  #endif
>
>  static void do_info_status_print(Monitor *mon, const QObject *data)
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index a9f109a..ae08b7a 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -430,6 +430,33 @@ Example:
>  EQMP
>
>     {
> +        .name       = "inject-nmi",
> +        .args_type  = "",
> +        .params     = "",
> +        .help       = "",
> +        .user_print = monitor_user_noop,
> +        .mhandler.cmd_new = do_inject_nmi_all,
> +    },
> +
> +SQMP
> +inject-nmi
> +----------
> +
> +Inject an NMI on guest's CPUs.
> +
> +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.4
>
>
>
Luiz Capitulino June 6, 2011, 2:17 p.m. UTC | #2
On Sat, 4 Jun 2011 11:34:17 +0300
Blue Swirl <blauwirbel@gmail.com> wrote:

> On Wed, Jun 1, 2011 at 6:54 PM, Luiz Capitulino <lcapitulino@redhat.com> wrote:
> > From: Lai Jiangshan <laijs@cn.fujitsu.com>
> >
> > 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.
> 
> Please rename the command to 'x-inject-nmi' to point out that it will
> be replaced by a generic method later.

Won't the generic interface be called 'inject'? In that case calling this
command 'inject-nmi' makes sense as it's exactly what the command does and
in the future it can be written in terms of the new 'inject' command.

> 
> > Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> > ---
> >  monitor.c       |   17 +++++++++++++++++
> >  qmp-commands.hx |   27 +++++++++++++++++++++++++++
> >  2 files changed, 44 insertions(+), 0 deletions(-)
> >
> > diff --git a/monitor.c b/monitor.c
> > index f63cce0..81d3c9b 100644
> > --- a/monitor.c
> > +++ b/monitor.c
> > @@ -2555,6 +2555,23 @@ static void do_inject_nmi(Monitor *mon, const QDict *qdict)
> >             break;
> >         }
> >  }
> > +
> > +static int do_inject_nmi_all(Monitor *mon, const QDict *qdict, QObject **ret_data)
> > +{
> > +    CPUState *env;
> > +
> > +    for (env = first_cpu; env != NULL; env = env->next_cpu) {
> > +        cpu_interrupt(env, CPU_INTERRUPT_NMI);
> > +    }
> > +
> > +    return 0;
> > +}
> > +#else
> > +static int do_inject_nmi_all(Monitor *mon, const QDict *qdict, QObject **ret_data)
> > +{
> > +    qerror_report(QERR_UNSUPPORTED);
> > +    return -1;
> > +}
> >  #endif
> >
> >  static void do_info_status_print(Monitor *mon, const QObject *data)
> > diff --git a/qmp-commands.hx b/qmp-commands.hx
> > index a9f109a..ae08b7a 100644
> > --- a/qmp-commands.hx
> > +++ b/qmp-commands.hx
> > @@ -430,6 +430,33 @@ Example:
> >  EQMP
> >
> >     {
> > +        .name       = "inject-nmi",
> > +        .args_type  = "",
> > +        .params     = "",
> > +        .help       = "",
> > +        .user_print = monitor_user_noop,
> > +        .mhandler.cmd_new = do_inject_nmi_all,
> > +    },
> > +
> > +SQMP
> > +inject-nmi
> > +----------
> > +
> > +Inject an NMI on guest's CPUs.
> > +
> > +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.4
> >
> >
> >
>
Blue Swirl June 12, 2011, 9:22 p.m. UTC | #3
On Mon, Jun 6, 2011 at 5:17 PM, Luiz Capitulino <lcapitulino@redhat.com> wrote:
> On Sat, 4 Jun 2011 11:34:17 +0300
> Blue Swirl <blauwirbel@gmail.com> wrote:
>
>> On Wed, Jun 1, 2011 at 6:54 PM, Luiz Capitulino <lcapitulino@redhat.com> wrote:
>> > From: Lai Jiangshan <laijs@cn.fujitsu.com>
>> >
>> > 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.
>>
>> Please rename the command to 'x-inject-nmi' to point out that it will
>> be replaced by a generic method later.
>
> Won't the generic interface be called 'inject'? In that case calling this
> command 'inject-nmi' makes sense as it's exactly what the command does and
> in the future it can be written in terms of the new 'inject' command.

This is a bit useless since the patch was committed, but I was pointed
out that 'inject' wasn't so great name, 'raise/lower/pulse' should
have been more precise. But I guess we can live with yet another poor
interface, so who cares what the name is.
diff mbox

Patch

diff --git a/monitor.c b/monitor.c
index f63cce0..81d3c9b 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2555,6 +2555,23 @@  static void do_inject_nmi(Monitor *mon, const QDict *qdict)
             break;
         }
 }
+
+static int do_inject_nmi_all(Monitor *mon, const QDict *qdict, QObject **ret_data)
+{
+    CPUState *env;
+
+    for (env = first_cpu; env != NULL; env = env->next_cpu) {
+        cpu_interrupt(env, CPU_INTERRUPT_NMI);
+    }
+
+    return 0;
+}
+#else
+static int do_inject_nmi_all(Monitor *mon, const QDict *qdict, QObject **ret_data)
+{
+    qerror_report(QERR_UNSUPPORTED);
+    return -1;
+}
 #endif
 
 static void do_info_status_print(Monitor *mon, const QObject *data)
diff --git a/qmp-commands.hx b/qmp-commands.hx
index a9f109a..ae08b7a 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -430,6 +430,33 @@  Example:
 EQMP
 
     {
+        .name       = "inject-nmi",
+        .args_type  = "",
+        .params     = "",
+        .help       = "",
+        .user_print = monitor_user_noop,
+        .mhandler.cmd_new = do_inject_nmi_all,
+    },
+
+SQMP
+inject-nmi
+----------
+
+Inject an NMI on guest's CPUs.
+
+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",