qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/5] util/qemu-sockets: Introduce inet socket options controlling TCP keep-alive
@ 2025-04-08 11:24 Juraj Marcin
  2025-04-08 11:25 ` [PATCH v3 1/5] io: Fix partial struct copy in qio_dns_resolver_lookup_sync_inet() Juraj Marcin
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Juraj Marcin @ 2025-04-08 11:24 UTC (permalink / raw)
  To: qemu-devel
  Cc: Juraj Marcin, vsementsov, Daniel P. Berrangé, Paolo Bonzini

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 adds support for keep-alive on server sockets and adds
three new InetSocketAddress options for 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/20190725094937.32454-1-vsementsov@virtuozzo.com/

---
V3:
- moved the InetSocketAddress struct copy fix and the common function
  setting socket options into a separate commit
- refactored inet_listen_saddr()

V2:
- moved socket options setting into a common function for both server
  and client sockets (suggested by Vladimir)

Juraj Marcin (5):
  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
  utils/qemu-sockets: Introduce inet socket options controlling TCP
    keep-alive

 io/dns-resolver.c   |  21 ++----
 meson.build         |   6 ++
 qapi/sockets.json   |  19 ++++-
 util/qemu-sockets.c | 177 ++++++++++++++++++++++++++++++++++----------
 4 files changed, 165 insertions(+), 58 deletions(-)

-- 
2.48.1



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v3 1/5] io: Fix partial struct copy in qio_dns_resolver_lookup_sync_inet()
  2025-04-08 11:24 [PATCH v3 0/5] util/qemu-sockets: Introduce inet socket options controlling TCP keep-alive Juraj Marcin
@ 2025-04-08 11:25 ` Juraj Marcin
  2025-04-11 10:38   ` Daniel P. Berrangé
  2025-04-08 11:25 ` [PATCH v3 2/5] util/qemu-sockets: Refactor setting client sockopts into a separate function Juraj Marcin
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: Juraj Marcin @ 2025-04-08 11:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Juraj Marcin, vsementsov, Daniel P. Berrangé, Paolo Bonzini

From: Juraj Marcin <jmarcin@redhat.com>

Commit aec21d3175 (qapi: Add InetSocketAddress member keep-alive)
introduces the keep-alive flag, but this flag is not copied together
with other options in qio_dns_resolver_lookup_sync_inet().

This patch fixes this issue and also prevents future ones by copying the
entire structure first and only then overriding a few attributes that
need to be different.

Fixes: aec21d31756c (qapi: Add InetSocketAddress member keep-alive)
Signed-off-by: Juraj Marcin <jmarcin@redhat.com>
---
 io/dns-resolver.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/io/dns-resolver.c b/io/dns-resolver.c
index 53b0e8407a..3712438f82 100644
--- a/io/dns-resolver.c
+++ b/io/dns-resolver.c
@@ -111,22 +111,11 @@ static int qio_dns_resolver_lookup_sync_inet(QIODNSResolver *resolver,
                     uaddr, INET6_ADDRSTRLEN, uport, 32,
                     NI_NUMERICHOST | NI_NUMERICSERV);
 
-        newaddr->u.inet = (InetSocketAddress){
-            .host = g_strdup(uaddr),
-            .port = g_strdup(uport),
-            .has_numeric = true,
-            .numeric = true,
-            .has_to = iaddr->has_to,
-            .to = iaddr->to,
-            .has_ipv4 = iaddr->has_ipv4,
-            .ipv4 = iaddr->ipv4,
-            .has_ipv6 = iaddr->has_ipv6,
-            .ipv6 = iaddr->ipv6,
-#ifdef HAVE_IPPROTO_MPTCP
-            .has_mptcp = iaddr->has_mptcp,
-            .mptcp = iaddr->mptcp,
-#endif
-        };
+        newaddr->u.inet = *iaddr;
+        newaddr->u.inet.host = g_strdup(uaddr),
+        newaddr->u.inet.port = g_strdup(uport),
+        newaddr->u.inet.has_numeric = true,
+        newaddr->u.inet.numeric = true,
 
         (*addrs)[i] = newaddr;
     }
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 2/5] util/qemu-sockets: Refactor setting client sockopts into a separate function
  2025-04-08 11:24 [PATCH v3 0/5] util/qemu-sockets: Introduce inet socket options controlling TCP keep-alive Juraj Marcin
  2025-04-08 11:25 ` [PATCH v3 1/5] io: Fix partial struct copy in qio_dns_resolver_lookup_sync_inet() Juraj Marcin
@ 2025-04-08 11:25 ` Juraj Marcin
  2025-04-11 10:40   ` Daniel P. Berrangé
  2025-04-08 11:25 ` [PATCH v3 3/5] util/qemu-sockets: Refactor success and failure paths in inet_listen_saddr() Juraj Marcin
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: Juraj Marcin @ 2025-04-08 11:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Juraj Marcin, vsementsov, Daniel P. Berrangé, Paolo Bonzini

From: Juraj Marcin <jmarcin@redhat.com>

This is done in preparation for enabling the SO_KEEPALIVE support for
server sockets and adding settings for more TCP keep-alive socket
options.

Signed-off-by: Juraj Marcin <jmarcin@redhat.com>
---
 util/qemu-sockets.c | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 77477c1cd5..d15f6aa4b0 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -205,6 +205,22 @@ static int try_bind(int socket, InetSocketAddress *saddr, struct addrinfo *e)
 #endif
 }
 
+static int inet_set_sockopts(int sock, InetSocketAddress *saddr, Error **errp)
+{
+    if (saddr->keep_alive) {
+        int keep_alive = 1;
+        int ret = setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
+                             &keep_alive, sizeof(keep_alive));
+
+        if (ret < 0) {
+            error_setg_errno(errp, errno,
+                             "Unable to set keep-alive option on socket");
+            return -1;
+        }
+    }
+    return 0;
+}
+
 static int inet_listen_saddr(InetSocketAddress *saddr,
                              int port_offset,
                              int num,
@@ -475,16 +491,9 @@ int inet_connect_saddr(InetSocketAddress *saddr, Error **errp)
         return sock;
     }
 
