Skip to contentSkip to conversation

Do we need CONFIG_AIO?

Qemu-devel Christoph Hellwig 6 participants 15 messages May 25, 2009 – May 26, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Currently all aio code in the raw-posix block driver depends on a CONFIG_AIO symbol that gets set based on the availability of the pthreads library. Beeing able to rely on unconditional aio support means we could remove the whole code for plain bdrv_read/bdrv_write in raw-posix.c which is about 300 lines of code and a duplicated code path. Is there any Posix-ish platform qemu supports that does not have pthreads support?

#1 lore raw
Quoted 8 lines · Christoph Hellwig

Currently all aio code in the raw-posix block driver depends on a CONFIG_AIO symbol that gets set based on the availability of the pthreads library. Beeing able to rely on unconditional aio support means we could remove the whole code for plain bdrv_read/bdrv_write in raw-posix.c which is about 300 lines of code and a duplicated code path. Is there any Posix-ish platform qemu supports that does not have pthreads support?

MiniOS.
I would appreciate if you keep that flag.

#2 lore raw
Quoted 11 lines · Stefano Stabellini
Quoted 8 lines

Currently all aio code in the raw-posix block driver depends on a CONFIG_AIO symbol that gets set based on the availability of the pthreads library. Beeing able to rely on unconditional aio support means we could remove the whole code for plain bdrv_read/bdrv_write in raw-posix.c which is about 300 lines of code and a duplicated code path. Is there any Posix-ish platform qemu supports that does not have pthreads support?

MiniOS.
I would appreciate if you keep that flag.

I can't find MiniOS mentioned anywhere in the qemu tree. From googling around it seems to be some Xen demo kernel. Do you plan to merge support for it one day? And what's the use case for qemu on MiniOS? If it's anything performance sensitive the lack of aio will cause quite severe stalling of the guest.

#3 lore raw
Quoted 5 lines · Christoph Hellwig, le Mon 25 May 2009 14:29:29 +0200, a écrit :
Quoted 4 lines · Stefano Stabellini
Quoted 3 lines

Is there any Posix-ish platform qemu supports that does not have pthreads support?

Quoted 8 lines
Quoted 2 lines

MiniOS.
I would appreciate if you keep that flag.

I can't find MiniOS mentioned anywhere in the qemu tree. From googling around it seems to be some Xen demo kernel. Do you plan to merge support for it one day? And what's the use case for qemu on MiniOS? If it's anything performance sensitive the lack of aio will cause quite severe stalling of the guest.

qemu on MiniOS is used to provide efficient full virtualisation, so yes it's performance sensitive, but for performances we use a block-vbd interface. Keeping the block-posix interface for non-performance critical resources that can not go through vbd is still important, so we need to be able to compile it.

Samuel

#4 lore raw
Quoted 5 lines · Samuel Thibault

qemu on MiniOS is used to provide efficient full virtualisation, so yes it's performance sensitive, but for performances we use a block-vbd interface. Keeping the block-posix interface for non-performance critical resources that can not go through vbd is still important, so we need to be able to compile it.

Apparently all this is not in upstream qemu, right? I really don't see the reason to keep all this stuff around for out of tree bits only given it is a significant burden.

#5 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 5 lines · Samuel Thibault

qemu on MiniOS is used to provide efficient full virtualisation, so yes it's performance sensitive, but for performances we use a block-vbd interface. Keeping the block-posix interface for non-performance critical resources that can not go through vbd is still important, so we need to be able to compile it.

Apparently all this is not in upstream qemu, right? I really don't see the reason to keep all this stuff around for out of tree bits only given it is a significant burden.

I completely agree with you, but I couldn't find the time to merge all the bits yet. I hope to find more time in the next 6 months.

#6 lore raw
In reply to Stefano Stabellini

Penned by Stefano Stabellini on 20090525 12:49.08, we have:

