aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Replace posix-aio with custom thread poolaliguori2008-12-121-91/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | glibc implements posix-aio as a thread pool and imposes a number of limitations. 1) it limits one request per-file descriptor. we hack around this by dup()'ing file descriptors which is hideously ugly 2) it's impossible to add new interfaces and we need a vectored read/write operation to properly support a zero-copy API. What has been suggested to me by glibc folks, is to implement whatever new interfaces we want and then it can eventually be proposed for standardization. This requires that we implement our own posix-aio implementation though. This patch implements posix-aio using pthreads. It immediately eliminates the need for fd pooling. It performs at least as well as the current posix-aio code (in some circumstances, even better). Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5996 c046a42c-6fe2-441c-8c8c-71466251a162
* block: make raw aio signaling non-blocking (Gerd Hoffman)aliguori2008-11-131-7/+10
| | | | | | | | | | | | | | This patch switches the read handle of the signaling pipe into non-blocking mode. This avoids unwanted blocking reads and also allows to read all bytes out of the signaling pipe in case we got signaled more that once before the handler ran. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5716 c046a42c-6fe2-441c-8c8c-71466251a162
* Fix previous commit (spotted by Robert Riebisch).aliguori2008-10-141-1/+1
| | | | | | | | Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5487 c046a42c-6fe2-441c-8c8c-71466251a162
* Define O_DSYNC as O_SYNC if necessary.aliguori2008-10-141-0/+5
| | | | | | | | | | O_DSYNC isn't available on OS X. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5486 c046a42c-6fe2-441c-8c8c-71466251a162
* Expand cache= option and use write-through caching by defaultaliguori2008-10-141-24/+17
| | | | | | | | | | | | | | | | | | This patch changes the cache= option to accept none, writeback, or writethough to control the host page cache behavior. By default, writethrough caching is now used which internally is implemented by using O_DSYNC to open the disk images. When using -snapshot, writeback is used by default since data integrity it not at all an issue. cache=none has the same behavior as cache=off previously. The later syntax is still supported by now deprecated. I also cleaned up the O_DIRECT implementation to avoid many of the #ifdefs. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5485 c046a42c-6fe2-441c-8c8c-71466251a162
* Fix IO performance regression in sparcaliguori2008-10-081-35/+35
| | | | | | | | | | | | | | | | | | Replace signalfd with signal handler/pipe. There is no way to interrupt the CPU execution loop when a file descriptor becomes readable. This results in a large performance regression in sparc emulation during bootup. This patch switches us to signal handler/pipe which was originally suggested by Ian Jackson. The signal handler lets us interrupt the CPU emulation loop while the write to a pipe lets us avoid the select/signal race condition. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5451 c046a42c-6fe2-441c-8c8c-71466251a162
* Fix warning about missing return valueblueswir12008-10-031-0/+1
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5405 c046a42c-6fe2-441c-8c8c-71466251a162
* Make compatfd fallback more robustaliguori2008-09-271-0/+4
| | | | | | | | | | | | | | | | | Be more friendly when signalfd() fails, and also add configure checks to detect that syscall(SYS_signalfd) actually works. malc pointed out that some installs do not have /usr/include/linux headers that are in sync with the glibc headers so why SYS_signalfd is defined, it's #defined to _NR_signalfd which is not defined in the /usr/include/linux header. While this is a distro bug, it doesn't hurt to do a more thorough job in detection. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5334 c046a42c-6fe2-441c-8c8c-71466251a162
* Really fix the BSD build this timealiguori2008-09-261-11/+16
| | | | | | | | | | | struct aioinit isn't defined on BSD it appears so we need to guard everything in an #if defined(__linux__). Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5325 c046a42c-6fe2-441c-8c8c-71466251a162
* Fix build on non-Linux unicesaliguori2008-09-261-1/+0
| | | | | | | | Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5324 c046a42c-6fe2-441c-8c8c-71466251a162
* Implement an fd pool to get real AIO with posix-aioaliguori2008-09-261-3/+65
| | | | | | | | | | | | | | | | | | | | | | | This patch implements a simple fd pool to allow many AIO requests with posix-aio. The result is significantly improved performance (identical to that reported for linux-aio) for both cache=on and cache=off. The fundamental problem with posix-aio is that it limits itself to one thread per-file descriptor. I don't know why this is, but this patch provides a simple mechanism to work around this (duplicating the file descriptor). This isn't a great solution, but it seems like a reasonable intermediate step between posix-aio and a custom thread-pool to replace it. Ryan Harper will be posting some performance analysis he did comparing posix-aio with fd pooling against linux-aio. The size of the posix-aio thread pool and the fd pool were largely determined by him based on this analysis. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5323 c046a42c-6fe2-441c-8c8c-71466251a162
* Fix build on FreeBSDaliguori2008-09-261-10/+12
| | | | | | | | | | | | | | | __GLIBC_PREREQ is defined in such a way that the ! cannot be used in front of it on FreeBSD. Also, -lpthread is not implied by the build and we definitely use it for compatfd support. While at it, I added a default initialization for posix-aio that seems to perform well in our testing. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5322 c046a42c-6fe2-441c-8c8c-71466251a162
* Relax posix-aio restrictions on newer glibcsaliguori2008-09-231-1/+1
| | | | | | | | | | | | RedHat 9 shipped glibc 2.3. Modern versions of glibc do not have the aio thread exit issue that the comment references. This patch adjusts the check to only limit aio_init on glibc versions < 2.4. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5304 c046a42c-6fe2-441c-8c8c-71466251a162
* Refactor AIO to allow multiple AIO implementationsaliguori2008-09-221-65/+44
| | | | | | | | | | | | | | | | | | | | | | This patch refactors the AIO layer to allow multiple AIO implementations. It's only possible because of the recent signalfd() patch. Right now, the AIO infrastructure is pretty specific to the block raw backend. For other block devices to implement AIO, the qemu_aio_wait function must support registration. This patch introduces a new function, qemu_aio_set_fd_handler, which can be used to register a file descriptor to be called back. qemu_aio_wait() now polls a set of file descriptors registered with this function until one becomes readable or writable. This patch should allow the implementation of alternative AIO backends (via a thread pool or linux-aio) and AIO backends in non-traditional block devices (like NBD). Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5297 c046a42c-6fe2-441c-8c8c-71466251a162
* Do not allow AIO to be inited multiple timesaliguori2008-09-221-0/+3
| | | | | | | | | | | This prevents two signalfd() threads from being spawned. This problem was originally spotted by Blue Swirl. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5289 c046a42c-6fe2-441c-8c8c-71466251a162
* block-raw is not a protocolaliguori2008-09-161-1/+0
| | | | | | | | | | | | | | | | | | The protocol_name "file" was added to the block driver when async IO was introduced. This can be used to select that a file is treated as a raw device instead of probing for the type. However, protocols are not subject to path interpretation which cases qcow2 images with raw base images to not function is the path was specified relatively. The fix is simply to remove the protocol_name from the raw block driver. The proper way to force the use of a raw block format is to use the format= option with -drive. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5233 c046a42c-6fe2-441c-8c8c-71466251a162
* Make sure to define fd_open when not on Linuxaliguori2008-09-151-0/+5
| | | | | | | | | | My previous commit broke the build. This was spotted by C.W. Betts. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5231 c046a42c-6fe2-441c-8c8c-71466251a162
* Use common objects for qemu-img and qemu-nbdaliguori2008-09-151-27/+8
| | | | | | | | | | | | | | | | | | | | | | | Right now, we sprinkle #if defined(QEMU_IMG) && defined(QEMU_NBD) all over the code. It's ugly and causes us to have to build multiple object files for linking against qemu and the tools. This patch introduces a new file, qemu-tool.c which contains enough for qemu-img, qemu-nbd, and QEMU to all share the same objects. This also required getting qemu-nbd to be a bit more Windows friendly. I also changed the Windows block-raw to use normal IO instead of overlapping IO since we don't actually do AIO yet on Windows. I changed the various #if 0's to #if WIN32_AIO to make it easier for someone to eventually fix AIO on Windows. After this patch, there are no longer any #ifdef's related to qemu-img and qemu-nbd. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5226 c046a42c-6fe2-441c-8c8c-71466251a162
* Only build compatfd when using AIO and make sure to always init AIOaliguori2008-09-111-0/+3
| | | | | | | | | | | | | | OpenBSD doesn't use AIO so don't try to build compatfd when not using AIO. Also make sure to call qemu_aio_init() from bdrv_init. Everything that uses bdrv calls bdrv_init so it makes sense to init aio from there instead of in every single tool. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5197 c046a42c-6fe2-441c-8c8c-71466251a162
* Make sure to read siginfo from signalfdaliguori2008-09-111-0/+27
| | | | | | | | | | Otherwise, we'll idle at 100% cpu. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5195 c046a42c-6fe2-441c-8c8c-71466251a162
* Use signalfd() to work around signal/select racealiguori2008-09-101-81/+48
| | | | | | | | | | | | | | | | | | | This patch introduces signalfd() to work around the signal/select race in checking for AIO completions. For platforms that don't support signalfd(), we emulate it with threads. There was a long discussion about this approach. I don't believe there are any fundamental problems with this approach and I believe eliminating the use of signals is a good thing. I've tested Windows and Linux using Windows and Linux guests. I've also checked for disk IO performance regressions. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5187 c046a42c-6fe2-441c-8c8c-71466251a162
* Add missing FreeBSD #include (Juergen Lock)blueswir12008-08-241-0/+1
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5081 c046a42c-6fe2-441c-8c8c-71466251a162
* Preliminary OpenBSD host support (based on OpenBSD patches by Todd T. Fries)blueswir12008-08-151-0/+27
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5012 c046a42c-6fe2-441c-8c8c-71466251a162
* Use AIO only if host supports it (based on OpenBSD patches by Todd T. Fries)blueswir12008-08-151-0/+38
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5010 c046a42c-6fe2-441c-8c8c-71466251a162
* Add a parameter to disable host cache, by Laurent Vivier.ths2008-07-031-8/+8
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4836 c046a42c-6fe2-441c-8c8c-71466251a162
* Align file accesses with cache=off (O_DIRECT) (Kevin Wolf, Laurent Vivier)bellard2008-05-281-2/+238
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4599 c046a42c-6fe2-441c-8c8c-71466251a162
* Revert 4367blueswir12008-05-071-113/+6
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4377 c046a42c-6fe2-441c-8c8c-71466251a162
* Align file accesses with cache=off (Kevin Wolf, Laurent Vivier)blueswir12008-05-061-6/+113
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4367 c046a42c-6fe2-441c-8c8c-71466251a162
* restore original values for ai.aio_threads and ai.aio_numbellard2008-01-061-2/+2
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3896 c046a42c-6fe2-441c-8c8c-71466251a162
* Real SCSI device passthrough (v4), by Laurent Vivier.ths2007-12-241-5/+22
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3851 c046a42c-6fe2-441c-8c8c-71466251a162
* Add "cache" parameter to "-drive" (Laurent Vivier).balrog2007-12-241-0/+8
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3848 c046a42c-6fe2-441c-8c8c-71466251a162
* Split block-raw.c into block-raw-posix.c and block-raw-win32.c, byths2007-12-151-0/+901
Anthony Liguori. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3814 c046a42c-6fe2-441c-8c8c-71466251a162