* [Qemu-devel] [patch 1/2] qemu: block SIGCHLD in vcpu thread(s)
2009-10-22 19:38 [Qemu-devel] [patch 0/2] iothread fixes Marcelo Tosatti
@ 2009-10-22 19:38 ` Marcelo Tosatti
2009-10-22 19:38 ` [Qemu-devel] [patch 2/2] qemu: kvm specific wait_io_event Marcelo Tosatti
1 sibling, 0 replies; 3+ messages in thread
From: Marcelo Tosatti @ 2009-10-22 19:38 UTC (permalink / raw)
To: qemu-devel; +Cc: glommer, Marcelo Tosatti, aliguori
[-- Attachment #1: block-sigchld --]
[-- Type: text/plain, Size: 517 bytes --]
Otherwise a vcpu thread can run the sigchild handler causing
waitpid() from iothread to fail.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: qemu/vl.c
===================================================================
--- qemu.orig/vl.c
+++ qemu/vl.c
@@ -3722,6 +3722,7 @@ static void block_io_signals(void)
sigaddset(&set, SIGUSR2);
sigaddset(&set, SIGIO);
sigaddset(&set, SIGALRM);
+ sigaddset(&set, SIGCHLD);
pthread_sigmask(SIG_BLOCK, &set, NULL);
sigemptyset(&set);
^ permalink raw reply [flat|nested] 3+ messages in thread* [Qemu-devel] [patch 2/2] qemu: kvm specific wait_io_event
2009-10-22 19:38 [Qemu-devel] [patch 0/2] iothread fixes Marcelo Tosatti
2009-10-22 19:38 ` [Qemu-devel] [patch 1/2] qemu: block SIGCHLD in vcpu thread(s) Marcelo Tosatti
@ 2009-10-22 19:38 ` Marcelo Tosatti
1 sibling, 0 replies; 3+ messages in thread
From: Marcelo Tosatti @ 2009-10-22 19:38 UTC (permalink / raw)
To: qemu-devel; +Cc: glommer, Marcelo Tosatti, aliguori
[-- Attachment #1: wait-io-event --]
[-- Type: text/plain, Size: 1855 bytes --]
In KVM mode the global mutex is released when vcpus are executing,
which means acquiring the fairness mutex is not required.
Also for KVM there is one thread per vcpu, so tcg_has_work is meaningless.
Add a new qemu_wait_io_event_common function to hold common code
between TCG/KVM.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: qemu/vl.c
===================================================================
--- qemu.orig/vl.c
+++ qemu/vl.c
@@ -3590,6 +3590,7 @@ static QemuCond qemu_pause_cond;
static void block_io_signals(void);
static void unblock_io_signals(void);
static int tcg_has_work(void);
+static int cpu_has_work(CPUState *env);
static int qemu_init_main_loop(void)
{
@@ -3610,6 +3611,15 @@ static int qemu_init_main_loop(void)
return 0;
}
+static void qemu_wait_io_event_common(CPUState *env)
+{
+ if (env->stop) {
+ env->stop = 0;
+ env->stopped = 1;
+ qemu_cond_signal(&qemu_pause_cond);
+ }
+}
+
static void qemu_wait_io_event(CPUState *env)
{
while (!tcg_has_work())
@@ -3626,11 +3636,15 @@ static void qemu_wait_io_event(CPUState
qemu_mutex_unlock(&qemu_fair_mutex);
qemu_mutex_lock(&qemu_global_mutex);
- if (env->stop) {
- env->stop = 0;
- env->stopped = 1;
- qemu_cond_signal(&qemu_pause_cond);
- }
+ qemu_wait_io_event_common(env);
+}
+
+static void qemu_kvm_wait_io_event(CPUState *env)
+{
+ while (!cpu_has_work(env))
+ qemu_cond_timedwait(env->halt_cond, &qemu_global_mutex, 1000);
+
+ qemu_wait_io_event_common(env);
}
static int qemu_cpu_exec(CPUState *env);
@@ -3656,7 +3670,7 @@ static void *kvm_cpu_thread_fn(void *arg
while (1) {
if (cpu_can_run(env))
qemu_cpu_exec(env);
- qemu_wait_io_event(env);
+ qemu_kvm_wait_io_event(env);
}
return NULL;
^ permalink raw reply [flat|nested] 3+ messages in thread