Hello,

Am 22.02.2010 um 22:26 schrieb Marcelo Tosatti:

Change the way the internal qemu signal, used for communication between
iothread and vcpus, is handled.

Block and consume it with sigtimedwait on the outer vcpu loop, which
allows more precise timing control.

Mac OS X v10.5 does not seem to support sigtimedwait():

  CC    arm-softmmu/cpus.o
/Users/andreas/QEMU/qemu/cpus.c: In function ‘qemu_kvm_eat_signals’:
/Users/andreas/QEMU/qemu/cpus.c:379: warning: implicit declaration of function ‘sigtimedwait’ /Users/andreas/QEMU/qemu/cpus.c:379: warning: nested extern declaration of ‘sigtimedwait’ /Users/andreas/QEMU/qemu/cpus.c:388: warning: implicit declaration of function ‘sigbus_reraise’ /Users/andreas/QEMU/qemu/cpus.c:388: warning: nested extern declaration of ‘sigbus_reraise’

Could you please add some #ifdef? It used to be an optional POSIX extension.

Thanks,
Andreas

Change from standard signal (SIGUSR1) to real-time one, so multiple
signals are not collapsed.

Set the signal number on KVM's in-kernel allowed sigmask.

Signed-off-by: Marcelo Tosatti <mtosa...@redhat.com>
Signed-off-by: Avi Kivity <a...@redhat.com>
---
kvm-all.c |   19 +++++++++++++
kvm.h     |    1 +
vl.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++ +--------
3 files changed, 97 insertions(+), 12 deletions(-)

diff --git a/vl.c b/vl.c
index af198c1..dc05da3 100644
--- a/vl.c
+++ b/vl.c

@@ -3432,11 +3439,36 @@ static void qemu_wait_io_event(CPUState *env)
    qemu_wait_io_event_common(env);
}

+static void qemu_kvm_eat_signal(CPUState *env, int timeout)
+{
+    struct timespec ts;
+    int r, e;
+    siginfo_t siginfo;
+    sigset_t waitset;
+
+    ts.tv_sec = timeout / 1000;
+    ts.tv_nsec = (timeout % 1000) * 1000000;
+
+    sigemptyset(&waitset);
+    sigaddset(&waitset, SIG_IPI);
+
+    qemu_mutex_unlock(&qemu_global_mutex);
+    r = sigtimedwait(&waitset, &siginfo, &ts);
+    e = errno;
+    qemu_mutex_lock(&qemu_global_mutex);
+
+    if (r == -1 && !(e == EAGAIN || e == EINTR)) {
+        fprintf(stderr, "sigtimedwait: %s\n", strerror(e));
+        exit(1);
+    }
+}


Reply via email to