qemu-kvm: Consolidate kvm_eat_signal v2
PATCH 1/1 qemu-kvm: Consolidate kvm_eat_signal v2
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 <[email protected]>
--- qemu/qemu-kvm.c | 43 ++++++++----------------------------------- 1 file changed, 8 insertions(+), 35 deletions(-)
qemu/qemu-kvm.c +8 -35
@@ -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/
Avi Kivity
AppliedQuoted 4 lines · Jan Kiszka
Here comes the second revision of the attempt to consolidate kvm_eat_signal[s]. It follows the suggestions to remove looping over
kvm_eat_signaland folds everything intokvm_main_loop_wait.
Applied, thanks.
Signature · 1 line
error compiling committee.c: too many arguments to function