qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Arun R Bharadwaj <arun@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: stefanha@gmail.com, aliguori@us.ibm.com,
	jvrao@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com,
	Arun Bharadwaj <arun@linux.vnet.ibm.com>
Subject: [Qemu-devel] [v1 PATCH 1/3]: Move the paio_signal_handler to a generic location.
Date: Tue, 15 Mar 2011 16:06:26 +0530	[thread overview]
Message-ID: <20110315103626.GB23922@linux.vnet.ibm.com> (raw)
In-Reply-To: <20110315103453.GA23922@linux.vnet.ibm.com>

* Arun R Bharadwaj <arun@linux.vnet.ibm.com> [2011-03-15 16:04:53]:

Author: Arun R Bharadwaj <arun@linux.vnet.ibm.com>
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 <arun@linux.vnet.ibm.com>
    Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

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);
     }

  reply	other threads:[~2011-03-15 10:36 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-15 10:34 [Qemu-devel] [v1 PATCH 0/3]: Use GLib threadpool in 9pfs Arun R Bharadwaj
2011-03-15 10:36 ` Arun R Bharadwaj [this message]
2011-03-15 11:38   ` [Qemu-devel] Re: [v1 PATCH 1/3]: Move the paio_signal_handler to a generic location Stefan Hajnoczi
2011-03-15 15:27     ` Arun R Bharadwaj
2011-03-15 10:38 ` [Qemu-devel] [v1 PATCH 2/3]: Helper routines to use GLib threadpool infrastructure in 9pfs Arun R Bharadwaj
2011-03-15 11:45   ` Harsh Bora
2011-03-15 15:30     ` Arun R Bharadwaj
2011-03-15 13:13   ` [Qemu-devel] " Anthony Liguori
2011-03-15 15:33     ` Arun R Bharadwaj
2011-03-16  9:20     ` Stefan Hajnoczi
2011-03-16 13:10       ` Anthony Liguori
2011-03-16 14:20         ` Venkateswararao Jujjuri (JV)
2011-03-16 17:03           ` Stefan Hajnoczi
2011-03-15 10:39 ` [Qemu-devel] [v1 PATCH 3/3]: Convert v9fs_stat to threaded model Arun R Bharadwaj
2011-03-16 10:23   ` [Qemu-devel] " Stefan Hajnoczi
2011-03-16 14:33     ` Venkateswararao Jujjuri (JV)
2011-03-16 17:10       ` Stefan Hajnoczi
2011-03-17  4:26         ` Venkateswararao Jujjuri (JV)
2011-03-17  7:19           ` Stefan Hajnoczi

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=20110315103626.GB23922@linux.vnet.ibm.com \
    --to=arun@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=jvrao@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).