Skip to contentSkip to conversation

Host AIO support detection, OpenBSD host support

RFC PATCH In review Blue Swirl 5 participants 16 messages Aug 12, 2008 – Aug 17, 2008 Kbuild

lore
Share & tools
lore

Blue Swirl

author
#0 lore raw

RFC PATCH 1/1 Host AIO support detection, OpenBSD host support

Here are two patches, loosely based on patches in OpenBSD ports system that enable compiling Qemu. The first patch makes AIO use conditional on host AIO support. The second one adjusts various include files etc.

I'd like to commit both of these, is that OK?

Background: I got fed up with Sparc glibc mangling global registers and buggy gdb/gdb64, so I installed OpenBSD. Now debugging Sparc host support is so much easier.

block-raw-posix.c +38 -0
Index: qemu/block-raw-posix.c
===================================================================
@@ -28,7 +28,9 @@
 #endif
 #include "block_int.h"
 #include <assert.h>
+#ifdef CONFIG_AIO
 #include <aio.h>
+#endif
 
 #ifdef CONFIG_COCOA
 #include <paths.h>
@@ -418,6 +420,7 @@
 #endif
 
 
+#ifdef CONFIG_AIO
 /***********************************************************/
 /* Unix AIO using POSIX AIO */
 
@@ -688,6 +691,37 @@
     }
 }
 
+# else /* CONFIG_AIO */
+
+void qemu_aio_init(void)
+{
+}
+
+void qemu_aio_poll(void)
+{
+}
+
+void qemu_aio_flush(void)
+{
+}
+
+void qemu_aio_wait_start(void)
+{
+}
+
+void qemu_aio_wait(void)
+{
+#if !defined(QEMU_IMG) && !defined(QEMU_NBD)
+    qemu_bh_poll();
+#endif
+}
+
+void qemu_aio_wait_end(void)
+{
+}
+
+#endif /* CONFIG_AIO */
+
 static void raw_close(BlockDriverState *bs)
 {
     BDRVRawState *s = bs->opaque;
@@ -792,10 +826,12 @@
     raw_create,
     raw_flush,
 
+#ifdef CONFIG_AIO
     .bdrv_aio_read = raw_aio_read,
     .bdrv_aio_write = raw_aio_write,
     .bdrv_aio_cancel = raw_aio_cancel,
     .aiocb_size = sizeof(RawAIOCB),
+#endif
     .protocol_name = "file",
     .bdrv_pread = raw_pread,
     .bdrv_pwrite = raw_pwrite,
@@ -1144,10 +1180,12 @@
     NULL,
     raw_flush,
 
+#ifdef CONFIG_AIO
     .bdrv_aio_read = raw_aio_read,
     .bdrv_aio_write = raw_aio_write,
     .bdrv_aio_cancel = raw_aio_cancel,
     .aiocb_size = sizeof(RawAIOCB),
+#endif
     .bdrv_pread = raw_pread,
     .bdrv_pwrite = raw_pwrite,
     .bdrv_getlength = raw_getlength,
configure +15 -0
Index: qemu/configure
===================================================================
@@ -106,6 +106,7 @@
 build_docs="no"
 uname_release=""
 curses="yes"
+aio="no"
 nptl="yes"
 mixemu="no"
 
@@ -859,6 +860,16 @@
   fi
 fi # test "$curses"
 
+##########################################
+# AIO probe
+cat > $TMPC << EOF
+#include <aio.h>
+int main(void) { return aio_write(NULL); }
+EOF
+if $cc $ARCH_CFLAGS -o $TMPE $AIOLIBS $TMPC 2> /dev/null ; then
+  aio=yes
+fi
+
 # Check if tools are available to build documentation.
 if [ -x "`which texi2html 2>/dev/null`" ] && \
    [ -x "`which pod2man 2>/dev/null`" ]; then
@@ -930,6 +941,7 @@
 echo "uname -r          $uname_release"
 echo "NPTL support      $nptl"
 echo "vde support       $vde"
+echo "AIO support       $aio"
 
 if test $sdl_too_old = "yes"; then
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -1175,6 +1187,9 @@
   echo "#define CONFIG_BRLAPI 1" >> $config_h
   echo "BRLAPI_LIBS=-lbrlapi" >> $config_mak
 fi
+if test "$aio" = "yes" ; then
+  echo "#define CONFIG_AIO 1" >> $config_h
+fi
 
 # XXX: suppress that
 if [ "$bsd" = "yes" ] ; then
block-raw-posix.c +27 -0
Index: qemu/block-raw-posix.c
===================================================================
@@ -58,6 +58,12 @@
 #include <sys/disk.h>
 #endif
 
+#ifdef __OpenBSD__
+#include <sys/ioctl.h>
+#include <sys/disklabel.h>
+#include <sys/dkio.h>
+#endif
+
 //#define DEBUG_FLOPPY
 
 //#define DEBUG_BLOCK
@@ -745,6 +751,26 @@
     return 0;
 }
 