-    if (saddr->keep_alive) {
-        int val = 1;
-        int ret = setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
-                             &val, sizeof(val));
-
-        if (ret < 0) {
-            error_setg_errno(errp, errno, "Unable to set KEEPALIVE");
-            close(sock);
-            return -1;
-        }
+    if (inet_set_sockopts(sock, saddr, errp)) {
+        close(sock);
+        return -1;
     }
 
     return sock;
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 3/5] util/qemu-sockets: Refactor success and failure paths in inet_listen_saddr()
  2025-04-08 11:24 [PATCH v3 0/5] util/qemu-sockets: Introduce inet socket options controlling TCP keep-alive Juraj Marcin
  2025-04-08 11:25 ` [PATCH v3 1/5] io: Fix partial struct copy in qio_dns_resolver_lookup_sync_inet() Juraj Marcin
  2025-04-08 11:25 ` [PATCH v3 2/5] util/qemu-sockets: Refactor setting client sockopts into a separate function Juraj Marcin
@ 2025-04-08 11:25 ` Juraj Marcin
  2025-04-11 13:47   ` Daniel P. Berrangé
  2025-04-08 11:25 ` [PATCH v3 4/5] util/qemu-sockets: Add support for keep-alive flag to passive sockets Juraj Marcin
  2025-04-08 11:25 ` [PATCH v3 5/5] utils/qemu-sockets: Introduce inet socket options controlling TCP keep-alive Juraj Marcin
  4 siblings, 1 reply; 13+ messages in thread
From: Juraj Marcin @ 2025-04-08 11:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Juraj Marcin, vsementsov, Daniel P. Berrangé, Paolo Bonzini

From: Juraj Marcin <jmarcin@redhat.com>

To get a listening socket, we need to first create a socket, try binding
it to a certain port, and lastly starting listening to it. Each of these
operations can fail due to various reasons, one of them being that the
requested address/port is already in use. In such case, the function
tries the same process with a new port number.

This patch refactors the port number loop, so the success path is no
longer buried inside the 'if' statements in the middle of the loop. Now,
the success path is not nested and ends at the end of the iteration
after successful socket creation, binding, and listening. In case any of
the operations fails, it either continues to the next iteration (and the
next port) or jumps out of the loop to handle the error and exits the
function.

Signed-off-by: Juraj Marcin <jmarcin@redhat.com>
---
 util/qemu-sockets.c | 51 ++++++++++++++++++++++++---------------------
 1 file changed, 27 insertions(+), 24 deletions(-)

diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index d15f6aa4b0..a86964786a 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -303,11 +303,20 @@ static int inet_listen_saddr(InetSocketAddress *saddr,
         port_min = inet_getport(e);
         port_max = saddr->has_to ? saddr->to + port_offset : port_min;
         for (p = port_min; p <= port_max; p++) {
+            if (slisten >= 0) {
+                /*
+                 * We have a socket we tried with the previous port. It cannot
+                 * be rebound, we need to close it and create a new one.
+                 */
+                close(slisten);
+                slisten = -1;
+            }
             inet_setport(e, p);
 
             slisten = create_fast_reuse_socket(e);
             if (slisten < 0) {
-                /* First time we expect we might fail to create the socket
+                /*
+                 * First time we expect we might fail to create the socket
                  * eg if 'e' has AF_INET6 but ipv6 kmod is not loaded.
                  * Later iterations should always succeed if first iteration
                  * worked though, so treat that as fatal.
@@ -317,40 +326,38 @@ static int inet_listen_saddr(InetSocketAddress *saddr,
                 } else {
                     error_setg_errno(errp, errno,
                                      "Failed to recreate failed listening socket");
-                    goto listen_failed;
+                    goto fail;
                 }
             }
             socket_created = true;
 
             rc = try_bind(slisten, saddr, e);
             if (rc < 0) {
-                if (errno != EADDRINUSE) {
-                    error_setg_errno(errp, errno, "Failed to bind socket");
-                    goto listen_failed;
+                if (errno == EADDRINUSE) {
+                    /* This port is already used, try the next one */
+                    continue;
                 }
-            } else {
-                if (!listen(slisten, num)) {
-                    goto listen_ok;
-                }
-                if (errno != EADDRINUSE) {
-                    error_setg_errno(errp, errno, "Failed to listen on socket");
-                    goto listen_failed;
+                error_setg_errno(errp, errno, "Failed to bind socket");
+                goto fail;
+            }
+            if (listen(slisten, num)) {
+                if (errno == EADDRINUSE) {
+                    /* This port is already used, try the next one */
+                    continue;
                 }
+                error_setg_errno(errp, errno, "Failed to listen on socket");
+                goto fail;
             }
-            /* Someone else managed to bind to the same port and beat us
-             * to listen on it! Socket semantics does not allow us to
-             * recover from this situation, so we need to recreate the
-             * socket to allow bind attempts for subsequent ports:
-             */
-            close(slisten);
-            slisten = -1;
+            /* We have a listening socket */
+            freeaddrinfo(res);
+            return slisten;
         }
     }
     error_setg_errno(errp, errno,
                      socket_created ?
                      "Failed to find an available port" :
                      "Failed to create a socket");