| Christoph Hellwig wrote:
| 
| > Currently all aio code in the raw-posix block driver depends on a
| > CONFIG_AIO symbol that gets set based on the availability of the
| > pthreads library.  Beeing able to rely on unconditional aio support
| > means we could remove the whole code for plain bdrv_read/bdrv_write
| > in raw-posix.c which is about 300 lines of code and a duplicated code
| > path.  Is there any Posix-ish platform qemu supports that does not
| > have pthreads support?
| > 
| 
| MiniOS.
| I would appreciate if you keep that flag.

You seem to be under the illusion that pthreads implies AIO.

OpenBSD has two flavors of threads libraries (arguably one is not fit for consumption yet) and neither provide AIO.

This flag is most useful for OpenBSD as well.

Thanks,

Signature · 12 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
#7 lore raw
Quoted 1 line · Todd T. Fries

You seem to be under the illusion that pthreads implies AIO.

I'm not just under the illusion, but in the context of qemu we do implement our own aio support using pthread. And that's exactly what CONFIG_AIO enables.

#8 lore raw
In reply to Todd T. Fries
Quoted 12 lines · Todd T. Fries

Penned by Stefano Stabellini on 20090525 12:49.08, we have:

| Christoph Hellwig wrote:
| | > Currently all aio code in the raw-posix block driver depends on a
| > CONFIG_AIO symbol that gets set based on the availability of the
| > pthreads library.  Beeing able to rely on unconditional aio support
| > means we could remove the whole code for plain bdrv_read/bdrv_write
| > in raw-posix.c which is about 300 lines of code and a duplicated code
| > path.  Is there any Posix-ish platform qemu supports that does not
| > have pthreads support?
| > | | MiniOS.
| I would appreciate if you keep that flag.
Quoted 2 lines

You seem to be under the illusion that pthreads implies AIO.

He isn't.

Quoted 5 lines

OpenBSD has two flavors of threads libraries (arguably one is not fit for consumption yet) and neither provide AIO.

This flag is most useful for OpenBSD as well.

Qemu's CONFIG_AIO requires thread support from the host, not posix aio support.

Signature · 1 line
error compiling committee.c: too many arguments to function
#9 lore raw

Penned by Avi Kivity on 20090525 16:47.14, we have:

Quoted 18 lines
Quoted 12 lines · Todd T. Fries

Penned by Stefano Stabellini on 20090525 12:49.08, we have:

| Christoph Hellwig wrote:
| | > Currently all aio code in the raw-posix block driver depends on a
| > CONFIG_AIO symbol that gets set based on the availability of the
| > pthreads library.  Beeing able to rely on unconditional aio support
| > means we could remove the whole code for plain bdrv_read/bdrv_write
| > in raw-posix.c which is about 300 lines of code and a duplicated code
| > path.  Is there any Posix-ish platform qemu supports that does not
| > have pthreads support?
| > | | MiniOS.
| I would appreciate if you keep that flag.
Quoted 2 lines

You seem to be under the illusion that pthreads implies AIO.

He isn't.

Quoted 8 lines
Quoted 5 lines

OpenBSD has two flavors of threads libraries (arguably one is not fit for consumption yet) and neither provide AIO.

This flag is most useful for OpenBSD as well.

Qemu's CONFIG_AIO requires thread support from the host, not posix aio support.

If thats the way things work, great. I just recall when AIO made its debut in qemu we had to figure out some strange workarounds..

Signature · 12 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
#10 lore raw
Quoted 6 lines · Todd T. Fries
Quoted 2 lines

Qemu's CONFIG_AIO requires thread support from the host, not posix aio support.

If thats the way things work, great. I just recall when AIO made its debut in qemu we had to figure out some strange workarounds..

Things have changed, mostly due to EGLIBC's crappy aio implementation.

Signature · 1 line
error compiling committee.c: too many arguments to function
#11 lore raw
In reply to Stefano Stabellini
Quoted 13 lines · Stefano Stabellini
Quoted 9 lines · Christoph Hellwig