+#ifdef __OpenBSD__
+static int64_t raw_getlength(BlockDriverState *bs)
+{
+    BDRVRawState *s = bs->opaque;
+    int fd = s->fd;
+    struct stat st;
+
+    if (fstat(fd, &st))
+        return -1;
+    if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) {
+        struct disklabel dl;
+
+        if (ioctl(fd, DIOCGDINFO, &dl))
+            return -1;
+        return (uint64_t)dl.d_secsize *
+            dl.d_partitions[DISKPART(st.st_rdev)].p_size;
+    } else
+        return st.st_size;
+}
+#else /* !__OpenBSD__ */
 static int64_t  raw_getlength(BlockDriverState *bs)
 {
     BDRVRawState *s = bs->opaque;
@@ -791,6 +817,7 @@
     }
     return size;
 }
+#endif
 
 static int raw_create(const char *filename, int64_t total_size,
                       const char *backing_file, int flags)
configure +13 -0
Index: qemu/configure
===================================================================
@@ -150,6 +150,7 @@
 ;;
 OpenBSD)
 bsd="yes"
+openbsd="yes"
 audio_drv_list="oss"
 audio_possible_drivers="oss sdl esd"
 ;;
@@ -819,6 +820,10 @@
         "pa_simple *s = NULL; pa_simple_free(s); return 0;"
     ;;
 
+    oss)
+    :
+    ;;
+
     *)
     echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
         echo
@@ -1076,6 +1081,14 @@
     echo "#define HAVE_BYTESWAP_H 1" >> $config_h
   fi
 fi
+
+if [ "$openbsd" = "yes" ] ; then
+  echo "#define ENOTSUP 4096" >> $config_h
+  echo "#define qemu_siginfo siginfo_t" >> $config_h
+else
+  echo "#define qemu_siginfo struct siginfo" >> $config_h
+fi
+
 if test "$darwin" = "yes" ; then
   echo "CONFIG_DARWIN=yes" >> $config_mak
   echo "#define CONFIG_DARWIN 1" >> $config_h
dyngen-exec.h +4 -0
Index: qemu/dyngen-exec.h
===================================================================
@@ -32,6 +32,9 @@
    host headers do not allow that. */
 #include <stddef.h>
 
+#ifdef __OpenBSD__
+#include <sys/types.h>
+#else
 typedef unsigned char uint8_t;
 typedef unsigned short uint16_t;
 typedef unsigned int uint32_t;
@@ -61,6 +64,7 @@
 typedef signed long long int64_t;
 #endif
 #endif
+#endif
 
 /* XXX: This may be wrong for 64-bit ILP32 hosts.  */
 typedef void * host_reg_t;
osdep.c +16 -2
Index: qemu/osdep.c
===================================================================
@@ -68,7 +68,14 @@
 
 #if defined(USE_KQEMU)
 
+#ifdef __OpenBSD__
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/mount.h>
+#else
 #include <sys/vfs.h>
+#endif
+
 #include <sys/mman.h>
 #include <fcntl.h>
 
@@ -76,9 +83,15 @@
 {
     static int phys_ram_fd = -1;
     static int phys_ram_size = 0;
+    void *ptr;
+
+#ifdef __OpenBSD__ /* no need (?) for a dummy file on OpenBSD */
+    int map_anon = MAP_ANON;
+#else
+    int map_anon = 0;
     const char *tmpdir;
     char phys_ram_file[1024];
-    void *ptr;
+
 #ifdef HOST_SOLARIS
     struct statvfs stfs;
 #else
@@ -140,9 +153,10 @@
     }
     size = (size + 4095) & ~4095;
     ftruncate(phys_ram_fd, phys_ram_size + size);
+#endif /* !__OpenBSD__ */
     ptr = mmap(NULL,
                size,
-               PROT_WRITE | PROT_READ, MAP_SHARED,
+               PROT_WRITE | PROT_READ, map_anon | MAP_SHARED,
                phys_ram_fd, phys_ram_size);
     if (ptr == MAP_FAILED) {
         fprintf(stderr, "Could not map physical memory\n");
vl.c +5 -1
Index: qemu/vl.c
===================================================================
@@ -61,9 +61,12 @@
 #include <arpa/inet.h>
 #ifdef _BSD
 #include <sys/stat.h>
-#ifndef __APPLE__
+#if !defined(__APPLE__) && !defined(__OpenBSD__)
 #include <libutil.h>
 #endif
+#ifdef __OpenBSD__
+#include <net/if.h>
+#endif
 #elif defined (__GLIBC__) && defined (__FreeBSD_kernel__)
 #include <freebsd/stdlib.h>
 #else
@@ -4583,6 +4586,7 @@
     int fd;
     char ifname[128];
 
+    memset(&ifname, '\0', sizeof(ifname));
     if (ifname1 != NULL)
         pstrcpy(ifname, sizeof(ifname), ifname1);
     else
osdep.h +4 -0
Index: qemu/osdep.h
===================================================================
@@ -2,6 +2,10 @@
 #define QEMU_OSDEP_H
 
 #include <stdarg.h>
+#ifdef __OpenBSD__
+#include <sys/types.h>
+#include <sys/signal.h>
+#endif
 
 #ifndef glue
 #define xglue(x, y) x ## y
fpu/softfloat-native.h +11 -1
Index: qemu/fpu/softfloat-native.h
===================================================================
@@ -15,7 +15,9 @@
  *   Solaris 10 with GCC4 does not need these macros as they
  *   are defined in <iso/math_c99.h> with a compiler directive
  */
-#if defined(HOST_SOLARIS) && (( HOST_SOLARIS <= 9 ) || ((HOST_SOLARIS >= 10) && (__GNUC__ <= 4)))
+#if defined(HOST_SOLARIS) && (( HOST_SOLARIS <= 9 ) || ((HOST_SOLARIS >= 10) \
+                                                        && (__GNUC__ <= 4))) \
+    || defined(__OpenBSD__)
 /*
  * C99 7.12.3 classification macros
  * and
@@ -24,6 +26,9 @@
  * ... do not work on Solaris 10 using GNU CC 3.4.x.
  * Try to workaround the missing / broken C99 math macros.
  */