-listen_failed:
+fail:
     saved_errno = errno;
     if (slisten >= 0) {
         close(slisten);
@@ -358,10 +365,6 @@ listen_failed:
     freeaddrinfo(res);
     errno = saved_errno;
     return -1;
-
-listen_ok:
-    freeaddrinfo(res);
-    return slisten;
 }
 
 #ifdef _WIN32
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 4/5] util/qemu-sockets: Add support for keep-alive flag to passive sockets
  2025-04-08 11:24 [PATCH v3 0/5] util/qemu-sockets: Introduce inet socket options controlling TCP keep-alive Juraj Marcin
                   ` (2 preceding siblings ...)
  2025-04-08 11:25 ` [PATCH v3 3/5] util/qemu-sockets: Refactor success and failure paths in inet_listen_saddr() Juraj Marcin
@ 2025-04-08 11:25 ` Juraj Marcin
  2025-04-11 13:49   ` Daniel P. Berrangé
  2025-04-08 11:25 ` [PATCH v3 5/5] utils/qemu-sockets: Introduce inet socket options controlling TCP keep-alive Juraj Marcin
  4 siblings, 1 reply; 13+ messages in thread
From: Juraj Marcin @ 2025-04-08 11:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Juraj Marcin, vsementsov, Daniel P. Berrangé, Paolo Bonzini

From: Juraj Marcin <jmarcin@redhat.com>

Commit aec21d3175 (qapi: Add InetSocketAddress member keep-alive)
introduces the keep-alive flag, which enables the SO_KEEPALIVE socket
option, but only on client-side sockets. However, this option is also
useful for server-side sockets, so they can check if a client is still
reachable or drop the connection otherwise.

This patch enables the SO_KEEPALIVE socket option on passive server-side
sockets if the keep-alive flag is enabled. This socket option is then
inherited by active server-side sockets communicating with connected
clients.

Signed-off-by: Juraj Marcin <jmarcin@redhat.com>
---
 qapi/sockets.json   | 4 ++--
 util/qemu-sockets.c | 9 +++------
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/qapi/sockets.json b/qapi/sockets.json
index 6a95023315..62797cd027 100644
--- a/qapi/sockets.json
+++ b/qapi/sockets.json
@@ -56,8 +56,8 @@
 # @ipv6: whether to accept IPv6 addresses, default try both IPv4 and
 #     IPv6
 #
-# @keep-alive: enable keep-alive when connecting to this socket.  Not
-#     supported for passive sockets.  (Since 4.2)
+# @keep-alive: enable keep-alive when connecting to/listening on this socket.
+#     (Since 4.2, not supported for listening sockets until 10.1)
 #
 # @mptcp: enable multi-path TCP.  (Since 6.1)
 #
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index a86964786a..fed17a1ffb 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -236,12 +236,6 @@ static int inet_listen_saddr(InetSocketAddress *saddr,
     int saved_errno = 0;
     bool socket_created = false;
 
-    if (saddr->keep_alive) {
-        error_setg(errp, "keep-alive option is not supported for passive "
-                   "sockets");
-        return -1;
-    }
-
     memset(&ai,0, sizeof(ai));
     ai.ai_flags = AI_PASSIVE;
     if (saddr->has_numeric && saddr->numeric) {
@@ -349,6 +343,9 @@ static int inet_listen_saddr(InetSocketAddress *saddr,
                 goto fail;
             }
             /* We have a listening socket */
+            if (inet_set_sockopts(slisten, saddr, errp)) {
+                goto fail;
+            }
             freeaddrinfo(res);
             return slisten;
         }
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 5/5] utils/qemu-sockets: Introduce inet socket options controlling TCP keep-alive
  2025-04-08 11:24 [PATCH v3 0/5] util/qemu-sockets: Introduce inet socket options controlling TCP keep-alive Juraj Marcin
                   ` (3 preceding siblings ...)
  2025-04-08 11:25 ` [PATCH v3 4/5] util/qemu-sockets: Add support for keep-alive flag to passive sockets Juraj Marcin
@ 2025-04-08 11:25 ` Juraj Marcin
  2025-04-11 13:54   ` Daniel P. Berrangé
  4 siblings, 1 reply; 13+ messages in thread
From: Juraj Marcin @ 2025-04-08 11:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Juraj Marcin, vsementsov, Daniel P. Berrangé, Paolo Bonzini

From: Juraj Marcin <jmarcin@redhat.com>

With the default TCP stack configuration, it could be even 2 hours
before the connection times out due to the other side not being
reachable. However, in some cases, the application needs to be aware of
a connection issue much sooner.

This is the case, for example, for postcopy live migration. If there is
no traffic from the migration destination guest (server-side) to the
migration source guest (client-side), the destination keeps waiting for
pages indefinitely and does not switch to the postcopy-paused state.
This can happen, for example, if the destination QEMU instance is
started with the '-S' command line option and the machine is not started
yet, or if the machine is idle and produces no new page faults for
not-yet-migrated pages.

This patch introduces new inet socket parameters that control count,
idle period, and interval of TCP keep-alive packets before the
connection is considered broken. These parameters are available on
systems where the respective TCP socket options are defined
(TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL).

The default value for all is 0, which means the system configuration is
used.

Signed-off-by: Juraj Marcin <jmarcin@redhat.com>
---
 meson.build         |  6 ++++
 qapi/sockets.json   | 15 ++++++++
 util/qemu-sockets.c | 88 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 109 insertions(+)

diff --git a/meson.build b/meson.build
index 41f68d3806..680f47cf42 100644
--- a/meson.build
+++ b/meson.build
@@ -2734,6 +2734,12 @@ if linux_io_uring.found()
   config_host_data.set('HAVE_IO_URING_PREP_WRITEV2',
                        cc.has_header_symbol('liburing.h', 'io_uring_prep_writev2'))
 endif
+config_host_data.set('HAVE_TCP_KEEPCNT',
+                     cc.has_header_symbol('netinet/tcp.h', 'TCP_KEEPCNT'))
+config_host_data.set('HAVE_TCP_KEEPIDLE',
+                     cc.has_header_symbol('netinet/tcp.h', 'TCP_KEEPIDLE'))
+config_host_data.set('HAVE_TCP_KEEPINTVL',
+                     cc.has_header_symbol('netinet/tcp.h', 'TCP_KEEPINTVL'))
 
 # has_member
 config_host_data.set('HAVE_SIGEV_NOTIFY_THREAD_ID',
diff --git a/qapi/sockets.json b/qapi/sockets.json
index 62797cd027..bb9d298635 100644
--- a/qapi/sockets.json
+++ b/qapi/sockets.json
@@ -59,6 +59,18 @@
 # @keep-alive: enable keep-alive when connecting to/listening on this socket.
 #     (Since 4.2, not supported for listening sockets until 10.1)
 #
+# @keep-alive-count: number of keep-alive packets sent before the connection is
+#     closed.  Only supported for TCP sockets on systems where TCP_KEEPCNT
+#     socket option is defined.  (Since 10.1)
+#
+# @keep-alive-idle: time in seconds the connection needs to be idle before
+#     sending a keepalive packet.  Only supported for TCP sockets on systems
+#     where TCP_KEEPIDLE socket option is defined.  (Since 10.1)
+#
+# @keep-alive-interval: time in secods between keep-alive packets.  Only
+#     supported for TCP sockets on systems where TCP_KEEPINTVL is defined.
+#     (Since 10.1)
+#
 # @mptcp: enable multi-path TCP.  (Since 6.1)
 #
 # Since: 1.3
@@ -71,6 +83,9 @@
     '*ipv4': 'bool',
     '*ipv6': 'bool',
     '*keep-alive': 'bool',
+    '*keep-alive-count': { 'type': 'uint32', 'if': 'HAVE_TCP_KEEPCNT' },
+    '*keep-alive-idle': { 'type': 'uint32', 'if': 'HAVE_TCP_KEEPIDLE' },
+    '*keep-alive-interval': { 'type': 'uint32', 'if': 'HAVE_TCP_KEEPINTVL' },
     '*mptcp': { 'type': 'bool', 'if': 'HAVE_IPPROTO_MPTCP' } } }
 
 ##
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index fed17a1ffb..8e355b097c 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -217,6 +217,45 @@ static int inet_set_sockopts(int sock, InetSocketAddress *saddr, Error **errp)
                              "Unable to set keep-alive option on socket");
             return -1;
         }
+#ifdef HAVE_TCP_KEEPCNT
+        if (saddr->has_keep_alive_count &&
+            saddr->keep_alive_count) {
+            int keep_count = saddr->has_keep_alive_count;
+            ret = setsockopt(sock, IPPROTO_TCP, TCP_KEEPCNT, &keep_count,
+                             sizeof(keep_count));
+            if (ret < 0) {
+                error_setg_errno(errp, errno,
+                                 "Unable to set TCP keep-alive count option on socket");
+                return -1;
+            }
+        }
+#endif
+#ifdef HAVE_TCP_KEEPIDLE
+        if (saddr->has_keep_alive_idle &&
+            saddr->keep_alive_idle) {
+            int keep_idle = saddr->has_keep_alive_idle;
+            ret = setsockopt(sock, IPPROTO_TCP, TCP_KEEPIDLE, &keep_idle,
+                             sizeof(keep_idle));
+            if (ret < 0) {
+                error_setg_errno(errp, errno,
+                                 "Unable to set TCP keep-alive idle option on socket");
+                return -1;
+            }
+        }
+#endif
+#ifdef HAVE_TCP_KEEPINTVL
+        if (saddr->has_keep_alive_interval &&
+            saddr->keep_alive_interval) {
+            int keep_interval = saddr->has_keep_alive_interval;
+            ret = setsockopt(sock, IPPROTO_TCP, TCP_KEEPINTVL, &keep_interval,
+                             sizeof(keep_interval));
+            if (ret < 0) {
+                error_setg_errno(errp, errno,
+                                 "Unable to set TCP keep-alive interval option on socket");
+                return -1;
+            }
+        }
+#endif
     }
     return 0;
 }
@@ -628,6 +667,22 @@ static int inet_parse_flag(const char *flagname, const char *optstr, bool *val,
     return 0;
 }
 
+static int inet_parse_u32(const char *optname, const char *optstr,
+                          uint32_t max, uint32_t *val, Error **errp)
+{
+    int pos;
+    if (sscanf(optstr, "%" PRIu32 "%n", val, &pos) != 1 ||
+        (optstr[pos] != '\0' && optstr[pos] != ',')) {
+        error_setg(errp, "error parsing %s argument", optname);
+        return -1;
+    }
+    if (*val > max) {
+        error_setg(errp, "%s is too large", optname);
+        return -1;
+    }
+    return 0;
+}
+
 int inet_parse(InetSocketAddress *addr, const char *str, Error **errp)
 {
     const char *optstr, *h;
@@ -700,6 +755,39 @@ int inet_parse(InetSocketAddress *addr, const char *str, Error **errp)
         }
         addr->has_keep_alive = true;
     }
+#ifdef HAVE_TCP_KEEPCNT
+    begin = strstr(optstr, ",keep-alive-count=");
+    if (begin) {
+        if (inet_parse_u32("keep-alive-count",
+                           begin + strlen(",keep-alive-count="), INT_MAX,
+                           &addr->keep_alive_count, errp)) {
+            return -1;
+        }
+        addr->has_keep_alive_count = true;
+    }
+#endif
+#ifdef HAVE_TCP_KEEPIDLE
+    begin = strstr(optstr, ",keep-alive-idle=");
+    if (begin) {
+        if (inet_parse_u32("keep-alive-idle",
+                           begin + strlen(",keep-alive-idle="), INT_MAX,
+                           &addr->keep_alive_idle, errp)) {
+            return -1;
+        }
+        addr->has_keep_alive_idle = true;
+    }
+#endif
+#ifdef HAVE_TCP_KEEPINTVL
+    begin = strstr(optstr, ",keep-alive-interval=");
+    if (begin) {
+        if (inet_parse_u32("keep-alive-interval",
+                           begin + strlen(",keep-alive-interval="), INT_MAX,
+                           &addr->keep_alive_interval, errp)) {
+            return -1;
+        }
+        addr->has_keep_alive_interval = true;
+    }
+#endif
 #ifdef HAVE_IPPROTO_MPTCP
     begin = strstr(optstr, ",mptcp");
     if (begin) {
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 1/5] io: Fix partial struct copy in qio_dns_resolver_lookup_sync_inet()
  2025-04-08 11:25 ` [PATCH v3 1/5] io: Fix partial struct copy in qio_dns_resolver_lookup_sync_inet() Juraj Marcin