Currently all aio code in the raw-posix block driver depends on a CONFIG_AIO symbol that gets set based on the availability of the pthreads library. Beeing able to rely on unconditional aio support means we could remove the whole code for plain bdrv_read/bdrv_write in raw-posix.c which is about 300 lines of code and a duplicated code path. Is there any Posix-ish platform qemu supports that does not have pthreads support?

Quoted 3 lines

MiniOS.
I would appreciate if you keep that flag.

Threads are not going to be able to remain an optional dependency forever. I would be willing to merge something to remove CONFIG_AIO although I expect that there will be some fall out. Some people are using --disable-aio today for either historic reasons or because there are weird bugs with AIO enabled.

Regards,

Anthony Liguori

#12 lore raw
Quoted 5 lines · Anthony Liguori

Threads are not going to be able to remain an optional dependency forever. I would be willing to merge something to remove CONFIG_AIO although I expect that there will be some fall out. Some people are using --disable-aio today for either historic reasons or because there are weird bugs with AIO enabled.

Btw, this is the example patch I had in mind. Also when finishing up the configure bits I noticed DragonflyBSD currently does disable aio (but not pthreads in general), but that's the only platform I found.

block/raw-posix.c +5 -328
Index: qemu/block/raw-posix.c
===================================================================
@@ -26,9 +26,7 @@
 #include "qemu-char.h"
 #include "block_int.h"
 #include "module.h"
-#ifdef CONFIG_AIO
 #include "posix-aio-compat.h"
-#endif
 
 #ifdef CONFIG_COCOA
 #include <paths.h>
