Patchwork [PULL,07/17] monitor: Simplify do_inject_mce() with qemu_get_cpu()

login
register
mail settings
Submitter Andreas Färber
Date June 13, 2013, 12:45 a.m.
Message ID <1371084329-814-8-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/250957/
State New
Headers show

Comments

Andreas Färber - June 13, 2013, 12:45 a.m.
Avoids an open-coded CPU loop.

Reviewed-by: liguang <lig.fnst@cn.fujitsu.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 monitor.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

Patch

diff --git a/monitor.c b/monitor.c
index 017411f..70ae8f5 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2013,7 +2013,6 @@  static void do_acl_remove(Monitor *mon, const QDict *qdict)
 static void do_inject_mce(Monitor *mon, const QDict *qdict)
 {
     X86CPU *cpu;
-    CPUX86State *cenv;
     CPUState *cs;
     int cpu_index = qdict_get_int(qdict, "cpu_index");
     int bank = qdict_get_int(qdict, "bank");
@@ -2026,14 +2025,11 @@  static void do_inject_mce(Monitor *mon, const QDict *qdict)
     if (qdict_get_try_bool(qdict, "broadcast", 0)) {
         flags |= MCE_INJECT_BROADCAST;
     }
-    for (cenv = first_cpu; cenv != NULL; cenv = cenv->next_cpu) {
-        cpu = x86_env_get_cpu(cenv);
-        cs = CPU(cpu);
-        if (cs->cpu_index == cpu_index) {
-            cpu_x86_inject_mce(mon, cpu, bank, status, mcg_status, addr, misc,
-                               flags);
-            break;
-        }
+    cs = qemu_get_cpu(cpu_index);
+    if (cs != NULL) {
+        cpu = X86_CPU(cs);
+        cpu_x86_inject_mce(mon, cpu, bank, status, mcg_status, addr, misc,
+                           flags);
     }
 }
 #endif