Skip to contentSkip to conversation

[6343] Fix false positive for AIO on OpenBSD

Qemu-devel Blue Swirl 2 participants 8 messages Jan 16, 2009

lore
Share & tools
lore

Blue Swirl

author
#0 lore raw

Revision: 6343

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6343
Author:   blueswir1
Date:     2009-01-16 18:13:32 +0000 (Fri, 16 Jan 2009)

Log Message:
-----------
Fix false positive for AIO on OpenBSD

Modified Paths:
--------------
trunk/configure

Modified: trunk/configure
===================================================================

configure +3 -1
@@ -1005,7 +1005,9 @@
   aio=no
   cat > $TMPC << EOF
 #include <pthread.h>
-int main(void) { pthread_mutex_t lock; return 0; }
+#include <signal.h>
+int main(void) { struct sigevent s; pthread_mutex_t lock;
+    return sigqueue(0, 0, s.sigev_value); }
 EOF
   if $cc $ARCH_CFLAGS -o $TMPE $AIOLIBS $TMPC 2> /dev/null ; then
     aio=yes
#1 lore raw
Quoted 9 lines · Blue Swirl

Revision: 6343

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6343
Author:   blueswir1
Date:     2009-01-16 18:13:32 +0000 (Fri, 16 Jan 2009)

Log Message:
-----------
Fix false positive for AIO on OpenBSD

If OpenBSD doesn't have sigqueue, we could just replace it with kill. I don't think we need to disable AIO.

Regards,

Anthony Liguori

Quoted 24 lines

Modified Paths:
--------------
trunk/configure

Modified: trunk/configure
===================================================================

configure +3 -1
@@ -1005,7 +1005,9 @@
   aio=no
   cat > $TMPC << EOF
 #include <pthread.h>
-int main(void) { pthread_mutex_t lock; return 0; }
+#include <signal.h>
+int main(void) { struct sigevent s; pthread_mutex_t lock;
+    return sigqueue(0, 0, s.sigev_value); }
 EOF
   if $cc $ARCH_CFLAGS -o $TMPE $AIOLIBS $TMPC 2> /dev/null ; then
     aio=yes
author
#2 lore raw
Quoted 8 lines · Anthony Liguori
Quoted 2 lines · Blue Swirl

Revision: 6343

http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6343

Quoted 3 lines
Author:   blueswir1
Date:     2009-01-16 18:13:32 +0000 (Fri, 16 Jan 2009)
Quoted 8 lines
Quoted 5 lines

Log Message:
-----------
Fix false positive for AIO on OpenBSD

If OpenBSD doesn't have sigqueue, we could just replace it with kill. I
don't think we need to disable AIO.

struct sigevent is also missing, is that a problem?

#3 lore raw
Quoted 19 lines · Blue Swirl
Quoted 17 lines · Anthony Liguori
Quoted 3 lines · Blue Swirl

Revision: 6343

http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6343

Quoted 9 lines
Author:   blueswir1
Date:     2009-01-16 18:13:32 +0000 (Fri, 16 Jan 2009)

Log Message:
-----------
Fix false positive for AIO on OpenBSD

Quoted 6 lines
Quoted 3 lines

If OpenBSD doesn't have sigqueue, we could just replace it with kill. I
don't think we need to disable AIO.

struct sigevent is also missing, is that a problem?

It's just used for assigning the signal value. We could have a #ifdef HAVE_SIGEVENT and define it if it doesn't exist--or just change the aioinit structure to use an int instead of the struct sigevent structure. It's sigevent for glibc compatibility but that's not really important at this stage.

Regards,

Anthony Liguori

author
#4 lore raw
Quoted 37 lines · Anthony Liguori
Quoted 7 lines · Blue Swirl
Quoted 4 lines · Anthony Liguori

Blue Swirl wrote:

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Revision: 6343

http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6343

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Author:   blueswir1
Date:     2009-01-16 18:13:32 +0000 (Fri, 16 Jan 2009)
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

Log Message:
-----------
Fix false positive for AIO on OpenBSD

If OpenBSD doesn't have sigqueue, we could just replace it with kill.

I

