You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
qemu/tests/unit
Stefan Hajnoczi ded29e64c6 aio-posix: integrate fdmon into glib event loop
AioContext's glib integration only supports ppoll(2) file descriptor
monitoring. epoll(7) and io_uring(7) disable themselves and switch back
to ppoll(2) when the glib event loop is used. The main loop thread
cannot use epoll(7) or io_uring(7) because it always uses the glib event
loop.

Future QEMU features may require io_uring(7). One example is uring_cmd
support in FUSE exports. Each feature could create its own io_uring(7)
context and integrate it into the event loop, but this is inefficient
due to extra syscalls. It would be more efficient to reuse the
AioContext's existing fdmon-io_uring.c io_uring(7) context because
fdmon-io_uring.c will already be active on systems where Linux io_uring
is available.

In order to keep fdmon-io_uring.c's AioContext operational even when the
glib event loop is used, extend FDMonOps with an API similar to
GSourceFuncs so that file descriptor monitoring can integrate into the
glib event loop.

A quick summary of the GSourceFuncs API:
- prepare() is called each event loop iteration before waiting for file
  descriptors and timers.
- check() is called to determine whether events are ready to be
  dispatched after waiting.
- dispatch() is called to process events.

More details here: https://docs.gtk.org/glib/struct.SourceFuncs.html

Move the ppoll(2)-specific code from aio-posix.c into fdmon-poll.c and
also implement epoll(7)- and io_uring(7)-specific file descriptor
monitoring code for glib event loops.

Note that it's still faster to use aio_poll() rather than the glib event
loop since glib waits for file descriptor activity with ppoll(2) and
does not support adaptive polling. But at least epoll(7) and io_uring(7)
now work in glib event loops.

