diff mbox series

[14/18] cpu: Introduce cpu_is_paused()

Message ID 20240923162208.90745-15-iii@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series Stop all qemu-cpu threads on a breakpoint | expand

Commit Message

Ilya Leoshkevich Sept. 23, 2024, 4:13 p.m. UTC
A qemu-system CPU is considered paused as a result of an external
request. A qemu-user CPU, in addition to that, should be considered
paused when it's executing a syscall.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 accel/tcg/user-exec.c     | 5 +++++
 include/exec/cpu-common.h | 1 +
 system/cpus.c             | 7 ++++++-
 3 files changed, 12 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
index 57a13c81fc4..de4753cded7 100644
--- a/accel/tcg/user-exec.c
+++ b/accel/tcg/user-exec.c
@@ -1329,3 +1329,8 @@  bool cpu_thread_is_idle(CPUState *cpu)
 
     return ret == -1 ? true : ret;
 }
+
+bool cpu_is_paused(CPUState *cpu)
+{
+    return cpu->stopped || cpu->in_syscall;
+}
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index d7fc24bc13d..e8b530ed889 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -233,6 +233,7 @@  void cpu_exit_syscall(CPUState *cs);
 
 int cpu_thread_is_idle_common(CPUState *cpu);
 bool cpu_thread_is_idle(CPUState *cpu);
+bool cpu_is_paused(CPUState *cpu);
 
 /**
  * env_archcpu(env)
diff --git a/system/cpus.c b/system/cpus.c
index 13072be26fa..407140c41f6 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -530,12 +530,17 @@  void cpu_resume(CPUState *cpu)
     qemu_cpu_kick(cpu);
 }
 
+bool cpu_is_paused(CPUState *cpu)
+{
+    return cpu->stopped;
+}
+
 static bool all_vcpus_paused(void)
 {
     CPUState *cpu;
 
     CPU_FOREACH(cpu) {
-        if (!cpu->stopped) {
+        if (!cpu_is_paused(cpu)) {
             return false;
         }
     }