Use the epoll-based client in qemu_driver when io_uring isn't available #151

Merged
vitalif merged 1 commits from koolkhel/vitastor:qemu-nouring-exit into master 2026-11-24 12:44:09 +03:00
Contributor

Description

Without io_uring (seccomp profile, kernel.io_uring_disabled, old kernel) qemu_driver falls back to vitastor_c_create_qemu(), which registers every OSD socket in QEMU's AioContext. Two problems come from that:

  • It takes no options, so the driver can't pass client_exit_on_error=0. A client start error (for example an unreachable etcd) calls exit(1) and ends the whole QEMU process, for example on a disk hot-plug into a running VM.
  • The AioContext is level-triggered, while the messenger works with edge-triggered events. With the EPOLLOUT subscription an idle QEMU spins on a writable socket.

This makes the fallback create the client with vitastor_c_create_epoll_json() from the same option list as the io_uring path, and register only its epoll descriptor (vitastor_c_epoll_get_fd()) in the AioContext, with vitastor_c_epoll_handle_events(proxy, 0) as the read handler. The descriptor goes through the code the io_uring eventfd already uses: registration, close and attach/detach of the AioContext. There is no change in the C API.

Details:

  • A driver built against a library older than VITASTOR_C_API_VERSION 3 keeps calling vitastor_c_create_qemu(). The function stays in the library.
  • Writeback stays disabled without io_uring, as before: cluster_client_t::flush() waits for the flush only when it has a ring loop.
  • The fallback now gets its options from the same string list as the io_uring path. The vitastor: filename syntax stores use-rdma, rdma-gid-index and rdma-mtu as integers, and that list doesn't pick integers up (qdict_get_try_str), so in the fallback they are no longer read. The io_uring path already ignores them the same way.

Tested: the same driver change in our downstream tree (library with e4a7e9bf and b88e2ea6), QEMU 8.2.2 running with io_uring_setup() failing with ENOSYS (seccomp filter), old fallback and new fallback on the same library:

Check Old fallback New fallback
write and read back 8 MiB with pattern verification (qemu-io) works works
CPU used by an idle QEMU in 60 s 59.96 s 0.01 s
blockdev-add with an etcd address that refuses connections QEMU exits with code 1 QMP error, QEMU keeps running, the same image then opens with the right address
x-blockdev-set-iothread to an iothread and back, with I/O before, between and after works works

Contributor Name

Yury Luneff (MIND Software LLC, https://mindsw.io)

CLA

### Description Without io_uring (seccomp profile, `kernel.io_uring_disabled`, old kernel) qemu_driver falls back to `vitastor_c_create_qemu()`, which registers every OSD socket in QEMU's AioContext. Two problems come from that: - It takes no options, so the driver can't pass `client_exit_on_error=0`. A client start error (for example an unreachable etcd) calls `exit(1)` and ends the whole QEMU process, for example on a disk hot-plug into a running VM. - The AioContext is level-triggered, while the messenger works with edge-triggered events. With the EPOLLOUT subscription an idle QEMU spins on a writable socket. This makes the fallback create the client with `vitastor_c_create_epoll_json()` from the same option list as the io_uring path, and register only its epoll descriptor (`vitastor_c_epoll_get_fd()`) in the AioContext, with `vitastor_c_epoll_handle_events(proxy, 0)` as the read handler. The descriptor goes through the code the io_uring eventfd already uses: registration, close and attach/detach of the AioContext. There is no change in the C API. Details: - A driver built against a library older than `VITASTOR_C_API_VERSION` 3 keeps calling `vitastor_c_create_qemu()`. The function stays in the library. - Writeback stays disabled without io_uring, as before: `cluster_client_t::flush()` waits for the flush only when it has a ring loop. - The fallback now gets its options from the same string list as the io_uring path. The `vitastor:` filename syntax stores `use-rdma`, `rdma-gid-index` and `rdma-mtu` as integers, and that list doesn't pick integers up (`qdict_get_try_str`), so in the fallback they are no longer read. The io_uring path already ignores them the same way. Tested: the same driver change in our downstream tree (library with e4a7e9bf and b88e2ea6), QEMU 8.2.2 running with `io_uring_setup()` failing with ENOSYS (seccomp filter), old fallback and new fallback on the same library: | Check | Old fallback | New fallback | |---|---|---| | write and read back 8 MiB with pattern verification (`qemu-io`) | works | works | | CPU used by an idle QEMU in 60 s | 59.96 s | 0.01 s | | `blockdev-add` with an etcd address that refuses connections | QEMU exits with code 1 | QMP error, QEMU keeps running, the same image then opens with the right address | | `x-blockdev-set-iothread` to an iothread and back, with I/O before, between and after | works | works | ### Contributor Name Yury Luneff (MIND Software LLC, https://mindsw.io) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
koolkhel added 1 commit 2026-11-22 20:32:30 +03:00
qemu_driver passes client_exit_on_error=0 only when it creates the
client with io_uring. When io_uring isn't available (seccomp profile,
kernel.io_uring_disabled, old kernel) it falls back to
vitastor_c_create_qemu(), which takes no options, so an initialization
error (for example an unreachable etcd) still calls exit(1) and kills
the whole QEMU process, for example on a disk hot-plug into a running
VM.

Add vitastor_c_create_qemu_json() which takes the same option list as
vitastor_c_create_uring_json() and use it in the fallback path
(VITASTOR_C_API_VERSION 7).
koolkhel force-pushed qemu-nouring-exit from ebd9122190 to 6b28914352 2026-11-23 01:43:51 +03:00 Compare
koolkhel changed title from Capture client init errors in qemu_driver without io_uring too to Use the epoll-based client in qemu_driver when io_uring isn't available 2026-11-23 01:43:58 +03:00
vitalif merged commit de3644bc00 into master 2026-11-24 12:44:09 +03:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#151
No description provided.