From: Glauber Costa <glommer@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com
Subject: [Qemu-devel] [PATCH] Provide a general purpose way of probing if cpus are stopped
Date: Mon, 20 Jul 2009 19:12:28 -0400 [thread overview]
Message-ID: <1248131548-11428-1-git-send-email-glommer@redhat.com> (raw)
We don't have anything that requires that in tree yet, but avi does.
So Let's be nice with him, and provide him with those functions that diminish
the amount of kvm-specific code.
Signed-off-by: Glauber Costa <glommer@redhat.com>
---
cpu-all.h | 3 +++
exec.c | 22 ++++++++++++++++++++++
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/cpu-all.h b/cpu-all.h
index df3aa2e..6801938 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -741,6 +741,9 @@ int page_get_flags(target_ulong address);
void page_set_flags(target_ulong start, target_ulong end, int flags);
int page_check_range(target_ulong start, target_ulong len, int flags);
+int qemu_cpu_stopped(CPUState *env);
+uint32_t qemu_cpus_running(void);
+
void cpu_exec_init_all(unsigned long tb_size);
CPUState *cpu_copy(CPUState *env);
CPUState *qemu_get_cpu(int cpu);
diff --git a/exec.c b/exec.c
index d6e5d3c..2e5f05a 100644
--- a/exec.c
+++ b/exec.c
@@ -32,6 +32,7 @@
#include <unistd.h>
#include <inttypes.h>
+#include "sysemu.h"
#include "cpu.h"
#include "exec-all.h"
#include "qemu-common.h"
@@ -558,6 +559,27 @@ CPUState *qemu_get_cpu(int cpu)
return env;
}
+int qemu_cpu_stopped(CPUState *env)
+{
+ return !vm_running || env->stopped;
+}
+
+/* Returns the number of cpus that are in the stopped state.
+ * It is a 32-bit value, because if it weren't SGI would */
+uint32_t qemu_cpus_running(void)
+{
+ uint32_t count = 0;
+
+ if (!vm_running)
+ return count;
+
+ CPUState *penv = first_cpu;
+ while (penv) {
+ count += !penv->stopped;
+ }
+ return count;
+}
+
void cpu_exec_init(CPUState *env)
{
CPUState **penv;
--
1.6.2.2
next reply other threads:[~2009-07-20 23:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-20 23:12 Glauber Costa [this message]
2009-07-22 13:02 ` [Qemu-devel] [PATCH] Provide a general purpose way of probing if cpus are stopped Anthony Liguori
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=1248131548-11428-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).