qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH qom-cpu v4 15/18] dump: Abstract dump_init() further


From: Andreas Färber
Subject: [Qemu-devel] [PATCH qom-cpu v4 15/18] dump: Abstract dump_init() further with qemu_for_each_cpu()
Date: Sun, 9 Jun 2013 18:10:44 +0200

Allows to drop CPUArchState variable.

Signed-off-by: Andreas Färber <address@hidden>
---
 dump.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/dump.c b/dump.c
index 44a1339..4e6b855 100644
--- a/dump.c
+++ b/dump.c
@@ -702,10 +702,16 @@ static ram_addr_t get_start_block(DumpState *s)
     return -1;
 }
 
+static void count_one_cpu(CPUState *cpu, void *data)
+{
+    int *nr = data;
+
+    *nr = *nr + 1;
+}
+
 static int dump_init(DumpState *s, int fd, bool paging, bool has_filter,
                      int64_t begin, int64_t length, Error **errp)
 {
-    CPUArchState *env;
     int nr_cpus;
     Error *err = NULL;
     int ret;
@@ -738,9 +744,7 @@ static int dump_init(DumpState *s, int fd, bool paging, 
bool has_filter,
      */
     cpu_synchronize_all_states();
     nr_cpus = 0;
-    for (env = first_cpu; env != NULL; env = env->next_cpu) {
-        nr_cpus++;
-    }
+    qemu_for_each_cpu(count_one_cpu, &nr_cpus);
 
     ret = cpu_get_dump_info(&s->dump_info);
     if (ret < 0) {
-- 
1.8.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]