Skip to content

Fix deadlock with bdrv_open of self-served NBD

Eric Blake qemu-devel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest13 patches 2 repliesIn review
  2. v212 patches 14 repliesSuperseded
  3. v18 patches 36 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13iotests: Drop execute permissions on vvfat.outtests/qemu-iotests/tests/vvfat.out+0 -00 replies
2/13qio: Add trace points to net_listenerio/net-listener.c io/trace-events+15 -00 replies
3/13qio: Unwatch before notify in QIONetListenerio/net-listener.c+8 -80 replies
4/13qio: Remember context of qio_net_listener_set_client_func_fullinclude/io/net-listener.h io/net-listener.c io/trace-events+20 -120 replies
5/13qio: Protect NetListener callback with mutexinclude/io/net-listener.h io/net-listener.c+44 -150 replies
6/13qio: Minor optimization when callback function is unchangedio/net-listener.c+5 -00 replies
7/13qio: Factor out helpers qio_net_listener_[un]watchio/net-listener.c+52 -700 replies
8/13chardev: Reuse channel's cached local addresschardev/char-socket.c+1 -10 replies
9/13qio: Provide accessor around QIONetListener->siocchardev/char-socket.c include/io/channel-socket.h include/io/net-listener.h +3 more+94 -170 replies
10/13qio: Prepare NetListener to use AioContextinclude/io/net-listener.h io/net-listener.c io/trace-events+78 -390 replies
11/13qio: Add QIONetListener API for using AioContextinclude/io/net-listener.h io/net-listener.c+84 -30 replies
12/13nbd: Avoid deadlock in client connecting to same-process serverblockdev-nbd.c+2 -20 replies
13/13iotests: Add coverage of recent NBD qio deadlock fixtests/qemu-iotests/tests/nbd-in-qcow2-chain tests/qemu-iotests/tests/nbd-in-qcow2-chain.out+169 -00 replies

Reviews trailers per patch

8 of 13 patches have a Reviewed-by or Acked-by.

PatchDaniel P. BerrangéVladimir Sementsov-Ogievskiy
1/13R-b
2/13R-b
3/13R-b
4/13R-b
5/13
6/13R-b
7/13
8/13
9/13
10/13R-b
11/13
12/13R-b
13/13R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 for-10.2 00/13] Fix deadlock with bdrv_open of self-served NBD

v2 was here:
https://lists.nongnu.org/archive/html/qemu-devel/2025-11/msg01243.html

Since then:
- drop patch 7/12; refcounting for GSource case is now unchanged
- add a couple of patches: fix a chardev leaky abstraction, and add a mutex lock for cross-thread safety
- improve commit messages to document why NBD is safe now, even without adding notify callbacks to AioContext

Now that the new behavior is opt-in rather than a change of defaults, and only NBD opts in, it should still be safe to include in 10.2. But the technical debt here means that we really should consider improving the AioContext API for 11.0 to allow for a notify function similar to what GSource provides.

Key:
[----] : patches are identical
[####] : number of functional differences between upstream/downstream patch [down] : patch is downstream-only
The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively

001/13:[----] [--] 'iotests: Drop execute permissions on vvfat.out' 002/13:[----] [--] 'qio: Add trace points to net_listener' 003/13:[----] [--] 'qio: Unwatch before notify in QIONetListener' 004/13:[----] [--] 'qio: Remember context of qio_net_listener_set_client_func_full' 005/13:[down] 'qio: Protect NetListener callback with mutex' 006/13:[----] [-C] 'qio: Minor optimization when callback function is unchanged' 007/13:[0042] [FC] 'qio: Factor out helpers qio_net_listener_[un]watch' 008/13:[down] 'chardev: Reuse channel's cached local address' 009/13:[0053] [FC] 'qio: Provide accessor around QIONetListener->sioc' 010/13:[0013] [FC] 'qio: Prepare NetListener to use AioContext' 011/13:[0041] [FC] 'qio: Add QIONetListener API for using AioContext' 012/13:[----] [--] 'nbd: Avoid deadlock in client connecting to same-process server' 013/13:[----] [--] 'iotests: Add coverage of recent NBD qio deadlock fix'

Eric Blake (13):
iotests: Drop execute permissions on vvfat.out
qio: Add trace points to net_listener
qio: Unwatch before notify in QIONetListener
qio: Remember context of qio_net_listener_set_client_func_full
qio: Protect NetListener callback with mutex
qio: Minor optimization when callback function is unchanged
qio: Factor out helpers qio_net_listener_[un]watch
chardev: Reuse channel's cached local address
qio: Provide accessor around QIONetListener->sioc
qio: Prepare NetListener to use AioContext
qio: Add QIONetListener API for using AioContext
nbd: Avoid deadlock in client connecting to same-process server
iotests: Add coverage of recent NBD qio deadlock fix

 include/io/channel-socket.h                   |   2 +-
 include/io/net-listener.h                     |  71 ++++-
 blockdev-nbd.c                                |   4 +-
 chardev/char-socket.c                         |   2 +-
 io/net-listener.c                             | 300 +++++++++++++-----
 migration/socket.c                            |   4 +-
 ui/vnc.c                                      |  34 +-
 io/trace-events                               |   5 +
 tests/qemu-iotests/tests/nbd-in-qcow2-chain   |  94 ++++++
 .../qemu-iotests/tests/nbd-in-qcow2-chain.out |  75 +++++
 tests/qemu-iotests/tests/vvfat.out            |   0
 11 files changed, 498 insertions(+), 93 deletions(-)
 create mode 100755 tests/qemu-iotests/tests/nbd-in-qcow2-chain
 create mode 100644 tests/qemu-iotests/tests/nbd-in-qcow2-chain.out
 mode change 100755 => 100644 tests/qemu-iotests/tests/vvfat.out
Signature · 1 line
2.51.1