+#if defined(__OpenBSD__)
+#define unordered(x, y) (isnan(x) || isnan(y))
+#endif
 
 #define isnormal(x)             (fpclass(x) >= FP_NZERO)
 #define isgreater(x, y)         ((!unordered(x, y)) && ((x) > (y)))
@@ -84,6 +89,11 @@
 | Software IEC/IEEE floating-point rounding mode.
 *----------------------------------------------------------------------------*/
 #if (defined(_BSD) && !defined(__APPLE__)) || defined(HOST_SOLARIS)
+#if defined(__OpenBSD__)
+#define FE_RM FP_RM
+#define FE_RP FP_RP
+#define FE_RZ FP_RZ
+#endif
 enum {
     float_round_nearest_even = FP_RN,
     float_round_down         = FP_RM,
curses.c +4 -0
Index: qemu/curses.c
===================================================================
@@ -34,6 +34,10 @@
 #include <termios.h>
 #endif
 
+#ifdef __OpenBSD__
+#define resize_term resizeterm
+#endif
+
 #define FONT_HEIGHT 16
 #define FONT_WIDTH 8
 
#1 lore raw
Quoted 6 lines · Blue Swirl

Here are two patches, loosely based on patches in OpenBSD ports system that enable compiling Qemu. The first patch makes AIO use conditional on host AIO support. The second one adjusts various include files etc.

I'd like to commit both of these, is that OK?

The first patch is fine but the second patch has some bogus things in it. For instance:

Quoted 7 lines

Index: qemu/configure
===================================================================

configure 2008-08-12 17:33:36.000000000 +0000 renamed from configure 2008-08-12 17:12:15.000000000 +0000 +0 -0
@@ -150,6 +150,7 @@

configure 2008-08-12 17:33:36.000000000 +0000 line 1090

Quoted 10 lines
configure 2008-08-12 17:33:36.000000000 +0000 renamed from configure 2008-08-12 17:12:15.000000000 +0000 +7 -0
@@ -1076,6 +1081,14 @@
     echo "#define HAVE_BYTESWAP_H 1" >> $config_h
   fi
 fi
+
+if [ "$openbsd" = "yes" ] ; then
+  echo "#define ENOTSUP 4096" >> $config_h
+  echo "#define qemu_siginfo siginfo_t" >> $config_h
+else
+  echo "#define qemu_siginfo struct siginfo" >> $config_h
+fi

But qemu_siginfo isn't actually used anywhere. That's just one example, the patch seems to have a lot of things like this in it.

Regards,

Anthony Liguori

#2 lore raw

I am responsible for that. Back when the qemu siginfo stuff was in use it was necessary.

Sorry for the extra cruft, will look for cleaning it when qemu releases next..

Looking forward to the next release with OpenBSD/sparc running inside qemu ;-)

Thanks,

Signature · 14 lines
Todd Fries .. [email protected]

 _____________________________________________
|                                             \  1.636.410.0632 (voice)
| Free Daemon Consulting, LLC                 \  1.405.227.9094 (voice)
| http://FreeDaemonConsulting.com             \  1.866.792.3418 (FAX)
| "..in support of free software solutions."  \          250797 (FWD)
|                                             \
 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
                                                 
              37E7 D3EB 74D0 8D66 A68D  B866 0326 204E 3F42 004A
                        http://todd.fries.net/pgp.txt

Penned by Anthony Liguori on 20080812 14:46.53, we have:
Quoted 36 lines
Quoted 6 lines · Blue Swirl

Here are two patches, loosely based on patches in OpenBSD ports system that enable compiling Qemu. The first patch makes AIO use conditional on host AIO support. The second one adjusts various include files etc.

I'd like to commit both of these, is that OK?

The first patch is fine but the second patch has some bogus things in it. For instance:

Quoted 7 lines

Index: qemu/configure
===================================================================

configure 2008-08-12 17:33:36.000000000 +0000 renamed from configure 2008-08-12 17:12:15.000000000 +0000 +0 -0
@@ -150,6 +150,7 @@

configure 2008-08-12 17:33:36.000000000 +0000 line 1090

Quoted 10 lines
configure 2008-08-12 17:33:36.000000000 +0000 renamed from configure 2008-08-12 17:12:15.000000000 +0000 +7 -0
@@ -1076,6 +1081,14 @@
     echo "#define HAVE_BYTESWAP_H 1" >> $config_h
   fi
 fi
+
+if [ "$openbsd" = "yes" ] ; then
+  echo "#define ENOTSUP 4096" >> $config_h
+  echo "#define qemu_siginfo siginfo_t" >> $config_h
+else
+  echo "#define qemu_siginfo struct siginfo" >> $config_h
+fi

But qemu_siginfo isn't actually used anywhere. That's just one example, the patch seems to have a lot of things like this in it.

