]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
cpus: Replace open-coded CPU loop in qmp_memsave() with qemu_get_cpu()
authorAndreas Färber <afaerber@suse.de>
Fri, 15 Feb 2013 14:41:49 +0000 (15:41 +0100)
committerAndreas Färber <afaerber@suse.de>
Tue, 12 Mar 2013 09:35:54 +0000 (10:35 +0100)
No functional change, just less usages of first_cpu and next_cpu fields.

env is passed to cpu_memory_rw_debug(), which in turn passes it to
target-specific cpu_get_phys_page_debug(). Changing both would be a
larger refactoring, so defer that by using env_ptr for now.

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
cpus.c

diff --git a/cpus.c b/cpus.c
index c4b021dd2eb04ad3eed7f986eabe195f672ec66d..46355c132141db54619058e3eb25e1bdf2441b01 100644 (file)
--- a/cpus.c
+++ b/cpus.c
@@ -1241,18 +1241,13 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename,
         cpu_index = 0;
     }
 
-    for (env = first_cpu; env; env = env->next_cpu) {
-        cpu = ENV_GET_CPU(env);
-        if (cpu_index == cpu->cpu_index) {
-            break;
-        }
-    }
-
-    if (env == NULL) {
+    cpu = qemu_get_cpu(cpu_index);
+    if (cpu == NULL) {
         error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
                   "a CPU number");
         return;
     }
+    env = cpu->env_ptr;
 
     f = fopen(filename, "wb");
     if (!f) {