[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 19/21] add next_cpu_index
From: |
Glauber Costa |
Subject: |
[Qemu-devel] [PATCH 19/21] add next_cpu_index |
Date: |
Wed, 15 Oct 2008 19:55:16 -0200 |
From: Glauber Costa <address@hidden>
separate the logic for calculating the next cpu index
from cpu creation. It will allow others to query what's
the next cpu index to be created before cpu creation.
Signed-off-by: Glauber Costa <address@hidden>
---
exec.c | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/exec.c b/exec.c
index bd2a26f..7710564 100644
--- a/exec.c
+++ b/exec.c
@@ -526,25 +526,31 @@ static int cpu_common_load(QEMUFile *f, void *opaque, int
version_id)
}
#endif
-void cpu_exec_init(CPUState *env)
+int next_cpu_index(void)
{
CPUState **penv;
- int cpu_index;
+ int cpu_index = 0;
- env->next_cpu = NULL;
penv = &first_cpu;
- cpu_index = 0;
+
while (*penv != NULL) {
penv = (CPUState **)&(*penv)->next_cpu;
cpu_index++;
}
- env->cpu_index = cpu_index;
+ return cpu_index;
+}
+
+void cpu_exec_init(CPUState *env)
+{
+ env->next_cpu = NULL;
+ env->cpu_index = next_cpu_index();
env->nb_watchpoints = 0;
- *penv = env;
+ if (env->cpu_index == 0)
+ first_cpu = env;
#if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY)
- register_savevm("cpu_common", cpu_index, CPU_COMMON_SAVE_VERSION,
+ register_savevm("cpu_common", env->cpu_index, CPU_COMMON_SAVE_VERSION,
cpu_common_save, cpu_common_load, env);
- register_savevm("cpu", cpu_index, CPU_SAVE_VERSION,
+ register_savevm("cpu", env->cpu_index, CPU_SAVE_VERSION,
cpu_save, cpu_load, env);
#endif
}
--
1.5.5.1
- [Qemu-devel] [PATCH 12/21] build list of available accelerators, (continued)
- [Qemu-devel] [PATCH 12/21] build list of available accelerators, Glauber Costa, 2008/10/15
- [Qemu-devel] [PATCH 13/21] provide --accel option, Glauber Costa, 2008/10/15
- [Qemu-devel] [PATCH 14/21] add tsc field to cpu definition, Glauber Costa, 2008/10/15
- [Qemu-devel] [PATCH 15/21] shift for masks., Glauber Costa, 2008/10/15
- [Qemu-devel] [PATCH 16/21] add hook to cpu_register_physical_memory, Glauber Costa, 2008/10/15
- [Qemu-devel] [PATCH 18/21] get_env accel wrapper, Glauber Costa, 2008/10/15
- [Qemu-devel] [PATCH 17/21] accel_trace_io, Glauber Costa, 2008/10/15
- [Qemu-devel] [PATCH 19/21] add next_cpu_index,
Glauber Costa <=
- [Qemu-devel] [PATCH 20/21] check wether kqemu is enabled in open code, Glauber Costa, 2008/10/15
- [Qemu-devel] [PATCH 21/21] provide an opaque for accelerator in cpu state, Glauber Costa, 2008/10/15
- [Qemu-devel] Re: [PATCH 0/21] Accelerators: cleaned up version, Anthony Liguori, 2008/10/15