Regards,

Anthony Liguori

#3 lore raw

Hi Todd,

Quoted 6 lines · Todd T. Fries

I am responsible for that. Back when the qemu siginfo stuff was in use it was necessary.

Sorry for the extra cruft, will look for cleaning it when qemu releases next..

It would be good to get SVN working consistently on OpenBSD/sparc. We're probably a ways off from another release as we still have regressed platforms due to the addition of TCG.

Regards,

Anthony Liguori

Quoted 5 lines

Looking forward to the next release with OpenBSD/sparc running inside qemu ;-)

Thanks,

author
#4 lore raw
In reply to Todd T. Fries
Quoted 2 lines · Todd T. Fries

I am responsible for that. Back when the qemu siginfo stuff was in use
it was necessary.

Okay, I'll refer to you in the commit message so you'll get the blame. ;-)

Quoted 5 lines

Sorry for the extra cruft, will look for cleaning it when qemu releases next..

Looking forward to the next release with OpenBSD/sparc running inside qemu ;-)

Well, don't hold your breath but I'm already making some progress.

author
#5 lore raw
In reply to Anthony Liguori
Quoted 11 lines · Anthony Liguori
Quoted 7 lines · Blue Swirl

Here are two patches, loosely based on patches in OpenBSD ports system that enable compiling Qemu. The first patch makes AIO use conditional on host AIO support. The second one adjusts various include files etc.

I'd like to commit both of these, is that OK?

The first patch is fine but the second patch has some bogus things in it.

Thanks for the review. I removed the unneeded parts, made a separate patch for fixing OSS selection, and added a configure option for AIO as requested by Samuel Thibault.

block-raw-posix.c +38 -0
Index: qemu/block-raw-posix.c
===================================================================
@@ -28,7 +28,9 @@
 #endif
 #include "block_int.h"
 #include <assert.h>
+#ifdef CONFIG_AIO
 #include <aio.h>
+#endif
 
 #ifdef CONFIG_COCOA
 #include <paths.h>
@@ -418,6 +420,7 @@
 #endif
 
 
+#ifdef CONFIG_AIO
 /***********************************************************/
 /* Unix AIO using POSIX AIO */
 
@@ -688,6 +691,37 @@
     }
 }
 
+# else /* CONFIG_AIO */
+
+void qemu_aio_init(void)
+{
+}
+
+void qemu_aio_poll(void)
+{
+}
+
+void qemu_aio_flush(void)
+{
+}
+
+void qemu_aio_wait_start(void)
+{
+}
+
+void qemu_aio_wait(void)
+{
+#if !defined(QEMU_IMG) && !defined(QEMU_NBD)
+    qemu_bh_poll();
+#endif
+}
+
+void qemu_aio_wait_end(void)
+{
+}
+
+#endif /* CONFIG_AIO */
+
 static void raw_close(BlockDriverState *bs)
 {
     BDRVRawState *s = bs->opaque;
@@ -792,10 +826,12 @@
     raw_create,
     raw_flush,
 
+#ifdef CONFIG_AIO
     .bdrv_aio_read = raw_aio_read,
     .bdrv_aio_write = raw_aio_write,
     .bdrv_aio_cancel = raw_aio_cancel,
     .aiocb_size = sizeof(RawAIOCB),
+#endif
     .protocol_name = "file",
     .bdrv_pread = raw_pread,
     .bdrv_pwrite = raw_pwrite,
@@ -1144,10 +1180,12 @@
     NULL,
     raw_flush,
 
+#ifdef CONFIG_AIO
     .bdrv_aio_read = raw_aio_read,
     .bdrv_aio_write = raw_aio_write,
     .bdrv_aio_cancel = raw_aio_cancel,
     .aiocb_size = sizeof(RawAIOCB),
+#endif
     .bdrv_pread = raw_pread,
     .bdrv_pwrite = raw_pwrite,
     .bdrv_getlength = raw_getlength,
configure +21 -0
Index: qemu/configure
===================================================================
@@ -106,6 +106,7 @@
 build_docs="no"
 uname_release=""
 curses="yes"
+aio="yes"
 nptl="yes"
 mixemu="no"
 
@@ -334,6 +335,8 @@
   ;;
   --enable-mixemu) mixemu="yes"
   ;;
+  --disable-aio) aio="no"
+  ;;
   *) echo "ERROR: unknown option $opt"; show_help="yes"
   ;;
   esac
@@ -436,6 +439,7 @@
 echo "  --enable-uname-release=R Return R for uname -r in usermode emulation"
 echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
 echo "  --disable-vde            disable support for vde network"
+echo "  --disable-aio            disable AIO support"
 echo ""
 echo "NOTE: The object files are built at the place where configure is launched"
 exit 1
@@ -859,6 +863,19 @@
   fi
 fi # test "$curses"
 
+##########################################
+# AIO probe
+if test "$aio" = "yes" ; then
+  aio=no
+  cat > $TMPC << EOF
+#include <aio.h>
+int main(void) { return aio_write(NULL); }
+EOF
+  if $cc $ARCH_CFLAGS -o $TMPE $AIOLIBS $TMPC 2> /dev/null ; then
+    aio=yes
+  fi
+fi
+
 # Check if tools are available to build documentation.
 if [ -x "`which texi2html 2>/dev/null`" ] && \
    [ -x "`which pod2man 2>/dev/null`" ]; then