Splitting this into multiple commits without temporarily breaking
AioContext proved difficult so this commit makes all the changes. The
next commit will remove the aio_context_use_g_source() API because it is
no longer needed.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-ID: <20251104022933.618123-7-stefanha@redhat.com>
[kwolf: Build fixes; fix AioContext.list_lock use after destroy]
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
3 days ago
..
check-block-qdict.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
check-qdict.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
check-qjson.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
check-qlist.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
check-qlit.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
check-qnull.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
check-qnum.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
check-qobject.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
check-qom-interface.c qom: Make InterfaceInfo[] uses const 7 months ago
check-qom-proplist.c qom: Make InterfaceInfo[] uses const 7 months ago
check-qstring.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
crypto-tls-psk-helpers.c crypto: Remove 'crypto-tls-x509-helpers.h' from crypto-tls-psk-helpers.c 1 year ago
crypto-tls-psk-helpers.h
crypto-tls-x509-helpers.c tests/unit/crypto-tls-x509-helpers: deinit privkey in test_tls_cleanup 1 year ago
crypto-tls-x509-helpers.h crypto: stop requiring "key encipherment" usage in x509 certs 3 weeks ago
io-channel-helpers.c treewide: handle result of qio_channel_set_blocking() 2 months ago
io-channel-helpers.h
iothread.c
iothread.h
meson.build crypto: drop in-tree XTS cipher mode impl 2 weeks ago
pkix_asn1_tab.c.inc crypto: Restrict pkix_asn1_tab[] to crypto-tls-x509-helpers.c 1 year ago
ptimer-test-stubs.c
ptimer-test.c hw/core/ptimer: fix timer zero period condition for freq > 1GHz 1 year ago
ptimer-test.h
rcutorture.c
socket-helpers.c util: drop qemu_socket_set_nonblock() 2 months ago
socket-helpers.h
test-aio-multithread.c timers: properly prefix init_clocks() 2 weeks ago
test-aio.c aio-posix: integrate fdmon into glib event loop 3 days ago
test-authz-list.c
test-authz-listfile.c
test-authz-pam.c
test-authz-simple.c
test-base64.c
test-bdrv-drain.c block: drop wrapper for bdrv_set_backing_hd_drained() 4 months ago
test-bdrv-graph-mod.c block: drop wrapper for bdrv_set_backing_hd_drained() 4 months ago
test-bitcnt.c
test-bitmap.c
test-bitops.c
test-block-backend.c include: Rename sysemu/ -> system/ 11 months ago
test-block-iothread.c mirror: Drop redundant zero_target parameter 6 months ago
test-blockjob-txn.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
test-blockjob.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
test-bufferiszero.c
test-char.c char: rename CharBackend->CharFrontend 2 weeks ago
test-clone-visitor.c
test-coroutine.c
test-crypto-afsplit.c qapi/crypto: Rename QCryptoHashAlgorithm to *Algo, and drop prefix 1 year ago
test-crypto-akcipher.c qapi/crypto: Rename QCryptoRSAPaddingAlgorithm to *Algo, and drop prefix 1 year ago
test-crypto-block.c crypto: bump min gnutls to 3.7.5 2 weeks ago
test-crypto-cipher.c tests: fix skipping cipher tests when AES is not available 6 months ago
test-crypto-der.c
test-crypto-hash.c crypto: Introduce SM3 hash hmac pbkdf algorithm 1 year ago
test-crypto-hmac.c crypto: Introduce SM3 hash hmac pbkdf algorithm 1 year ago
test-crypto-ivgen.c qapi/crypto: Rename QCryptoIVGenAlgorithm to *Algo, and drop prefix 1 year ago
test-crypto-pbkdf.c crypto: Introduce SM3 hash hmac pbkdf algorithm 1 year ago
test-crypto-secret.c tests: skip encrypted secret tests if AES is not available 6 months ago
test-crypto-tlscredsx509.c crypto: avoid loading the identity certs twice 2 weeks ago
test-crypto-tlssession.c io/channel: Have read/write functions take void * buffer argument 2 weeks ago
test-cutils.c
test-div128.c
test-error-report.c error: Kill @error_warn 1 month ago
test-fifo.c tests/unit: Comment FIFO8 tests 1 year ago
test-forward-visitor.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
test-hbitmap.c
test-image-locking.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
test-int128.c
test-interval-tree.c
test-io-channel-buffer.c
test-io-channel-command.c
test-io-channel-file.c
test-io-channel-null.c
test-io-channel-socket.c tests/unit: Add a assert for test_io_channel_unix_listen_cleanup 1 year ago
test-io-channel-tls.c crypto: stop requiring "key encipherment" usage in x509 certs 3 weeks ago
test-io-task.c
test-iov.c treewide: use qemu_set_blocking instead of g_unix_set_fd_nonblocking 2 months ago
test-keyval.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
test-logging.c
test-mul64.c
test-nested-aio-poll.c tests/unit: skip test-nested-aio-poll with io_uring 3 days ago
test-opts-visitor.c
test-qapi-util.c
test-qdev-global-props.c qom: Have class_init() take a const data argument 7 months ago
test-qdist.c
test-qemu-opts.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
test-qga.c qga: Add tests for guest-get-load command 5 months ago
test-qgraph.c cleanup: Drop pointless return at end of function 7 months ago
test-qht.c
test-qmp-cmds.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
test-qmp-event.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
test-qobject-input-visitor.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
test-qobject-output-visitor.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
test-qtree.c
test-rcu-list.c
test-rcu-simpleq.c
test-rcu-slist.c
test-rcu-tailq.c
test-replication.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
test-resv-mem.c include/system: Move exec/memory.h to system/memory.h 7 months ago
test-seccomp.c include: Rename sysemu/ -> system/ 11 months ago
test-shift128.c
test-smp-parse.c qom: Have class_init() take a const data argument 7 months ago
test-string-input-visitor.c
test-string-output-visitor.c
test-thread-pool.c thread-pool: Remove thread_pool_submit() function 8 months ago
test-throttle.c include: Rename sysemu/ -> system/ 11 months ago
test-timed-average.c include: Rename sysemu/ -> system/ 11 months ago
test-util-filemonitor.c
test-util-sockets.c tests/unit/test-util-sockets: fix mem-leak on error object 6 months ago
test-uuid.c
test-virtio-dmabuf.c
test-visitor-serialization.c qapi: Move include/qapi/qmp/ to include/qobject/ 9 months ago
test-vmstate.c migration: Remove error variant of vmstate_save_state() function 1 month ago
test-write-threshold.c
test-x86-topo.c tests: Add test case of APIC ID for module level parsing 2 years ago
test-xbzrle.c
test-xs-node.c tests/unit: replace assert(0) with g_assert_not_reached() 1 year ago
test-yank.c char: rename CharBackend->CharFrontend 2 weeks ago