@@ -102,7 +100,7 @@
 typedef struct BDRVRawState {
     int fd;
     int type;
-    unsigned int lseek_err_cnt;
+    int flags;
     int open_flags;
 #if defined(__linux__)
     /* linux floppy specific */
@@ -111,7 +109,6 @@ typedef struct BDRVRawState {
     int fd_got_error;
     int fd_media_changed;
 #endif
-    uint8_t* aligned_buf;
 } BDRVRawState;
 
 static int posix_aio_init(void);
@@ -130,8 +127,6 @@ static int raw_open_common(BlockDriverSt
 
     posix_aio_init();
 
-    s->lseek_err_cnt = 0;
-
     s->open_flags |= O_BINARY;
     if ((flags & BDRV_O_ACCESS) == O_RDWR) {
         s->open_flags |= O_RDWR;
@@ -156,15 +151,8 @@ static int raw_open_common(BlockDriverSt
         return ret;
     }
     s->fd = fd;
-    s->aligned_buf = NULL;
-    if ((flags & BDRV_O_NOCACHE)) {
-        s->aligned_buf = qemu_blockalign(bs, ALIGNED_BUFFER_SIZE);
-        if (s->aligned_buf == NULL) {
-            ret = -errno;
-            close(fd);
-            return ret;
-        }
-    }
+    s->flags = flags;
+
     return 0;
 }
 
@@ -196,282 +184,6 @@ static int raw_open(BlockDriverState *bs
 #endif
 */
 
-/*
- * offset and count are in bytes, but must be multiples of 512 for files
- * opened with O_DIRECT. buf must be aligned to 512 bytes then.
- *
- * This function may be called without alignment if the caller ensures
- * that O_DIRECT is not in effect.
- */
-static int raw_pread_aligned(BlockDriverState *bs, int64_t offset,
-                     uint8_t *buf, int count)
-{
-    BDRVRawState *s = bs->opaque;
-    int ret;
-
-    ret = fd_open(bs);
-    if (ret < 0)
-        return ret;
-
-    if (offset >= 0 && lseek(s->fd, offset, SEEK_SET) == (off_t)-1) {
-        ++(s->lseek_err_cnt);
-        if(s->lseek_err_cnt <= 10) {
-            DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
-                              "] lseek failed : %d = %s\n",
-                              s->fd, bs->filename, offset, buf, count,
-                              bs->total_sectors, errno, strerror(errno));
-        }
-        return -1;
-    }
-    s->lseek_err_cnt=0;
-
-    ret = read(s->fd, buf, count);
-    if (ret == count)
-        goto label__raw_read__success;
-
-    DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
-                      "] read failed %d : %d = %s\n",
-                      s->fd, bs->filename, offset, buf, count,
-                      bs->total_sectors, ret, errno, strerror(errno));
-
-    /* Try harder for CDrom. */
-    if (bs->type == BDRV_TYPE_CDROM) {
-        lseek(s->fd, offset, SEEK_SET);
-        ret = read(s->fd, buf, count);
-        if (ret == count)
-            goto label__raw_read__success;
-        lseek(s->fd, offset, SEEK_SET);
-        ret = read(s->fd, buf, count);
-        if (ret == count)
-            goto label__raw_read__success;
-
-        DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
-                          "] retry read failed %d : %d = %s\n",
-                          s->fd, bs->filename, offset, buf, count,
-                          bs->total_sectors, ret, errno, strerror(errno));
-    }
-
-label__raw_read__success:
-
-    return  (ret < 0) ? -errno : ret;
-}
-
-/*
- * offset and count are in bytes, but must be multiples of 512 for files
- * opened with O_DIRECT. buf must be aligned to 512 bytes then.
- *
- * This function may be called without alignment if the caller ensures
- * that O_DIRECT is not in effect.
- */
-static int raw_pwrite_aligned(BlockDriverState *bs, int64_t offset,
-                      const uint8_t *buf, int count)
-{
-    BDRVRawState *s = bs->opaque;
-    int ret;
-
-    ret = fd_open(bs);
-    if (ret < 0)
-        return -errno;
-
-    if (offset >= 0 && lseek(s->fd, offset, SEEK_SET) == (off_t)-1) {
-        ++(s->lseek_err_cnt);
-        if(s->lseek_err_cnt) {
-            DEBUG_BLOCK_PRINT("raw_pwrite(%d:%s, %" PRId64 ", %p, %d) [%"
-                              PRId64 "] lseek failed : %d = %s\n",
-                              s->fd, bs->filename, offset, buf, count,
-                              bs->total_sectors, errno, strerror(errno));
-        }
-        return -EIO;
-    }
-    s->lseek_err_cnt = 0;
-
-    ret = write(s->fd, buf, count);
-    if (ret == count)
-        goto label__raw_write__success;
-
-    DEBUG_BLOCK_PRINT("raw_pwrite(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
-                      "] write failed %d : %d = %s\n",
-                      s->fd, bs->filename, offset, buf, count,
-                      bs->total_sectors, ret, errno, strerror(errno));
-
-label__raw_write__success:
-
-    return  (ret < 0) ? -errno : ret;
-}
-
-
-/*
- * offset and count are in bytes and possibly not aligned. For files opened
- * with O_DIRECT, necessary alignments are ensured before calling
- * raw_pread_aligned to do the actual read.
- */
-static int raw_pread(BlockDriverState *bs, int64_t offset,
-                     uint8_t *buf, int count)
-{
-    BDRVRawState *s = bs->opaque;
-    int size, ret, shift, sum;
-
-    sum = 0;
-
-    if (s->aligned_buf != NULL)  {
-
-        if (offset & 0x1ff) {
-            /* align offset on a 512 bytes boundary */
-
-            shift = offset & 0x1ff;
-            size = (shift + count + 0x1ff) & ~0x1ff;
-            if (size > ALIGNED_BUFFER_SIZE)
-                size = ALIGNED_BUFFER_SIZE;
-            ret = raw_pread_aligned(bs, offset - shift, s->aligned_buf, size);
-            if (ret < 0)
-                return ret;
-
-            size = 512 - shift;
-            if (size > count)
-                size = count;
-            memcpy(buf, s->aligned_buf + shift, size);
-
-            buf += size;
-            offset += size;
-            count -= size;
-            sum += size;
-
-            if (count == 0)
-                return sum;
-        }
-        if (count & 0x1ff || (uintptr_t) buf & 0x1ff) {
-
-            /* read on aligned buffer */
-
-            while (count) {
-
-                size = (count + 0x1ff) & ~0x1ff;
-                if (size > ALIGNED_BUFFER_SIZE)
-                    size = ALIGNED_BUFFER_SIZE;
-
-                ret = raw_pread_aligned(bs, offset, s->aligned_buf, size);
-                if (ret < 0)
-                    return ret;
-
-                size = ret;
-                if (size > count)
-                    size = count;
-
-                memcpy(buf, s->aligned_buf, size);
-
-                buf += size;
-                offset += size;
-                count -= size;
-                sum += size;
-            }
-
-            return sum;
-        }
-    }
-
-    return raw_pread_aligned(bs, offset, buf, count) + sum;
-}
-
-static int raw_read(BlockDriverState *bs, int64_t sector_num,
-                    uint8_t *buf, int nb_sectors)
-{
-    int ret;
-
-    ret = raw_pread(bs, sector_num * 512, buf, nb_sectors * 512);
-    if (ret == (nb_sectors * 512))
-        ret = 0;
-    return ret;
-}
-
-/*
- * offset and count are in bytes and possibly not aligned. For files opened
- * with O_DIRECT, necessary alignments are ensured before calling
- * raw_pwrite_aligned to do the actual write.
- */
-static int raw_pwrite(BlockDriverState *bs, int64_t offset,
-                      const uint8_t *buf, int count)
-{
-    BDRVRawState *s = bs->opaque;
-    int size, ret, shift, sum;
-
-    sum = 0;
-
-    if (s->aligned_buf != NULL) {
-
-        if (offset & 0x1ff) {
-            /* align offset on a 512 bytes boundary */
-            shift = offset & 0x1ff;
-            ret = raw_pread_aligned(bs, offset - shift, s->aligned_buf, 512);
-            if (ret < 0)
-                return ret;
-
-            size = 512 - shift;
-            if (size > count)
-                size = count;
-            memcpy(s->aligned_buf + shift, buf, size);
-
-            ret = raw_pwrite_aligned(bs, offset - shift, s->aligned_buf, 512);
-            if (ret < 0)
-                return ret;
-
-            buf += size;
-            offset += size;
-            count -= size;
-            sum += size;
-
-            if (count == 0)
-                return sum;
-        }
-        if (count & 0x1ff || (uintptr_t) buf & 0x1ff) {
-
-            while ((size = (count & ~0x1ff)) != 0) {
-
-                if (size > ALIGNED_BUFFER_SIZE)
-                    size = ALIGNED_BUFFER_SIZE;
-
-                memcpy(s->aligned_buf, buf, size);
-
-                ret = raw_pwrite_aligned(bs, offset, s->aligned_buf, size);
-                if (ret < 0)
-                    return ret;
-
-                buf += ret;
-                offset += ret;
-                count -= ret;
-                sum += ret;
-            }
-            /* here, count < 512 because (count & ~0x1ff) == 0 */
-            if (count) {
-                ret = raw_pread_aligned(bs, offset, s->aligned_buf, 512);
-                if (ret < 0)
-                    return ret;
-                 memcpy(s->aligned_buf, buf, count);
-
-                 ret = raw_pwrite_aligned(bs, offset, s->aligned_buf, 512);
-                 if (ret < 0)
-                     return ret;
-                 if (count < ret)
-                     ret = count;
-
-                 sum += ret;
-            }
-            return sum;
-        }
-    }
-    return raw_pwrite_aligned(bs, offset, buf, count) + sum;
-}
-
-static int raw_write(BlockDriverState *bs, int64_t sector_num,
-                     const uint8_t *buf, int nb_sectors)
-{
-    int ret;
-    ret = raw_pwrite(bs, sector_num * 512, buf, nb_sectors * 512);
-    if (ret == (nb_sectors * 512))
-        ret = 0;
-    return ret;
-}
-
-#ifdef CONFIG_AIO
 /***********************************************************/
 /* Unix AIO using POSIX AIO */
 
