Commit 950f147249643635289003d7dd291915ad330b29

Authored by Glauber Costa
Committed by Anthony Liguori
1 parent 7d9aa9c0

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 <glommer@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing 2 changed files with 14 additions and 0 deletions
cpu-all.h
@@ -743,6 +743,7 @@ int page_check_range(target_ulong start, target_ulong len, int flags); @@ -743,6 +743,7 @@ int page_check_range(target_ulong start, target_ulong len, int flags);
743 743
744 void cpu_exec_init_all(unsigned long tb_size); 744 void cpu_exec_init_all(unsigned long tb_size);
745 CPUState *cpu_copy(CPUState *env); 745 CPUState *cpu_copy(CPUState *env);
  746 +CPUState *qemu_get_cpu(int cpu);
746 747
747 void cpu_dump_state(CPUState *env, FILE *f, 748 void cpu_dump_state(CPUState *env, FILE *f,
748 int (*cpu_fprintf)(FILE *f, const char *fmt, ...), 749 int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
@@ -541,6 +541,19 @@ static int cpu_common_load(QEMUFile *f, void *opaque, int version_id) @@ -541,6 +541,19 @@ static int cpu_common_load(QEMUFile *f, void *opaque, int version_id)
541 } 541 }
542 #endif 542 #endif
543 543
  544 +CPUState *qemu_get_cpu(int cpu)
  545 +{
  546 + CPUState *env = first_cpu;
  547 +
  548 + while (env) {
  549 + if (env->cpu_index == cpu)
  550 + break;
  551 + env = env->next_cpu;
  552 + }
  553 +
  554 + return env;
  555 +}
  556 +
544 void cpu_exec_init(CPUState *env) 557 void cpu_exec_init(CPUState *env)
545 { 558 {
546 CPUState **penv; 559 CPUState **penv;