From patchwork Mon Feb 28 09:10:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 594771 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1S9BXot007160 for ; Mon, 28 Feb 2011 09:11:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753068Ab1B1JLZ (ORCPT ); Mon, 28 Feb 2011 04:11:25 -0500 Received: from mail-yx0-f174.google.com ([209.85.213.174]:34184 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752995Ab1B1JLX (ORCPT ); Mon, 28 Feb 2011 04:11:23 -0500 Received: by mail-yx0-f174.google.com with SMTP id 7so1456975yxs.19 for ; Mon, 28 Feb 2011 01:11:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:to:cc:subject:date:message-id :x-mailer:in-reply-to:references; bh=GEDYGONt69BNV0H6LwLhLhHBpG3hD87OWWTLTXQur50=; b=rDBq6bGS4MOQeUzKADov4lJlJn1HJxlTYxB9EP2anIJ8E/yB47AjuV0MVN63FwIQnd vRMsRI0Ay5EbhoaHjEQ/+g4hGZCqn7P0nDYGA4WJPhqUekCipkoHx6pMnXiQ8Epb/TvS 0ApffyNiJkTNHNLeZ0vkiweVO1o2AxVBTB2w0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=eUv9ti+u5veHj/iB9qaXeawEwFPlxvkCyqZNVu4waVH7NnEL9tmt91XSVOTA7y8x6t mKfpqslNdDGerHFkzvf1Ns2LgrzDR6Zde8pglZZZkkIMWo+tdDFIgwKWuVKjMjaWZNRX E0F/41KEmD/dihFCNAqER4gQ+X20C3++GBcqA= Received: by 10.151.76.30 with SMTP id d30mr6871831ybl.395.1298884282765; Mon, 28 Feb 2011 01:11:22 -0800 (PST) Received: from localhost.localdomain (93-34-149-100.ip50.fastwebnet.it [93.34.149.100]) by mx.google.com with ESMTPS id 1sm2037209yhl.11.2011.02.28.01.11.21 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 28 Feb 2011 01:11:22 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, aurelien@aurel32.net, blauwirbel@gmail.com, jan.kiszka@siemes.com, mtosatti@redhat.com Subject: [PATCH v3 uq/master 19/22] merge all signal initialization with qemu_signalfd_init, rename Date: Mon, 28 Feb 2011 10:10:21 +0100 Message-Id: <1298884224-19734-20-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.4 In-Reply-To: <1298884224-19734-1-git-send-email-pbonzini@redhat.com> References: <1298884224-19734-1-git-send-email-pbonzini@redhat.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 28 Feb 2011 09:11:33 +0000 (UTC) diff --git a/cpus.c b/cpus.c index 32e9352..2b491a9 100644 --- a/cpus.c +++ b/cpus.c @@ -346,11 +346,37 @@ static void sigfd_handler(void *opaque) } } -static int qemu_signalfd_init(sigset_t mask) +static int qemu_signal_init(void) { int sigfd; + sigset_t set; - sigfd = qemu_signalfd(&mask); +#ifdef CONFIG_IOTHREAD + /* SIGUSR2 used by posix-aio-compat.c */ + sigemptyset(&set); + sigaddset(&set, SIGUSR2); + pthread_sigmask(SIG_UNBLOCK, &set, NULL); + + sigemptyset(&set); + sigaddset(&set, SIGIO); + sigaddset(&set, SIGALRM); + sigaddset(&set, SIG_IPI); + sigaddset(&set, SIGBUS); + pthread_sigmask(SIG_BLOCK, &set, NULL); +#else + sigemptyset(&set); + sigaddset(&set, SIGBUS); + if (kvm_enabled()) { + /* + * We need to process timer signals synchronously to avoid a race + * between exit_request check and KVM vcpu entry. + */ + sigaddset(&set, SIGIO); + sigaddset(&set, SIGALRM); + } +#endif + + sigfd = qemu_signalfd(&set); if (sigfd == -1) { fprintf(stderr, "failed to create signalfd\n"); return -errno; @@ -438,6 +464,12 @@ static void qemu_event_increment(void) static void qemu_kvm_eat_signals(CPUState *env) { } + +static int qemu_signal_init(void) +{ + return 0; +} + #endif /* _WIN32 */ #ifndef CONFIG_IOTHREAD @@ -471,39 +503,14 @@ static void qemu_kvm_init_cpu_signals(CPUState *env) #endif } -#ifndef _WIN32 -static sigset_t block_synchronous_signals(void) -{ - sigset_t set; - - sigemptyset(&set); - sigaddset(&set, SIGBUS); - if (kvm_enabled()) { - /* - * We need to process timer signals synchronously to avoid a race - * between exit_request check and KVM vcpu entry. - */ - sigaddset(&set, SIGIO); - sigaddset(&set, SIGALRM); - } - - return set; -} -#endif - int qemu_init_main_loop(void) { -#ifndef _WIN32 - sigset_t blocked_signals; int ret; - blocked_signals = block_synchronous_signals(); - - ret = qemu_signalfd_init(blocked_signals); + ret = qemu_signal_init(); if (ret) { return ret; } -#endif qemu_init_sigbus(); @@ -651,35 +658,13 @@ static void qemu_tcg_init_cpu_signals(void) pthread_sigmask(SIG_UNBLOCK, &set, NULL); } -static sigset_t block_io_signals(void) -{ - sigset_t set; - - /* SIGUSR2 used by posix-aio-compat.c */ - sigemptyset(&set); - sigaddset(&set, SIGUSR2); - pthread_sigmask(SIG_UNBLOCK, &set, NULL); - - sigemptyset(&set); - sigaddset(&set, SIGIO); - sigaddset(&set, SIGALRM); - sigaddset(&set, SIG_IPI); - sigaddset(&set, SIGBUS); - pthread_sigmask(SIG_BLOCK, &set, NULL); - - return set; -} - int qemu_init_main_loop(void) { int ret; - sigset_t blocked_signals; qemu_init_sigbus(); - blocked_signals = block_io_signals(); - - ret = qemu_signalfd_init(blocked_signals); + ret = qemu_signal_init(); if (ret) { return ret; }