@ 2025-04-11 10:38   ` Daniel P. Berrangé
  0 siblings, 0 replies; 13+ messages in thread
From: Daniel P. Berrangé @ 2025-04-11 10:38 UTC (permalink / raw)
  To: Juraj Marcin; +Cc: qemu-devel, vsementsov, Paolo Bonzini

On Tue, Apr 08, 2025 at 01:25:00PM +0200, Juraj Marcin wrote:
> From: Juraj Marcin <jmarcin@redhat.com>
> 
> Commit aec21d3175 (qapi: Add InetSocketAddress member keep-alive)
> introduces the keep-alive flag, but this flag is not copied together
> with other options in qio_dns_resolver_lookup_sync_inet().
> 
> This patch fixes this issue and also prevents future ones by copying the
> entire structure first and only then overriding a few attributes that
> need to be different.
> 
> Fixes: aec21d31756c (qapi: Add InetSocketAddress member keep-alive)
> Signed-off-by: Juraj Marcin <jmarcin@redhat.com>
> ---
>  io/dns-resolver.c | 21 +++++----------------
>  1 file changed, 5 insertions(+), 16 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 2/5] util/qemu-sockets: Refactor setting client sockopts into a separate function
  2025-04-08 11:25 ` [PATCH v3 2/5] util/qemu-sockets: Refactor setting client sockopts into a separate function Juraj Marcin
