It can be useful to run an AioContext from a thread which normally does
not "own" the AioContext. For example, request draining can be
implemented by acquiring the AioContext and looping aio_poll() until all
requests have been completed.
The following pattern should work:
/* Event loop thread */
while (running) {
aio_context_acquire(ctx);
aio_poll(ctx, true);
aio_context_release(ctx);
}
/* Another thread */
aio_context_acquire(ctx);
bdrv_read(bs, 0x1000, buf, 1);
aio_context_release(ctx);
This patch implements aio_context_acquire() and aio_context_release().
Note that existing aio_poll() callers do not need to worry about
acquiring and releasing - it is only needed when multiple threads will
call aio_poll() on the same AioContext.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||
|---|---|---|
| .. | ||
| acpi-test-data | ||
| libqos | ||
| multiboot | ||
| qapi-schema | ||
| qemu-iotests | ||
| tcg | ||
| .gitignore | ||
| Makefile | ||
| acpi-test.c | ||
| blockdev-test.c | ||
| boot-order-test.c | ||
| check-block.sh | ||
| check-qdict.c | ||
| check-qfloat.c | ||
| check-qint.c | ||
| check-qjson.c | ||
| check-qlist.c | ||
| check-qom-interface.c | ||
| check-qstring.c | ||
| e1000-test.c | ||
| eepro100-test.c | ||
| endianness-test.c | ||
| fdc-test.c | ||
| fw_cfg-test.c | ||
| hd-geo-test.c | ||
| i440fx-test.c | ||
| ide-test.c | ||
| ipoctal232-test.c | ||
| libqtest.c | ||
| libqtest.h | ||
| m48t59-test.c | ||
| ne2000-test.c | ||
| pcnet-test.c | ||
| qdev-monitor-test.c | ||
| qemu-iotests-quick.sh | ||
| qom-test.c | ||
| rtc-test.c | ||
| rtl8139-test.c | ||
| test-aio.c | ||
| test-bitops.c | ||
| test-coroutine.c | ||
| test-cutils.c | ||
| test-hbitmap.c | ||
| test-int128.c | ||
| test-iov.c | ||
| test-mul64.c | ||
| test-opts-visitor.c | ||
| test-qdev-global-props.c | ||
| test-qmp-commands.c | ||
| test-qmp-input-strict.c | ||
| test-qmp-input-visitor.c | ||
| test-qmp-output-visitor.c | ||
| test-rfifolock.c | ||
| test-string-input-visitor.c | ||
| test-string-output-visitor.c | ||
| test-thread-pool.c | ||
| test-throttle.c | ||
| test-visitor-serialization.c | ||
| test-vmstate.c | ||
| test-x86-cpuid.c | ||
| test-xbzrle.c | ||
| tmp105-test.c | ||
| tpci200-test.c | ||
| virtio-net-test.c | ||
| vmxnet3-test.c | ||