diff options
author | Eric Blake <eblake@redhat.com> | 2025-02-27 16:06:15 -0600 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2025-03-05 13:00:22 -0600 |
commit | 3e1683485656c095860a8dfbe39ab2d0664b84d9 (patch) | |
tree | f424832f37f23310e3225c999f6984b9262af260 /rust/qemu-api/src | |
parent | 57f3962bf17c088c3567d216e3eaa1b3131be5a4 (diff) | |
download | qemu-3e1683485656c095860a8dfbe39ab2d0664b84d9.zip qemu-3e1683485656c095860a8dfbe39ab2d0664b84d9.tar.gz qemu-3e1683485656c095860a8dfbe39ab2d0664b84d9.tar.bz2 |
nbd: Defer trace init until after daemonization
At least the simple trace backend works by spawning a helper thread,
and setting up an atexit() handler that coordinates completion with
the helper thread. But since atexit registrations survive fork() but
helper threads do not, this means that qemu-nbd configured to use the
simple trace will deadlock waiting for a thread that no longer exists
when it has daemonized.
Better is to follow the example of vl.c: don't call any setup
functions that might spawn helper threads until we are in the final
process that will be doing the work worth tracing.
Tested by configuring with --enable-trace-backends=simple, then running
qemu-nbd --fork --trace=nbd_\*,file=qemu-nbd.trace -f raw -r README.rst
followed by `nbdinfo nbd://localhost`, and observing that the trace
file is now created without hanging.
Reported-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-ID: <20250227220625.870246-2-eblake@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'rust/qemu-api/src')
0 files changed, 0 insertions, 0 deletions