Patchwork [10/22] kvm: Set up signal mask also for !CONFIG_IOTHREAD

login
register
mail settings
Submitter Jan Kiszka
Date Jan. 27, 2011, 1:09 p.m.
Message ID <62151287710d788ebae642df9c4451bafaf8fd23.1296133797.git.jan.kiszka@siemens.com>
Download mbox | patch
Permalink /patch/80675/
State New
Headers show

Comments

Jan Kiszka - Jan. 27, 2011, 1:09 p.m.
Block SIG_IPI, unblock it during KVM_RUN, just like in io-thread mode.
It's unused so far, but this infrastructure will be required for
self-IPIs and to process SIGBUS plus, in KVM mode, SIGIO and SIGALRM. As
Windows doesn't support signal services, we need to provide a stub for
the init function.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 cpus.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
Paolo Bonzini - Jan. 28, 2011, 8:08 a.m.
On 01/27/2011 02:09 PM, Jan Kiszka wrote:
> Block SIG_IPI, unblock it during KVM_RUN, just like in io-thread mode.
> It's unused so far, but this infrastructure will be required for
> self-IPIs and to process SIGBUS plus, in KVM mode, SIGIO and SIGALRM. As
> Windows doesn't support signal services, we need to provide a stub for
> the init function.
>
> Signed-off-by: Jan Kiszka<jan.kiszka@siemens.com>
> ---
>   cpus.c |   13 +++++++++++--
>   1 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/cpus.c b/cpus.c
> index 16bd8fa..03c89b4 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -231,7 +231,6 @@ fail:
>       return err;
>   }
>
> -#ifdef CONFIG_IOTHREAD
>   static void dummy_signal(int sig)
>   {
>   }
> @@ -246,6 +245,12 @@ static void qemu_kvm_init_cpu_signals(CPUState *env)
>       sigact.sa_handler = dummy_signal;
>       sigaction(SIG_IPI,&sigact, NULL);
>
> +#ifndef CONFIG_IOTHREAD
> +    sigemptyset(&set);
> +    sigaddset(&set, SIG_IPI);
> +    pthread_sigmask(SIG_BLOCK,&set, NULL);
> +#endif
> +
>       pthread_sigmask(SIG_BLOCK, NULL,&set);
>       sigdelset(&set, SIG_IPI);
>       sigdelset(&set, SIGBUS);
> @@ -255,7 +260,6 @@ static void qemu_kvm_init_cpu_signals(CPUState *env)
>           exit(1);
>       }
>   }
> -#endif
>
>   #else /* _WIN32 */
>
> @@ -284,6 +288,10 @@ static void qemu_event_increment(void)
>           exit (1);
>       }
>   }
> +
> +static void qemu_kvm_init_cpu_signals(CPUState *env)
> +{
> +}
>   #endif /* _WIN32 */
>
>   #ifndef CONFIG_IOTHREAD
> @@ -312,6 +320,7 @@ void qemu_init_vcpu(void *_env)
>               fprintf(stderr, "kvm_init_vcpu failed: %s\n", strerror(-r));
>               exit(1);
>           }
> +        qemu_kvm_init_cpu_signals(env);
>       }
>   }
>

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Patch

diff --git a/cpus.c b/cpus.c
index 16bd8fa..03c89b4 100644
--- a/cpus.c
+++ b/cpus.c
@@ -231,7 +231,6 @@  fail:
     return err;
 }
 
-#ifdef CONFIG_IOTHREAD
 static void dummy_signal(int sig)
 {
 }
@@ -246,6 +245,12 @@  static void qemu_kvm_init_cpu_signals(CPUState *env)
     sigact.sa_handler = dummy_signal;
     sigaction(SIG_IPI, &sigact, NULL);
 
+#ifndef CONFIG_IOTHREAD
+    sigemptyset(&set);
+    sigaddset(&set, SIG_IPI);
+    pthread_sigmask(SIG_BLOCK, &set, NULL);
+#endif
+
     pthread_sigmask(SIG_BLOCK, NULL, &set);
     sigdelset(&set, SIG_IPI);
     sigdelset(&set, SIGBUS);
@@ -255,7 +260,6 @@  static void qemu_kvm_init_cpu_signals(CPUState *env)
         exit(1);
     }
 }
-#endif
 
 #else /* _WIN32 */
 
@@ -284,6 +288,10 @@  static void qemu_event_increment(void)
         exit (1);
     }
 }
+
+static void qemu_kvm_init_cpu_signals(CPUState *env)
+{
+}
 #endif /* _WIN32 */
 
 #ifndef CONFIG_IOTHREAD
@@ -312,6 +320,7 @@  void qemu_init_vcpu(void *_env)
             fprintf(stderr, "kvm_init_vcpu failed: %s\n", strerror(-r));
             exit(1);
         }
+        qemu_kvm_init_cpu_signals(env);
     }
 }