@@ -930,6 +947,7 @@
 echo "uname -r          $uname_release"
 echo "NPTL support      $nptl"
 echo "vde support       $vde"
+echo "AIO support       $aio"
 
 if test $sdl_too_old = "yes"; then
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -1175,6 +1193,9 @@
   echo "#define CONFIG_BRLAPI 1" >> $config_h
   echo "BRLAPI_LIBS=-lbrlapi" >> $config_mak
 fi
+if test "$aio" = "yes" ; then
+  echo "#define CONFIG_AIO 1" >> $config_h
+fi
 
 # XXX: suppress that
 if [ "$bsd" = "yes" ] ; then
configure +4 -0
Index: qemu/configure
===================================================================
@@ -822,6 +822,10 @@
         "pa_simple *s = NULL; pa_simple_free(s); return 0;"
     ;;
 
+    oss)
+    :
+    ;;
+
     *)
     echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
         echo
block-raw-posix.c +27 -0
Index: qemu/block-raw-posix.c
===================================================================
@@ -58,6 +58,12 @@
 #include <sys/disk.h>
 #endif
 
+#ifdef __OpenBSD__
+#include <sys/ioctl.h>
+#include <sys/disklabel.h>
+#include <sys/dkio.h>
+#endif
+
 //#define DEBUG_FLOPPY
 
 //#define DEBUG_BLOCK
@@ -745,6 +751,26 @@
     return 0;
 }
 
+#ifdef __OpenBSD__
+static int64_t raw_getlength(BlockDriverState *bs)
+{
+    BDRVRawState *s = bs->opaque;
+    int fd = s->fd;
+    struct stat st;
+
+    if (fstat(fd, &st))
+        return -1;
+    if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) {
+        struct disklabel dl;
+
+        if (ioctl(fd, DIOCGDINFO, &dl))
+            return -1;
+        return (uint64_t)dl.d_secsize *
+            dl.d_partitions[DISKPART(st.st_rdev)].p_size;
+    } else
+        return st.st_size;
+}
+#else /* !__OpenBSD__ */
 static int64_t  raw_getlength(BlockDriverState *bs)
 {
     BDRVRawState *s = bs->opaque;
@@ -791,6 +817,7 @@
     }
     return size;
 }
+#endif
 
 static int raw_create(const char *filename, int64_t total_size,
                       const char *backing_file, int flags)
configure +6 -0
Index: qemu/configure
===================================================================
@@ -150,6 +150,7 @@
 ;;
 OpenBSD)
 bsd="yes"
+openbsd="yes"
 audio_drv_list="oss"
 audio_possible_drivers="oss sdl esd"
 ;;
@@ -1086,6 +1087,11 @@
     echo "#define HAVE_BYTESWAP_H 1" >> $config_h
   fi
 fi
+
+if [ "$openbsd" = "yes" ] ; then
+  echo "#define ENOTSUP 4096" >> $config_h
+fi
+
 if test "$darwin" = "yes" ; then
   echo "CONFIG_DARWIN=yes" >> $config_mak
   echo "#define CONFIG_DARWIN 1" >> $config_h
dyngen-exec.h +4 -0
Index: qemu/dyngen-exec.h
===================================================================
@@ -32,6 +32,9 @@
    host headers do not allow that. */
 #include <stddef.h>
 
+#ifdef __OpenBSD__
+#include <sys/types.h>
+#else
 typedef unsigned char uint8_t;
 typedef unsigned short uint16_t;
 typedef unsigned int uint32_t;
@@ -61,6 +64,7 @@
 typedef signed long long int64_t;
 #endif
 #endif
+#endif
 
 /* XXX: This may be wrong for 64-bit ILP32 hosts.  */
 typedef void * host_reg_t;
osdep.c +15 -2
Index: qemu/osdep.c
===================================================================
@@ -68,7 +68,14 @@
 
 #if defined(USE_KQEMU)
 
+#ifdef __OpenBSD__
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/mount.h>
+#else
 #include <sys/vfs.h>
+#endif
+
 #include <sys/mman.h>
 #include <fcntl.h>
 
@@ -76,9 +83,14 @@
 {
     static int phys_ram_fd = -1;
     static int phys_ram_size = 0;
+    void *ptr;
+
+#ifdef __OpenBSD__ /* no need (?) for a dummy file on OpenBSD */
+    int map_anon = MAP_ANON;
+#else
+    int map_anon = 0;
     const char *tmpdir;
     char phys_ram_file[1024];
-    void *ptr;
 #ifdef HOST_SOLARIS
     struct statvfs stfs;
 #else
@@ -140,9 +152,10 @@
     }
     size = (size + 4095) & ~4095;
     ftruncate(phys_ram_fd, phys_ram_size + size);
