Commit 414f0dab0970795f043f2396fe9449f69b49b20c

Authored by blueswir1
1 parent 53c37487

Use AIO only if host supports it (based on OpenBSD patches by Todd T. Fries)

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5010 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 2 changed files with 59 additions and 0 deletions
block-raw-posix.c
@@ -28,7 +28,9 @@ @@ -28,7 +28,9 @@
28 #endif 28 #endif
29 #include "block_int.h" 29 #include "block_int.h"
30 #include <assert.h> 30 #include <assert.h>
  31 +#ifdef CONFIG_AIO
31 #include <aio.h> 32 #include <aio.h>
  33 +#endif
32 34
33 #ifdef CONFIG_COCOA 35 #ifdef CONFIG_COCOA
34 #include <paths.h> 36 #include <paths.h>
@@ -418,6 +420,7 @@ static int raw_pwrite(BlockDriverState *bs, int64_t offset, @@ -418,6 +420,7 @@ static int raw_pwrite(BlockDriverState *bs, int64_t offset,
418 #endif 420 #endif
419 421
420 422
  423 +#ifdef CONFIG_AIO
421 /***********************************************************/ 424 /***********************************************************/
422 /* Unix AIO using POSIX AIO */ 425 /* Unix AIO using POSIX AIO */
423 426
@@ -688,6 +691,37 @@ static void raw_aio_cancel(BlockDriverAIOCB *blockacb) @@ -688,6 +691,37 @@ static void raw_aio_cancel(BlockDriverAIOCB *blockacb)
688 } 691 }
689 } 692 }
690 693
  694 +# else /* CONFIG_AIO */
  695 +
  696 +void qemu_aio_init(void)
  697 +{
  698 +}
  699 +
  700 +void qemu_aio_poll(void)
  701 +{
  702 +}
  703 +
  704 +void qemu_aio_flush(void)
  705 +{
  706 +}
  707 +
  708 +void qemu_aio_wait_start(void)
  709 +{
  710 +}
  711 +
  712 +void qemu_aio_wait(void)
  713 +{
  714 +#if !defined(QEMU_IMG) && !defined(QEMU_NBD)
  715 + qemu_bh_poll();
  716 +#endif
  717 +}
  718 +
  719 +void qemu_aio_wait_end(void)
  720 +{
  721 +}
  722 +
  723 +#endif /* CONFIG_AIO */
  724 +
