diff mbox

[4/4] cpus: call the core nmi injection function

Message ID 1463696116-31631-5-git-send-email-bsd@redhat.com
State New
Headers show

Commit Message

Bandan Das May 19, 2016, 10:15 p.m. UTC
Now that the common functions are in place, we can call it
instead of duplicating code.

Signed-off-by: Bandan Das <bsd@redhat.com>
---
 cpus.c | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

Comments

Paolo Bonzini May 20, 2016, 7:50 a.m. UTC | #1
On 20/05/2016 00:15, Bandan Das wrote:
>  void qmp_inject_nmi(Error **errp)
>  {
> -#if defined(TARGET_I386)
> -    CPUState *cs;
> -
> -    CPU_FOREACH(cs) {
> -        X86CPU *cpu = X86_CPU(cs);
> -
> -        if (!cpu->apic_state) {
> -            cpu_interrupt(cs, CPU_INTERRUPT_NMI);
> -        } else {
> -            apic_deliver_nmi(cpu->apic_state);
> -        }
> -    }
> -#else
> -    nmi_monitor_handle(monitor_get_cpu_index(), errp);
> -#endif
> +    inject_nmi(errp);

This changes the first argument to nmi_monitor_handle in the !i386 case.
 It should just remove the #ifdef, which I think makes the third patch
unnecessary.  The first two patches are okay.

Paolo
Paolo Bonzini May 20, 2016, 7:50 a.m. UTC | #2
On 20/05/2016 00:15, Bandan Das wrote:
>  void qmp_inject_nmi(Error **errp)
>  {
> -#if defined(TARGET_I386)
> -    CPUState *cs;
> -
> -    CPU_FOREACH(cs) {
> -        X86CPU *cpu = X86_CPU(cs);
> -
> -        if (!cpu->apic_state) {
> -            cpu_interrupt(cs, CPU_INTERRUPT_NMI);
> -        } else {
> -            apic_deliver_nmi(cpu->apic_state);
> -        }
> -    }
> -#else
> -    nmi_monitor_handle(monitor_get_cpu_index(), errp);
> -#endif
> +    inject_nmi(errp);

This changes the first argument to nmi_monitor_handle in the !i386 case.
 It should just remove the #ifdef, which I think makes the third patch
unnecessary.  The first two patches are okay.

Paolo
Bandan Das May 20, 2016, 4:29 p.m. UTC | #3
Paolo Bonzini <pbonzini@redhat.com> writes:

> On 20/05/2016 00:15, Bandan Das wrote:
>>  void qmp_inject_nmi(Error **errp)
>>  {
>> -#if defined(TARGET_I386)
>> -    CPUState *cs;
>> -
>> -    CPU_FOREACH(cs) {
>> -        X86CPU *cpu = X86_CPU(cs);
>> -
>> -        if (!cpu->apic_state) {
>> -            cpu_interrupt(cs, CPU_INTERRUPT_NMI);
>> -        } else {
>> -            apic_deliver_nmi(cpu->apic_state);
>> -        }
>> -    }
>> -#else
>> -    nmi_monitor_handle(monitor_get_cpu_index(), errp);
>> -#endif
>> +    inject_nmi(errp);
>
> This changes the first argument to nmi_monitor_handle in the !i386 case.
>  It should just remove the #ifdef, which I think makes the third patch
> unnecessary.  The first two patches are okay.

Thanks for the review, I have sent a v2.

> Paolo
diff mbox

Patch

diff --git a/cpus.c b/cpus.c
index eb34b4f..ead4e3f 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1693,21 +1693,7 @@  exit:
 
 void qmp_inject_nmi(Error **errp)
 {
-#if defined(TARGET_I386)
-    CPUState *cs;
-
-    CPU_FOREACH(cs) {
-        X86CPU *cpu = X86_CPU(cs);
-
-        if (!cpu->apic_state) {
-            cpu_interrupt(cs, CPU_INTERRUPT_NMI);
-        } else {
-            apic_deliver_nmi(cpu->apic_state);
-        }
-    }
-#else
-    nmi_monitor_handle(monitor_get_cpu_index(), errp);
-#endif
+    inject_nmi(errp);
 }
 
 void dump_drift_info(FILE *f, fprintf_function cpu_fprintf)