+#endif /* !__OpenBSD__ */
     ptr = mmap(NULL,
                size,
-               PROT_WRITE | PROT_READ, MAP_SHARED,
+               PROT_WRITE | PROT_READ, map_anon | MAP_SHARED,
                phys_ram_fd, phys_ram_size);
     if (ptr == MAP_FAILED) {
         fprintf(stderr, "Could not map physical memory\n");
vl.c +4 -1
Index: qemu/vl.c
===================================================================
@@ -61,9 +61,12 @@
 #include <arpa/inet.h>
 #ifdef _BSD
 #include <sys/stat.h>
-#ifndef __APPLE__
+#if !defined(__APPLE__) && !defined(__OpenBSD__)
 #include <libutil.h>
 #endif
+#ifdef __OpenBSD__
+#include <net/if.h>
+#endif
 #elif defined (__GLIBC__) && defined (__FreeBSD_kernel__)
 #include <freebsd/stdlib.h>
 #else
osdep.h +4 -0
Index: qemu/osdep.h
===================================================================
@@ -2,6 +2,10 @@
 #define QEMU_OSDEP_H
 
 #include <stdarg.h>
+#ifdef __OpenBSD__
+#include <sys/types.h>
+#include <sys/signal.h>
+#endif
 
 #ifndef glue
 #define xglue(x, y) x ## y
fpu/softfloat-native.h +11 -1
Index: qemu/fpu/softfloat-native.h
===================================================================
@@ -15,7 +15,9 @@
  *   Solaris 10 with GCC4 does not need these macros as they
  *   are defined in <iso/math_c99.h> with a compiler directive
  */
-#if defined(HOST_SOLARIS) && (( HOST_SOLARIS <= 9 ) || ((HOST_SOLARIS >= 10) && (__GNUC__ <= 4)))
+#if defined(HOST_SOLARIS) && (( HOST_SOLARIS <= 9 ) || ((HOST_SOLARIS >= 10) \
+                                                        && (__GNUC__ <= 4))) \
+    || defined(__OpenBSD__)
 /*
  * C99 7.12.3 classification macros
  * and
@@ -24,6 +26,9 @@
  * ... do not work on Solaris 10 using GNU CC 3.4.x.
  * Try to workaround the missing / broken C99 math macros.
  */
+#if defined(__OpenBSD__)
+#define unordered(x, y) (isnan(x) || isnan(y))
+#endif
 
 #define isnormal(x)             (fpclass(x) >= FP_NZERO)
 #define isgreater(x, y)         ((!unordered(x, y)) && ((x) > (y)))
@@ -84,6 +89,11 @@
 | Software IEC/IEEE floating-point rounding mode.
 *----------------------------------------------------------------------------*/
 #if (defined(_BSD) && !defined(__APPLE__)) || defined(HOST_SOLARIS)
+#if defined(__OpenBSD__)
+#define FE_RM FP_RM
+#define FE_RP FP_RP
+#define FE_RZ FP_RZ
+#endif
 enum {
     float_round_nearest_even = FP_RN,
     float_round_down         = FP_RM,
curses.c +4 -0
Index: qemu/curses.c
===================================================================
@@ -34,6 +34,10 @@
 #include <termios.h>
 #endif
 
+#ifdef __OpenBSD__
+#define resize_term resizeterm
+#endif
+
 #define FONT_HEIGHT 16
 #define FONT_WIDTH 8
 
#6 lore raw
Quoted 10 lines · Blue Swirl
Quoted 3 lines · Anthony Liguori

The first patch is fine but the second patch has some bogus things in it.

Thanks for the review. I removed the unneeded parts, made a separate patch for fixing OSS selection, and added a configure option for AIO as requested by Samuel Thibault.

They look good to me.

Regards,

Anthony Liguori

#7 lore raw
In reply to Blue Swirl
Quoted 11 lines · Blue Swirl
Quoted 10 lines · Anthony Liguori
Quoted 7 lines · Blue Swirl

Here are two patches, loosely based on patches in OpenBSD ports system that enable compiling Qemu. The first patch makes AIO use conditional on host AIO support. The second one adjusts various include files etc.

I'd like to commit both of these, is that OK?

Quoted 5 lines
Quoted 1 line

The first patch is fine but the second patch has some bogus things in it.

Thanks for the review. I removed the unneeded parts, made a separate patch for fixing OSS selection, and added a configure option for AIO as requested by Samuel Thibault.

Thanks for the OSS bits, i have committed slightly modified patch that takes all possible drivers into consideration.

Signature · 1 line
mailto:[email protected]
author
#8 lore raw
Quoted 21 lines · malc
Quoted 9 lines · Blue Swirl
Quoted 7 lines · Anthony Liguori
Quoted 4 lines · Blue Swirl

Here are two patches, loosely based on patches in OpenBSD ports system that enable compiling Qemu. The first patch makes AIO use conditional on host AIO support. The second one adjusts various include files etc.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

I'd like to commit both of these, is that OK?

The first patch is fine but the second patch has some bogus things in

it.

Quoted 2 lines
Quoted 1 line
Quoted 7 lines
Quoted 4 lines

Thanks for the review. I removed the unneeded parts, made a separate patch for fixing OSS selection, and added a configure option for AIO as requested by Samuel Thibault.

Thanks for the OSS bits, i have committed slightly modified patch that takes all possible drivers into consideration.

Great, but there is a bug in your commit, *) case seems to be checked before oss|sdl... case gets into play so the error is still present:

Error: Unknown driver 'oss' selected
Possible drivers are: oss sdl esd

#9 lore raw

Actually, the problem is that some driver lists (NetBSD in particular) were changed to

	list="<a> <b> <c>"

while others (OpenBSD in particular) were left with
list="a b c"

fun!

Signature · 14 lines
Todd Fries .. [email protected]

 _____________________________________________
