kvm: consume internal signal with sigtimedwait
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.
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 <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
diff --git a/kvm-all.c b/kvm-all.c
index 79345b2..38c372f 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -771,6 +771,7 @@
kvm_arch_post_run(env, run);
if (ret == -EINTR || ret == -EAGAIN) {
+ cpu_exit(env);
dprintf("io window exit\n");
ret = 0;
break;
@@ -1116,3 +1117,21 @@
{
}
#endif /* !KVM_CAP_SET_GUEST_DEBUG */
+
+int kvm_set_signal_mask(CPUState *env, const sigset_t *sigset)
+{
+ struct kvm_signal_mask *sigmask;
+ int r;
+
+ if (!sigset)
+ return kvm_vcpu_ioctl(env, KVM_SET_SIGNAL_MASK, NULL);
+
+ sigmask = qemu_malloc(sizeof(*sigmask) + sizeof(*sigset));
+
+ sigmask->len = 8;
+ memcpy(sigmask->sigset, sigset, sizeof(*sigset));
+ r = kvm_vcpu_ioctl(env, KVM_SET_SIGNAL_MASK, sigmask);
+ free(sigmask);
+
+ return r;
+}