Skip to contentSkip to conversation

cpus: Fix pausing TCG CPUs while in vCPU thread

PATCH In review Andreas Färber 2 participants 3 messages May 2, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpus: Fix pausing TCG CPUs while in vCPU thread

Due to a preceding while loop, no CPU would've been put into stopped state. Reinitialize the variable.
This fixes commit d798e97456658ea7605303b7c69b04ec7df95c10 (Allow to use pause_all_vcpus from VCPU context) for non-KVM case.

While at it, change a 0 to false, amending commit 4fdeee7cd4c8f90ef765537b9346a195d9483ab5 (cpu: Move stop field to CPUState).

---
For 1.5 I'm going for the least invasive change here.
On qom-cpu-10 I'm preparing to replace each CPU loop with qemu_for_each_cpu().

 cpus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
cpus.c +2 -1
index a2d92c7..c232265 100644
@@ -974,9 +974,10 @@ void pause_all_vcpus(void)
     if (qemu_in_vcpu_thread()) {
         cpu_stop_current();
         if (!kvm_enabled()) {
+            penv = first_cpu;
             while (penv) {
                 CPUState *pcpu = ENV_GET_CPU(penv);
-                pcpu->stop = 0;
+                pcpu->stop = false;
                 pcpu->stopped = true;
                 penv = penv->next_cpu;
             }
Signature · 1 line
1.8.1.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Andreas Färber

Due to a preceding while loop, no CPU would've been put into stopped state. Reinitialize the variable.
This fixes commit d798e97456658ea7605303b7c69b04ec7df95c10 (Allow to use pause_all_vcpus from VCPU context) for non-KVM case.

While at it, change a 0 to false, amending commit 4fdeee7cd4c8f90ef765537b9346a195d9483ab5 (cpu: Move stop field to CPUState).

---
For 1.5 I'm going for the least invasive change here.
On qom-cpu-10 I'm preparing to replace each CPU loop with qemu_for_each_cpu().

 cpus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
cpus.c +0 -0
index a2d92c7..c232265 100644
@@ -974,9 +974,10 @@ void pause_all_vcpus(void)
     if (qemu_in_vcpu_thread()) {

cpus.c void pause_all_vcpus(void) · line 983

Quoted 10 lines
cpus.c +2 -1
         cpu_stop_current();
         if (!kvm_enabled()) {
+            penv = first_cpu;
             while (penv) {
                 CPUState *pcpu = ENV_GET_CPU(penv);
-                pcpu->stop = 0;
+                pcpu->stop = false;
                 pcpu->stopped = true;
                 penv = penv->next_cpu;
             }

Thanks,
Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux
author Applied
#2 lore raw

Am 02.05.2013 12:14, schrieb Jan Kiszka:

Quoted 29 lines · Andreas Färber
Quoted 28 lines

Due to a preceding while loop, no CPU would've been put into stopped state. Reinitialize the variable.
This fixes commit d798e97456658ea7605303b7c69b04ec7df95c10 (Allow to use pause_all_vcpus from VCPU context) for non-KVM case.

While at it, change a 0 to false, amending commit 4fdeee7cd4c8f90ef765537b9346a195d9483ab5 (cpu: Move stop field to CPUState).

---
For 1.5 I'm going for the least invasive change here.
On qom-cpu-10 I'm preparing to replace each CPU loop with qemu_for_each_cpu().

 cpus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
cpus.c +1 -0
index a2d92c7..c232265 100644
@@ -974,9 +974,10 @@ void pause_all_vcpus(void)
     if (qemu_in_vcpu_thread()) {
         cpu_stop_current();
         if (!kvm_enabled()) {
+            penv = first_cpu;
             while (penv) {
                 CPUState *pcpu = ENV_GET_CPU(penv);
Quoted 8 lines

cpus.c void pause_all_vcpus(void) · line 983

Quoted 6 lines
cpus.c +1 -1
-                pcpu->stop = 0;
+                pcpu->stop = false;
                 pcpu->stopped = true;
                 penv = penv->next_cpu;
             }

Thanks, applied to qom-cpu:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg