diff options
author | Christoph Hellwig <hch@lst.de> | 2009-08-20 16:58:35 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-08-27 20:30:22 -0500 |
commit | 5c6c3a6c54b23caa84fb4e046e85a461612279bb (patch) | |
tree | 7c23c2c86ca96f0a1b3dcbb86c70d5989e156710 /vl.c | |
parent | 9ef91a677110ec200d7b2904fc4bcae5a77329ad (diff) | |
download | qemu-5c6c3a6c54b23caa84fb4e046e85a461612279bb.zip qemu-5c6c3a6c54b23caa84fb4e046e85a461612279bb.tar.gz qemu-5c6c3a6c54b23caa84fb4e046e85a461612279bb.tar.bz2 |
raw-posix: add Linux native AIO support
Now that do have a nicer interface to work against we can add Linux native
AIO support. It's an extremly thing layer just setting up an iocb for
the io_submit system call in the submission path, and registering an
eventfd with the qemu poll handler to do complete the iocbs directly
from there.
This started out based on Anthony's earlier AIO patch, but after
estimated 42,000 rewrites and just as many build system changes
there's not much left of it.
To enable native kernel aio use the aio=native sub-command on the
drive command line. I have also added an option to qemu-io to
test the aio support without needing a guest.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'vl.c')
-rw-r--r-- | vl.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -1916,6 +1916,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque, int max_devs; int index; int cache; + int aio = 0; int bdrv_flags, onerror; const char *devaddr; DriveInfo *dinfo; @@ -2049,6 +2050,19 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque, } } +#ifdef CONFIG_LINUX_AIO + if ((buf = qemu_opt_get(opts, "aio")) != NULL) { + if (!strcmp(buf, "threads")) + aio = 0; + else if (!strcmp(buf, "native")) + aio = 1; + else { + fprintf(stderr, "qemu: invalid aio option\n"); + return NULL; + } + } +#endif + if ((buf = qemu_opt_get(opts, "format")) != NULL) { if (strcmp(buf, "?") == 0) { fprintf(stderr, "qemu: Supported formats:"); @@ -2218,11 +2232,19 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque, bdrv_flags |= BDRV_O_NOCACHE; else if (cache == 2) /* write-back */ bdrv_flags |= BDRV_O_CACHE_WB; + + if (aio == 1) { + bdrv_flags |= BDRV_O_NATIVE_AIO; + } else { + bdrv_flags &= ~BDRV_O_NATIVE_AIO; + } + if (bdrv_open2(dinfo->bdrv, file, bdrv_flags, drv) < 0) { fprintf(stderr, "qemu: could not open disk image %s\n", file); return NULL; } + if (bdrv_key_required(dinfo->bdrv)) autostart = 0; *fatal_error = 0; |