@ 2025-04-11 10:40   ` Daniel P. Berrangé
  0 siblings, 0 replies; 13+ messages in thread
From: Daniel P. Berrangé @ 2025-04-11 10:40 UTC (permalink / raw)
  To: Juraj Marcin; +Cc: qemu-devel, vsementsov, Paolo Bonzini

On Tue, Apr 08, 2025 at 01:25:01PM +0200, Juraj Marcin wrote:
> From: Juraj Marcin <jmarcin@redhat.com>
> 
> This is done in preparation for enabling the SO_KEEPALIVE support for
> server sockets and adding settings for more TCP keep-alive socket
> options.
> 
> Signed-off-by: Juraj Marcin <jmarcin@redhat.com>
> ---
>  util/qemu-sockets.c | 29 +++++++++++++++++++----------
>  1 file changed, 19 insertions(+), 10 deletions(-)
> 
> diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
> index 77477c1cd5..d15f6aa4b0 100644
> --- a/util/qemu-sockets.c
> +++ b/util/qemu-sockets.c
> @@ -205,6 +205,22 @@ static int try_bind(int socket, InetSocketAddress *saddr, struct addrinfo *e)
>  #endif
>  }
>  
> +static int inet_set_sockopts(int sock, InetSocketAddress *saddr, Error **errp)
> +{
> +    if (saddr->keep_alive) {
> +        int keep_alive = 1;
> +        int ret = setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
> +                             &keep_alive, sizeof(keep_alive));
> +
> +        if (ret < 0) {
> +            error_setg_errno(errp, errno,
> +                             "Unable to set keep-alive option on socket");
> +            return -1;
> +        }
> +    }
> +    return 0;
> +}
> +
>  static int inet_listen_saddr(InetSocketAddress *saddr,
>                               int port_offset,
>                               int num,
> @@ -475,16 +491,9 @@ int inet_connect_saddr(InetSocketAddress *saddr, Error **errp)
>          return sock;
>      }
>  
> -    if (saddr->keep_alive) {
> -        int val = 1;
> -        int ret = setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
> -                             &val, sizeof(val));
> -
> -        if (ret < 0) {
> -            error_setg_errno(errp, errno, "Unable to set KEEPALIVE");
> -            close(sock);
> -            return -1;
> -        }
> +    if (inet_set_sockopts(sock, saddr, errp)) {

Since this returns -1 on error, by convention we check "< 0", reserving
positive return values for future non-error scenarios.

> +        close(sock);
> +        return -1;
>      }
>  
>      return sock;
> -- 
> 2.48.1
> 

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 3/5] util/qemu-sockets: Refactor success and failure paths in inet_listen_saddr()
  2025-04-08 11:25 ` [PATCH v3 3/5] util/qemu-sockets: Refactor success and failure paths in inet_listen_saddr() Juraj Marcin
@ 2025-04-11 13:47   ` Daniel P. Berrangé
  0 siblings, 0 replies; 13+ messages in thread
From: Daniel P. Berrangé @ 2025-04-11 13:47 UTC (permalink / raw)
  To: Juraj Marcin; +Cc: qemu-devel, vsementsov, Paolo Bonzini

On Tue, Apr 08, 2025 at 01:25:02PM +0200, Juraj Marcin wrote:
> From: Juraj Marcin <jmarcin@redhat.com>
> 
> To get a listening socket, we need to first create a socket, try binding
> it to a certain port, and lastly starting listening to it. Each of these
> operations can fail due to various reasons, one of them being that the
> requested address/port is already in use. In such case, the function
> tries the same process with a new port number.
> 
> This patch refactors the port number loop, so the success path is no
> longer buried inside the 'if' statements in the middle of the loop. Now,
> the success path is not nested and ends at the end of the iteration
> after successful socket creation, binding, and listening. In case any of
> the operations fails, it either continues to the next iteration (and the
> next port) or jumps out of the loop to handle the error and exits the
> function.
> 
> Signed-off-by: Juraj Marcin <jmarcin@redhat.com>
> ---
>  util/qemu-sockets.c | 51 ++++++++++++++++++++++++---------------------
>  1 file changed, 27 insertions(+), 24 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 4/5] util/qemu-sockets: Add support for keep-alive flag to passive sockets
  2025-04-08 11:25 ` [PATCH v3 4/5] util/qemu-sockets: Add support for keep-alive flag to passive sockets Juraj Marcin
