public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: kvm-devel <kvm-devel@lists.sourceforge.net>
Cc: Avi Kivity <avi@qumranet.com>
Subject: [PATCH] qemu-kvm: Consolidate kvm_eat_signal v2
Date: Fri, 16 May 2008 09:21:47 +0200	[thread overview]
Message-ID: <482D360B.70904@web.de> (raw)

Here comes the second revision of the attempt to consolidate
kvm_eat_signal[s]. It follows the suggestions to remove looping over
kvm_eat_signal and folds everything into kvm_main_loop_wait.

Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
---
 qemu/qemu-kvm.c |   43 ++++++++-----------------------------------
 1 file changed, 8 insertions(+), 35 deletions(-)

Index: b/qemu/qemu-kvm.c
===================================================================
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -173,64 +173,37 @@ static int has_work(CPUState *env)
     return kvm_arch_has_work(env);
 }
 
-static int kvm_eat_signal(CPUState *env, int timeout)
+static void kvm_main_loop_wait(CPUState *env, int timeout)
 {
     struct timespec ts;
-    int r, e, ret = 0;
+    int r, e;
     siginfo_t siginfo;
     sigset_t waitset;
 
+    pthread_mutex_unlock(&qemu_mutex);
+
     ts.tv_sec = timeout / 1000;
     ts.tv_nsec = (timeout % 1000) * 1000000;
     sigemptyset(&waitset);
     sigaddset(&waitset, SIG_IPI);
 
     r = sigtimedwait(&waitset, &siginfo, &ts);
-    if (r == -1 && (errno == EAGAIN || errno == EINTR) && !timeout)
-	return 0;
     e = errno;
 
     pthread_mutex_lock(&qemu_mutex);
-    if (env && vcpu)
-        cpu_single_env = vcpu->env;
-    if (r == -1 && !(errno == EAGAIN || errno == EINTR)) {
+
+    if (r == -1 && !(e == EAGAIN || e == EINTR)) {
 	printf("sigtimedwait: %s\n", strerror(e));
 	exit(1);
     }
-    if (r != -1)
-	ret = 1;
 
-    if (env && vcpu_info[env->cpu_index].stop) {
+    if (vcpu_info[env->cpu_index].stop) {
 	vcpu_info[env->cpu_index].stop = 0;
 	vcpu_info[env->cpu_index].stopped = 1;
 	pthread_cond_signal(&qemu_pause_cond);
     }
-    pthread_mutex_unlock(&qemu_mutex);
-
-    return ret;
-}
-
-
-static void kvm_eat_signals(CPUState *env, int timeout)
-{
-    int r = 0;
-
-    while (kvm_eat_signal(env, 0))
-	r = 1;
-    if (!r && timeout) {
-	r = kvm_eat_signal(env, timeout);
-	if (r)
-	    while (kvm_eat_signal(env, 0))
-		;
-    }
-}
-
-static void kvm_main_loop_wait(CPUState *env, int timeout)
-{
-    pthread_mutex_unlock(&qemu_mutex);
-    kvm_eat_signals(env, timeout);
-    pthread_mutex_lock(&qemu_mutex);
     cpu_single_env = env;
+
     vcpu_info[env->cpu_index].signalled = 0;
 }
 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

             reply	other threads:[~2008-05-16  7:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-16  7:21 Jan Kiszka [this message]
2008-05-19 11:43 ` [kvm-devel] [PATCH] qemu-kvm: Consolidate kvm_eat_signal v2 Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=482D360B.70904@web.de \
    --to=jan.kiszka@web.de \
    --cc=avi@qumranet.com \
    --cc=kvm-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox