diff mbox

[qom-cpu,33/59] kvm: Simplify kvm_remove_all_breakpoints() further

Message ID 1370805206-26574-34-git-send-email-afaerber@suse.de (mailing list archive)
State New, archived
Headers show

Commit Message

Andreas Färber June 9, 2013, 7:13 p.m. UTC
Use new qemu_for_each_cpu().

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 kvm-all.c | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/kvm-all.c b/kvm-all.c
index d5ed831..312106d 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1986,24 +1986,36 @@  int kvm_remove_breakpoint(CPUArchState *current_env, target_ulong addr,
     return 0;
 }
 
+typedef struct KVMRemoveBreakpointData {
+    struct kvm_sw_breakpoint *bp;
+    bool removed;
+} KVMRemoveBreakpointData;
+
+static void kvm_remove_all_breakpoints_one(CPUState *cpu, void *data)
+{
+    KVMRemoveBreakpointData *s = data;
+
+    if (s->removed) {
+        return;
+    }
+    s->removed = kvm_arch_remove_sw_breakpoint(cpu, s->bp) == 0;
+}
+
 void kvm_remove_all_breakpoints(CPUArchState *current_env)
 {
     CPUState *current_cpu = ENV_GET_CPU(current_env);
     struct kvm_sw_breakpoint *bp, *next;
     KVMState *s = current_cpu->kvm_state;
-    CPUArchState *env;
-    CPUState *cpu;
     int err;
 
     QTAILQ_FOREACH_SAFE(bp, &s->kvm_sw_breakpoints, entry, next) {
         if (kvm_arch_remove_sw_breakpoint(current_cpu, bp) != 0) {
             /* Try harder to find a CPU that currently sees the breakpoint. */
-            for (env = first_cpu; env != NULL; env = env->next_cpu) {
-                cpu = ENV_GET_CPU(env);
-                if (kvm_arch_remove_sw_breakpoint(cpu, bp) == 0) {
-                    break;
-                }
-            }
+            KVMRemoveBreakpointData data = {
+                .bp = bp,
+                .removed = false,
+            };
+            qemu_for_each_cpu(kvm_remove_all_breakpoints_one, &data);
         }
         QTAILQ_REMOVE(&s->kvm_sw_breakpoints, bp, entry);
         g_free(bp);