@@ -629,7 +341,7 @@ static RawAIOCB *raw_aio_setup(BlockDriv
      * boundary. Tell the low level code to ensure that in case it's
      * not done yet.
      */
-    if (s->aligned_buf)
+    if (s->flags & BDRV_O_NOCACHE)
         acb->aiocb.aio_flags |= QEMU_AIO_SECTOR_ALIGNED;
 
     acb->next = posix_aio_state->first_aio;
@@ -702,13 +414,6 @@ static void raw_aio_cancel(BlockDriverAI
 
     raw_aio_remove(acb);
 }
-#else /* CONFIG_AIO */
-static int posix_aio_init(void)
-{
-    return 0;
-}
-#endif /* CONFIG_AIO */
-
 
 static void raw_close(BlockDriverState *bs)
 {
@@ -716,8 +421,6 @@ static void raw_close(BlockDriverState *
     if (s->fd >= 0) {
         close(s->fd);
         s->fd = -1;
-        if (s->aligned_buf != NULL)
-            qemu_free(s->aligned_buf);
     }
 }
 
@@ -866,18 +569,14 @@ static BlockDriver bdrv_raw = {
     .instance_size = sizeof(BDRVRawState),
     .bdrv_probe = NULL, /* no probe for protocols */
     .bdrv_open = raw_open,
-    .bdrv_read = raw_read,
-    .bdrv_write = raw_write,
     .bdrv_close = raw_close,
     .bdrv_create = raw_create,
     .bdrv_flush = raw_flush,
 
-#ifdef CONFIG_AIO
     .bdrv_aio_readv = raw_aio_readv,
     .bdrv_aio_writev = raw_aio_writev,
     .bdrv_aio_cancel = raw_aio_cancel,
     .aiocb_size = sizeof(RawAIOCB),
-#endif
 
     .bdrv_truncate = raw_truncate,
     .bdrv_getlength = raw_getlength,
@@ -978,7 +677,7 @@ static int hdev_open(BlockDriverState *b
 #endif
 
     s->type = FTYPE_FILE;
-#if defined(__linux__) && defined(CONFIG_AIO)
+#if defined(__linux__)
     if (strstart(filename, "/dev/sg", NULL)) {
         bs->sg = 1;
     }
@@ -1044,7 +743,6 @@ static int hdev_ioctl(BlockDriverState *
     return ioctl(s->fd, req, buf);
 }
 
-#ifdef CONFIG_AIO
 static BlockDriverAIOCB *hdev_aio_ioctl(BlockDriverState *bs,
         unsigned long int req, void *buf,
         BlockDriverCompletionFunc *cb, void *opaque)
@@ -1075,7 +773,6 @@ static BlockDriverAIOCB *hdev_aio_ioctl(
 
     return &acb->common;
 }
-#endif
 
 #elif defined(__FreeBSD__)
 static int fd_open(BlockDriverState *bs)
@@ -1134,24 +831,18 @@ static BlockDriver bdrv_host_device = {
     .bdrv_create        = hdev_create,
     .bdrv_flush		= raw_flush,
 
-#ifdef CONFIG_AIO
     .bdrv_aio_readv	= raw_aio_readv,
     .bdrv_aio_writev	= raw_aio_writev,
     .bdrv_aio_cancel	= raw_aio_cancel,
     .aiocb_size		= sizeof(RawAIOCB),
-#endif
 
-    .bdrv_read          = raw_read,
-    .bdrv_write         = raw_write,
     .bdrv_getlength	= raw_getlength,
 
     /* generic scsi device */
 #ifdef __linux__
     .bdrv_ioctl         = hdev_ioctl,
-#ifdef CONFIG_AIO
     .bdrv_aio_ioctl     = hdev_aio_ioctl,
 #endif
-#endif
 };
 
 #ifdef __linux__
@@ -1228,15 +919,11 @@ static BlockDriver bdrv_host_floppy = {
     .bdrv_create        = hdev_create,
     .bdrv_flush         = raw_flush,
 
-#ifdef CONFIG_AIO
     .bdrv_aio_readv     = raw_aio_readv,
     .bdrv_aio_writev    = raw_aio_writev,
     .bdrv_aio_cancel    = raw_aio_cancel,
     .aiocb_size         = sizeof(RawAIOCB),
-#endif
 
-    .bdrv_read          = raw_read,
-    .bdrv_write         = raw_write,
     .bdrv_getlength	= raw_getlength,
 
     /* removable device support */
@@ -1305,15 +992,11 @@ static BlockDriver bdrv_host_cdrom = {
     .bdrv_create        = hdev_create,
     .bdrv_flush         = raw_flush,
 
-#ifdef CONFIG_AIO
     .bdrv_aio_readv     = raw_aio_readv,
     .bdrv_aio_writev    = raw_aio_writev,
     .bdrv_aio_cancel    = raw_aio_cancel,
     .aiocb_size         = sizeof(RawAIOCB),
-#endif
 
-    .bdrv_read          = raw_read,
-    .bdrv_write         = raw_write,
     .bdrv_getlength     = raw_getlength,
 
     /* removable device support */
@@ -1323,9 +1006,7 @@ static BlockDriver bdrv_host_cdrom = {
 
     /* generic scsi device */
     .bdrv_ioctl         = hdev_ioctl,
-#ifdef CONFIG_AIO
     .bdrv_aio_ioctl     = hdev_aio_ioctl,
-#endif
 };
 #endif /* __linux__ */
 
@@ -1421,15 +1102,11 @@ static BlockDriver bdrv_host_cdrom = {
     .bdrv_create        = hdev_create,
     .bdrv_flush         = raw_flush,
 
-#ifdef CONFIG_AIO
     .bdrv_aio_readv     = raw_aio_readv,
     .bdrv_aio_writev    = raw_aio_writev,
     .bdrv_aio_cancel    = raw_aio_cancel,
     .aiocb_size         = sizeof(RawAIOCB),
-#endif
 
-    .bdrv_read          = raw_read,
-    .bdrv_write         = raw_write,
     .bdrv_getlength     = raw_getlength,
 
     /* removable device support */
Makefile +1 -4
Index: qemu/Makefile
===================================================================
@@ -74,10 +74,7 @@ BLOCK_OBJS+=nbd.o block.o aio.o
 ifdef CONFIG_WIN32
 BLOCK_OBJS += block/raw-win32.o
 else
-ifdef CONFIG_AIO
-BLOCK_OBJS += posix-aio-compat.o
-endif
-BLOCK_OBJS += block/raw-posix.o
+BLOCK_OBJS += block/raw-posix.o posix-aio-compat.o
 endif
 
 ifdef CONFIG_CURL
configure +9 -21
Index: qemu/configure
===================================================================
@@ -181,7 +181,6 @@ uname_release=""
 curses="yes"
 curl="yes"
 pthread="yes"
-aio="yes"
 io_thread="no"
 nptl="yes"
 mixemu="no"
@@ -246,7 +245,6 @@ audio_possible_drivers="oss sdl esd pa"
 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
     kqemu="yes"
 fi
-aio="no"
 ;;
 NetBSD)
 bsd="yes"
@@ -481,10 +479,6 @@ for opt do
   ;;
   --enable-mixemu) mixemu="yes"
   ;;
-  --disable-pthread) pthread="no"
-  ;;
-  --disable-aio) aio="no"
-  ;;
   --enable-io-thread) io_thread="yes"
   ;;
   --disable-blobs) blobs="no"
@@ -620,8 +614,6 @@ echo "  --oss-lib                path to
 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-pthread        disable pthread support"
-echo "  --disable-aio            disable AIO support"
 echo "  --enable-io-thread       enable IO thread"
 echo "  --disable-blobs          disable installing provided firmware blobs"
 echo "  --kerneldir=PATH         look for kernel includes in PATH"
@@ -1152,21 +1144,22 @@ fi
 # pthread probe
 PTHREADLIBS=""
 
-if test "$pthread" = yes; then
-  pthread=no
+pthread=no
 cat > $TMPC << EOF
 #include <pthread.h>
 int main(void) { pthread_mutex_t lock;  return 0; }
 EOF
-  if $cc $ARCH_CFLAGS -o $TMPE $PTHREADLIBS $TMPC 2> /dev/null > /dev/null ; then
-    pthread=yes
-    PTHREADLIBS="-lpthread"
-  fi
+if $cc $ARCH_CFLAGS -o $TMPE $PTHREADLIBS $TMPC 2> /dev/null > /dev/null ; then
+  pthread=yes
+  PTHREADLIBS="-lpthread"
 fi
 
 if test "$pthread" = no; then
-   aio=no
-   io_thread=no
+    echo
+    echo "Error: pthread check failed"
+    echo "Make sure to have the pthread libs and headers installed."
+    echo
+    exit 1
 fi
 
 ##########################################
@@ -1354,7 +1347,6 @@ echo "Documentation     $build_docs"
 echo "uname -r          $uname_release"
 echo "NPTL support      $nptl"
 echo "vde support       $vde"
-echo "AIO support       $aio"
 echo "IO thread         $io_thread"
 echo "Install blobs     $blobs"
 echo "KVM support       $kvm"
@@ -1666,10 +1658,6 @@ fi
 if test "$xen" = "yes" ; then
   echo "XEN_LIBS=-lxenstore -lxenctrl -lxenguest" >> $config_mak
 fi
-if test "$aio" = "yes" ; then
-  echo "#define CONFIG_AIO 1" >> $config_h
-  echo "CONFIG_AIO=yes" >> $config_mak
-fi
 if test "$io_thread" = "yes" ; then
   echo "CONFIG_IOTHREAD=yes" >> $config_mak
   echo "#define CONFIG_IOTHREAD 1" >> $config_h
#13 lore raw
In reply to Anthony Liguori
Quoted 17 lines · Anthony Liguori
Quoted 12 lines · Stefano Stabellini
Quoted 9 lines · Christoph Hellwig

Currently all aio code in the raw-posix block driver depends on a CONFIG_AIO symbol that gets set based on the availability of the pthreads library. Beeing able to rely on unconditional aio support means we could remove the whole code for plain bdrv_read/bdrv_write in raw-posix.c which is about 300 lines of code and a duplicated code path. Is there any Posix-ish platform qemu supports that does not have pthreads support?

Quoted 3 lines

MiniOS.
I would appreciate if you keep that flag.

Quoted 6 lines

Threads are not going to be able to remain an optional dependency forever. I would be willing to merge something to remove CONFIG_AIO although I expect that there will be some fall out. Some people are using --disable-aio today for either historic reasons or because there are weird bugs with AIO enabled.

Obviously I would prefer if threads remained optional too, but let's just focus on AIO for the moment: as Todd pointed out OpenBSD doesn't currently provide AIO and also some small libc, like newlib, do not have AIO either.

#14 lore raw
Quoted 7 lines · Stefano Stabellini

Anthony Liguori wrote:

Obviously I would prefer if threads remained optional too, but let's just focus on AIO for the moment: as Todd pointed out OpenBSD doesn't currently provide AIO and also some small libc, like newlib, do not have AIO either.

CONFIG_AIO is a misnomer. It no longer has anything to do with posix-aio.

It's just a standard read/write IO with a thread pool.

Regards,

Anthony Liguori