Quoted 7 lines
Quoted 3 lines

don't think we need to disable AIO.

struct sigevent is also missing, is that a problem?

Quoted 5 lines

It's just used for assigning the signal value. We could have a #ifdef
HAVE_SIGEVENT and define it if it doesn't exist--or just change the aioinit structure to use an int instead of the struct sigevent structure. It's sigevent for glibc compatibility but that's not really important at this stage.

Ok. Should kill be used always or just when sigqueue is not available?

#5 lore raw
Quoted 12 lines · Blue Swirl
Quoted 7 lines · Anthony Liguori

It's just used for assigning the signal value. We could have a #ifdef
HAVE_SIGEVENT and define it if it doesn't exist--or just change the aioinit structure to use an int instead of the struct sigevent structure. It's sigevent for glibc compatibility but that's not really important at this stage.

Ok. Should kill be used always or just when sigqueue is not available?

Since we use it for process instead of thread signaling, I think it's safe to always use kill(). I'm not completely sure though, having it conditional on sigqueue would certainly be the conservative thing to do.

Regards,

Anthony Liguori

author
#6 lore raw
Quoted 15 lines · Anthony Liguori
Quoted 6 lines · Blue Swirl
Quoted 3 lines · Anthony Liguori

It's just used for assigning the signal value. We could have a #ifdef
HAVE_SIGEVENT and define it if it doesn't exist--or just change the

aioinit

Quoted 6 lines
Quoted 5 lines

structure to use an int instead of the struct sigevent structure. It's sigevent for glibc compatibility but that's not really important at this stage.

Quoted 7 lines
Quoted 3 lines

Ok. Should kill be used always or just when sigqueue is not available?

Since we use it for process instead of thread signaling, I think it's safe
to always use kill(). I'm not completely sure though, having it conditional on sigqueue would certainly be the conservative thing to do.

This version uses just kill. Seems to work on Linux and OpenBSD.

block-raw-posix.c +1 -2
Index: qemu/block-raw-posix.c
===================================================================
@@ -579,8 +579,7 @@
     if (!acb)
         return NULL;
     acb->aiocb.aio_fildes = s->fd;
-    acb->aiocb.aio_sigevent.sigev_signo = SIGUSR2;
-    acb->aiocb.aio_sigevent.sigev_notify = SIGEV_SIGNAL;
+    acb->aiocb.sigev_signo = SIGUSR2;
     acb->aiocb.aio_buf = buf;
     if (nb_sectors < 0)
         acb->aiocb.aio_nbytes = -nb_sectors;
configure +1 -3
Index: qemu/configure
===================================================================
@@ -1005,9 +1005,7 @@
   aio=no
   cat > $TMPC << EOF
 #include <pthread.h>
-#include <signal.h>
-int main(void) { struct sigevent s; pthread_mutex_t lock;
-    return sigqueue(0, 0, s.sigev_value); }
+int main(void) { pthread_mutex_t lock;  return 0; }
 EOF
   if $cc $ARCH_CFLAGS -o $TMPE $AIOLIBS $TMPC 2> /dev/null ; then
     aio=yes
posix-aio-compat.c +1 -3
Index: qemu/posix-aio-compat.c
===================================================================
@@ -94,9 +94,7 @@
         idle_threads++;
         pthread_mutex_unlock(&lock);
 
-        sigqueue(getpid(),
-                 aiocb->aio_sigevent.sigev_signo,
-                 aiocb->aio_sigevent.sigev_value);
+        kill(getpid(), aiocb->sigev_signo);
     }
 
     idle_threads--;
posix-aio-compat.h +1 -1
Index: qemu/posix-aio-compat.h
===================================================================
@@ -29,7 +29,7 @@
     int aio_fildes;
     void *aio_buf;
     size_t aio_nbytes;
-    struct sigevent aio_sigevent;
+    int sigev_signo;
     off_t aio_offset;
 
     /* private */
#7 lore raw
Quoted 6 lines · Blue Swirl
Quoted 1 line · Anthony Liguori

This version uses just kill. Seems to work on Linux and OpenBSD.

Looks good to me.

Regards,

Anthony Liguori