Skip to content

io: enable DNS resolving separately of socket create

Daniel P. Berrange qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest8 patches 3 repliesIn review
  2. v18 patches 13 repliesSuperseded

Changes in v2 from the cover letter

- Fix qapi schema version annotation (Eric)
- Fix qapi schema optional status for "numeric" (Eric)
- Use bool instead of gboolean (Eric)
- Document that qio_task_set_error() accepts NULL (Eric)
- Make qio_task_set_error() calls unconditional (Eric)
- Fix leak of SocketAddress results (Eric)
- Other misc typos (Eric)

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8sockets: add ability to disable DNS resolution for InetSocketAddressqapi-schema.json util/qemu-sockets.c+8 -01 reply
2/8io: stop incrementing reference in qio_task_get_sourceinclude/io/task.h io/channel-socket.c io/channel-tls.c +2 more+4 -100 replies
3/8io: fix typo in docs for QIOTaskinclude/io/task.h+3 -30 replies
4/8io: add ability to associate an opaque "result" with with a taskinclude/io/task.h io/task.c+47 -00 replies
5/8io: add ability to associate an error with a taskinclude/io/task.h io/task.c+55 -01 reply
6/8io: change the QIOTask callback signatureinclude/io/task.h io/channel-tls.c io/channel-websock.c +12 more+110 -1120 replies
7/8io: remove Error parameter from QIOTask thread workerinclude/io/task.h io/channel-socket.c io/task.c +1 more+30 -520 replies
8/8io: introduce a DNS resolver APIinclude/io/dns-resolver.h include/qemu/sockets.h io/Makefile.objs +2 more+500 -21 reply

Reviews trailers per patch

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

PatchEric Blake
1/8R-b
2/8R-b
3/8R-b
4/8R-b
5/8R-b
6/8R-b
7/8R-b
8/8R-b

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

Read the v2 thread

Cover letter [Qemu-devel] [PATCH v2 0/8] io: enable DNS resolving separately of socket create

This is a followup of:

v1: https://lists.gnu.org/archive/html/qemu-devel/2017-01/msg00574.html

Currently DNS resolution of SocketAddress structs is done as part of the socket connect/listen process. This is very inflexible as it assumes that a single SocketAddress struct will only ever require a single socket to be opened. While true for connect(), it is not the case for listen() in two scenarios

- A name may resolve to both an IPv4 and IPv6 address. Currently we workaround that by clearing the IPV6_V6ONLY flag.

- A name may resolve to multiple IP addresses of the same protocol. eg "myhostname" may return "192.168.122.1" and "10.0.0.2" when the host has multiple NICs, or multiple addresses per NIC.

The only way to deal with the latter problem is to open multiple sockets and that requires the ability to separate DNS resolution from socket creation.

This series thus enhances the I/O framework in QEMU to introduce the "QIODNSResolver" concept. This (singleton) object allows the caller to feed in a single SocketAddress struct, perform DNS resolution, and get back out one or more new SocketAddress structs for the results. The API allows both synchronous and asynchrounous DNS lookups, the latter done by spawning a thread to do the getaddrinfo call via the QIOTask framework.

In this series the InetSocketAddress struct gains a new field to let the caller indicate that the address is providing a numeric host value, thus skipping DNS altogether.

The QIOTask object had some refactoring to allow results to be associated with it explicitly, so that the asynchronous DNS results can be passed around. This triggered the code churn across other files in QEMU using QIOTask.

This series will be utilized by a second series that will be sent that updates the VNC server code to use this new feature.

Changed in v2:

- Fix qapi schema version annotation (Eric)
- Fix qapi schema optional status for "numeric" (Eric)
- Use bool instead of gboolean (Eric)
- Document that qio_task_set_error() accepts NULL (Eric)
- Make qio_task_set_error() calls unconditional (Eric)
- Fix leak of SocketAddress results (Eric)
- Other misc typos (Eric)

Daniel P. Berrange (8):
sockets: add ability to disable DNS resolution for InetSocketAddress
io: stop incrementing reference in qio_task_get_source
io: fix typo in docs for QIOTask
io: add ability to associate an opaque "result" with with a task
io: add ability to associate an error with a task
io: change the QIOTask callback signature
io: remove Error parameter from QIOTask thread worker
io: introduce a DNS resolver API

 include/io/dns-resolver.h      | 228 +++++++++++++++++++++++++++++++++++
 include/io/task.h              | 154 +++++++++++++++++-------
 include/qemu/sockets.h         |   2 +
 io/Makefile.objs               |   1 +
 io/channel-socket.c            |  44 +++----
 io/channel-tls.c               |  16 +--
 io/channel-websock.c           |   8 +-
 io/dns-resolver.c              | 267 +++++++++++++++++++++++++++++++++++++++++
 io/task.c                      |  62 +++++++---
 io/trace-events                |   1 -
 migration/socket.c             |  11 +-
 migration/tls.c                |  19 +--
 nbd/common.c                   |   8 +-
 nbd/nbd-internal.h             |   3 +-
 qapi-schema.json               |   5 +
 qemu-char.c                    |  18 +--
 tests/test-io-channel-socket.c |   5 +-
 tests/test-io-channel-tls.c    |   5 +-
 tests/test-io-task.c           |  31 ++---
 ui/vnc-auth-vencrypt.c         |   7 +-
 ui/vnc-ws.c                    |  14 ++-
 util/qemu-sockets.c            |   7 +-
 22 files changed, 747 insertions(+), 169 deletions(-)
 create mode 100644 include/io/dns-resolver.h
 create mode 100644 io/dns-resolver.c
Signature · 1 line
2.9.3