From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: [patch 2/2] QEMU/KVM: add function to handle signals Date: Thu, 27 Mar 2008 21:22:00 -0300 Message-ID: <20080328002426.768055767@localhost.localdomain> References: <20080328002158.941885832@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel To: Avi Kivity , Anthony Liguori Return-path: Content-Disposition: inline; filename=io-thread-sig List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org SIGUSR1 has no handler, and the SIGUSR2 one does nothing useful anymore (thats also true for SIGIO on tap fd, which runs host_alarm_handler unnecessarily). Index: kvm-userspace.io/qemu/qemu-kvm.c =================================================================== --- kvm-userspace.io.orig/qemu/qemu-kvm.c +++ kvm-userspace.io/qemu/qemu-kvm.c @@ -163,13 +163,30 @@ static int has_work(CPUState *env) return kvm_arch_has_work(env); } +static int kvm_process_signal(int si_signo) +{ + struct sigaction sa; + + switch (si_signo) { + case SIGUSR2: + pthread_cond_signal(&qemu_aio_cond); + break; + case SIGALRM: + case SIGIO: + sigaction(si_signo, NULL, &sa); + sa.sa_handler(si_signo); + break; + } + + return 1; +} + static int kvm_eat_signal(struct qemu_kvm_signal_table *waitset, CPUState *env, int timeout) { struct timespec ts; int r, e, ret = 0; siginfo_t siginfo; - struct sigaction sa; ts.tv_sec = timeout / 1000; ts.tv_nsec = (timeout % 1000) * 1000000; @@ -184,13 +201,9 @@ static int kvm_eat_signal(struct qemu_kv printf("sigtimedwait: %s\n", strerror(e)); exit(1); } - if (r != -1) { - sigaction(siginfo.si_signo, NULL, &sa); - sa.sa_handler(siginfo.si_signo); - if (siginfo.si_signo == SIGUSR2) - pthread_cond_signal(&qemu_aio_cond); - ret = 1; - } + if (r != -1) + ret = kvm_process_signal(siginfo.si_signo); + if (env && vcpu_info[env->cpu_index].stop) { vcpu_info[env->cpu_index].stop = 0; vcpu_info[env->cpu_index].stopped = 1; -- ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace