From 950f147249643635289003d7dd291915ad330b29 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Tue, 9 Jun 2009 12:15:18 -0400 Subject: provide cpu_index to env mapping There are some people interested in, given a cpu number, pick its CPUState. KVM is an example, although not yet in tree. This patch provides a way of doing that. Signed-off-by: Glauber Costa Signed-off-by: Anthony Liguori --- exec.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'exec.c') diff --git a/exec.c b/exec.c index 3023f44184..bbaf0b6892 100644 --- a/exec.c +++ b/exec.c @@ -541,6 +541,19 @@ static int cpu_common_load(QEMUFile *f, void *opaque, int version_id) } #endif +CPUState *qemu_get_cpu(int cpu) +{ + CPUState *env = first_cpu; + + while (env) { + if (env->cpu_index == cpu) + break; + env = env->next_cpu; + } + + return env; +} + void cpu_exec_init(CPUState *env) { CPUState **penv; -- cgit v1.2.3