Skip to content

util/qemu-sockets: Introduce inet socket options controlling TCP keep-alive

Juraj Marcin qemu-devel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest6 patches 2 repliesIn review
  2. v47 patches 4 repliesSuperseded
  3. v35 patches 7 repliesSuperseded

Changes in v5 from the cover letter

- squashed "tests/unit/test-util-sockets: Add tests for inet_parse()" and "util/qemu-sockets: Refactor inet_parse() to use QemuOpts"
- updated the existing test case to use only explicit bool option values and added a second test case using only implicit bool option values

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6io: Fix partial struct copy in qio_dns_resolver_lookup_sync_inet()io/dns-resolver.c+5 -162 replies
2/6util/qemu-sockets: Refactor setting client sockopts into a separate functionutil/qemu-sockets.c+19 -100 replies
3/6util/qemu-sockets: Refactor success and failure paths in inet_listen_saddr()util/qemu-sockets.c+27 -240 replies
4/6util/qemu-sockets: Add support for keep-alive flag to passive socketsqapi/sockets.json util/qemu-sockets.c+5 -80 replies
5/6util/qemu-sockets: Refactor inet_parse() to use QemuOptstests/unit/test-util-sockets.c util/qemu-sockets.c+269 -840 replies
6/6util/qemu-sockets: Introduce inet socket options controlling TCP keep-alivemeson.build qapi/sockets.json tests/unit/test-util-sockets.c +1 more+162 -00 replies

Reviews trailers per patch

All 6 patches have a Reviewed-by or Acked-by.

PatchDaniel P. Berrangé
1/6R-b
2/6R-b
3/6R-b
4/6R-b
5/6R-b
6/6R-b

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

Read the v5 thread

Cover letter [PATCH v5 0/6] util/qemu-sockets: Introduce inet socket options controlling TCP keep-alive

This series extends the work introduced by commit aec21d3175 ("qapi: Add InetSocketAddress member keep-alive"). [1]

First, the series fixes an issue in qio_dns_resolver_lookup_sync_inet(), where the InetSocketAddress structure is only partially copied. Next, it refactors setting client socket options into a separate function and the success and failure paths in inet_listen_saddr() in preparation for keep-alive support on server sockets and the addition of new TCP keep-alive options.

Then, the series extends the support for keep-alive on server sockets.

Before adding new inet address options, there are a couple of issues with the inet address options parsing this series resolves:
- the parser contains a bug where it does not allow options with names that start with the name of another flag,
- the parser lacks some common function for parsing numeric values,
- the parser supports only a subset of the inet address options, namely the 'numeric' flag is missing.
This is resolved by the sixth patch by reworking with parser using the QemuOpts parser. The series also includes unit tests to verify, there is no regression in the refactored parser.

Finally, the series introduces three new InetSocketAddress options for the control of TCP keep-alive settings. By default, the value of all new settings is 0, which means no custom socket option value is set.

This is useful, for example, for live migration. In case there is no traffic from the destination to the source machine during postcopy, the destination cannot detect a failed connection due to a lack of non-acknowledged packets and stays in the postcopy-active state until paused by the management of the QEMU instance.

[1]: https://lore.kernel.org/all/[email protected]/

---
V5:
- squashed "tests/unit/test-util-sockets: Add tests for inet_parse()" and "util/qemu-sockets: Refactor inet_parse() to use QemuOpts"
- updated the existing test case to use only explicit bool option values and added a second test case using only implicit bool option values

V4:
https://lore.kernel.org/all/[email protected]/
- refactored inet_parse() to use QemuOpts, this resolves a bug and allows more option types, with tests
- fixed HAVE_TCP_* macros on Windows and macOS and other suggestions by Daniel

V3:
https://lore.kernel.org/all/[email protected]/
- moved the InetSocketAddress struct copy fix and the common function setting socket options into a separate commit
- refactored inet_listen_saddr()

V2:
https://lore.kernel.org/all/[email protected]/
- moved socket options setting into a common function for both server and client sockets (suggested by Vladimir)

V1:
https://lore.kernel.org/all/[email protected]/

Juraj Marcin (6):
io: Fix partial struct copy in qio_dns_resolver_lookup_sync_inet() util/qemu-sockets: Refactor setting client sockopts into a separate
function
util/qemu-sockets: Refactor success and failure paths in
inet_listen_saddr()
util/qemu-sockets: Add support for keep-alive flag to passive sockets util/qemu-sockets: Refactor inet_parse() to use QemuOpts util/qemu-sockets: Introduce inet socket options controlling TCP
keep-alive

 io/dns-resolver.c              |  21 +--
 meson.build                    |  30 +++
 qapi/sockets.json              |  23 ++-
 tests/unit/test-util-sockets.c | 228 +++++++++++++++++++++++
 util/qemu-sockets.c            | 327 ++++++++++++++++++++-------------
 5 files changed, 487 insertions(+), 142 deletions(-)
Signature · 1 line
2.49.0