@ 2025-04-11 13:49   ` Daniel P. Berrangé
  0 siblings, 0 replies; 13+ messages in thread
From: Daniel P. Berrangé @ 2025-04-11 13:49 UTC (permalink / raw)
  To: Juraj Marcin; +Cc: qemu-devel, vsementsov, Paolo Bonzini

On Tue, Apr 08, 2025 at 01:25:03PM +0200, Juraj Marcin wrote:
> From: Juraj Marcin <jmarcin@redhat.com>
> 
> Commit aec21d3175 (qapi: Add InetSocketAddress member keep-alive)
> introduces the keep-alive flag, which enables the SO_KEEPALIVE socket
> option, but only on client-side sockets. However, this option is also
> useful for server-side sockets, so they can check if a client is still
> reachable or drop the connection otherwise.
> 
> This patch enables the SO_KEEPALIVE socket option on passive server-side
> sockets if the keep-alive flag is enabled. This socket option is then
> inherited by active server-side sockets communicating with connected
> clients.
> 
> Signed-off-by: Juraj Marcin <jmarcin@redhat.com>
> ---
>  qapi/sockets.json   | 4 ++--
>  util/qemu-sockets.c | 9 +++------
>  2 files changed, 5 insertions(+), 8 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 5/5] utils/qemu-sockets: Introduce inet socket options controlling TCP keep-alive
  2025-04-08 11:25 ` [PATCH v3 5/5] utils/qemu-sockets: Introduce inet socket options controlling TCP keep-alive Juraj Marcin
@ 2025-04-11 13:54   ` Daniel P. Berrangé
  2025-04-11 15:49     ` Daniel P. Berrangé
  0 siblings, 1 reply; 13+ messages in thread
From: Daniel P. Berrangé @ 2025-04-11 13:54 UTC (permalink / raw)
  To: Juraj Marcin; +Cc: qemu-devel, vsementsov, Paolo Bonzini

On Tue, Apr 08, 2025 at 01:25:04PM +0200, Juraj Marcin wrote:
> From: Juraj Marcin <jmarcin@redhat.com>
> 
> With the default TCP stack configuration, it could be even 2 hours
> before the connection times out due to the other side not being
> reachable. However, in some cases, the application needs to be aware of
> a connection issue much sooner.
> 
> This is the case, for example, for postcopy live migration. If there is
> no traffic from the migration destination guest (server-side) to the
> migration source guest (client-side), the destination keeps waiting for
> pages indefinitely and does not switch to the postcopy-paused state.
> This can happen, for example, if the destination QEMU instance is
> started with the '-S' command line option and the machine is not started
> yet, or if the machine is idle and produces no new page faults for
> not-yet-migrated pages.
> 
> This patch introduces new inet socket parameters that control count,
> idle period, and interval of TCP keep-alive packets before the
> connection is considered broken. These parameters are available on
> systems where the respective TCP socket options are defined
> (TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL).
> 
> The default value for all is 0, which means the system configuration is
> used.
> 
> Signed-off-by: Juraj Marcin <jmarcin@redhat.com>
> ---
>  meson.build         |  6 ++++
>  qapi/sockets.json   | 15 ++++++++
>  util/qemu-sockets.c | 88 +++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 109 insertions(+)
> 
> diff --git a/meson.build b/meson.build
> index 41f68d3806..680f47cf42 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -2734,6 +2734,12 @@ if linux_io_uring.found()
>    config_host_data.set('HAVE_IO_URING_PREP_WRITEV2',
>                         cc.has_header_symbol('liburing.h', 'io_uring_prep_writev2'))
>  endif
> +config_host_data.set('HAVE_TCP_KEEPCNT',
> +                     cc.has_header_symbol('netinet/tcp.h', 'TCP_KEEPCN'T))
> +config_host_data.set('HAVE_TCP_KEEPIDLE',
> +                     cc.has_header_symbol('netinet/tcp.h', 'TCP_KEEPIDLE'))
> +config_host_data.set('HAVE_TCP_KEEPINTVL',
> +                     cc.has_header_symbol('netinet/tcp.h', 'TCP_KEEPINTVL'))

What platforms are you aware of that do NOT have these
settings available ? I'm wondering if we can just assume
they always exist.