|                                             \  1.636.410.0632 (voice)
| Free Daemon Consulting, LLC                 \  1.405.227.9094 (voice)
| http://FreeDaemonConsulting.com             \  1.866.792.3418 (FAX)
| "..in support of free software solutions."  \          250797 (FWD)
|                                             \
 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
                                                 
              37E7 D3EB 74D0 8D66 A68D  B866 0326 204E 3F42 004A
                        http://todd.fries.net/pgp.txt

Penned by Blue Swirl on 20080815 23:05.40, we have:
| On 8/14/08, malc <[email protected]> wrote:
| > On Wed, 13 Aug 2008, Blue Swirl wrote:
| >
| >
| > > On 8/12/08, Anthony Liguori <[email protected]> wrote:
| > >
| > > > Blue Swirl wrote:
| > > >
| > > >
| > > > > Here are two patches, loosely based on patches in OpenBSD ports system
| > > > > that enable compiling Qemu. The first patch makes AIO use conditional
| > > > > on host AIO support. The second one adjusts various include files etc.
| > > > >
| > > > > I'd like to commit both of these, is that OK?
| > > > >
| > > > >
| > > > >
| > > >
| > > >  The first patch is fine but the second patch has some bogus things in
| > it.
| > > >
| > >
| > > Thanks for the review. I removed the unneeded parts, made a separate
| > > patch for fixing OSS selection, and added a configure option for AIO
| > > as requested by Samuel Thibault.
| > >
| >
| >  Thanks for the OSS bits, i have committed slightly modified patch that
| >  takes all possible drivers into consideration.
| 
| Great, but there is a bug in your commit, *) case seems to be checked
| before oss|sdl... case gets into play so the error is still present:
| 
| Error: Unknown driver 'oss' selected
| Possible drivers are: oss sdl esd
| 
#10 lore raw
In reply to Blue Swirl
Quoted 5 lines · Blue Swirl
Quoted 4 lines · malc
Quoted 1 line · Blue Swirl

On 8/12/08, Anthony Liguori <[email protected]> wrote:

[..snip..]

Quoted 6 lines
Quoted 3 lines

Thanks for the OSS bits, i have committed slightly modified patch that takes all possible drivers into consideration.

Great, but there is a bug in your commit, *) case seems to be checked before oss|sdl... case gets into play so the error is still present:

I was ready to apologize for not testing, but then rechecked my scripts and i in fact did test it properly and it worked (and still does), that said you are ofcourse right here. Must be some sort of shell difference, which one did you use?

Quoted 4 lines

Error: Unknown driver 'oss' selected
Possible drivers are: oss sdl esd

Signature · 1 line
mailto:[email protected]
author
#11 lore raw
Quoted 23 lines · malc
Quoted 10 lines · Blue Swirl
Quoted 7 lines · malc
Quoted 2 lines · Blue Swirl

On 8/12/08, Anthony Liguori <[email protected]> wrote:

[..snip..]

Quoted 6 lines
Quoted 5 lines

Thanks for the OSS bits, i have committed slightly modified patch that takes all possible drivers into consideration.

Quoted 8 lines
Quoted 3 lines

Great, but there is a bug in your commit, *) case seems to be checked before oss|sdl... case gets into play so the error is still present:

I was ready to apologize for not testing, but then rechecked my scripts and i in fact did test it properly and it worked (and still does), that said you are ofcourse right here. Must be some sort of shell difference, which one did you use?

/bin/sh is hard linked to ksh (Korn shell).

#12 lore raw
Quoted 28 lines · Blue Swirl
Quoted 27 lines · malc
Quoted 10 lines · Blue Swirl
Quoted 7 lines · malc
Quoted 2 lines · Blue Swirl

On 8/12/08, Anthony Liguori <[email protected]> wrote:

[..snip..]

Quoted 9 lines
Quoted 5 lines

Thanks for the OSS bits, i have committed slightly modified patch that takes all possible drivers into consideration.

Great, but there is a bug in your commit, *) case seems to be checked before oss|sdl... case gets into play so the error is still present:

Quoted 6 lines
Quoted 4 lines

I was ready to apologize for not testing, but then rechecked my scripts and i in fact did test it properly and it worked (and still does), that said you are ofcourse right here. Must be some sort of shell difference, which one did you use?

/bin/sh is hard linked to ksh (Korn shell).

