diff mbox

[41/41] cpus: create qemu_cpu_is_vcpu()

Message ID 1348217255-22441-42-git-send-email-quintela@redhat.com
State New
Headers show

Commit Message

Juan Quintela Sept. 21, 2012, 8:47 a.m. UTC
Old code used !io_thread to know if a thread was an vcpu or not.  That
fails when we introduce the iothread.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 cpus.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Paolo Bonzini Sept. 21, 2012, 12:54 p.m. UTC | #1
Il 21/09/2012 10:47, Juan Quintela ha scritto:
> Old code used !io_thread to know if a thread was an vcpu or not.  That
> fails when we introduce the iothread.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  cpus.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/cpus.c b/cpus.c
> index e476a3c..1b7061a 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -902,6 +902,11 @@ int qemu_cpu_is_self(void *_env)
>      return qemu_thread_is_self(cpu->thread);
>  }
> 
> +static bool qemu_cpu_is_vcpu(void)
> +{
> +    return cpu_single_env && qemu_cpu_is_self(&cpu_single_env);

Should be "cpu_single_env && qemu_cpu_is_self(&cpu_single_env)".

Please named the function qemu_in_vcpu_thread.

Paolo

> +}
> +
>  void qemu_mutex_lock_iothread(void)
>  {
>      if (!tcg_enabled()) {
> @@ -947,7 +952,7 @@ void pause_all_vcpus(void)
>          penv = penv->next_cpu;
>      }
> 
> -    if (!qemu_thread_is_self(&io_thread)) {
> +    if (qemu_cpu_is_vcpu()) {
>          cpu_stop_current();
>          if (!kvm_enabled()) {
>              while (penv) {
> @@ -1064,7 +1069,7 @@ void cpu_stop_current(void)
> 
>  void vm_stop(RunState state)
>  {
> -    if (!qemu_thread_is_self(&io_thread)) {
> +    if (qemu_cpu_is_vcpu()) {
>          qemu_system_vmstop_request(state);
>          /*
>           * FIXME: should not return to device code in case
>
Andreas Färber Sept. 21, 2012, 2:48 p.m. UTC | #2
Am 21.09.2012 14:54, schrieb Paolo Bonzini:
> Il 21/09/2012 10:47, Juan Quintela ha scritto:
>> Old code used !io_thread to know if a thread was an vcpu or not.  That
>> fails when we introduce the iothread.
>>
>> Signed-off-by: Juan Quintela <quintela@redhat.com>
>> ---
>>  cpus.c | 9 +++++++--
>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/cpus.c b/cpus.c
>> index e476a3c..1b7061a 100644
>> --- a/cpus.c
>> +++ b/cpus.c
>> @@ -902,6 +902,11 @@ int qemu_cpu_is_self(void *_env)
>>      return qemu_thread_is_self(cpu->thread);
>>  }
>>
>> +static bool qemu_cpu_is_vcpu(void)
>> +{
>> +    return cpu_single_env && qemu_cpu_is_self(&cpu_single_env);
> 
> Should be "cpu_single_env && qemu_cpu_is_self(&cpu_single_env)".

"cpu_single_env && qemu_cpu_is_self(cpu_single_env)" maybe?

> Please named the function qemu_in_vcpu_thread.

Seconded, it does not take a CPU argument.

Thanks,
Andreas
Paolo Bonzini Sept. 21, 2012, 3:36 p.m. UTC | #3
Il 21/09/2012 16:48, Andreas Färber ha scritto:
>>> >>
>>> >> +static bool qemu_cpu_is_vcpu(void)
>>> >> +{
>>> >> +    return cpu_single_env && qemu_cpu_is_self(&cpu_single_env);
>> > 
>> > Should be "cpu_single_env && qemu_cpu_is_self(&cpu_single_env)".
> "cpu_single_env && qemu_cpu_is_self(cpu_single_env)" maybe?

O:-)

Paolo
Juan Quintela Sept. 24, 2012, 6:11 p.m. UTC | #4
Paolo Bonzini <pbonzini@redhat.com> wrote:
> Il 21/09/2012 10:47, Juan Quintela ha scritto:
>> Old code used !io_thread to know if a thread was an vcpu or not.  That
>> fails when we introduce the iothread.
>> 
>> Signed-off-by: Juan Quintela <quintela@redhat.com>
>> ---
>>  cpus.c | 9 +++++++--
>>  1 file changed, 7 insertions(+), 2 deletions(-)
>> 
>> diff --git a/cpus.c b/cpus.c
>> index e476a3c..1b7061a 100644
>> --- a/cpus.c
>> +++ b/cpus.c
>> @@ -902,6 +902,11 @@ int qemu_cpu_is_self(void *_env)
>>      return qemu_thread_is_self(cpu->thread);
>>  }
>> 
>> +static bool qemu_cpu_is_vcpu(void)
>> +{
>> +    return cpu_single_env && qemu_cpu_is_self(&cpu_single_env);
>
> Should be "cpu_single_env && qemu_cpu_is_self(&cpu_single_env)".
>
> Please named the function qemu_in_vcpu_thread.

Agreed to both changes.

Later, Juan.
diff mbox

Patch

diff --git a/cpus.c b/cpus.c
index e476a3c..1b7061a 100644
--- a/cpus.c
+++ b/cpus.c
@@ -902,6 +902,11 @@  int qemu_cpu_is_self(void *_env)
     return qemu_thread_is_self(cpu->thread);
 }

+static bool qemu_cpu_is_vcpu(void)
+{
+    return cpu_single_env && qemu_cpu_is_self(&cpu_single_env);
+}
+
 void qemu_mutex_lock_iothread(void)
 {
     if (!tcg_enabled()) {
@@ -947,7 +952,7 @@  void pause_all_vcpus(void)
         penv = penv->next_cpu;
     }

-    if (!qemu_thread_is_self(&io_thread)) {
+    if (qemu_cpu_is_vcpu()) {
         cpu_stop_current();
         if (!kvm_enabled()) {
             while (penv) {
@@ -1064,7 +1069,7 @@  void cpu_stop_current(void)

 void vm_stop(RunState state)
 {
-    if (!qemu_thread_is_self(&io_thread)) {
+    if (qemu_cpu_is_vcpu()) {
         qemu_system_vmstop_request(state);
         /*
          * FIXME: should not return to device code in case