>  
>  # has_member
>  config_host_data.set('HAVE_SIGEV_NOTIFY_THREAD_ID',
> diff --git a/qapi/sockets.json b/qapi/sockets.json
> index 62797cd027..bb9d298635 100644
> --- a/qapi/sockets.json
> +++ b/qapi/sockets.json
> @@ -59,6 +59,18 @@
>  # @keep-alive: enable keep-alive when connecting to/listening on this socket.
>  #     (Since 4.2, not supported for listening sockets until 10.1)
>  #
> +# @keep-alive-count: number of keep-alive packets sent before the connection is
> +#     closed.  Only supported for TCP sockets on systems where TCP_KEEPCNT
> +#     socket option is defined.  (Since 10.1)
> +#
> +# @keep-alive-idle: time in seconds the connection needs to be idle before
> +#     sending a keepalive packet.  Only supported for TCP sockets on systems
> +#     where TCP_KEEPIDLE socket option is defined.  (Since 10.1)
> +#
> +# @keep-alive-interval: time in secods between keep-alive packets.  Only

Trivial typo s/secods/seconds/

> +#     supported for TCP sockets on systems where TCP_KEEPINTVL is defined.
> +#     (Since 10.1)
> +#
>  # @mptcp: enable multi-path TCP.  (Since 6.1)
>  #
>  # Since: 1.3
> @@ -71,6 +83,9 @@
>      '*ipv4': 'bool',
>      '*ipv6': 'bool',
>      '*keep-alive': 'bool',
> +    '*keep-alive-count': { 'type': 'uint32', 'if': 'HAVE_TCP_KEEPCNT' },
> +    '*keep-alive-idle': { 'type': 'uint32', 'if': 'HAVE_TCP_KEEPIDLE' },
> +    '*keep-alive-interval': { 'type': 'uint32', 'if': 'HAVE_TCP_KEEPINTVL' },
>      '*mptcp': { 'type': 'bool', 'if': 'HAVE_IPPROTO_MPTCP' } } }
>  
>  ##

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 5/5] utils/qemu-sockets: Introduce inet socket options controlling TCP keep-alive
  2025-04-11 13:54   ` Daniel P. Berrangé
@ 2025-04-11 15:49     ` Daniel P. Berrangé
  2025-04-30 14:47       ` Juraj Marcin
  0 siblings, 1 reply; 13+ messages in thread
From: Daniel P. Berrangé @ 2025-04-11 15:49 UTC (permalink / raw)
  To: Juraj Marcin, qemu-devel, vsementsov, Paolo Bonzini

On Fri, Apr 11, 2025 at 02:54:29PM +0100, Daniel P. Berrangé wrote:
> On Tue, Apr 08, 2025 at 01:25:04PM +0200, Juraj Marcin wrote:
> > From: Juraj Marcin <jmarcin@redhat.com>
> > 
> > With the default TCP stack configuration, it could be even 2 hours
> > before the connection times out due to the other side not being
> > reachable. However, in some cases, the application needs to be aware of
> > a connection issue much sooner.
> > 
> > This is the case, for example, for postcopy live migration. If there is
> > no traffic from the migration destination guest (server-side) to the
> > migration source guest (client-side), the destination keeps waiting for
> > pages indefinitely and does not switch to the postcopy-paused state.
> > This can happen, for example, if the destination QEMU instance is
> > started with the '-S' command line option and the machine is not started
> > yet, or if the machine is idle and produces no new page faults for
> > not-yet-migrated pages.
> > 
> > This patch introduces new inet socket parameters that control count,
> > idle period, and interval of TCP keep-alive packets before the
> > connection is considered broken. These parameters are available on
> > systems where the respective TCP socket options are defined
> > (TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL).
> > 
> > The default value for all is 0, which means the system configuration is
> > used.
> > 
> > Signed-off-by: Juraj Marcin <jmarcin@redhat.com>
> > ---
> >  meson.build         |  6 ++++
> >  qapi/sockets.json   | 15 ++++++++
> >  util/qemu-sockets.c | 88 +++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 109 insertions(+)
> > 
> > diff --git a/meson.build b/meson.build
> > index 41f68d3806..680f47cf42 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -2734,6 +2734,12 @@ if linux_io_uring.found()
> >    config_host_data.set('HAVE_IO_URING_PREP_WRITEV2',
> >                         cc.has_header_symbol('liburing.h', 'io_uring_prep_writev2'))
> >  endif
> > +config_host_data.set('HAVE_TCP_KEEPCNT',
> > +                     cc.has_header_symbol('netinet/tcp.h', 'TCP_KEEPCN'T))
> > +config_host_data.set('HAVE_TCP_KEEPIDLE',
> > +                     cc.has_header_symbol('netinet/tcp.h', 'TCP_KEEPIDLE'))
> > +config_host_data.set('HAVE_TCP_KEEPINTVL',
> > +                     cc.has_header_symbol('netinet/tcp.h', 'TCP_KEEPINTVL'))
> 
> What platforms are you aware of that do NOT have these
> settings available ? I'm wondering if we can just assume
> they always exist.

macOS appears to have these, except that 'TCP_KEEPIDLE' is under a
differnt name 'TCP_KEEPALIVE':

  https://github.com/apple/darwin-xnu/blob/xnu-4570.1.46/bsd/man/man4/tcp.4#L172

Likewise I see them available in mingw for Wndows builds, with both
names

$ grep -r TCP_KEEP /usr/i686-w64-mingw32/sys-root/mingw/include/
/usr/i686-w64-mingw32/sys-root/mingw/include/ws2ipdef.h:#define TCP_KEEPALIVE 3
/usr/i686-w64-mingw32/sys-root/mingw/include/ws2ipdef.h:#define TCP_KEEPCNT 16
/usr/i686-w64-mingw32/sys-root/mingw/include/ws2ipdef.h:#define TCP_KEEPIDLE TCP_KEEPALIVE
/usr/i686-w64-mingw32/sys-root/mingw/include/ws2ipdef.h:#define TCP_KEEPINTVL 17

but your patch wouldn't enable it because it checks netinet/tcp.h

AFAICT, the only platform that matters to QEMU that seems to miss this
is OpenBSD 

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 5/5] utils/qemu-sockets: Introduce inet socket options controlling TCP keep-alive
  2025-04-11 15:49     ` Daniel P. Berrangé