691 static void raw_close(BlockDriverState *bs) 725 static void raw_close(BlockDriverState *bs)
692 { 726 {
693 BDRVRawState *s = bs->opaque; 727 BDRVRawState *s = bs->opaque;
@@ -792,10 +826,12 @@ BlockDriver bdrv_raw = { @@ -792,10 +826,12 @@ BlockDriver bdrv_raw = {
792 raw_create, 826 raw_create,
793 raw_flush, 827 raw_flush,
794 828
  829 +#ifdef CONFIG_AIO
795 .bdrv_aio_read = raw_aio_read, 830 .bdrv_aio_read = raw_aio_read,
796 .bdrv_aio_write = raw_aio_write, 831 .bdrv_aio_write = raw_aio_write,
797 .bdrv_aio_cancel = raw_aio_cancel, 832 .bdrv_aio_cancel = raw_aio_cancel,
798 .aiocb_size = sizeof(RawAIOCB), 833 .aiocb_size = sizeof(RawAIOCB),
  834 +#endif
799 .protocol_name = "file", 835 .protocol_name = "file",
800 .bdrv_pread = raw_pread, 836 .bdrv_pread = raw_pread,
801 .bdrv_pwrite = raw_pwrite, 837 .bdrv_pwrite = raw_pwrite,
@@ -1144,10 +1180,12 @@ BlockDriver bdrv_host_device = { @@ -1144,10 +1180,12 @@ BlockDriver bdrv_host_device = {
1144 NULL, 1180 NULL,
1145 raw_flush, 1181 raw_flush,
1146 1182
  1183 +#ifdef CONFIG_AIO
1147 .bdrv_aio_read = raw_aio_read, 1184 .bdrv_aio_read = raw_aio_read,
1148 .bdrv_aio_write = raw_aio_write, 1185 .bdrv_aio_write = raw_aio_write,
1149 .bdrv_aio_cancel = raw_aio_cancel, 1186 .bdrv_aio_cancel = raw_aio_cancel,
1150 .aiocb_size = sizeof(RawAIOCB), 1187 .aiocb_size = sizeof(RawAIOCB),
  1188 +#endif
1151 .bdrv_pread = raw_pread, 1189 .bdrv_pread = raw_pread,
1152 .bdrv_pwrite = raw_pwrite, 1190 .bdrv_pwrite = raw_pwrite,
1153 .bdrv_getlength = raw_getlength, 1191 .bdrv_getlength = raw_getlength,
configure
@@ -106,6 +106,7 @@ darwin_user=&quot;no&quot; @@ -106,6 +106,7 @@ darwin_user=&quot;no&quot;
106 build_docs="no" 106 build_docs="no"
107 uname_release="" 107 uname_release=""
108 curses="yes" 108 curses="yes"
  109 +aio="yes"
109 nptl="yes" 110 nptl="yes"
110 mixemu="no" 111 mixemu="no"
111 112
@@ -334,6 +335,8 @@ for opt do @@ -334,6 +335,8 @@ for opt do
334 ;; 335 ;;
335 --enable-mixemu) mixemu="yes" 336 --enable-mixemu) mixemu="yes"
336 ;; 337 ;;
  338 + --disable-aio) aio="no"
  339 + ;;
337 *) echo "ERROR: unknown option $opt"; show_help="yes" 340 *) echo "ERROR: unknown option $opt"; show_help="yes"
338 ;; 341 ;;
339 esac 342 esac
@@ -436,6 +439,7 @@ echo &quot; --fmod-inc path to FMOD includes&quot; @@ -436,6 +439,7 @@ echo &quot; --fmod-inc path to FMOD includes&quot;
436 echo " --enable-uname-release=R Return R for uname -r in usermode emulation" 439 echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
437 echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9" 440 echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
438 echo " --disable-vde disable support for vde network" 441 echo " --disable-vde disable support for vde network"
  442 +echo " --disable-aio disable AIO support"
439 echo "" 443 echo ""
440 echo "NOTE: The object files are built at the place where configure is launched" 444 echo "NOTE: The object files are built at the place where configure is launched"
441 exit 1 445 exit 1
@@ -863,6 +867,19 @@ EOF @@ -863,6 +867,19 @@ EOF
863 fi 867 fi
864 fi # test "$curses" 868 fi # test "$curses"
865 869
  870 +##########################################
  871 +# AIO probe
  872 +if test "$aio" = "yes" ; then
  873 + aio=no
  874 + cat > $TMPC << EOF
  875 +#include <aio.h>
  876 +int main(void) { return aio_write(NULL); }
  877 +EOF
  878 + if $cc $ARCH_CFLAGS -o $TMPE $AIOLIBS $TMPC 2> /dev/null ; then
  879 + aio=yes
  880 + fi
  881 +fi
  882 +
866 # Check if tools are available to build documentation. 883 # Check if tools are available to build documentation.
867 if [ -x "`which texi2html 2>/dev/null`" ] && \ 884 if [ -x "`which texi2html 2>/dev/null`" ] && \
868 [ -x "`which pod2man 2>/dev/null`" ]; then 885 [ -x "`which pod2man 2>/dev/null`" ]; then
@@ -934,6 +951,7 @@ echo &quot;Documentation $build_docs&quot; @@ -934,6 +951,7 @@ echo &quot;Documentation $build_docs&quot;
934 echo "uname -r $uname_release" 951 echo "uname -r $uname_release"
935 echo "NPTL support $nptl" 952 echo "NPTL support $nptl"
936 echo "vde support $vde" 953 echo "vde support $vde"
  954 +echo "AIO support $aio"
937 955
938 if test $sdl_too_old = "yes"; then 956 if test $sdl_too_old = "yes"; then
939 echo "-> Your SDL version is too old - please upgrade to have SDL support" 957 echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -1179,6 +1197,9 @@ if test &quot;$brlapi&quot; = &quot;yes&quot; ; then @@ -1179,6 +1197,9 @@ if test &quot;$brlapi&quot; = &quot;yes&quot; ; then
1179 echo "#define CONFIG_BRLAPI 1" >> $config_h 1197 echo "#define CONFIG_BRLAPI 1" >> $config_h
1180 echo "BRLAPI_LIBS=-lbrlapi" >> $config_mak 1198 echo "BRLAPI_LIBS=-lbrlapi" >> $config_mak
1181 fi 1199 fi
  1200 +if test "$aio" = "yes" ; then
  1201 + echo "#define CONFIG_AIO 1" >> $config_h
  1202 +fi
1182 1203
1183 # XXX: suppress that 1204 # XXX: suppress that
1184 if [ "$bsd" = "yes" ] ; then 1205 if [ "$bsd" = "yes" ] ; then