From: Markus Armbruster <armbru@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: den@openvz.org, berrange@redhat.com, qemu-devel@nongnu.org,
kraxel@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2] qapi: InitSocketAddress: add keepalive option
Date: Tue, 11 Jun 2019 15:48:18 +0200 [thread overview]
Message-ID: <8736kg2py5.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20190610160957.46809-1-vsementsov@virtuozzo.com> (Vladimir Sementsov-Ogievskiy's message of "Mon, 10 Jun 2019 19:09:57 +0300")
You misspelled InetSocketAddress and keep-alive in the subject. Suggest
qapi: Add InetSocketAddress member keep-alive
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:
> It's needed to provide keepalive for nbd client to track server
> availability.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>
> v2: [by Markus's comments]
> - improve commit message
> - s/keepalive/keep-alive
> - update inet_parse()
>
>
> qapi/sockets.json | 5 ++++-
> util/qemu-sockets.c | 22 ++++++++++++++++++++++
> 2 files changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/qapi/sockets.json b/qapi/sockets.json
> index fc81d8d5e8..13a2627e1d 100644
> --- a/qapi/sockets.json
> +++ b/qapi/sockets.json
> @@ -53,6 +53,8 @@
> #
> # @ipv6: whether to accept IPv6 addresses, default try both IPv4 and IPv6
> #
> +# @keep-alive: enable keep-alive when connecting to this socket (Since 4.1)
> +#
> # Since: 1.3
> ##
> { 'struct': 'InetSocketAddress',
Please document that @keep-alive is silently ignored for passive
sockets.
Even better would be rejecting it then, of course.
> @@ -61,7 +63,8 @@
> '*numeric': 'bool',
> '*to': 'uint16',
> '*ipv4': 'bool',
> - '*ipv6': 'bool' } }
> + '*ipv6': 'bool',
> + '*keep-alive': 'bool' } }
>
> ##
> # @UnixSocketAddress:
> diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
> index 8850a280a8..9c842c4a93 100644
> --- a/util/qemu-sockets.c
> +++ b/util/qemu-sockets.c
> @@ -457,6 +457,19 @@ int inet_connect_saddr(InetSocketAddress *saddr, Error **errp)
> }
>
> freeaddrinfo(res);
> +
> + if (saddr->keep_alive) {
> + int val = 1;
> + int ret = qemu_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;
> + }
> + }
> +
> return sock;
> }
>
> @@ -652,6 +665,15 @@ int inet_parse(InetSocketAddress *addr, const char *str, Error **errp)
> }
> addr->has_ipv6 = true;
> }
> + begin = strstr(optstr, ",keep-alive");
> + if (begin) {
> + if (inet_parse_flag("keep-alive", begin + strlen("keep-alive="),
Shouldn't you use strlen(",keep-alive")?
> + &addr->keep_alive, errp) < 0)
> + {
> + return -1;
> + }
> + addr->has_keep_alive = true;
> + }
> return 0;
> }
next prev parent reply other threads:[~2019-06-11 14:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-10 16:09 [Qemu-devel] [PATCH v2] qapi: InitSocketAddress: add keepalive option Vladimir Sementsov-Ogievskiy
2019-06-11 13:48 ` Markus Armbruster [this message]
2019-06-14 17: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=8736kg2py5.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=den@openvz.org \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/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.