@ 2025-04-30 14:47       ` Juraj Marcin
  0 siblings, 0 replies; 13+ messages in thread
From: Juraj Marcin @ 2025-04-30 14:47 UTC (permalink / raw)
  To: Daniel P. Berrangé; +Cc: qemu-devel, vsementsov, Paolo Bonzini

Hi Daniel

On 2025-04-11 16:49, Daniel P. Berrangé wrote:
> On Fri, Apr 11, 2025 at 02:54:29PM +0100, Daniel P. Berrangé wrote:
> > On Tue, Apr 08, 2025 at 01:25:04PM +0200, Juraj Marcin wrote:
> > > From: Juraj Marcin <jmarcin@redhat.com>
> > > 
> > > With the default TCP stack configuration, it could be even 2 hours
> > > before the connection times out due to the other side not being
> > > reachable. However, in some cases, the application needs to be aware of
> > > a connection issue much sooner.
> > > 
> > > This is the case, for example, for postcopy live migration. If there is
> > > no traffic from the migration destination guest (server-side) to the
> > > migration source guest (client-side), the destination keeps waiting for
> > > pages indefinitely and does not switch to the postcopy-paused state.
> > > This can happen, for example, if the destination QEMU instance is
> > > started with the '-S' command line option and the machine is not started
> > > yet, or if the machine is idle and produces no new page faults for
> > > not-yet-migrated pages.
> > > 
> > > This patch introduces new inet socket parameters that control count,
> > > idle period, and interval of TCP keep-alive packets before the
> > > connection is considered broken. These parameters are available on
> > > systems where the respective TCP socket options are defined
> > > (TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL).
> > > 
> > > The default value for all is 0, which means the system configuration is
> > > used.
> > > 
> > > Signed-off-by: Juraj Marcin <jmarcin@redhat.com>
> > > ---
> > >  meson.build         |  6 ++++
> > >  qapi/sockets.json   | 15 ++++++++
> > >  util/qemu-sockets.c | 88 +++++++++++++++++++++++++++++++++++++++++++++
> > >  3 files changed, 109 insertions(+)
> > > 
> > > diff --git a/meson.build b/meson.build
> > > index 41f68d3806..680f47cf42 100644
> > > --- a/meson.build
> > > +++ b/meson.build
> > > @@ -2734,6 +2734,12 @@ if linux_io_uring.found()
> > >    config_host_data.set('HAVE_IO_URING_PREP_WRITEV2',
> > >                         cc.has_header_symbol('liburing.h', 'io_uring_prep_writev2'))
> > >  endif
> > > +config_host_data.set('HAVE_TCP_KEEPCNT',
> > > +                     cc.has_header_symbol('netinet/tcp.h', 'TCP_KEEPCN'T))
> > > +config_host_data.set('HAVE_TCP_KEEPIDLE',
> > > +                     cc.has_header_symbol('netinet/tcp.h', 'TCP_KEEPIDLE'))
> > > +config_host_data.set('HAVE_TCP_KEEPINTVL',
> > > +                     cc.has_header_symbol('netinet/tcp.h', 'TCP_KEEPINTVL'))
> > 
> > What platforms are you aware of that do NOT have these
> > settings available ? I'm wondering if we can just assume
> > they always exist.
> 
> macOS appears to have these, except that 'TCP_KEEPIDLE' is under a
> differnt name 'TCP_KEEPALIVE':
> 
>   https://github.com/apple/darwin-xnu/blob/xnu-4570.1.46/bsd/man/man4/tcp.4#L172
> 
> Likewise I see them available in mingw for Wndows builds, with both
> names
> 
> $ grep -r TCP_KEEP /usr/i686-w64-mingw32/sys-root/mingw/include/
> /usr/i686-w64-mingw32/sys-root/mingw/include/ws2ipdef.h:#define TCP_KEEPALIVE 3
> /usr/i686-w64-mingw32/sys-root/mingw/include/ws2ipdef.h:#define TCP_KEEPCNT 16
> /usr/i686-w64-mingw32/sys-root/mingw/include/ws2ipdef.h:#define TCP_KEEPIDLE TCP_KEEPALIVE
> /usr/i686-w64-mingw32/sys-root/mingw/include/ws2ipdef.h:#define TCP_KEEPINTVL 17
> 
> but your patch wouldn't enable it because it checks netinet/tcp.h
> 
> AFAICT, the only platform that matters to QEMU that seems to miss this
> is OpenBSD 
> 

Yes, I couldn't find them in the OpenBSD man-pages. Other BSD variants
support all of them. I will mention it explicitly in the QAPI docs, that
OpenBSD is not supported.

I will also fix it for Windows and Darwin, and submit an updated series.


Thank you!

Best regards,

Juraj Marcin

> 
> With regards,
> Daniel
> -- 
> |: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org         -o-            https://fstop138.berrange.com :|
> |: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
> 



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-04-30 14:48 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-08 11:24 [PATCH v3 0/5] util/qemu-sockets: Introduce inet socket options controlling TCP keep-alive Juraj Marcin
2025-04-08 11:25 ` [PATCH v3 1/5] io: Fix partial struct copy in qio_dns_resolver_lookup_sync_inet() Juraj Marcin
2025-04-11 10:38   ` Daniel P. Berrangé
2025-04-08 11:25 ` [PATCH v3 2/5] util/qemu-sockets: Refactor setting client sockopts into a separate function Juraj Marcin
2025-04-11 10:40   ` Daniel P. Berrangé
2025-04-08 11:25 ` [PATCH v3 3/5] util/qemu-sockets: Refactor success and failure paths in inet_listen_saddr() Juraj Marcin
2025-04-11 13:47   ` Daniel P. Berrangé
2025-04-08 11:25 ` [PATCH v3 4/5] util/qemu-sockets: Add support for keep-alive flag to passive sockets Juraj Marcin
2025-04-11 13:49   ` Daniel P. Berrangé
2025-04-08 11:25 ` [PATCH v3 5/5] utils/qemu-sockets: Introduce inet socket options controlling TCP keep-alive Juraj Marcin
2025-04-11 13:54   ` Daniel P. Berrangé
2025-04-11 15:49     ` Daniel P. Berrangé
2025-04-30 14:47       ` Juraj Marcin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).