I see. If my reading of [1] is correct, ksh is right and `GNU bash, version 3.1.17(2)-release' (which is what i have) is wrong.

[1] http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html

Signature · 1 line
mailto:[email protected]
author
#13 lore raw
In reply to malc
Quoted 21 lines · malc
Quoted 9 lines · Blue Swirl
Quoted 7 lines · Anthony Liguori
Quoted 4 lines · Blue Swirl

Here are two patches, loosely based on patches in OpenBSD ports system that enable compiling Qemu. The first patch makes AIO use conditional on host AIO support. The second one adjusts various include files etc.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

I'd like to commit both of these, is that OK?

The first patch is fine but the second patch has some bogus things in

it.

Quoted 2 lines
Quoted 1 line
Quoted 7 lines
Quoted 4 lines

Thanks for the review. I removed the unneeded parts, made a separate patch for fixing OSS selection, and added a configure option for AIO as requested by Samuel Thibault.

Thanks for the OSS bits, i have committed slightly modified patch that takes all possible drivers into consideration.

This patch fixes OSS selection and adds the needed libraries to LIBS.

configure +11 -5
Index: qemu/configure
===================================================================
@@ -92,6 +92,7 @@
 vde="yes"
 fmod_lib=""
 fmod_inc=""
+oss_lib=""
 vnc_tls="yes"
 bsd="no"
 linux="no"
@@ -153,6 +154,7 @@
 openbsd="yes"
 audio_drv_list="oss"
 audio_possible_drivers="oss sdl esd"
+oss_lib="-lossaudio"
 ;;
 Darwin)
 bsd="yes"
@@ -273,6 +275,8 @@
   ;;
   --fmod-inc=*) fmod_inc="$optarg"
   ;;
+  --oss-lib=*) oss_lib="$optarg"
+  ;;
   --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
   ;;
   --audio-drv-list=*) audio_drv_list="$optarg"
@@ -437,6 +441,7 @@
 echo "  --disable-darwin-user    disable all darwin usermode emulation targets"
 echo "  --fmod-lib               path to FMOD library"
 echo "  --fmod-inc               path to FMOD includes"
+echo "  --oss-lib                path to OSS library"
 echo "  --enable-uname-release=R Return R for uname -r in usermode emulation"
 echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
 echo "  --disable-vde            disable support for vde network"
@@ -823,6 +828,10 @@
         "pa_simple *s = NULL; pa_simple_free(s); return 0;"
     ;;
 
+    oss|sdl|core|wav|dsound)
+    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
+    ;;
+
     *)
     echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
         echo
@@ -832,11 +841,6 @@
         exit 1
     }
     ;;
-
-    oss|sdl|core|wav|dsound)
-    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
-    ;;
-
     esac
 done
 
@@ -1145,6 +1149,8 @@
     if test "$drv" = "fmod"; then
         echo "CONFIG_FMOD_LIB=$fmod_lib" >> $config_mak
         echo "CONFIG_FMOD_INC=$fmod_inc" >> $config_mak
+    elif test "$drv" = "oss"; then
+        echo "CONFIG_OSS_LIB=$oss_lib" >> $config_mak
     fi
 done
 echo "" >>$config_h
Makefile.target +3 -0
Index: qemu/Makefile.target
===================================================================
@@ -495,6 +495,9 @@
 ifdef CONFIG_FMOD
 LIBS += $(CONFIG_FMOD_LIB)
 endif
+ifdef CONFIG_OSS
+LIBS += $(CONFIG_OSS_LIB)
+endif
 
 SOUND_HW = sb16.o es1370.o
 ifdef CONFIG_AC97
#14 lore raw
In reply to Blue Swirl
Quoted 1 line · Blue Swirl, le Tue 12 Aug 2008 21:45:51 +0300, a écrit :

The first patch makes AIO use conditional on host AIO support.

Cool, we actually had something very similar in the xen tree. Could you add a configure option as well?

Samuel

#15 lore raw
In reply to Blue Swirl

For BSD, you may need the patch below as well (from the xen repo)

changeset:   15970:04cc0e22a20a 
user:        Keir Fraser <[email protected]> 
date:        Thu Sep 27 16:36:23 2007 +0100 
files:       tools/ioemu/audio/audio.c tools/ioemu/audio/mixeng.c tools/ioemu/audio/ossaudio.c tools/ioemu/block-raw.c tools/ioemu/block-vvfat.c tools/ioemu/bswap.h tools/ioemu/cutils.c tools/ioemu/monitor.c tools/ioemu/osdep.h tools/ioemu/target-i386-dm/exec-dm.c tools/ioemu/usb-linux.c tools/ioemu/vl.c tools/ioemu/vl.h tools/ioemu/vnc.c 

description:
ioemu: Fixes for BSD.

Samuel

I don't know why this one was done, it looks a bit odd.

audio/mixeng.c +4 -0
index b668c52..f4b8003 100644
@@ -146,6 +146,7 @@
 #undef SHIFT
 
 t_sample *mixeng_conv[2][2][2][3] = {
+#ifndef _BSD
     {
         {
             {
@@ -198,9 +199,11 @@ t_sample *mixeng_conv[2][2][2][3] = {
             }
         }
     }
+#endif /* !_BSD */
 };
 
 f_sample *mixeng_clip[2][2][2][3] = {
+#ifndef _BSD
     {
         {
             {
@@ -253,6 +256,7 @@ f_sample *mixeng_clip[2][2][2][3] = {
             }
         }
     }
+#endif /* !_BSD */
 };
 
 /*

Possibly related to the hunk above, something like improper endian detection?

bswap.h +7 -0
index 523d805..fd589da 100644
@@ -5,6 +5,11 @@
 
 #include <inttypes.h>
 
+#ifdef _BSD
+#include <sys/endian.h>
+#include <sys/types.h>
+#else
+
 #ifdef HAVE_BYTESWAP_H
 #include <byteswap.h>
 #else
@@ -73,6 +78,8 @@ static inline void bswap64s(uint64_t *s)
     *s = bswap64(*s);
 }
 
+#endif /* _BSD */
+
 #if defined(WORDS_BIGENDIAN)
 #define be_bswap(v, size) (v)
 #define le_bswap(v, size) bswap ## size(v)