Skip to contentSkip to conversation

provide cpu_index to env mapping

PATCH In review Glauber Costa 3 participants 7 messages Jun 9, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 cpu-all.h |    1 +
 exec.c    |   13 +++++++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)
cpu-all.h +1 -0
index dc9b034..8990be3 100644
@@ -741,6 +741,7 @@ int page_check_range(target_ulong start, target_ulong len, int flags);
 
 void cpu_exec_init_all(unsigned long tb_size);
 CPUState *cpu_copy(CPUState *env);
+CPUState *qemu_get_cpu(int cpu);
 
 void cpu_dump_state(CPUState *env, FILE *f,
                     int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
exec.c +13 -0
index 52f4e89..6c26cb6 100644
@@ -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;
Signature · 1 line
1.5.6.6
#1 lore raw
Quoted 5 lines · Glauber Costa

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.

I think it's better to migrate kvm towards using env as the handle instead of the cpu index.

kvm will soon address lose its cpu numbering in favor of apic ids; and apic ids will not start from zero on large guests.

Signature · 1 line
error compiling committee.c: too many arguments to function
#2 lore raw
Quoted 9 lines · Avi Kivity
Quoted 5 lines · Glauber Costa

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.

I think it's better to migrate kvm towards using env as the handle instead of the cpu index.

btw: the particular user of this is cpu hotplug.

#3 lore raw
Quoted 10 lines · Glauber Costa
Quoted 8 lines · Avi Kivity
Quoted 6 lines · Glauber Costa

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.

Quoted 4 lines
Quoted 2 lines

I think it's better to migrate kvm towards using env as the handle instead of the cpu index.

btw: the particular user of this is cpu hotplug.

Well, cpu hotplug should definitely use the apic id.

Signature · 1 line
error compiling committee.c: too many arguments to function
#4 lore raw
Quoted 10 lines · Avi Kivity
Quoted 9 lines · Glauber Costa
Quoted 7 lines · Avi Kivity
Quoted 5 lines · Glauber Costa

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.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

I think it's better to migrate kvm towards using env as the handle instead of the cpu index.

btw: the particular user of this is cpu hotplug.

Well, cpu hotplug should definitely use the apic id.

yes.

#5 lore raw
In reply to Glauber Costa
Quoted 8 lines · Glauber Costa
Quoted 7 lines · Avi Kivity
Quoted 5 lines · Glauber Costa

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.

Quoted 4 lines
Quoted 2 lines

I think it's better to migrate kvm towards using env as the handle instead of the cpu index.

btw: the particular user of this is cpu hotplug.

cpu hotplug can use apic ids too.

--
Gleb.

#6 lore raw
In reply to Avi Kivity
Quoted 7 lines · Avi Kivity
Quoted 5 lines · Glauber Costa

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.

Quoted 6 lines

I think it's better to migrate kvm towards using env as the handle instead of the cpu index.

kvm will soon address lose its cpu numbering in favor of apic ids; and apic ids will not start from zero on large guests.

The work is almost done.

--
Gleb.