From patchwork Tue Mar 15 10:36:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Bharadwaj X-Patchwork-Id: 86936 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 08162B7008 for ; Tue, 15 Mar 2011 21:37:54 +1100 (EST) Received: from localhost ([127.0.0.1]:39010 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PzRdH-0006mU-1S for incoming@patchwork.ozlabs.org; Tue, 15 Mar 2011 06:37:43 -0400 Received: from [140.186.70.92] (port=53025 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PzRcA-0006kM-LN for qemu-devel@nongnu.org; Tue, 15 Mar 2011 06:36:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PzRc9-0003Xa-5e for qemu-devel@nongnu.org; Tue, 15 Mar 2011 06:36:34 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:60429) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PzRc8-0003X9-Ix for qemu-devel@nongnu.org; Tue, 15 Mar 2011 06:36:33 -0400 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [202.81.31.245]) by e23smtp07.au.ibm.com (8.14.4/8.13.1) with ESMTP id p2FAaV5E002228 for ; Tue, 15 Mar 2011 21:36:31 +1100 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p2FAaVOs2461792 for ; Tue, 15 Mar 2011 21:36:31 +1100 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p2FAaUe8007998 for ; Tue, 15 Mar 2011 21:36:31 +1100 Received: from linux.vnet.ibm.com ([9.124.35.19]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p2FAaQxF007898 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Tue, 15 Mar 2011 21:36:29 +1100 Date: Tue, 15 Mar 2011 16:06:26 +0530 From: Arun R Bharadwaj To: qemu-devel@nongnu.org Message-ID: <20110315103626.GB23922@linux.vnet.ibm.com> References: <20110315103453.GA23922@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110315103453.GA23922@linux.vnet.ibm.com> User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 202.81.31.140 Cc: stefanha@gmail.com, aliguori@us.ibm.com, jvrao@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com, Arun Bharadwaj Subject: [Qemu-devel] [v1 PATCH 1/3]: Move the paio_signal_handler to a generic location. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: arun@linux.vnet.ibm.com List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org * Arun R Bharadwaj [2011-03-15 16:04:53]: Author: Arun R Bharadwaj Date: Thu Mar 10 14:45:25 2011 +0530 Move the paio_signal_handler to a generic location. The paio subsystem uses the signal, SIGUSR2. So move the signal handler to a more generic place such that other subsystems like 9pfs can also use it. TODO: I have moved the signal handler code to qemu-thread.c, which is NOT the right place. I need suggestions as to where is the right place to put it. Signed-off-by: Arun R Bharadwaj Reviewed-by: Aneesh Kumar K.V diff --git a/posix-aio-compat.c b/posix-aio-compat.c index fa5494d..df001d6 100644 --- a/posix-aio-compat.c +++ b/posix-aio-compat.c @@ -28,6 +28,7 @@ #include "qemu-common.h" #include "trace.h" #include "block_int.h" +#include "qemu-thread.h" #include "block/raw-posix-aio.h" @@ -302,6 +303,8 @@ static ssize_t handle_aiocb_rw(struct qemu_paiocb *aiocb) return nbytes; } +static PosixAioState *posix_aio_state; + static void *aio_thread(void *unused) { pid_t pid; @@ -356,6 +359,15 @@ static void *aio_thread(void *unused) idle_threads++; mutex_unlock(&lock); + if (posix_aio_state) { + char byte = 0; + ssize_t ret; + + ret = write(posix_aio_state->wfd, &byte, sizeof(byte)); + if (ret < 0 && errno != EAGAIN) + die("write()"); + } + if (kill(pid, aiocb->ev_signo)) die("kill failed"); } @@ -497,22 +509,6 @@ static int posix_aio_flush(void *opaque) return !!s->first_aio; } -static PosixAioState *posix_aio_state; - -static void aio_signal_handler(int signum) -{ - if (posix_aio_state) { - char byte = 0; - ssize_t ret; - - ret = write(posix_aio_state->wfd, &byte, sizeof(byte)); - if (ret < 0 && errno != EAGAIN) - die("write()"); - } - - qemu_service_io(); -} - static void paio_remove(struct qemu_paiocb *acb) { struct qemu_paiocb **pacb; @@ -616,7 +612,6 @@ BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd, int paio_init(void) { - struct sigaction act; PosixAioState *s; int fds[2]; int ret; @@ -626,11 +621,6 @@ int paio_init(void) s = qemu_malloc(sizeof(PosixAioState)); - sigfillset(&act.sa_mask); - act.sa_flags = 0; /* do not restart syscalls to interrupt select() */ - act.sa_handler = aio_signal_handler; - sigaction(SIGUSR2, &act, NULL); - s->first_aio = NULL; if (qemu_pipe(fds) == -1) { fprintf(stderr, "failed to create pipe\n"); diff --git a/qemu-thread.c b/qemu-thread.c index 2c521ab..bed1b60 100644 --- a/qemu-thread.c +++ b/qemu-thread.c @@ -149,3 +149,18 @@ void qemu_thread_exit(void *retval) { g_thread_exit(retval); } + +void sigusr2_signal_handler(int signum) +{ + qemu_service_io(); +} + +void register_sigusr2_signal_handler(void) +{ + struct sigaction act; + + sigfillset(&act.sa_mask); + act.sa_flags = 0; /* do not restart syscalls to interrupt select() */ + act.sa_handler = sigusr2_signal_handler; + sigaction(SIGUSR2, &act, NULL); +} diff --git a/qemu-thread.h b/qemu-thread.h index dc22a60..0f1cbe8 100644 --- a/qemu-thread.h +++ b/qemu-thread.h @@ -41,5 +41,7 @@ void qemu_thread_signal(QemuThread *thread, int sig); void qemu_thread_self(QemuThread *thread); int qemu_thread_equal(QemuThread *thread1, QemuThread *thread2); void qemu_thread_exit(void *retval); +void sigusr2_signal_handler(int signum); +void register_sigusr2_signal_handler(void); #endif diff --git a/vl.c b/vl.c index 3225b1d..a8dc4fc 100644 --- a/vl.c +++ b/vl.c @@ -148,6 +148,7 @@ int main(int argc, char **argv) #include "qemu-config.h" #include "qemu-objects.h" #include "qemu-options.h" +#include "qemu-thread.h" #ifdef CONFIG_VIRTFS #include "fsdev/qemu-fsdev.h" #endif @@ -3003,6 +3004,8 @@ int main(int argc, char **argv, char **envp) } } + register_sigusr2_signal_handler(); + if (qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, 1) != 0) { exit(1); }