From: Glauber Costa <glommer@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com
Subject: [Qemu-devel] [PATCH] provide cpu_index to env mapping
Date: Tue, 9 Jun 2009 12:15:18 -0400 [thread overview]
Message-ID: <1244564118-428-1-git-send-email-glommer@redhat.com> (raw)
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>
---
cpu-all.h | 1 +
exec.c | 13 +++++++++++++
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/cpu-all.h b/cpu-all.h
index dc9b034..8990be3 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -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, ...),
diff --git a/exec.c b/exec.c
index 52f4e89..6c26cb6 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;
--
1.5.6.6
next reply other threads:[~2009-06-09 16:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-09 16:15 Glauber Costa [this message]
2009-06-09 16:25 ` [Qemu-devel] [PATCH] provide cpu_index to env mapping Avi Kivity
2009-06-09 16:40 ` Glauber Costa
2009-06-09 16:42 ` Avi Kivity
2009-06-09 16:52 ` Glauber Costa
2009-06-09 16:46 ` Gleb Natapov
2009-06-09 16:45 ` Gleb Natapov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1244564118-428-1-git-send-email-glommer@redhat.com \
--to=glommer@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).