All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org
Cc: vsementsov@virtuozzo.com, berrange@redhat.com, armbru@redhat.com,
	kraxel@redhat.com, den@openvz.org
Subject: [PATCH 2/2] util/qemu-sockets: make keep-alive enabled by default
Date: Wed,  8 Jul 2020 22:15:39 +0300	[thread overview]
Message-ID: <20200708191540.28455-3-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20200708191540.28455-1-vsementsov@virtuozzo.com>

Keep-alive won't hurt, let's try to enable it even if not requested by
user.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 util/qemu-sockets.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index b961963472..f6851376f5 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -438,7 +438,8 @@ static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr,
  *
  * Handle keep_alive settings. If user specified settings explicitly, fail if
  * can't set the settings. If user just enabled keep-alive, not specifying the
- * settings, try to set defaults but ignore failures.
+ * settings, try to set defaults but ignore failures. If keep-alive option is
+ * not specified, try to set it but ignore failures.
  */
 static int inet_set_keepalive(int sock, bool has_keep_alive,
                               KeepAliveField *keep_alive, Error **errp)
@@ -447,8 +448,8 @@ static int inet_set_keepalive(int sock, bool has_keep_alive,
     int val;
     bool has_settings = has_keep_alive &&  keep_alive->type == QTYPE_QDICT;
 
-    if (!has_keep_alive || (keep_alive->type == QTYPE_QBOOL &&
-                            !keep_alive->u.enabled))
+    if (has_keep_alive &&
+        keep_alive->type == QTYPE_QBOOL && !keep_alive->u.enabled)
     {
         return 0;
     }
@@ -456,8 +457,12 @@ static int inet_set_keepalive(int sock, bool has_keep_alive,
     val = 1;
     ret = qemu_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
     if (ret < 0) {
-        error_setg_errno(errp, errno, "Unable to set KEEPALIVE");
-        return -1;
+        if (has_keep_alive) {
+            error_setg_errno(errp, errno, "Unable to set KEEPALIVE");
+            return -1;
+        } else {
+            return 0;
+        }
     }
 
     val = has_settings ? keep_alive->u.settings.idle : 30;
-- 
2.21.0



  parent reply	other threads:[~2020-07-08 19:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-08 19:15 [PATCH 0/2] keepalive default Vladimir Sementsov-Ogievskiy
2020-07-08 19:15 ` [PATCH 1/2] sockets: keep-alive settings Vladimir Sementsov-Ogievskiy
2020-07-09  8:33   ` Daniel P. Berrangé
2020-07-08 19:15 ` Vladimir Sementsov-Ogievskiy [this message]
2020-07-09  8:29   ` [PATCH 2/2] util/qemu-sockets: make keep-alive enabled by default Daniel P. Berrangé
2020-07-09  8:49     ` Vladimir Sementsov-Ogievskiy
2020-07-09 11:52       ` Daniel P. Berrangé
2020-07-09  8:54     ` Denis V. Lunev
2020-07-09 11:40       ` Markus Armbruster
2020-07-08 19:41 ` [PATCH 0/2] keepalive default no-reply
2020-07-09  8:35 ` Daniel P. Berrangé
2020-07-09 15:34   ` Eric Blake
2020-07-09 17:14     ` Vladimir Sementsov-Ogievskiy
2020-07-10 19:25       ` Vladimir Sementsov-Ogievskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200708191540.28455-3-vsementsov@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=den@openvz.org \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.