- kvm-file-posix-Define-DM_MPATH_PROBE_PATHS.patch [RHEL-65852] - kvm-file-posix-Probe-paths-and-retry-SG_IO-on-potential-.patch [RHEL-65852] - kvm-io-Fix-partial-struct-copy-in-qio_dns_resolver_looku.patch [RHEL-67706] - kvm-util-qemu-sockets-Refactor-setting-client-sockopts-i.patch [RHEL-67706] - kvm-util-qemu-sockets-Refactor-success-and-failure-paths.patch [RHEL-67706] - kvm-util-qemu-sockets-Add-support-for-keep-alive-flag-to.patch [RHEL-67706] - kvm-util-qemu-sockets-Refactor-inet_parse-to-use-QemuOpt.patch [RHEL-67706] - kvm-util-qemu-sockets-Introduce-inet-socket-options-cont.patch [RHEL-67706] - kvm-tests-unit-test-util-sockets-fix-mem-leak-on-error-o.patch [RHEL-67706] - Resolves: RHEL-65852 (Support multipath failover with scsi-block) - Resolves: RHEL-67706 (postcopy on the destination host can't switch into pause status under the network issue if boot VM with '-S')
84 lines
2.6 KiB
Diff
84 lines
2.6 KiB
Diff
From e6348c4dd343f1a367a30f08c01a0f25c764a93c Mon Sep 17 00:00:00 2001
|
|
From: Juraj Marcin <jmarcin@redhat.com>
|
|
Date: Wed, 21 May 2025 15:52:31 +0200
|
|
Subject: [PATCH 4/9] util/qemu-sockets: Refactor setting client sockopts into
|
|
a separate function
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
RH-Author: Juraj Marcin <None>
|
|
RH-MergeRequest: 368: util/qemu-sockets: Introduce inet socket options controlling TCP keep-alive
|
|
RH-Jira: RHEL-67706
|
|
RH-Acked-by: Peter Xu <peterx@redhat.com>
|
|
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
RH-Commit: [2/7] c06976f96dbdf70b15079aa81dd1ac87abb0f1ab (JurajMarcin/centos-src-qemu-kvm)
|
|
|
|
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>
|
|
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
|
(cherry picked from commit b8b5278aca78be4a1c2e7cbb11c6be176f63706d)
|
|
|
|
JIRA: https://issues.redhat.com/browse/RHEL-67706
|
|
|
|
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..4a878e0527 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) < 0) {
|
|
+ close(sock);
|
|
+ return -1;
|
|
}
|
|
|
|
return sock;
|
|
--
|
|
2.39.3
|
|
|